emWin功能的具体实现(在MainTask.c文件里面):
#include "MainTask.h"
#include "bsp.h"
/*
*********************************************************************************************************
* 函数声明
*********************************************************************************************************
*/
WM_HWIN CreateFramewin1(void);
WM_HWIN CreateFramewin2(void);
WM_HWIN CreateFramewin3(void);
/*
*********************************************************************************************************
* 宏定义
*********************************************************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_1 (GUI_ID_USER + 0x02)
#define ID_CHECKBOX_0 (GUI_ID_USER + 0x03)
#define ID_SLIDER_0 (GUI_ID_USER + 0x04)
#define ID_PROGBAR_0 (GUI_ID_USER + 0x05)
/*
*********************************************************************************************************
* GUI_WIDGET_CREATE_INFO类型数组
*********************************************************************************************************
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] =
{
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 34, 35, 177, 52, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 34, 130, 177, 52, 0, 0x0, 0 },
{ CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 345, 138, 104, 40, 0, 0x0, 0},
};
/*
*********************************************************************************************************
* 函 数 名: _cbDialog1
* 功能说明: 对话框回调函数
* 形 参: pMsg 回调参数
* 返 回 值: 无
*********************************************************************************************************
*/
static void _cbDialog1(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
//
// 初始化框架窗口
//
hItem = pMsg->hWin;
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
FRAMEWIN_SetFont(hItem, GUI_FONT_32B_ASCII);
FRAMEWIN_SetText(hItem, "Screen 1");
//
// 初始按钮控件
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetFont(hItem, GUI_FONT_20_1);
BUTTON_SetText(hItem, "Screen 2");
//
// 初始化按钮控件
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetFont(hItem, GUI_FONT_20_1);
BUTTON_SetText(hItem, "Screen 3");
//
// 初始化复选框控件
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
CHECKBOX_SetText(hItem, "Check");
CHECKBOX_SetFont(hItem, GUI_FONT_16_1);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id)
{
case ID_BUTTON_0:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
/* 关闭当前对话框, 创建对话框2 */
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
CreateFramewin2();
break;
}
break;
case ID_BUTTON_1:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
/* 关闭当前对话框, 创建对话框3 */
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
CreateFramewin3();
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
|