主运行函数还是方面MainTask.c文件里面,主程序如下:
复制代码
#include "includes.h"
#include "MainTask.h"
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFont36;(1)
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFont;
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFont72;
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFont144;
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFontA144;
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFontAEx144;
extern GUI_CONST_STORAGE GUI_FONT GUI_FontSongFontAExF144;
/*
*********************************************************************************************************
* 创建对话框信息
*********************************************************************************************************
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "armfly", 0, 0, 0, 800,480,FRAMEWIN_CF_MOVEABLE,0},
{ BUTTON_CreateIndirect, "安富莱", GUI_ID_BUTTON0, 350,20,420,150,0,0},
{ TEXT_CreateIndirect, "安富莱电子", GUI_ID_TEXT0, 5, 10, 300, 33, 0,0},
{ TEXT_CreateIndirect, "安富莱电子", GUI_ID_TEXT1, 5, 40,250, 50, 0,0},
{ TEXT_CreateIndirect, "安富莱", GUI_ID_TEXT2, 5, 100,360, 90, 0,0},
{ TEXT_CreateIndirect, "富", GUI_ID_TEXT3, 5, 220,144, 144, 0,0},
{ TEXT_CreateIndirect, "富", GUI_ID_TEXT4, 205, 230,144, 144, 0,0},
{ TEXT_CreateIndirect, "富", GUI_ID_TEXT5, 405, 230,144, 144, 0,0},
{ TEXT_CreateIndirect, "富", GUI_ID_TEXT6, 605, 230,144, 144, 0,0}
};
/*
*********************************************************************************************************
* 函 数 名: PaintDialog
* 功能说明: 对话框重绘函数
* 形 参:pMsg 消息指针
* 返 回 值: 无
*********************************************************************************************************
*/
void PaintDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hWin = pMsg->hWin;
}
/*
*********************************************************************************************************
* 函 数 名: 对话框初始化
* 功能说明: 对话框初始化
* 形 参:pMsg 消息指针
* 返 回 值: 无
*********************************************************************************************************
*/
void InitDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hWin = pMsg->hWin;
//
//FRAMEWIN
//
FRAMEWIN_SetFont(hWin,&GUI_Font32B_ASCII);
FRAMEWIN_SetTextAlign(hWin,GUI_TA_VCENTER|GUI_TA_CENTER);
FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1);
FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2);
FRAMEWIN_SetTitleHeight(hWin,35);
//
//GUI_ID_BUTTON0
//
GUI_UC_SetEncodeUTF8();(2)
BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON0),&GUI_FontSongFontA144);(3)
//
//GUI_ID_TEXT0
//
TEXT_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_TEXT0), GUI_RED);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT0),&GUI_FontSongFont);
TEXT_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_TEXT1), GUI_GREEN);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT1),&GUI_FontSongFont36);
TEXT_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_TEXT2), GUI_BLUE);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT2),&GUI_FontSongFont72);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT3),&GUI_FontSongFont144);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT4),&GUI_FontSongFontAEx144);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT5),&GUI_FontSongFontA144);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT6),&GUI_FontSongFontAExF144);
// GUI_UC_SetEncodeNone();
}
/*
*********************************************************************************************************
* 函 数 名: _cbCallback
* 功能说明: 对话框回调函数
* 形 参:pMsg 消息指针
* 返 回 值: 无
*********************************************************************************************************
*/
static void _cbCallback(WM_MESSAGE * pMsg)
{
int NCode, Id;
WM_HWIN hWin = pMsg->hWin;
switch (pMsg->MsgId)
{
case WM_PAINT:
PaintDialog(pMsg);
break;
case WM_INIT_DIALOG:
InitDialog(pMsg);
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
{
case GUI_KEY_ESCAPE:
GUI_EndDialog(hWin, 1);
break;
case GUI_KEY_ENTER:
GUI_EndDialog(hWin, 0);
break;
}
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id)
{
case GUI_ID_OK:
if(NCode==WM_NOTIFICATION_RELEASED)
GUI_EndDialog(hWin, 0);
break;
case GUI_ID_CANCEL:
if(NCode==WM_NOTIFICATION_RELEASED)
GUI_EndDialog(hWin, 0);
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
/*
*********************************************************************************************************
* 函 数 名: MainTask
* 功能说明: GUI主任务
* 形 参:无
* 返 回 值: 无
*********************************************************************************************************
*/
void MainTask(void)
{
GUI_Init();
WM_SetDesktopColor(GUI_WHITE); /* Automacally update desktop window */
WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */
PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);
PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
CHECKBOX_SetDefaultSkin(CHECKBOX_SKIN_FLEX);
DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX);
SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
SLIDER_SetDefaultSkin(SLIDER_SKIN_FLEX);
HEADER_SetDefaultSkin(HEADER_SKIN_FLEX);
RADIO_SetDefaultSkin(RADIO_SKIN_FLEX);
GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);
while(1)
{
GUI_Delay(10);
}
}