/********************************************************************* * * 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(); } }
/********************************************************************* * * DROPDOWN_SetTextColor */ void DROPDOWN_SetTextColor(DROPDOWN_Handle hObj, unsigned int Index, GUI_COLOR color) { DROPDOWN_Obj* pObj; if (hObj) { if (Index < GUI_COUNTOF(pObj->Props.aBackColor)) { WM_LOCK(); pObj = DROPDOWN_H2P(hObj); ASSERT_IS_VALID_PTR(pObj); pObj->Props.aTextColor[Index] = color; DROPDOWN_Invalidate(hObj); if (pObj->hListWin) { LISTBOX_SetTextColor(pObj->hListWin, Index, color); } WM_UNLOCK(); } } }
/** * @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; } }