/********************************************************************* * * MainTask */ void MainTask(void) { EDIT_Handle hEdit; GUI_Init(); WM_SetCallback(WM_HBKWIN, _cbBk); hEdit = EDIT_CreateEx(50, 110, 220, 25, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT0, TEXT_MAXLEN); WM_SetCallback(hEdit, _cbEdit); EDIT_SetText(hEdit, "Press <ENTER> when done..."); EDIT_SetFont(hEdit, &GUI_Font8x16); EDIT_SetTextColor(hEdit, 0, GUI_RED); EDIT_EnableBlink(hEdit, 300, 1); while (1) { GUI_Delay(10); } }
/********************************************************************* * * Dialog callback routine */ static void MeasureData_cbCallback (WM_MESSAGE* pMsg) { int NCode, Id; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: MeasureDataPaintDialog(pMsg); MeasureDataUpdata(); break; case WM_INIT_DIALOG: MeasureData_InitDialog(pMsg); /*初始化句柄-------------------------------------------------------*/ g_MeasureData.FreqHandle = WM_GetDialogItem(hWin, GUI_ID_EDIT1); g_MeasureData.DutyHandle = WM_GetDialogItem(hWin, GUI_ID_EDIT2); g_MeasureData.AmlifHandle = WM_GetDialogItem(hWin, GUI_ID_EDIT3); g_MeasureData.FreqUnitHandle = WM_GetDialogItem(hWin, GUI_ID_EDIT4); g_MeasureData.DutyUnitHandle = WM_GetDialogItem(hWin, GUI_ID_EDIT5); g_MeasureData.AmlifUnitHandle = WM_GetDialogItem(hWin, GUI_ID_EDIT6); /*禁止闪烁-------------------------------------------------------*/ EDIT_EnableBlink(g_MeasureData.FreqHandle, 0, 0); EDIT_EnableBlink(g_MeasureData.DutyHandle, 0, 0); EDIT_EnableBlink(g_MeasureData.AmlifHandle, 0, 0); EDIT_EnableBlink(g_MeasureData.FreqUnitHandle, 0, 0); EDIT_EnableBlink(g_MeasureData.DutyUnitHandle, 0, 0); EDIT_EnableBlink(g_MeasureData.AmlifUnitHandle, 0, 0); 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); } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END GUI_DrawBitmap(&bmlogo,40,10); #if(Gradient_Rectangle) { GUI_DrawGradientRoundedH(220,120,580,380,20,REC_color1,REC_color2); } #endif #if(RoundedFrame) GUI_SetColor(GUI_GREEN); GUI_DrawRoundedFrame(218,118,582,382,20,3); #endif #if(FillRoundedRect) GUI_SetColor(RoundedRect); GUI_FillRoundedRect(220,120,580,380,20); #endif switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'inuse' // hItem = pMsg->hWin; FRAMEWIN_SetTitleVis(hItem, 0); FRAMEWIN_SetClientColor( hItem, framewin_backcolor); FRAMEWIN_SetFont(hItem, GUI_FONT_8_1); FRAMEWIN_SetText(hItem, "Framewin"); FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); FRAMEWIN_SetTextColor(hItem, 0x00000000); hItem = pMsg->hWin; FRAMEWIN_SetTitleVis(hItem, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetFont(hItem, &GUI_Fonthz_song30); BUTTON_SetText(hItem, "返回 "); #if(Button_3Dskin) BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX); #endif #if(!Button_3Dskin) BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color); BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color); #endif // // Initialization of 'Button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetFont(hItem, &GUI_Fonthz_song30); BUTTON_SetText(hItem, "停止充电 "); #if(Button_3Dskin) BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX); #endif #if(!Button_3Dskin) BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color); BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color); #endif // // Initialization of 'Button' // // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,99,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,99,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,99,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000); // // Initialization of 'Edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3); EDIT_EnableBlink( hItem,1 ,0); EDIT_SetDecMode(hItem,0,0,9999,0,0); EDIT_SetFont(hItem, GUI_FONT_32_ASCII); EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000); // // Initialization of 'cddianliang' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "使用电量 "); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); TEXT_SetTextColor(hItem, 0x00000000); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "使用时间 "); TEXT_SetTextColor(hItem, 0x00000000); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "消费金额 "); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); TEXT_SetTextColor(hItem, 0x00000000); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetFont(hItem, &GUI_Fonthz_song24); TEXT_SetText(hItem, "账户余额 "); TEXT_SetTextAlign(hItem, GUI_TA_RIGHT); TEXT_SetTextColor(hItem, 0x00000000); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP); TEXT_SetText(hItem, "安徽绿建科技有限公司 "); TEXT_SetTextColor(hItem, 0x00000000); TEXT_SetFont(hItem, &GUI_FontSong_60); // // Initialization of 'Text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP); TEXT_SetTextColor(hItem, 0x00000000); TEXT_SetText(hItem, "ANHUI GREEN BUILDING TECHNOLOGY CO.,LTD."); TEXT_SetFont(hItem, GUI_FONT_24_ASCII); // USER START (Optionally insert additional code for further widget initialization) // USER END 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: // USER START (Optionally insert code for reacting on notification message) // USER END // op=ensure; // handle_button(); GUI_EndDialog( pMsg->hWin,1); Createensure(); break; // USER START (Optionally insert additional code for further notification handling) // USER END } 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: // USER START (Optionally insert code for reacting on notification message) // USER END GUI_EndDialog( pMsg->hWin,1); Createwindow0(); break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_0: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_1: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_2: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_3: // Notifications sent by 'Edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int cursorpos=0; int index=0; uint8_t res=0; uint8_t sel=0; char str[60]; uint8_t filename[110]; uint8_t NumChars=0; hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY); switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetTextAlign(hItem, TEXT_CF_HCENTER | TEXT_CF_VCENTER); TEXT_SetText(hItem, (char *)"保存自学习文件"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetText(hItem, (char *)"文件名称:"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetText(hItem, (char *)"文件类型:WTR"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetFont(hItem,&GUI_FontHZ_Song_16); TEXT_SetText(hItem, (char *)"保存路径:"); hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_16); DROPDOWN_AddString(hItem, (char *)"U盘"); DROPDOWN_AddString(hItem, (char *)"SD卡"); if(k_StorageGetStatus(MSD_DISK_UNIT) != 0) DROPDOWN_SetSel(hItem,1); else DROPDOWN_SetSel(hItem,0); hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); TEXT_SetFont(hItemwarn,&GUI_FontHZ_Song_12); TEXT_SetTextColor(hItemwarn,GUI_RED); TEXT_SetText(hItemwarn, (char *)"警告:文件名不能为空!"); WM_HideWindow(hItemwarn); hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12); TEXT_SetTextColor(hIteminfo,GUI_RED); TEXT_SetText(hIteminfo, (char *)"文件保存成功!"); WM_HideWindow(hIteminfo); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); //EDIT_SetDecMode(hItem, 24, 1,256, 0, 0); EDIT_SetFont(hItem,GUI_FONT_32_1); EDIT_SetMaxLen(hItem, 50); EDIT_EnableBlink(hItem, 600, 1); EDIT_SetInsertMode(hItem,1); //strcpy ((char*)str,(char *)path_studyfile); //strcat ((char*)str,"/"); //strcat ((char*)str,"A.wtr"); EDIT_SetText(hItem,"A"); cursorindex=EDIT_GetCursorCharPos(hItem); WM_SetFocus(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK); BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12); BUTTON_SetSkinClassic(hItem); BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_GREEN); BUTTON_SetFocussable(hItem,0);//不接收焦点 hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL); BUTTON_SetFont(hItem,&GUI_FontHZ_Song_12); BUTTON_SetSkinClassic(hItem); BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); BUTTON_SetBkColor(hItem,BUTTON_CI_UNPRESSED, GUI_RED); BUTTON_SetFocussable(hItem,0);//不接收焦点 break; // USER START (Optionally insert additional message handling) // USER END case WM_KEY: //GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点 break; case MY_MESSAGE_CLICK: GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点 break; case MY_MESSAGE_OK: hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); if(EDIT_GetNumChars(hItem)==0) { hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); WM_ShowWindow(hItemwarn); break; } else { hItemwarn = WM_GetDialogItem(pMsg->hWin, ID_TEXT_WARNING); WM_HideWindow(hItemwarn); } hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); store_dev=DROPDOWN_GetSel(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); EDIT_GetText(hItem, str, 51); if(store_dev == 0)//usb { if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile); else strcpy ((char*)filename,(char *)path_Default); } if(store_dev == 1)//sd { if(sizeof(path_studyfile) < 50) strcpy ((char*)filename,(char *)path_studyfile_sd); else strcpy ((char*)filename,(char *)path_Default_sd); } strcat ((char*)filename,"/"); strcat ((char*)filename,str); strcat ((char*)filename,".wtr"); hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetText(hIteminfo, "正在保存自学习文件!"); WM_ShowWindow(hIteminfo); GUI_Exec(); res=WT_StudyFiles_Write(filename);//0-ok, 1-hardware error, 2-file operate error, if(res==0) { hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetText(hIteminfo, (char *)"文件保存成功!"); WM_ShowWindow(hIteminfo); } else { hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_INFO); TEXT_SetText(hIteminfo, "警告:保存失败,未检测到存储设备!"); WM_ShowWindow(hIteminfo); break; } GUI_EndDialog(pMsg->hWin,0); break; case MY_MESSAGE_DOWN://向右移动光标 hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); if(WM_HasFocus(hItem))//选择存储路径 { sel=DROPDOWN_GetSel(hItem); if(sel<1) { DROPDOWN_IncSel(hItem); } else //sel>=2 { DROPDOWN_SetSel(hItem,0); } } hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); cursorpos=EDIT_GetCursorCharPos(hItem); NumChars = EDIT_GetNumChars(hItem); if(cursorpos <= (NumChars-1) ) { EDIT_SetCursorAtChar(hItem,cursorpos+1); EDIT_SetSel(hItem,cursorpos+1,cursorpos+1); cursorindex=EDIT_GetCursorCharPos(hItem); } //KeyLed_State.wheel=0; break; case MY_MESSAGE_UP://向左移动光标 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); cursorpos=EDIT_GetCursorCharPos(hItem); EDIT_SetCursorAtChar(hItem,cursorpos-1); EDIT_SetSel(hItem,cursorpos-1,cursorpos-1); cursorindex=EDIT_GetCursorCharPos(hItem); break; case MY_MESSAGE_WHEEL://处理滚轮事件 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); EDIT_SetCursorAtChar(hItem,cursorindex); index=KeyLed_State.wheel; if(KeyLed_State.wheel>=65 && KeyLed_State.wheel <130) index=KeyLed_State.wheel-65; if(KeyLed_State.wheel>=130 && KeyLed_State.wheel <195) index=KeyLed_State.wheel-130; if(KeyLed_State.wheel>=195) index=64; if(KeyLed_State.wheel<0 && KeyLed_State.wheel >= -65) index=KeyLed_State.wheel+65; if(KeyLed_State.wheel<-65 && KeyLed_State.wheel >= -130) index=KeyLed_State.wheel+130; if(KeyLed_State.wheel<-130) index=0; if(cursorindex==EDIT_GetCursorCharPos(hItem)) { EDIT_AddKey(hItem,GUI_KEY_DELETE); EDIT_AddKey(hItem,input_char[index]); cursorpos=EDIT_GetCursorCharPos(hItem); EDIT_SetSel(hItem,cursorpos-1,cursorpos-1); } break; case MY_MESSAGE_BUTTONDELETE://删除字符 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_TILEPATH); if(WM_HasFocus(hItem)) { EDIT_AddKey(hItem,GUI_KEY_BACKSPACE); cursorindex=EDIT_GetCursorCharPos(hItem); } break; case WM_PAINT://绘制标题栏 GUI_SetColor(GUI_DARKBLUE); GUI_FillRect(0,0,480,22); GUI_SetColor(GUI_DARKGRAY); GUI_SetPenSize(6); GUI_DrawRect(0,0,480-2,222-2); break; default: WM_DefaultProc(pMsg); break; } }