1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <string.h>
#include "GUI.h"
#include "WM.h"
typedef struct {
char str[50];
} MYWIDGET_Obj;
static void _cbMyWidget(WM_MESSAGE * pMsg) {
GUI_RECT WinRect;
MYWIDGET_Obj MyWidget;
switch (pMsg->MsgId) {
case WM_PAINT:
WM_GetWindowRectEx(pMsg->hWin, &WinRect);
GUI_MoveRect(&WinRect, -WinRect.x0, -WinRect.y0);
GUI_SetColor(GUI_YELLOW);
GUI_Clear();
WM_GetUserData(pMsg->hWin, &MyWidget, sizeof(MYWIDGET_Obj));
if(MyWidget.str)
{
GUI_DispStringInRect(MyWidget.str, &WinRect, GUI_TA_HCENTER | GUI_TA_VCENTER);
}
break;
}
}
WM_HWIN MYWIDGET_Create(int x0, int y0, int xSize, int ySize, WM_HWIN hWinParent, U32 Style, const char * pText) {
WM_HWIN hWin;
MYWIDGET_Obj MyWidget;
if (pText) {
strcpy(MyWidget.str, pText);
}
hWin = WM_CreateWindowAsChild(x0, y0, xSize, ySize, hWinParent, Style, _cbMyWidget, sizeof(MYWIDGET_Obj));
WM_SetUserData(hWin, &MyWidget, sizeof(MYWIDGET_Obj));
return hWin;
}
|