📄 gui.h
字号:
* *
*********************************
These defines come in two flavors: the long version (.._DRAWMODE_..)
and the short ones (.._DM_..). They are identical, feel free to use
which ever one you like best.
*/
#define GUI_DRAWMODE_NORMAL LCD_DRAWMODE_NORMAL
#define GUI_DRAWMODE_XOR LCD_DRAWMODE_XOR
#define GUI_DRAWMODE_TRANS LCD_DRAWMODE_TRANS
#define GUI_DRAWMODE_REV LCD_DRAWMODE_REV
#define GUI_DM_NORMAL LCD_DRAWMODE_NORMAL
#define GUI_DM_XOR LCD_DRAWMODE_XOR
#define GUI_DM_TRANS LCD_DRAWMODE_TRANS
#define GUI_DM_REV LCD_DRAWMODE_REV
#define GUI_TEXTMODE_NORMAL LCD_DRAWMODE_NORMAL
#define GUI_TEXTMODE_XOR LCD_DRAWMODE_XOR
#define GUI_TEXTMODE_TRANS LCD_DRAWMODE_TRANS
#define GUI_TEXTMODE_REV LCD_DRAWMODE_REV
#define GUI_TM_NORMAL LCD_DRAWMODE_NORMAL
#define GUI_TM_XOR LCD_DRAWMODE_XOR
#define GUI_TM_TRANS LCD_DRAWMODE_TRANS
#define GUI_TM_REV LCD_DRAWMODE_REV
/* Text alignment flags, horizontal */
#define GUI_TA_HORIZONTAL (3<<0)
#define GUI_TA_LEFT (0<<0)
#define GUI_TA_RIGHT (1<<0)
#define GUI_TA_CENTER (2<<0)
#define GUI_TA_HCENTER GUI_TA_CENTER /* easier to remember :-) */
/* Text alignment flags, vertical */
#define GUI_TA_VERTICAL (3<<2)
#define GUI_TA_TOP (0<<2)
#define GUI_TA_BOTTOM (1<<2)
#define GUI_TA_BASELINE (2<<2)
#define GUI_TA_VCENTER (3<<2)
/* *********************************
*
* Min/Max coordinates
*
*********************************
*/
/* Define minimum and maximum coordinates in x and y */
#define GUI_XMIN -4095
#define GUI_XMAX 4095
#define GUI_YMIN -4095
#define GUI_YMAX 4095
/*********************************************************************
*
* Support for multitasking systems (locking)
*
**********************************************************************
*/
#if !GUI_OS
#define GUI_LOCK()
#define GUI_UNLOCK()
#define GUITASK_INIT()
#define GUITASK_COPY_CONTEXT()
#else
void GUI_Lock(void);
void GUI_Unlock(void);
void GUITASK_Init(void);
void GUITASK_CopyContext(void);
#define GUI_LOCK() GUI_Lock()
#define GUI_UNLOCK() GUI_Unlock()
#define GUITASK_INIT() GUITASK_Init()
#define GUITASK_COPY_CONTEXT() GUITASK_CopyContext()
#endif
/*********************************************************************
*
* GUI_CONTEXT
*
**********************************************************************
This structure is public for one reason only:
To allow the application to save and restore the context.
*/
typedef union {
U8 aColorIndex8[2];
U16 aColorIndex16[2];
} LCD_COLORINDEX_UNION;
typedef struct {
/* Variables in LCD module */
LCD_COLORINDEX_UNION LCD;
LCD_RECT ClipRect;
U8 DrawMode;
U8 SelLayer;
U8 TextStyle;
/* Variables in GL module */
GUI_RECT* pClipRect_HL; /* High level clip rectangle ... Speed optimization so drawing routines can optimize */
U8 PenSize;
U8 PenShape;
U8 LineStyle;
U8 FillStyle;
/* Variables in GUICHAR module */
const GUI_FONT GUI_UNI_PTR * pAFont;
const GUI_UC_ENC_APILIST * pUC_API; /* Unicode encoding API */
I16P LBorder;
I16P DispPosX, DispPosY;
I16P DrawPosX, DrawPosY;
I16P TextMode, TextAlign;
GUI_COLOR Color, BkColor; /* Required only when changing devices and for speed opt (caching) */
/* Variables in WM module */
#if GUI_WINSUPPORT
const GUI_RECT* WM__pUserClipRect;
GUI_HWIN hAWin;
int xOff, yOff;
#endif
/* Variables in MEMDEV module (with memory devices only) */
#if GUI_SUPPORT_DEVICES
const tLCDDEV_APIList* pDeviceAPI; /* function pointers only */
GUI_HMEM hDevData;
GUI_RECT ClipRectPrev;
#endif
/* Variables in Anitaliasing module */
#if GUI_SUPPORT_AA
const tLCD_HL_APIList* pLCD_HL; /* Required to reroute drawing (HLine & Pixel) to the AA module */
U8 AA_Factor;
U8 AA_HiResEnable;
#endif
} GUI_CONTEXT;
/* Rename GUI_SaveContext in order to avoid crashes if wrong GUIConf is used */
#if ( GUI_WINSUPPORT && GUI_SUPPORT_DEVICES)
#define GUI_SaveContext GUI_SaveContext_W_M
#elif (!GUI_WINSUPPORT && GUI_SUPPORT_DEVICES)
#define GUI_SaveContext GUI_SaveContext_M
#elif ( GUI_WINSUPPORT && !GUI_SUPPORT_DEVICES)
#define GUI_SaveContext GUI_SaveContext_W
#else
#define GUI_SaveContext GUI_SaveContext_
#endif
/*********************************************************************
*
* General routines
*
**********************************************************************
*/
int GUI_Init(void);
void GUI_SetDefault(void);
GUI_DRAWMODE GUI_SetDrawMode(GUI_DRAWMODE dm);
const char * GUI_GetVersionString(void);
void GUI_SaveContext ( GUI_CONTEXT* pContext);
void GUI_RestoreContext(const GUI_CONTEXT* pContext);
/*********************************************************************
*
* Rectangle helper functions
*
**********************************************************************
*/
int GUI_RectsIntersect(const GUI_RECT* pr0, const GUI_RECT* pr1);
void GUI_MoveRect (GUI_RECT *pRect, int x, int y);
void GUI_MergeRect (GUI_RECT* pDest, const GUI_RECT* pr0, const GUI_RECT* pr1);
int GUI__IntersectRects(GUI_RECT* pDest, const GUI_RECT* pr0, const GUI_RECT* pr1);
void GUI__IntersectRect (GUI_RECT* pDest, const GUI_RECT* pr0);
void GUI__ReduceRect (GUI_RECT* pDest, const GUI_RECT *pRect, int Dist);
/*********************************************************************
*
* Misc helper functions
*
**********************************************************************
*/
int GUI__DivideRound (int a, int b);
I32 GUI__DivideRound32 (I32 a, I32 b);
int GUI__SetText(GUI_HMEM* phText, const char* s);
/*********************************************************************
*
* Get / Set Attributes
*
**********************************************************************
*/
GUI_COLOR GUI_GetBkColor (void);
GUI_COLOR GUI_GetColor (void);
int GUI_GetBkColorIndex(void);
int GUI_GetColorIndex (void);
U8 GUI_GetPenSize (void);
U8 GUI_GetPenShape (void);
U8 GUI_GetLineStyle (void);
U8 GUI_GetFillStyle (void);
void GUI_SetBkColor (GUI_COLOR);
void GUI_SetColor (GUI_COLOR);
void GUI_SetBkColorIndex(int Index);
void GUI_SetColorIndex(int Index);
U8 GUI_SetPenSize (U8 Size);
U8 GUI_SetPenShape (U8 Shape);
U8 GUI_SetLineStyle (U8 Style);
U8 GUI_SetFillStyle (U8 Style);
/* Get/Set Character used as decimal point (usually '.' or ',') */
char GUI_GetDecChar(void);
char GUI_SetDecChar(char c);
/*********************************************************************
*
* Color / Index related functions
*
**********************************************************************
*/
int GUI_Color2Index(GUI_COLOR color);
GUI_COLOR GUI_Color2VisColor(GUI_COLOR color);
char GUI_ColorIsAvailable(GUI_COLOR color);
GUI_COLOR GUI_Index2Color(int Index);
void GUI_InitLUT(void);
void GUI_SetLUTEntry (U8 Pos, GUI_COLOR Color);
void GUI_SetLUTColor (U8 Pos, GUI_COLOR Color);
void GUI_SetLUTColorEx(U8 Pos, LCD_COLOR Color, unsigned int LayerIndex);
U32 GUI_CalcColorDist (GUI_COLOR Color0, GUI_COLOR Color1);
U32 GUI_CalcVisColorError(GUI_COLOR color);
/*********************************************************************
*
* Logging (for debugging primarily)
*
**********************************************************************
*/
void GUI_Log (const char *s);
void GUI_Log1 (const char *s, int p0);
void GUI_Log2 (const char *s, int p0, int p1);
void GUI_Log3 (const char *s, int p0, int p1, int p2);
void GUI_Log4 (const char *s, int p0, int p1, int p2,int p3);
void GUI_Warn (const char *s);
void GUI_Warn1 (const char *s, int p0);
void GUI_Warn2 (const char *s, int p0, int p1);
void GUI_Warn3 (const char *s, int p0, int p1, int p2);
void GUI_Warn4 (const char *s, int p0, int p1, int p2, int p3);
void GUI_ErrorOut (const char *s);
void GUI_ErrorOut1(const char *s, int p0);
void GUI_ErrorOut2(const char *s, int p0, int p1);
void GUI_ErrorOut3(const char *s, int p0, int p1, int p2);
void GUI_ErrorOut4(const char *s, int p0, int p1, int p2, int p3);
/*********************************************************************
*
* 2d - GL
*
**********************************************************************
*/
int GUI_BMP_Draw (const void * pFileData, int x0, int y0);
int GUI_BMP_GetXSize (const void * pFileData);
int GUI_BMP_GetYSize (const void * pFileData);
void GUI_Clear (void);
void GUI_ClearRect (int x0, int y0, int x1, int y1);
void GUI_ClearRectEx (const GUI_RECT* pRect);
void GUI_DrawArc (int x0, int y0, int rx, int ry, int a0, int a1);
void GUI_DrawBitmap (const GUI_BITMAP GUI_UNI_PTR * pBM, int x0, int y0);
void GUI_DrawBitmapMag (const GUI_BITMAP GUI_UNI_PTR * pBM, int x0, int y0, int XMul, int YMul);
void GUI_DrawBitmapEx (const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0, int xCenter, int yCenter, int xMag, int yMag);
void GUI_DrawBitmapExp (int x0, int y0, int XSize, int YSize, int XMul, int YMul, int BitsPerPixel, int BytesPerLine, const U8 GUI_UNI_PTR * pData, const GUI_LOGPALETTE GUI_UNI_PTR * pPal);
void GUI_DrawCircle (int x0, int y0, int r);
void GUI_DrawEllipse (int x0, int y0, int rx, int ry);
void GUI_DrawGraph (I16 *pay, int NumPoints, int x0, int y0);
void GUI_DrawHLine (int y0, int x0, int x1);
void GUI_DrawLine (int x0, int y0, int x1, int y1);
void GUI_DrawLineRel (int dx, int dy);
void GUI_DrawLineTo (int x, int y);
void GUI_DrawPie (int x0, int y0, int r, int a0, int a1, int Type);
void GUI_DrawPixel (int x, int y);
void GUI_DrawPoint (int x, int y);
void GUI_DrawPolygon (const GUI_POINT* pPoints, int NumPoints, int x0, int y0);
void GUI_DrawPolyLine (const GUI_POINT* pPoints, int NumPoints, int x0, int y0);
void GUI_DrawFocusRect (const GUI_RECT *pRect, int Dist);
void GUI_DrawRect (int x0, int y0, int x1, int y1);
void GUI_DrawRectEx (const GUI_RECT *pRect);
void GUI_DrawVLine (int x0, int y0, int y1);
void GUI_FillCircle (int x0, int y0, int r);
void GUI_FillEllipse (int x0, int y0, int rx, int ry);
void GUI_FillPolygon (const GUI_POINT* pPoints, int NumPoints, int x0, int y0);
void GUI_FillRect (int x0, int y0, int x1, int y1);
void GUI_FillRectEx (const GUI_RECT* pRect);
void GUI_GetClientRect (GUI_RECT* pRect);
void GUI_InvertRect (int x0, int y0, int x1, int y1);
void GUI_MoveRel (int dx, int dy);
void GUI_MoveTo (int x, int y);
/*********************************************************************
*
* JPEG support
*
**********************************************************************
*/
typedef struct {
int XSize;
int YSize;
} GUI_JPEG_INFO;
int GUI_JPEG_Draw (const void * pFileData, int DataSize, int x0, int y0);
int GUI_JPEG_GetInfo (const void * pFileData, int DataSize, GUI_JPEG_INFO* pInfo);
/*********************************************************************
*
* Cursor routines
*
**********************************************************************
*/
typedef struct {
const GUI_UNI_PTR GUI_BITMAP * pBitmap;
int xHot, yHot;
} GUI_CURSOR;
#if GUI_SUPPORT_CURSOR
void GUI_CURSOR_Activate (void);
void GUI_CURSOR_Deactivate (void);
void GUI_CURSOR_Hide (void);
void GUI_CURSOR_SetXor (const GUI_BITMAP * pBM, int x, int y);
void GUI_CURSOR_SetPosition(int x, int y);
const GUI_CURSOR GUI_UNI_PTR * GUI_CURSOR_Select (const GUI_CURSOR GUI_UNI_PTR * pCursor);
void GUI_CURSOR_Show (void);
#else
#define GUI_CURSOR_Show()
#define GUI_CURSOR_Clear();
#endif
/*********************************************************************
*
* Cursors and their bitmaps
*
**********************************************************************
*/
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorArrowS, GUI_CursorArrowSI;
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorArrowM, GUI_CursorArrowMI;
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorArrowL, GUI_CursorArrowLI;
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorCrossS, GUI_CursorCrossSI;
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorCrossM, GUI_CursorCrossMI;
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorCrossL, GUI_CursorCrossLI;
extern GUI_CONST_STORAGE GUI_CURSOR GUI_CursorHeaderM, GUI_CursorHeaderMI;
extern GUI_CONST_STORAGE GUI_BITMAP GUI_BitmapArrowS, GUI_BitmapArrowSI;
extern GUI_CONST_STORAGE GUI_BITMAP GUI_BitmapArrowM, GUI_BitmapArrowMI;
extern GUI_CONST_STORAGE GUI_BITMAP GUI_BitmapArrowL, GUI_BitmapArrowLI;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -