/** * @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); }
/********************************************************************* * * DROPDOWN_InsertString */ void DROPDOWN_InsertString(DROPDOWN_Handle hObj, const char * s, unsigned int Index) { if (hObj && s) { DROPDOWN_Obj* pObj; unsigned int NumItems; WM_LOCK(); pObj = DROPDOWN_H2P(hObj); NumItems = DROPDOWN_GetNumItems(hObj); if (Index < NumItems) { WM_HMEM hItem; hItem = GUI_ARRAY_InsertItem(&pObj->Handles, Index, strlen(s) + 1); if (hItem) { char * pBuffer = (char *)GUI_ALLOC_h2p(hItem); strcpy(pBuffer, s); } WM_InvalidateWindow(hObj); if (pObj->hListWin) { LISTBOX_InsertString(pObj->hListWin, s, Index); } } else { DROPDOWN_AddString(hObj, s); if (pObj->hListWin) { LISTBOX_AddString(pObj->hListWin, s); } } WM_UNLOCK(); } }
/********************************************************************* * * LISTBOX_SetText */ void LISTBOX_SetText(LISTBOX_Handle hObj, const GUI_ConstString* ppText) { if (hObj) { int i; const char* s; WM_LOCK(); if (ppText) { for (i = 0; (s = *(ppText+i)) != 0; i++) { LISTBOX_AddString(hObj, s); } } LISTBOX_InvalidateItem(hObj, LISTBOX_ALL_ITEMS); WM_UNLOCK(); } }
/********************************************************************* * * 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(); } }
/********************************************************************* * * LISTBOX_InsertString */ void LISTBOX_InsertString(LISTBOX_Handle hObj, const char* s, unsigned int Index) { if (hObj && s) { LISTBOX_Obj* pObj; unsigned int NumItems; WM_LOCK(); pObj = LISTBOX_H2P(hObj); NumItems = LISTBOX__GetNumItems(pObj); if (Index < NumItems) { WM_HMEM hItem; hItem = GUI_ARRAY_InsertItem(&pObj->ItemArray, Index, sizeof(LISTBOX_ITEM) + strlen(s)); if (hItem) { LISTBOX_ITEM* pItem = (LISTBOX_ITEM*)GUI_ALLOC_h2p(hItem); pItem->Status = 0; strcpy(pItem->acText, s); LISTBOX_InvalidateItem(hObj, Index); } } else { LISTBOX_AddString(hObj, s); } WM_UNLOCK(); } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of '_mContent' // hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0); MULTIEDIT_SetText(hItem, "This software and following documnetion is published "); // // Initialization of '_lHelp' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); LISTBOX_AddString(hItem, "Preface"); LISTBOX_AddString(hItem, "Using"); LISTBOX_AddString(hItem, "Setting"); // // Initialization of '_tItem' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetText(hItem, "Item"); // // Initialization of '_tContent' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetText(hItem, "Content"); // 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_MULTIEDIT_0: // Notifications sent by '_mContent' 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_LISTBOX_0: // Notifications sent by '_lHelp' 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_SEL_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; } }
/** * @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; } }
/******************************************************************* * * _ShowSeveralFunctions */ static void _ShowSeveralFunctions(LISTBOX_Handle hListBox) { int NumEntries, i; /* Add scrollbar */ GUI_DispStringAtCEOL("SCROLLBAR_CreateAttached", 5, 55); GUI_Delay(SPEED); SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL); GUI_Delay(SPEED * 0.75); /* Add strings */ GUI_DispStringAtCEOL("LISTBOX_AddString", 5, 55); GUI_Delay(SPEED); LISTBOX_AddString(hListBox, "Français"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Japanese"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Italiano"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Español"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Other language ..."); GUI_Delay(SPEED * 0.6); /* Set focus */ GUI_DispStringAtCEOL("WM_SetFocus", 5, 55); GUI_Delay(SPEED * 0.9); WM_SetFocus(hListBox); GUI_Delay(SPEED * 0.7); /* Set font */ GUI_DispStringAtCEOL("LISTBOX_SetFont", 5, 55); GUI_Delay(SPEED * 0.9); LISTBOX_SetFont(hListBox, &GUI_Font13B_1); GUI_Delay(SPEED * 0.7); /* Increment selection */ GUI_DispStringAtCEOL("LISTBOX_IncSel", 5, 55); GUI_Delay(SPEED); NumEntries = LISTBOX_GetNumItems(hListBox); for (i = 0; i < NumEntries - 1; i++) { LISTBOX_IncSel(hListBox); GUI_Delay(SPEED / 6); } GUI_Delay(SPEED / 4); /* Show automatic scrollbar */ GUI_DispStringAtCEOL("Optional automatic scrollbar", 5, 55); GUI_Delay(SPEED); LISTBOX_SetAutoScrollH(hListBox, 1); LISTBOX_SetAutoScrollV(hListBox, 1); GUI_Delay(SPEED * 0.75); /* Set font */ GUI_DispStringAtCEOL("LISTBOX_SetFont", 5, 55); GUI_Delay(SPEED); LISTBOX_SetFont(hListBox, &GUI_Font16B_1); GUI_Delay(SPEED * 0.75); /* Decrement selection */ GUI_DispStringAtCEOL("LISTBOX_DecSel", 5, 55); GUI_Delay(SPEED); for (i = 0; i < NumEntries - 1; i++) { LISTBOX_DecSel(hListBox); GUI_Delay(SPEED / 6); } GUI_Delay(SPEED / 4); /* Change width of scrollbar */ GUI_DispStringAtCEOL("Change scrollbar width", 5, 55); GUI_Delay(SPEED * 0.7); { SCROLLBAR_Handle hScrollH = WM_GetDialogItem(hListBox, GUI_ID_HSCROLL); SCROLLBAR_Handle hScrollV = WM_GetDialogItem(hListBox, GUI_ID_VSCROLL); SCROLLBAR_SetWidth(hScrollV, 14); GUI_Delay(SPEED / 4); SCROLLBAR_SetWidth(hScrollH, 14); GUI_Delay(SPEED * 0.6); } /* Change size of listbox */ GUI_DispStringAtCEOL("Change size of listbox", 5, 55); GUI_Delay(SPEED * 0.75); WM_ResizeWindow(hListBox, -15, 0); GUI_Delay(SPEED / 4); WM_ResizeWindow(hListBox, 0, -15); GUI_Delay(SPEED / 4); WM_ResizeWindow(hListBox, 15, 0); GUI_Delay(SPEED / 4); WM_ResizeWindow(hListBox, 0, 15); GUI_Delay(SPEED / 2); /* Disable item */ GUI_DispStringAtCEOL("LISTBOX_SetItemDisabled", 5, 55); GUI_Delay(SPEED); LISTBOX_SetItemDisabled(hListBox, 4, 1); GUI_Delay(SPEED * 0.75); /* Set multi selection mode */ GUI_DispStringAtCEOL("LISTBOX_SetMulti", 5, 55); GUI_Delay(SPEED); LISTBOX_SetMulti(hListBox, 1); GUI_Delay(SPEED * 0.75); /* Select item */ GUI_DispStringAtCEOL("LISTBOX_SetItemSel", 5, 55); GUI_Delay(SPEED); LISTBOX_SetItemSel(hListBox, 0, 1); GUI_Delay(SPEED / 4); LISTBOX_SetItemSel(hListBox, 1, 1); GUI_Delay(SPEED / 4); LISTBOX_SetItemSel(hListBox, 2, 1); GUI_Delay(SPEED * 0.8); /* Delete listbox widget */ GUI_DispStringAtCEOL("LISTBOX_Delete", 5, 55); GUI_Delay(SPEED * 1.1); LISTBOX_Delete(hListBox); GUI_Delay(SPEED * 0.75); }
/********************************************************************* * * _cbCallbackWidgets * * Purpose: * Initializes the widgets of the main dialog box */ static void _cbCallbackWidgets(WM_MESSAGE * pMsg) { GRAPH_SCALE_Handle hScaleH, hScaleV; int i; WM_HWIN hDlg, hMenu; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Get handles of widgets */ for (i = 0; i < NUM_WIDGETS; i++) { _ahWin[i] = WM_GetDialogItem(hDlg, _aID[i]); } /* Init dropdown widget */ for (i = 0; i < 8; i++) { char acBuffer[] = {"Item x"}; int Len = strlen(acBuffer); acBuffer[Len - 1] = '1' + i; DROPDOWN_AddString(_ahWin[DROPDOWN0], acBuffer); } /* Init edit widget */ EDIT_SetText(_ahWin[EDIT0], "Edit"); /* Init listbox widget */ LISTBOX_SetAutoScrollV(_ahWin[LISTBOX0], 1); for (i = 0; i < 4; i++) { char acBuffer[] = {"Item x"}; int Len = strlen(acBuffer); acBuffer[Len - 1] = '1' + i; LISTBOX_AddString(_ahWin[LISTBOX0], acBuffer); } /* Init listview widget */ for (i = 0; i < 2; i++) { char acBuffer[] = {"Col. x"}; int Len = strlen(acBuffer); acBuffer[Len - 1] = '1' + i; LISTVIEW_AddColumn(_ahWin[LISTVIEW0], 60, acBuffer, GUI_TA_CENTER); } for (i = 0; i < 9; i++) { int j; LISTVIEW_AddRow(_ahWin[LISTVIEW0], NULL); for (j = 0; j < (int)LISTVIEW_GetNumColumns(_ahWin[LISTVIEW0]); j++) { char acBuffer[] = {"Rx/Cx"}; acBuffer[1] = '1' + i; acBuffer[4] = '1' + j; LISTVIEW_SetItemText(_ahWin[LISTVIEW0], j, i, acBuffer); } } LISTVIEW_SetGridVis(_ahWin[LISTVIEW0], 1); SCROLLBAR_CreateAttached(_ahWin[LISTVIEW0], SCROLLBAR_CF_VERTICAL); /* Init multiedit widget */ MULTIEDIT_SetText(_ahWin[MULTIEDIT0], "This text could be modified by the MULTIEDIT widget"); MULTIEDIT_SetWrapWord(_ahWin[MULTIEDIT0]); MULTIEDIT_SetAutoScrollV(_ahWin[MULTIEDIT0], 1); /* Init progbar widget */ WIDGET_SetEffect(_ahWin[PROGBAR0], &WIDGET_Effect_3D); /* Init graph widget */ for (i = 0; i < GUI_COUNTOF(_aColor); i++) { _aValue[i] = rand() % 95; _ahData[i] = GRAPH_DATA_YT_Create(_aColor[i], 500, 0, 0); GRAPH_AttachData(_ahWin[GRAPH0], _ahData[i]); } GRAPH_SetGridDistY(_ahWin[GRAPH0], 25); GRAPH_SetGridVis(_ahWin[GRAPH0], 1); GRAPH_SetGridFixedX(_ahWin[GRAPH0], 1); GRAPH_SetBorder(_ahWin[GRAPH0], 20, 4, 5, 4); /* Create and add vertical scale of graph widget */ hScaleV = GRAPH_SCALE_Create(18, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25); GRAPH_SCALE_SetTextColor(hScaleV, GUI_RED); GRAPH_AttachScale(_ahWin[GRAPH0], hScaleV); /* Create and add horizontal scale of graph widget */ hScaleH = GRAPH_SCALE_Create(46, GUI_TA_HCENTER | GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50); GRAPH_SCALE_SetTextColor(hScaleH, GUI_DARKGREEN); GRAPH_AttachScale(_ahWin[GRAPH0], hScaleH); /* Init multipage widget */ MULTIPAGE_AddPage(_ahWin[MULTIPAGE0], GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbDialogPage, WM_UNATTACHED, 0, 0), "Page 1"); MULTIPAGE_AddPage(_ahWin[MULTIPAGE0], GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), &_cbDialogPage, WM_UNATTACHED, 0, 0), "Page 2"); /* Create and attach menu */ hMenu = _CreateMenu(hDlg);/**/ break; default: WM_DefaultProc(pMsg); } }
/** * @brief Add entire folder to play list. * @param Foldername: pointer to folder name. * @retval None */ static void _AddEntireFolder(char *Foldername) { FRESULT res = FR_OK; FILINFO fno; DIR dir; char *fn; char tmp[FILEMGR_FULL_PATH_SIZE]; WM_HWIN hItem; #if _USE_LFN static char lfn[_MAX_LFN]; fno.lfname = lfn; fno.lfsize = sizeof(lfn); #endif res = f_opendir(&dir, Foldername); if (res == FR_OK) { while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif if (pImageList->ptr < FILEMGR_LIST_DEPDTH) { if ((fno.fattrib & AM_DIR) == 0) { if((strstr(fn, ".jpg")) || (strstr(fn, ".bmp")) || (strstr(fn, ".JPG")) || (strstr(fn, ".BMP"))) { strcpy(tmp, Foldername); strcat(tmp, "/"); strcat(tmp, fn); strncpy((char *)pImageList->file[pImageList->ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE); hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST); FILEMGR_GetFileOnly (tmp, fn); LISTBOX_AddString(hItem, fn); pImageList->ptr++; } } } } } f_closedir(&dir); }
/********************************************************************* * * _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; } }
/** * @brief Callback routine of the Benchmark dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; WM_HWIN hGraph; int cpu_speed = 0; RTC_TimeTypeDef RTC_Time; uint8_t sec, min, hour; char temp[50]; WM_CALLBACK *_cb; switch (pMsg->MsgId) { case WM_INIT_DIALOG: hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); /* Initialization of 'CPU' */ hItem = TEXT_CreateEx(20, 30, 100, 25, pMsg->hWin, WM_CF_SHOW,0, 0x123,""); TEXT_SetFont(hItem, GUI_FONT_13B_1); TEXT_SetTextColor(hItem, 0x00804000); TEXT_SetText(hItem, "CPU Usage %:"); hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU); TEXT_SetFont(hItem, GUI_FONT_16B_ASCII); TEXT_SetTextColor(hItem, GUI_DARKRED); hItem = WM_GetDialogItem(pMsg->hWin, ID_CPU_GRAPH); FRAMEWIN_SetBarColor(hItem, 0, GUI_DARKGRAY); FRAMEWIN_SetBarColor(hItem, 1, GUI_DARKGRAY); hGraph = GRAPH_CreateEx(20, 45, 280, 105, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_GRAPH0); hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20); GRAPH_SetGridVis(hGraph, 1); GRAPH_SetBorder(hGraph, 20, 4, 5, 4); GRAPH_AttachData(hGraph, hData); hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25); GRAPH_AttachScale(hGraph, hScale); GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW); GRAPH_SetGridDistX(hGraph, 25); GRAPH_SetGridDistY(hGraph, 25); WM_CreateWindowAsChild(80, 45, 354, 23, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ switch (Id) { case ID_BENCH_CPU: Stop_Test = 0; WM_HideWindow(pMsg->hWin); _cb = WM_GetCallback(WM_HBKWIN); WM_SetCallback(WM_HBKWIN, _ClearDesktop); cpu_speed = Run_SpeedTest(); hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST); k_GetTime(&RTC_Time); sec = RTC_Time.Seconds; min = RTC_Time.Minutes; hour = RTC_Time.Hours; sprintf(temp,"[%02d:%02d:%02d]: %d Pix/s ", hour , min, sec, cpu_speed); LISTBOX_AddString(hItem, temp); WM_ShowWindow(pMsg->hWin); hItem = WM_GetDialogItem(pMsg->hWin, ID_BENCH_CPU); sprintf (temp, "%d Pixels/s ", cpu_speed); TEXT_SetText(hItem, temp); WM_SetCallback(WM_HBKWIN, _cb); hItem = WM_GetDialogItem(WM_HBKWIN, ID_BUTTON_BKGND); WM_InvalidateWindow(hItem); WM_InvalidateWindow(WM_HBKWIN); WM_Paint(WM_HBKWIN); break; } break; case WM_NOTIFICATION_CHILD_DELETED: Stop_Test = 1; break; } break; default: WM_DefaultProc(pMsg); break; } }
/********************************************************************* * * _cbCallback */ static void _cbCallback(WM_MESSAGE * pMsg) { int NCode, Id; WM_HWIN hDlg, hListBox, hItem; hDlg = pMsg->hWin; hListBox = WM_GetDialogItem(hDlg, GUI_ID_MULTIEDIT0); switch (pMsg->MsgId) { case WM_INIT_DIALOG: LISTBOX_SetText(hListBox, _ListBox); LISTBOX_AddString(hListBox, "Français"); LISTBOX_AddString(hListBox, "Japanese"); LISTBOX_AddString(hListBox, "Italiano"); LISTBOX_AddString(hListBox, "Español"); LISTBOX_AddString(hListBox, "Greek"); LISTBOX_AddString(hListBox, "Hebrew"); LISTBOX_AddString(hListBox, "Dutch"); LISTBOX_AddString(hListBox, "Other language ..."); LISTBOX_SetScrollStepH(hListBox, 6); LISTBOX_SetAutoScrollH(hListBox, 1); LISTBOX_SetAutoScrollV(hListBox, 1); LISTBOX_SetOwnerDraw(hListBox, _OwnerDraw); hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK1); CHECKBOX_Check(hItem); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hDlg, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hDlg, 0); break; } break; case WM_TOUCH_CHILD: WM_SetFocus(hListBox); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ hItem = WM_GetDialogItem(hDlg, Id); switch (NCode) { case WM_NOTIFICATION_SEL_CHANGED: LISTBOX_InvalidateItem(hListBox, LISTBOX_ALL_ITEMS); break; case WM_NOTIFICATION_RELEASED: /* React only if released */ switch (Id) { case GUI_ID_OK: GUI_EndDialog(hDlg, 0); break; case GUI_ID_CANCEL: GUI_EndDialog(hDlg, 1); break; case GUI_ID_CHECK0: _MultiSel ^= 1; LISTBOX_SetMulti(hListBox, _MultiSel); WM_SetFocus(hListBox); LISTBOX_InvalidateItem(hListBox, LISTBOX_ALL_ITEMS); break; case GUI_ID_CHECK1: _OwnerDrawn ^= 1; if (_OwnerDrawn) { LISTBOX_SetOwnerDraw(hListBox, _OwnerDraw); } else { LISTBOX_SetOwnerDraw(hListBox, NULL); } LISTBOX_InvalidateItem(hListBox, LISTBOX_ALL_ITEMS); break; } break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _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; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'Listbox' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); LISTBOX_AddString(hItem, "fun1"); LISTBOX_AddString(hItem, "fun2"); LISTBOX_AddString(hItem, "fun3"); // 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_LISTBOX_0: // Notifications sent by 'Listbox' 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_SEL_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_BUTTON_0: // Notifications sent by 'ok' 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) hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0); ListBox_Sel = LISTBOX_GetSel(hItem); if(ListBox_Sel == 1) { CreateNum_input(); } // 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; } }
void ChordFileChooserWindow::AddFile(char* path, char* fn) { string fileName = strtok(fn, "."), Title, Artist; MIDI::ChordFile::GetInfo(fileName, &Title, &Artist); LISTBOX_AddString(CurrentChooserWindow->Listbox, (Title + " - " + Artist).c_str()); CurrentChooserWindow->FileNames.push_back(fileName); }
/********************************************************************* * * _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; } }