void GUI_time(void)
{
WM_HWIN hText;
WM_HWIN hButton;
Win_Set.time=FRAMEWIN_CreateEx(0,0,Win_Set.xSizeWin,Win_Set.ySizeWin,Win_Set.hWinMain, WM_CF_SHOW, FRAMEWIN_CF_ACTIVE,GUI_ID_FRAMEWIN0, "Time",0);
FRAMEWIN_SetTitleHeight(Win_Set.time,20);
FRAMEWIN_SetSkin(Win_Set.time,FRAMEWIN_SKIN_FLEX);
FRAMEWIN_AddCloseButton(Win_Set.time, FRAMEWIN_BUTTON_RIGHT, 0);
FRAMEWIN_AddMaxButton(Win_Set.time, FRAMEWIN_BUTTON_RIGHT, 1);
FRAMEWIN_AddMinButton(Win_Set.time, FRAMEWIN_BUTTON_RIGHT, 2);
Win_Set.hBkWheel= WM_CreateWindowAsChild(0,20,240,280,Win_Set.time, WM_CF_SHOW, _cbBkWheel, 0);
hText = TEXT_CreateEx(5,30,240,40,Win_Set.hBkWheel,WM_CF_SHOW,GUI_TA_LEFT,GUI_ID_TEXT3,"12:20:30");
TEXT_SetFont(hText,GUI_FONT_32B_ASCII);
TEXT_SetTextColor(hText,GUI_WHITE);
hText = TEXT_CreateEx(130,20,240,40,Win_Set.hBkWheel,WM_CF_SHOW,GUI_TA_LEFT,GUI_ID_TEXT4,"monday");
TEXT_SetFont(hText,GUI_FONT_20B_ASCII);
TEXT_SetTextColor(hText,GUI_WHITE);
hText = TEXT_CreateEx(130,60,240,40,Win_Set.hBkWheel,WM_CF_SHOW,GUI_TA_LEFT,GUI_ID_TEXT5,"2014.1.1");
TEXT_SetFont(hText,GUI_FONT_24B_ASCII);
TEXT_SetTextColor(hText,GUI_WHITE);
hText = TEXT_CreateEx(0,100,240,40,Win_Set.hBkWheel,WM_CF_SHOW,GUI_TA_LEFT,GUI_ID_TEXT8," Time Setting:");
TEXT_SetFont(hText,&GUI_Font20B_ASCII);
TEXT_SetTextColor(hText,GUI_RED);
TEXT_SetBkColor(hText,GUI_WHITE);
hText = TEXT_CreateEx(0,120,240,20,Win_Set.hBkWheel,WM_CF_SHOW,GUI_TA_LEFT,GUI_ID_TEXT9," Year Month Day Hour Min Sec");
TEXT_SetFont(hText,&GUI_Font16B_ASCII);
TEXT_SetTextColor(hText,GUI_BLUE);
TEXT_SetBkColor(hText,GUI_WHITE);
hButton = BUTTON_CreateEx(190,100,40,20,Win_Set.hBkWheel,WM_CF_SHOW,0,GUI_ID_OK);
BUTTON_SetText(hButton,"OK");
BUTTON_SetSkin(hButton, BUTTON_SKIN_FLEX);
Wheel_Create(0, 141, 45, 130,GUI_ID_LISTWHEEL0,aYear);
Wheel_Create(46, 141, 47, 130,GUI_ID_LISTWHEEL1,aMon);
Wheel_Create(94, 141, 35, 130,GUI_ID_LISTWHEEL2,aDay);
Wheel_Create(130, 141, 35, 130,GUI_ID_LISTWHEEL3,aHour);
Wheel_Create(166, 141, 35, 130,GUI_ID_LISTWHEEL4,aNum);
Wheel_Create(202,141,37,130,GUI_ID_LISTWHEEL5,aNum);
}
static void _cbBkWheel(WM_MESSAGE * pMsg)
{
int xSize, ySize;
int Id;
int NCode;
WM_HWIN hText;
char text_buffer[30];
struct tm SrcTm;
WM_HWIN hListWheel;
switch (pMsg->MsgId)
{
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); // 控件的ID
NCode = pMsg->Data.v;
switch(NCode)
{
case WM_NOTIFICATION_SEL_CHANGED:
LISTWHEEL_SetSel(pMsg->hWinSrc,LISTWHEEL_GetPos(pMsg->hWinSrc));
break;
case WM_NOTIFICATION_RELEASED:
if(Id == GUI_ID_OK)
{
/* 年 */
hListWheel = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTWHEEL0);
SrcTm.tm_year = LISTWHEEL_GetSel(hListWheel);
SrcTm.tm_year += 2000;
/* 月 */
hListWheel = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTWHEEL1);
SrcTm.tm_mon = LISTWHEEL_GetSel(hListWheel);
/* 日 */
hListWheel = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTWHEEL2);
SrcTm.tm_mday = LISTWHEEL_GetSel(hListWheel);
SrcTm.tm_mday += 1;
/* 时 */
hListWheel = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTWHEEL3);
SrcTm.tm_hour = LISTWHEEL_GetSel(hListWheel);
/* 分 */
hListWheel = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTWHEEL4);
SrcTm.tm_min = LISTWHEEL_GetSel(hListWheel);
/* 秒 */
hListWheel = WM_GetDialogItem(pMsg->hWin, GUI_ID_LISTWHEEL5);
SrcTm.tm_sec = LISTWHEEL_GetSel(hListWheel);
//RTC_SetCalendarTime(SrcTm);
RTC_Config();
RTC_SetCalendarTime(SrcTm);
BKP_WriteBackupRegister(BKP_DR1, 0xA4A2);
}
break;
}
break;
case MY_MESSAGE_RTC:
// BJ_TimeVar =RTC_GetCounter() + 8*60*60;
// to_tm(BJ_TimeVar, &systmtime);//RTC_GetCalendarTime()
systmtime=RTC_GetCalendarTime();
sprintf(text_buffer,"%02d:%02d:%02d",systmtime.tm_hour,systmtime.tm_min,systmtime.tm_sec);
/* 获取text句柄 */
hText = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT3);
/* 输出时间 */
TEXT_SetText(hText,text_buffer);
sprintf(text_buffer,"%04d.%02d.%02d",systmtime.tm_year,systmtime.tm_mon+1,systmtime.tm_mday);
/* 获取text句柄 */
hText = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT5);
/* 输出时间 */
TEXT_SetText(hText,text_buffer);
hText = WM_GetDialogItem(pMsg->hWin, GUI_ID_TEXT4);
/* 输出星期 */
switch(systmtime.tm_wday)
{
case 1:
TEXT_SetText(hText,"Monday");
break;
case 2:
TEXT_SetText(hText,"Tuesday");
break;
case 3:
TEXT_SetText(hText,"Wednesday");
break;
case 4:
TEXT_SetText(hText,"Thursday");
break;
case 5:
TEXT_SetText(hText,"Friday");
break;
case 6:
TEXT_SetText(hText,"Saturday");
break;
case 7:
TEXT_SetText(hText,"Sunday");
break;
default:
break;
}
break;
case WM_PAINT:
xSize = WM_GetWindowSizeX(pMsg->hWin);
ySize = WM_GetWindowSizeY(pMsg->hWin);
GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, 0xfffff56c, 0xffffffe8);
GUI_DrawGradientV(0,0,240,280,0xffff0d23,0xfffff56c);
break;
/* case WM_DELETE:
WM_DeleteWindow(Win_Set.hBkWheel);
break;*/
default:
WM_DefaultProc(pMsg);
}
}