程序代码如下:
#include "Dialog.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#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_TEXT_0 (GUI_ID_USER + 0x03)
#define ID_RADIO_0 (GUI_ID_USER + 0x04)
#define ID_CHECKBOX_0 (GUI_ID_USER + 0x05)
//
// Recommended memory to run the sample with adequate performance
//
#define RECOMMENDED_MEMORY (1024L * 10)
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _aDialogCreate1
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = { //--------------(1)
{ FRAMEWIN_CreateIndirect, "Framewin1", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 5, 5, 80, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 5, 30, 80, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 110, 60, 160, 32, 0, 0x64, 0 },
};
/*********************************************************************
*
* _aDialogCreate2
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = { //--------------(2)
{ FRAMEWIN_CreateIndirect, "Framewin2", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 5, 5, 80, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 5, 30, 80, 20, 0, 0x0, 0 },
{ RADIO_CreateIndirect, "Radio", ID_RADIO_0, 110, 60, 80, 60, 0, 0x1403, 0 },
};
/*********************************************************************
*
* _aDialogCreate3
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate3[] = { //--------------(3)
{ FRAMEWIN_CreateIndirect, "Framewin3", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 5, 5, 80, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 5, 30, 80, 20, 0, 0x0, 0 },
{ CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 110, 60, 100, 20, 0, 0x0, 0 },
};
/*********************************************************************
*
* Prototypes
*
**********************************************************************
*/
static void _cbDialog1(WM_MESSAGE * pMsg);
static void _cbDialog2(WM_MESSAGE * pMsg);
static void _cbDialog3(WM_MESSAGE * pMsg);
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _cbDialog1
*/
static void _cbDialog1(WM_MESSAGE * pMsg) { //--------------(4)
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Framewin1'
//
hItem = pMsg->hWin;
FRAMEWIN_SetText(hItem, "Screen 1");
FRAMEWIN_SetFont(hItem, GUI_FONT_32_ASCII);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetText(hItem, "Screen 2");
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetText(hItem, "Screen 3");
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetFont(hItem, GUI_FONT_32_ASCII);
TEXT_SetText(hItem, "Some text");
break;
case WM_NOTIFY_PARENT:
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:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED: //--------------(5)
GUI_EndDialog(pMsg->hWin, 0);
GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), _cbDialog2, WM_HBKWIN, 0, 0);
break;
}
break;
case ID_BUTTON_1: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED: //--------------(6)
GUI_EndDialog(pMsg->hWin, 0);
GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), _cbDialog3, WM_HBKWIN, 0, 0);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
|