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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
| #include "GUI.h"
#include "WM.h"
#include "DIALOG.h"
#include <string.h>
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
/*******************************************************************
*
* Static variables
*
********************************************************************/
/* 资源表 */
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 240, 320,FRAMEWIN_CF_MOVEABLE, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button0", ID_BUTTON_0, 10, 30, 160, 48, 0, 0x0, 0 },
};
/*******************************************************************************
* static code
******************************************************************************/
/**
* @brief 对话框回调函数
* @note 无
* @param pMsg:消息指针
* @retval 无
*/
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
/* 初始化框架窗口控件 */
hItem = pMsg->hWin;
FRAMEWIN_SetTitleHeight(hItem, 32);
FRAMEWIN_SetFont(hItem, GUI_FONT_16_1);
FRAMEWIN_SetText(hItem, "STemWIN STM32F103");
/* 初始化Button0 */
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetFont(hItem, GUI_FONT_24B_ASCII);
break;
case WM_NOTIFY_PARENT:
/* 获取控件ID */
Id = WM_GetId(pMsg->hWinSrc);
/* 获取消息内容 */
NCode = pMsg->Data.v;
switch(Id)
{
case ID_BUTTON_0: // Notifications sent by 'Button'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/**
* @brief 以对话框方式间接创建控件
* @note 无
* @param 无
* @retval hWin:资源表中第一个控件的句柄
*/
WM_HWIN CreateFramewin(void)
{
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/**
* @brief GUI主任务
* @note 无
* @param 无
* @retval 无
*/
void MainTask(void)
{
/* 设置桌面窗口颜色 */
WM_SetDesktopColor(GUI_BLUE);
/* 创建对话框 */
CreateFramewin();
/* 开启光标 */
GUI_CURSOR_Show();
while (1)
{
GUI_Delay(500);
}
}
|