大学生
最后登录1970-1-1
在线时间 小时
注册时间2014-8-15
|
#include "XBF.h"
#include "bsp_led.h"
SD_FONT *ExFont;
SD_FONT SDFont;
static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
FIL hFile;
UINT NumBytesRead;
FRESULT fres;
hFile = *(FIL *)pVoid;
//
// Set file pointer to the requested position
//
fres = f_lseek(&hFile, Off) ;
if (fres != FR_OK) {
return 1; // Error
}
//
// Read font data
//
fres = f_read(&hFile, pBuffer, NumBytes, &NumBytesRead);
if (fres != FR_OK) {
return 1; // Error
}
if (NumBytesRead != NumBytes) {
return 1; // Error
}
return 0; // Ok
}
void CreateFont(SD_FONT *ExFont)
{
FRESULT res;
res = f_open(&ExFont->hFontFile,XBF_FONT_PATH,FA_READ|FA_OPEN_EXISTING);
if (res == FR_OK)
{
LED2(ON);
GUI_XBF_CreateFont( &ExFont->XFont,
&ExFont->XBF_Data,
GUI_XBF_TYPE_PROP_AA4_EXT,
_cbGetData,
&ExFont->hFontFile);
/* éèÖÃGUI×Öìå */
GUI_SetFont(&ExFont->XFont);
/* éèÖÃÎı¾×Öìå */
TEXT_SetDefaultFont(&ExFont->XFont);
/* éèÖÃGUI×Öìå±àÂë */
GUI_UC_SetEncodeUTF8();
}
}
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Caption", 0, 0, 0, 240,320,FRAMEWIN_CF_MOVEABLE,0},
{ TEXT_CreateIndirect, "你好", GUI_ID_TEXT0, 22, 69, 201,134,0,0}
};
void PaintDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hWin = pMsg->hWin;
}
void InitDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hWin = pMsg->hWin;
//
//FRAMEWIN
//
FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1);
FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2);
//
//GUI_ID_TEXT0
//
CreateFont(&SDFont);
TEXT_SetDefaultFont(&SDFont.XFont);
TEXT_SetBkColor(WM_GetDialogItem(hWin,GUI_ID_TEXT0),0x0000ff);
TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT0),&SDFont.XFont);
}
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);
}
}
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);
while(1)
{
GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);
}
}
在main函数调用maintask();
|
|