/** * @brief Image direct open * @param filename: Image file name * @retval None */ static void ImageDirectOpen(char *filename) { WM_HWIN hItem; static char tmp[FILEMGR_FILE_NAME_SIZE]; IMAGE_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26); strcpy((char *)pImageList->file[pImageList->ptr].name, filename); FILEMGR_GetFileOnly(tmp, (char *)filename); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_AddString(hItem, tmp); LISTBOX_SetSel(hItem, pImageList->ptr); pImageList->ptr++; file_pos = pImageList->ptr - 1; f_close(&Image_File); if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); }
static void _SelectByKey(LISTBOX_Handle hObj, int Key) { int i; LISTBOX_Obj* pObj = LISTBOX_H2P(hObj); Key = _Tolower(Key); for (i = 0; i < _GetNumItems(pObj); i++) { char c = _Tolower(*(*(pObj->ppText + i))); if (c == Key) { LISTBOX_SetSel(hObj, i); break; } } }
/********************************************************************* * * _SelectByKey */ static void _SelectByKey(LISTBOX_Handle hObj, int Key) { unsigned i; LISTBOX_Obj* pObj; pObj = LISTBOX_H2P(hObj); Key = _Tolower(Key); for (i = 0; i < LISTBOX__GetNumItems(pObj); i++) { const char* s = LISTBOX__GetpString(pObj, i); if (_Tolower(*s) == Key) { LISTBOX_SetSel(hObj, i); break; } } }
/********************************************************************* * * DROPDOWN_Expand */ void DROPDOWN_Expand(DROPDOWN_Handle hObj) { int xSize, ySize, i, NumItems; WM_HWIN hLst; GUI_RECT r; WM_HWIN hParent; WM_Obj* pParent; DROPDOWN_Obj* pObj; if (hObj) { WM_LOCK(); pObj = DROPDOWN_H2P(hObj); if (pObj->hListWin == 0) { hParent = WM_GetParent(hObj); pParent = WM_H2P(hParent); xSize = WM__GetWindowSizeX(&pObj->Widget.Win); ySize = pObj->ySizeEx; NumItems = _GetNumItems(pObj); /* Get coordinates of window in client coordiantes of parent */ r = pObj->Widget.Win.Rect; GUI_MoveRect(&r, -pParent->Rect.x0, -pParent->Rect.y0); if (pObj->Flags & DROPDOWN_CF_UP) { r.y0 -= ySize; } else { r.y0 = r.y1; } hLst = LISTBOX_CreateAsChild(NULL, WM_GetParent(hObj), r.x0, r.y0 , xSize, ySize, WM_CF_SHOW); if (pObj->Flags & DROPDOWN_SF_AUTOSCROLLBAR) { LISTBOX_SetScrollbarWidth(hLst, pObj->ScrollbarWidth); LISTBOX_SetAutoScrollV(hLst, 1); } for (i = 0; i< NumItems; i++) { LISTBOX_AddString(hLst, _GetpItem(pObj, i)); } for (i = 0; i < GUI_COUNTOF(pObj->Props.aBackColor); i++) { LISTBOX_SetBkColor(hLst, i, pObj->Props.aBackColor[i]); } for (i = 0; i < GUI_COUNTOF(pObj->Props.aTextColor); i++) { LISTBOX_SetTextColor(hLst, i, pObj->Props.aTextColor[i]); } LISTBOX_SetItemSpacing(hLst, pObj->ItemSpacing); LISTBOX_SetFont(hLst, pObj->Props.pFont); WM_SetFocus(hLst); pObj->hListWin = hLst; LISTBOX_SetOwner(hLst, hObj); LISTBOX_SetSel(hLst, pObj->Sel); WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED); } WM_UNLOCK(); } }
static int _OnMouseOver(LISTBOX_Handle hObj, LISTBOX_Obj* pObj, WM_MESSAGE* pMsg) { const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p; if (pObj->hOwner) { if (pState) { /* Something happened in our area (pressed or released) */ int Sel; Sel = _GetItemFromPos(hObj, pObj, pState->x, pState->y); if (Sel >= 0) { if (Sel < (int)(pObj->ScrollStateV.v + _GetNumVisItems(pObj, hObj))) { LISTBOX_SetSel(hObj, Sel); } } } } return 0; /* Message handled */ }
/********************************************************************* * * _OnTouch */ static int _OnTouch(LISTBOX_Handle hObj, LISTBOX_Obj* pObj, WM_MESSAGE*pMsg) { int Notification; int Sel; GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p; int FontDistY = GUI_GetYDistOfFont(pObj->pFont); if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { Sel = pState->y / FontDistY + pObj->ScrollState.v; WM_SetFocus(hObj); Notification = WM_NOTIFICATION_CLICKED; LISTBOX_SetSel(hObj, Sel); } else { Notification = WM_NOTIFICATION_RELEASED; } } else { /* Mouse moved out */ Notification = WM_NOTIFICATION_MOVED_OUT; } WM_NotifyParent(hObj, Notification); return 0; /* Message handled */ }
/********************************************************************* * * _MoveSel * * Moves the selection/focus to the next valid item */ static void _MoveSel(LISTBOX_Handle hObj, int Dir) { int Index, NewSel = -1, NumItems; LISTBOX_Obj * pObj; pObj = LISTBOX_H2P(hObj); Index = LISTBOX_GetSel(hObj); NumItems = LISTBOX__GetNumItems(pObj); do { WM_HMEM hItem; Index += Dir; if ((Index < 0) || (Index >= NumItems)) { break; } hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, Index); if (hItem) { LISTBOX_ITEM * pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem); if (!(pItem->Status & LISTBOX_ITEM_DISABLED)) { NewSel = Index; } } } while(NewSel < 0); if (NewSel >= 0) { LISTBOX_SetSel(hObj, NewSel); } }
/** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; GUI_RECT r; int result; int Id, NCode, Index; char tmp[FILEMGR_FILE_NAME_SIZE]; switch (pMsg->MsgId) { case WM_INIT_DIALOG: pImageList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef)); pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO)); pImageList->ptr = 0; file_pos = 0; effects = 0; ImSettings.d32 = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP); if(ImSettings.b.ss_timer == 0) { ImSettings.b.ss_timer = 1; } /* Image frame initialization */ IMAGE_Enlarge = 0; hItem = WM_GetClientWindow(pMsg->hWin); WM_GetClientRectEx(hItem, &r); imFrame = WM_CreateWindowAsChild(r.x0 + 6, r.y0 + 6, r.x1 - 98, r.y1 - 78, hItem, WM_CF_SHOW, _cbImageWindow, 0); /* Buttons initialization */ hItem = BUTTON_CreateEx(47, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON); WM_SetCallback(hItem, _cbButton_previous); hItem = BUTTON_CreateEx(94, 148, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDE_BUTTON); WM_SetCallback(hItem, _cbButton_play); slideshow_state = OFF; hItem = BUTTON_CreateEx(154, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON); WM_SetCallback(hItem, _cbButton_next); hItem = BUTTON_CreateEx(242, 145, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON); WM_SetCallback(hItem, _cbButton_add); hItem = BUTTON_CreateEx(242, 175, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON); WM_SetCallback(hItem, _cbButton_open); hItem = BUTTON_CreateEx(196, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_SETTINGS_BUTTON); WM_SetCallback(hItem, _cbButton_settings); hItem = BUTTON_CreateEx(10, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON); WM_SetCallback(hItem, _cbButton_close); hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); LISTBOX_SetBkColor(hItem, LISTBOX_CI_SEL, GUI_BLUE); LISTBOX_SetTextColor(hItem, LISTBOX_CI_SEL, GUI_WHITE); LISTBOX_SetBkColor(hItem, LISTBOX_CI_UNSEL, GUI_BLACK); LISTBOX_SetTextColor(hItem, LISTBOX_CI_UNSEL, GUI_CYAN); LISTBOX_SetAutoScrollV(hItem, 1); break; case WM_TIMER: playlist_select = 0; break; case WM_PAINT: DrawRect3D(5, 140, 222, 67); DrawRect3D(230, 140, 83, 67); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { /* Notification sent by "Button_Settings" */ case ID_SETTINGS_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, IMAGE_hWin, 0, 0); break; } break; /* Notifications sent by 'ListView' Slider */ case ID_IMAGE_LIST: if(NCode == WM_NOTIFICATION_CLICKED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); Index = LISTBOX_GetSel(hItem); if(Index < pImageList->ptr) { if(playlist_select == 0) { hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0); playlist_select = (Index + 1); } else if(playlist_select == (Index + 1)) { WM_DeleteTimer(hPlaylistTimer); hPlaylistTimer = 0; playlist_select = 0; if(Index < pImageList->ptr) { file_pos = Index; if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } } } } break; /* Notification sent by "Button_Close" */ case ID_CLOSE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: f_close(&Image_File); k_free(pImageList); k_free(pFileInfo); GUI_EndDialog(pMsg->hWin, 0); break; } break; /* Notification sent by "Button_Open" */ case ID_OPEN_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_dir; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "add a folder", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if(pImageList->ptr == 0) { _AddEntireFolder(pFileInfo->pRoot); file_pos = 0; if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } else { _AddEntireFolder(pFileInfo->pRoot); } } break; } break; /* Notification sent by "Button_Open" */ case ID_ADD_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: pFileInfo->pfGetData = k_GetData; pFileInfo->pMask = acMask_img; hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add an image to playlist", 0, pFileInfo); WM_MakeModal(hItem); result = GUI_ExecCreatedDialog(hItem); if (result == 0) { if((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP"))) { strcpy((char *)pImageList->file[pImageList->ptr].name, pFileInfo->pRoot); FILEMGR_GetFileOnly(tmp, (char *)pFileInfo->pRoot); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_AddString(hItem, tmp); LISTBOX_SetSel(hItem, pImageList->ptr); pImageList->ptr++; file_pos = pImageList->ptr - 1; f_close(&Image_File); if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); } } break; } break; /* Notification sent by "Button_SlideShow" */ case ID_SLIDE_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 1) { f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } WM_InvalidateWindow(imFrame); if (slideshow_state == OFF) { hTimerTime = WM_CreateTimer(imFrame, ID_SLIDER_TIMER, (ImSettings.b.ss_timer * 1000) , 0); } else if(hTimerTime != 0) { WM_DeleteTimer(hTimerTime); hTimerTime = 0; } slideshow_state = (slideshow_state == OFF ? ON : OFF); } break; } break; /* Notification sent by "Button_Next" */ case ID_NEXT_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 0) { if (file_pos < (pImageList->ptr - 1)) { file_pos++; f_close(&Image_File); } else { file_pos = 0; f_close(&Image_File); } if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } break; } break; /* Notification sent by "Button_Previous" */ case ID_PREVIOUS_BUTTON: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: if(pImageList->ptr > 0) { if (file_pos > 0 ) { file_pos--; f_close(&Image_File); } else { file_pos = (pImageList->ptr - 1); f_close(&Image_File); } if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } break; } break; } break; default: WM_DefaultProc(pMsg); break; } }
/** * @brief Callback function of the image frame * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbImageWindow(WM_MESSAGE * pMsg) { WM_HWIN hItem; GUI_RECT r; int Id; const GUI_PID_STATE * pState; switch (pMsg->MsgId) { case WM_TOUCH: pState = (const GUI_PID_STATE *)pMsg->Data.p; if(pImageList->ptr > 0) { if (pState) { if (pState->Pressed == 1) { IMAGE_Enlarge ^= 1; if (IMAGE_Enlarge) { WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0); WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize()); } else { WM_AttachWindowAt(pMsg->hWin, IMAGE_hWin, 6, 6); WM_SetSize(pMsg->hWin, 220, 134); } WM_InvalidateWindow(pMsg->hWin); } } } break; case WM_PAINT: WM_GetInsideRect(&r); GUI_ClearRectEx(&r); if (pImageList->ptr > 0) { if(_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0) { f_close(&Image_File); GUI_ClearRectEx(&r); GUI_DispStringAt("Error : Image cannot be displayed", 20, 80); if(hTimerTime != 0) { slideshow_state = OFF; hItem = WM_GetDialogItem(IMAGE_hWin, ID_SLIDE_BUTTON); WM_InvalidateWindow(hItem); WM_Update(hItem); WM_DeleteTimer(hTimerTime); hTimerTime = 0; } } } break; case WM_TIMER: Id = WM_GetTimerId(pMsg->Data.v); if(Id == ID_SLIDER_TIMER) { if(pImageList->ptr > 1) { if (file_pos < (pImageList->ptr - 1)) { file_pos++; } else if (file_pos == (pImageList->ptr - 1)) { file_pos=0; } if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { IMAGE_Type = IMAGE_TYPE_BMP; } else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { IMAGE_Type = IMAGE_TYPE_JPG; } f_close(&Image_File); f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ); WM_InvalidateWindow(imFrame); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); LISTBOX_SetSel(hItem, file_pos); } WM_RestartTimer(pMsg->Data.v, (ImSettings.b.ss_timer * 1000)); } else if (Id == ID_PLAYLIST_TIMER) { playlist_select = 0; } break; case WM_DELETE: if(hTimerTime != 0) { WM_DeleteTimer(hTimerTime); hTimerTime = 0; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; int SelNum; int i; switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'Listbox' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); for(i = 0;i < 6;i++) { LISTBOX_AddString(hItem, pTextPreamble[i]); } switch(g_rom_para.preamble) { case 0xFC: LISTBOX_SetSel(hItem,0); break; case 0xFA: LISTBOX_SetSel(hItem,1); break; case 0xFB: LISTBOX_SetSel(hItem,2); break; case 0xFD: LISTBOX_SetSel(hItem,3); break; case 0xFF: LISTBOX_SetSel(hItem,4); break; case 0xFE: LISTBOX_SetSel(hItem,5); break; } // // Initialization of 'Listbox' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1); for(i = 0;i < 7;i++) { LISTBOX_AddString(hItem, pTextSpeed[i]); } switch(g_rom_para.plc_freq) { case PLC_270_III: LISTBOX_SetSel(hItem,0); break; case PLC_270_III_5: LISTBOX_SetSel(hItem,1); break; case PLC_270_II: LISTBOX_SetSel(hItem,2); break; case PLC_421_50BPS: LISTBOX_SetSel(hItem,3); break; case PLC_421_100BPS: LISTBOX_SetSel(hItem,4); break; case PLC_421_600BPS: LISTBOX_SetSel(hItem,5); break; case PLC_421_1200BPS: LISTBOX_SetSel(hItem,6); break; } hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); WIDGET_AndState(hItem,WIDGET_STATE_FOCUSSABLE); BUTTON_SetBkColor(hItem,0,GUI_GREEN); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); WIDGET_AndState(hItem,WIDGET_STATE_FOCUSSABLE); BUTTON_SetBkColor(hItem,0,GUI_YELLOW); break; case WM_KEY: if((((WM_KEY_INFO *)(pMsg->Data.p))->PressedCnt) == 1) { switch(((WM_KEY_INFO *)(pMsg->Data.p))->Key) { case GUI_KEY_GREEN: if(g_rom_para.channel != CHANNEL_PLC) { ERR_NOTE(g_hWin_monitor,GUI_MSBOX_FUN_DISALE_ERROR); } else { if(g_hWin_ReadMeter > 0) { hItem = WM_GetDialogItem(pMsg->hWin,ID_LISTBOX_0); SelNum = LISTBOX_GetSel(hItem); if(SelNum != 5) //前导符不是FE { hItem = RMD_Get_Speed(); EDIT_SetText(hItem,pTextPreamble[SelNum]); } else if(SelNum == 5) { hItem = WM_GetDialogItem(pMsg->hWin,ID_LISTBOX_1); SelNum = LISTBOX_GetSel(hItem); hItem = RMD_Get_Speed(); EDIT_SetText(hItem,pTextSpeed[SelNum]); } } else if(g_hWin_ProtoDbg > 0) { hItem = WM_GetDialogItem(pMsg->hWin,ID_LISTBOX_0); SelNum = LISTBOX_GetSel(hItem); if(SelNum != 5) //前导符不是FE { hItem = CPT_Get_Speed(); EDIT_SetText(hItem,pTextPreamble[SelNum]); } else if(SelNum == 5) { hItem = WM_GetDialogItem(pMsg->hWin,ID_LISTBOX_1); SelNum = LISTBOX_GetSel(hItem); hItem = CPT_Get_Speed(); EDIT_SetText(hItem,pTextSpeed[SelNum]); } } else if(g_hWin_para > 0) { //保留 } FRQ_PreamSel(pMsg); if(0xFE == g_rom_para.preamble) { FRQ_FreqSel(pMsg); g_gui_para.cmd = GUI_CMD_PLC_FREQ_SET; g_gui_para.state = GUI_STATE_PLC_FREQ_SET; OSMboxPost(g_sys_ctrl.up_mbox, (void*)&g_gui_para); } DEV_Parameters_Write();//保存数据 WM_DeleteWindow(g_hWin_freq); FRQ_SetFocus(); g_hWin_freq = HBWIN_NULL; } break; case GUI_KEY_YELLOW: WM_DeleteWindow(g_hWin_freq); FRQ_SetFocus(); g_hWin_freq = HBWIN_NULL; break; } } 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; WM_MESSAGE Msg; WM_HWIN hIteminfo; int i; int sel; uint8_t items; FRESULT res; // FILINFO fno; //DIR dir; // USER START (Optionally insert additional variables) // USER END hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); //WM_SetFocus(hItem); switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem,&GUI_FontHZ_Song_12); TEXT_SetText(hItem, "自学习文件选择"); hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hIteminfo,&GUI_FontHZ_Song_12); TEXT_SetTextColor(hIteminfo,GUI_RED); TEXT_SetText(hIteminfo, (char *)"打开文件……"); WM_HideWindow(hIteminfo); // // Initialization of 'Dropdown' // hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12); DROPDOWN_AddString(hItem, "U盘"); DROPDOWN_AddString(hItem, "SD卡"); if(k_StorageGetStatus(MSD_DISK_UNIT) != 0) DROPDOWN_SetSel(hItem,1); else DROPDOWN_SetSel(hItem,0); // // Initialization of 'Treeview' // store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } LISTBOX_SetFont(hItem,GUI_FONT_20_1); LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile); 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);//不接收焦点 // USER START (Optionally insert additional code for further widget initialization) // USER END break; case MY_MESSAGE_CLICK: GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点 break; case MY_MESSAGE_DOWN: hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); if(WM_HasFocus(hItem)) { LISTBOX_IncSel(hItem); } hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); if(WM_HasFocus(hItem)) { sel=DROPDOWN_GetSel(hItem); if(sel<1) { DROPDOWN_IncSel(hItem); } else //sel>=1 { DROPDOWN_SetSel(hItem,0); } store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); items = LISTBOX_GetNumItems(hItem); for(i=0;i<items;i++) { LISTBOX_DeleteItem(hItem,0); } for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } } break; case MY_MESSAGE_UP: hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); if(WM_HasFocus(hItem)) { LISTBOX_DecSel(hItem); } hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); if(WM_HasFocus(hItem)) { sel=DROPDOWN_GetSel(hItem); if(sel>0) { DROPDOWN_DecSel(hItem); } else //sel>=1 { DROPDOWN_SetSel(hItem,1); } store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); items = LISTBOX_GetNumItems(hItem); for(i=0;i<items;i++) { LISTBOX_DeleteItem(hItem,0); } for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } } break; case MY_MESSAGE_CANCEL://取消 GUI_EndDialog(pMsg->hWin,0); break; case MY_MESSAGE_OK: hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetText(hIteminfo, (char *)"打开文件中……"); WM_ShowWindow(hIteminfo); GUI_Exec(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); TestFolder.number_CurrentFile=LISTBOX_GetSel(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); store_dev=DROPDOWN_GetSel(hItem); WT_TestItem_Init((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]); //WT_TestFile_Write2Flash((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);//将文件内容复制到Flash //WT_TestFiles_Write2card((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]);//将文件内容复制到SD card if(TestFile.file_status == 1)//文件读取OK { Msg.MsgId = MY_MESSAGE_BUTTONOK; WM_SendMessage(pMsg->hWinSrc,&Msg); GUI_EndDialog(pMsg->hWin,0); } else { TEXT_SetText(hIteminfo, (char *)"读取文件错误!"); WM_ShowWindow(hIteminfo); } Msg.MsgId = MY_MESSAGE_BUTTONOK; WM_SendMessage(pMsg->hWinSrc,&Msg); GUI_EndDialog(pMsg->hWin,0); break; case MY_MESSAGE_BUTTONDELETE: hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); store_dev=DROPDOWN_GetSel(hItem); if(store_dev==0) //usb strcpy(filename,path_testfile); //f_opendir(&dir, path_testfile); if(store_dev==1) //sd strcpy(filename,path_testfile_sd); //f_opendir(&dir, path_testfile_sd); //res = f_opendir(&dir, "1:/LZY_WireTester/Test Files"); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); strcat(filename,"/"); sel = LISTBOX_GetSel(hItem); if(sel < 0) break; strcat(filename,(char *)TestFolder.FilesName[LISTBOX_GetSel(hItem)]); res=f_unlink((const TCHAR*)filename); if(res == FR_OK) { hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); items = LISTBOX_GetNumItems(hItem); for(i=0;i<items;i++) { LISTBOX_DeleteItem(hItem,0); } for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } WM_SetFocus(hItem); if(sel > 0) LISTBOX_SetSel(hItem,sel - 1); else LISTBOX_SetSel(hItem,0); } break; case WM_PAINT://绘制标题栏 GUI_SetColor(GUI_DARKBLUE); GUI_FillRect(0,0,380,22); GUI_SetColor(GUI_DARKGRAY); GUI_SetPenSize(8); GUI_DrawRect(0,0,378,220); break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _LISTBOX_Callback */ static void _LISTBOX_Callback(WM_MESSAGE*pMsg) { LISTBOX_Handle hObj = pMsg->hWin; LISTBOX_Obj* pObj = LISTBOX_H2P(hObj); WM_SCROLL_STATE ScrollState; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { /* Owner needs to be informed about focus change */ if (pMsg->MsgId == WM_SET_FOCUS) { if (pMsg->Data.v == 0) { /* Lost focus ? */ _NotifyOwner(hObj, LISTBOX_NOTIFICATION_LOST_FOCUS); } } return; } switch (pMsg->MsgId) { case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTBOX__InvalidateInsideArea(hObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTBOX__InvalidateInsideArea(hObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: LISTBOX_UpdateScrollers(hObj); break; } break; case WM_PAINT: _OnPaint(hObj, pObj, pMsg); break; case WM_PID_STATE_CHANGED: { const WM_PID_STATE_CHANGED_INFO* pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p; if (pInfo->State) { int Sel; Sel = _GetItemFromPos(hObj, pObj, pInfo->x, pInfo->y); if (Sel >= 0) { _ToggleMultiSel(hObj, pObj, Sel); LISTBOX_SetSel(hObj, Sel); } _NotifyOwner(hObj, WM_NOTIFICATION_CLICKED); return; } } break; case WM_TOUCH: _OnTouch(hObj, pMsg); return; #if GUI_SUPPORT_MOUSE case WM_MOUSEOVER: if (_OnMouseOver(hObj, pObj, pMsg) == 0) return; break; #endif case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (LISTBOX_AddKey(hObj, Key)) { return; } } break; case WM_SIZE: LISTBOX_UpdateScrollers(hObj); WM_InvalidateWindow(hObj); break; } WM_DefaultProc(pMsg); }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hScrollbar, hDlgOptions; GUI_RECT RectDlg, RectClient; int Cnt = 0, IndexEffect = 0, ButtonState = 0, DropdownState = 0; int ProgbarValue = 0, ProgbarInc = 1; int SliderValue = 0, SliderInc = 1; int ScrollbarValue = 0, ScrollbarInc = 1; int ListViewInc = 1; int ListBoxInc = 1; int MultiEditInc = 1; int Vz = 1; const WIDGET_EFFECT * _apEffect[] = {&WIDGET_Effect_3D, /* Array of effects */ &WIDGET_Effect_Simple, &WIDGET_Effect_None}; const char * _apEffects[] = {"Widget effect: 3D", "Widget effect: Simple", "Widget effect: None"}; GUI_Init(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); /* Enable use of memory devices for desktop windows */ /* Create framewindow and set its properties */ _hFrameWin = FRAMEWIN_CreateEx(0, 0, 640, 480, 0, WM_CF_SHOW, 0, 0, "", &_cbCallbackFramewin); FRAMEWIN_SetMoveable(_hFrameWin, 1); FRAMEWIN_SetText(_hFrameWin, _apEffects[0]); FRAMEWIN_SetFont(_hFrameWin, &GUI_Font13B_ASCII); /* Create main dialog window as child from framewindows client window */ _hDlg = GUI_CreateDialogBox(_aDlgWidgets, GUI_COUNTOF(_aDlgWidgets), &_cbCallbackWidgets, WM_GetClientWindow(_hFrameWin), 0, 0); /* Attach scrollbar to framewindows client window and set its properties */ hScrollbar = SCROLLBAR_CreateAttached(WM_GetClientWindow(_hFrameWin), 0); WM_GetWindowRectEx(_hDlg, &RectDlg); WM_GetClientRectEx(WM_GetClientWindow(_hFrameWin), &RectClient); SCROLLBAR_SetNumItems(hScrollbar, RectDlg.x1); SCROLLBAR_SetPageSize(hScrollbar, RectClient.x1); /* Create options dialog with 'stay on top' and 'moveable' attribute */ hDlgOptions = GUI_CreateDialogBox(_aDlgOptions, GUI_COUNTOF(_aDlgOptions), &_cbCallbackOptions, WM_HBKWIN, 0, 0); FRAMEWIN_SetMoveable(hDlgOptions, 1); WM_SetStayOnTop(hDlgOptions, 1); /* Main loop for modifying the widgets */ while (1) { if (_AutoMode) { Cnt++; /* Modify progbar */ if ((Cnt % 2) == 0) { ProgbarValue += ProgbarInc; if ((ProgbarValue == 110) || (ProgbarValue == -10)) { ProgbarInc *= -1; } PROGBAR_SetValue(_ahWin[PROGBAR0], ProgbarValue); } /* Modify slider */ if ((Cnt % 2) == 0) { int j; SliderValue += SliderInc; if ((SliderValue == 100) || (SliderValue == 0)) { SliderInc *= -1; } for (j = 0; j < 3; j++) { SLIDER_SetValue(_ahWin[SLIDER0 + j], SliderValue); } } /* Modify scrollbar */ if ((Cnt % 3) == 0) { int j; ScrollbarValue += ScrollbarInc; if ((ScrollbarValue == 90) || (ScrollbarValue == 0)) { ScrollbarInc *= -1; } for (j = 0; j < 3; j++) { SCROLLBAR_SetValue(_ahWin[SCROLLBAR0 + j], ScrollbarValue); } } /* Modify multipage */ if ((Cnt % 120) == 0) { MULTIPAGE_SelectPage(_ahWin[MULTIPAGE0], MULTIPAGE_GetSelection(_ahWin[MULTIPAGE0]) ^ 1); } /* Modify dropdown */ if ((Cnt % 120) == 0) { DropdownState ^= 1; if (DropdownState) { DROPDOWN_Expand(_ahWin[DROPDOWN0]); } else { DROPDOWN_Collapse(_ahWin[DROPDOWN0]); } } /* Modify button */ if ((Cnt % 40) == 0) { ButtonState ^= 1; BUTTON_SetPressed(_ahWin[BUTTON0], ButtonState); } /* Modify listbox */ if ((Cnt % 30) == 0) { int Sel; Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if (Sel < 0) { Sel = 0; } LISTBOX_SetSel(_ahWin[LISTBOX0], Sel + ListBoxInc); Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if ((Sel == (int)LISTBOX_GetNumItems(_ahWin[LISTBOX0]) - 1) || (Sel == 0)) { ListBoxInc *= -1; } } /* Modify listview */ if ((Cnt % 50) == 0) { int Sel; Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if (Sel < 0) { Sel = 0; } LISTVIEW_SetSel(_ahWin[LISTVIEW0], Sel + ListViewInc); Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if ((Sel == (int)LISTVIEW_GetNumRows(_ahWin[LISTVIEW0]) - 1) || (Sel == 0)) { ListViewInc *= -1; } } /* Modify multiedit */ if ((Cnt % 5) == 0) { int Sel, Len; char acBuffer[100]; MULTIEDIT_SetCursorOffset(_ahWin[MULTIEDIT0], MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]) + MultiEditInc); MULTIEDIT_GetText(_ahWin[MULTIEDIT0], acBuffer, sizeof(acBuffer)); Sel = MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]); Len = strlen(acBuffer); if ((Sel == (Len - 1)) || (Sel == 0)) { MultiEditInc *= -1; } if (!DropdownState) { WM_SetFocus(_ahWin[MULTIEDIT0]); } } /* Modify graph */ _AddValues(_ahWin[GRAPH0], 95); /* Move window */ if ((Cnt % 1200) == 0) { int Inc; WM_HWIN hScroll; WM_SCROLL_STATE ScrollState; hScroll = WM_GetScrollbarH(WM_GetClientWindow(_hFrameWin)); WM_GetScrollState(hScroll, &ScrollState); Inc = (ScrollState.NumItems - ScrollState.PageSize) / 2; ScrollState.v += Inc * Vz; if ((ScrollState.v >= Inc * 2) || (ScrollState.v <= 0)) { Vz *= -1; } SCROLLBAR_SetValue(hScroll, ScrollState.v); } /* Change effect */ if ((Cnt % 400) == 0) { int Index; WM_HWIN hWin; IndexEffect++; Index = IndexEffect % GUI_COUNTOF(_apEffect); _SetEffect(Index); hWin = WM_GetDialogItem(hDlgOptions, GUI_ID_RADIO0); RADIO_SetValue(hWin, Index); } } /* Wait a while */ GUI_Delay(10); } }
void LISTBOX_DecSel (LISTBOX_Handle hObj) { int Sel = LISTBOX_GetSel(hObj); if (Sel) Sel--; LISTBOX_SetSel(hObj, Sel); }
void LISTBOX_IncSel (LISTBOX_Handle hObj) { LISTBOX_Obj* pObj = LISTBOX_H2P(hObj); int Sel = LISTBOX_GetSel(hObj); ASSERT_IS_VALID_PTR(pObj); LISTBOX_SetSel(hObj, Sel+1); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; WM_MESSAGE Msg; WM_HWIN hIteminfo; int i; uint8_t sel; uint8_t items; // int wheelval=0; // USER START (Optionally insert additional variables) // USER END hItem = pMsg->hWin; WINDOW_SetBkColor(hItem, GUI_LIGHTGRAY); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); //WM_SetFocus(hItem); switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem,&GUI_FontHZ_Song_12); TEXT_SetText(hItem, "测试文件选择"); hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); 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_TEXT_LOCKINFO); TEXT_SetFont(hItem,&GUI_FontHZ_Song_12); TEXT_SetTextColor(hItem,GUI_RED); TEXT_SetText(hItem, "系统被锁定,请解锁!"); WM_HideWindow(hItem); // // Initialization of 'Dropdown' // hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); DROPDOWN_SetFont(hItem,&GUI_FontHZ_Song_12); //if(k_StorageGetStatus(USB_DISK_UNIT) != 0) DROPDOWN_AddString(hItem, "U盘"); //if(k_StorageGetStatus(MSD_DISK_UNIT) != 0) DROPDOWN_AddString(hItem, "SD卡"); if(k_StorageGetStatus(MSD_DISK_UNIT) != 0) DROPDOWN_SetSel(hItem,1); else DROPDOWN_SetSel(hItem,0); // // Initialization of 'Listview' // store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } LISTBOX_SetFont(hItem,GUI_FONT_20_1); LISTBOX_SetSel(hItem,TestFolder.number_CurrentFile); 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);//不接收焦点 // USER START (Optionally insert additional code for further widget initialization) // USER END break; case MY_MESSAGE_CLICK: GUI_SendKeyMsg(GUI_KEY_TAB, 1);//改变输入焦点 hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); if(WM_HasFocus(hItem)) { LISTBOX_SetSel(hItem,0); } break; case MY_MESSAGE_DOWN: hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); if(WM_HasFocus(hItem)) { LISTBOX_IncSel(hItem); } hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); if(WM_HasFocus(hItem)) { sel=DROPDOWN_GetSel(hItem); if(sel<1) { DROPDOWN_IncSel(hItem); } else //sel>=1 { DROPDOWN_SetSel(hItem,0); } store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); items = LISTBOX_GetNumItems(hItem); for(i=0;i<items;i++) { LISTBOX_DeleteItem(hItem,0); } for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } } break; case MY_MESSAGE_UP: hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); if(WM_HasFocus(hItem)) { LISTBOX_DecSel(hItem); } hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); if(WM_HasFocus(hItem)) { sel=DROPDOWN_GetSel(hItem); if(sel>0) { DROPDOWN_DecSel(hItem); } else //sel>=1 { DROPDOWN_SetSel(hItem,1); } store_dev=DROPDOWN_GetSel(hItem); WT_TestFolder_Init(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); items = LISTBOX_GetNumItems(hItem); for(i=0;i<items;i++) { LISTBOX_DeleteItem(hItem,0); } for(i=0;i<TestFolder.number_TotalFile;i++) { LISTBOX_AddString(hItem, (char *)TestFolder.FilesName[i]); } } break; case MY_MESSAGE_CANCEL://取消 TestFile.command=2;//test cancel TestFile.item_total=0; GUI_EndDialog(pMsg->hWin,0); break; case MY_MESSAGE_OK: hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); if(LISTBOX_GetNumItems(hItem) ==0 ) break; TestFolder.number_CurrentFile=LISTBOX_GetSel(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0); store_dev=DROPDOWN_GetSel(hItem); TestFile.command = 0; hIteminfo = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetText(hIteminfo, (char *)"读取测试文件!"); WM_ShowWindow(hIteminfo); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO); WM_HideWindow(hItem); GUI_Exec(); WT_TestItem_Init((char *)TestFolder.FilesName[TestFolder.number_CurrentFile]); if(TestFile.file_status == 1)//文件读取OK { Msg.MsgId = MY_MESSAGE_BUTTONOK; WM_SendMessage(pMsg->hWinSrc,&Msg); GUI_EndDialog(pMsg->hWin,0); } else { TEXT_SetText(hIteminfo, (char *)"读取测试文件错误!"); WM_ShowWindow(hIteminfo); } // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL); // if(WM_HasFocus(hItem))//取消 // { // TestFolder.number_CurrentFile=0; // TestFile.command = 0; // WT_TestItem_Init(TestFolder.FilesName[0]); // Msg.MsgId = MY_MESSAGE_BUTTONCANCEL; // WM_SendMessage(pMsg->hWinSrc,&Msg); // GUI_EndDialog(pMsg->hWin,0); // } //GUI_EndDialog(pMsg->hWin,0); //Number_Windos = 0; break; case MY_MESSAGE_LOCK: hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); WM_HideWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO); TEXT_SetText(hItem, "系统被锁定,请解锁!"); WM_ShowWindow(hItem); GUI_Exec(); break; case MY_MESSAGE_UNLOCK: hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_LOCKINFO); WM_HideWindow(hItem); break; case WM_PAINT://绘制标题栏 GUI_SetColor(GUI_DARKBLUE); GUI_FillRect(0,0,480,22); GUI_SetColor(GUI_DARKGRAY); GUI_SetPenSize(8); GUI_DrawRect(0,0,478,220); // GUI_DrawRoundedFrame(0, 0, 480, 222, 0, 4); break; default: WM_DefaultProc(pMsg); break; } }