#include "DIALOG.h"
#include "MESSAGEBOX.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Recommended memory to run the sample with adequate performance
//
#define RECOMMENDED_MEMORY (1024L * 10)
/* 字体部分代码省略未贴 */
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _CreateMessageBox
*/
static WM_HWIN _CreateMessageBox(const char * sMessage, const char * sCaption, int Flags, const GUI_FONT * pFont) {
WM_HWIN hWin;
WM_HWIN hItem;
GUI_RECT Rect;
hWin = MESSAGEBOX_Create(sMessage, sCaption, Flags); //--------------(1)
//
// Change font of message box window
//
FRAMEWIN_SetFont(hWin, pFont); //--------------(2)
//
// Adjust size
//
WM_GetWindowRectEx(hWin, &Rect); //--------------(3)
WM_SetWindowPos(hWin, Rect.x0 - 15,
Rect.y0 - 15,
Rect.x1 - Rect.x0 + 1 + 30,
Rect.y1 - Rect.y0 + 1 + 30);
//
// Change font of button widget
//
hItem = WM_GetDialogItem(hWin, GUI_ID_OK); //--------------(4)
BUTTON_SetFont(hItem, pFont);
//
// Adjust size of button widget
//
WM_GetWindowRectEx(hItem, &Rect); //--------------(5)
WM_SetWindowPos(hItem, Rect.x0,
Rect.y0 + 10,
Rect.x1 - Rect.x0 + 1 + 30,
Rect.y1 - Rect.y0 + 1 + 5);
//
// Change font of text widget
//
hItem = WM_GetDialogItem(hWin, GUI_ID_TEXT0); //--------------(6)
TEXT_SetFont(hItem, pFont);
//
// Adjust size text widget
//
WM_GetWindowRectEx(hItem, &Rect); //--------------(7)
WM_SetWindowPos(hItem, Rect.x0,
Rect.y0,
Rect.x1 - Rect.x0 + 1 + 30,
Rect.y1 - Rect.y0 + 1 + 12);
return hWin;
}
/*********************************************************************
*
* _EnableSkinning
*/
static void _EnableSkinning(void) {
FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);
BUTTON_SetDefaultSkin (BUTTON_SKIN_FLEX);
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_Init();
//
// Check if recommended memory for the sample is available
//
if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
GUI_ErrorOut("Not enough memory available.");
return;
}
_EnableSkinning();
while (1) {
GUI_SetFont(&GUI_Font20B_ASCII);
GUI_DispStringHCenterAt("Application defined MESSAGEBOX", 160, 5);
GUI_ExecCreatedDialog(_CreateMessageBox("Message", "Caption", 0, &GUI_Font24)); //--------------(8)
GUI_Clear();
GUI_Delay(1000);
}
} |