/******************************************************************* * * _DemoListBoxAsChild */ static void _DemoListBoxAsChild(void) { FRAMEWIN_Handle hFrame; LISTBOX_Handle hListBox; /* Display titel */ GUI_SetBkColor(0xB00000); GUI_SetColor(0xFFFFFF); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Listbox as child - Sample", 160, 5); GUI_Delay(SPEED / 2); /* Create framewin */ GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("FRAMEWIN_Create", 5, 55); GUI_Delay(SPEED); hFrame = FRAMEWIN_Create("List box", NULL, WM_CF_SHOW, 100, 80, 120, 140); FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII); FRAMEWIN_SetActive(hFrame, 1); GUI_Delay(SPEED * 0.75); /* Create listbox */ GUI_DispStringAtCEOL("LISTBOX_CreateAsChild", 5, 55); GUI_Delay(SPEED); hListBox = LISTBOX_CreateAsChild(_ListBox, WM_GetClientWindow(hFrame), 0, 0, 0, 0, WM_CF_SHOW); GUI_Delay(SPEED * 0.75); /* Show serveral functions of listbox */ _ShowSeveralFunctions(hListBox); /* Delete framewin widget */ GUI_DispStringAtCEOL("FRAMEWIN_Delete", 5, 55); GUI_Delay(SPEED); FRAMEWIN_Delete(hFrame); GUI_Delay(SPEED * 0.75); /* Clear display */ GUI_Clear(); GUI_Delay(SPEED * 1.5); }
/********************************************************************* * * GUIDEMO_DemoFrameWin */ void GUIDEMO_DemoFrameWin(void) { FRAMEWIN_Handle hFrame; LISTBOX_Handle hListBox; int xSize = LCD_GetXSize(); int ySize = LCD_GetYSize(); int i, x, y, w, h; const GUI_FONT* pFont = &GUI_FontComic18B_1; GUI_COLOR DesktopColorOld; #if GUIDEMO_LARGE GUIDEMO_ShowIntro("Frame Window & Listbox", NULL); #else GUIDEMO_ShowIntro("Frame Window\n & Listbox", NULL); #endif DesktopColorOld = GUIDEMO_SetBkColor(GUI_RED); DesktopColorOld = WM_SetDesktopColor(DesktopColorOld); /* Automatically update desktop window */ x = BORDER; #if GUIDEMO_LARGE y = 75; #else y = BORDER; #endif w = xSize - x - BORDER; h = ySize - y - BORDER; if (w > 140) { w = 140; } if (h > 120) { h = 120; } hFrame = FRAMEWIN_Create("Select language", NULL, WM_CF_SHOW, x, y, w, h); FRAMEWIN_SetActive(hFrame, 1); FRAMEWIN_SetMoveable(hFrame, 1); FRAMEWIN_AddMaxButton(hFrame, FRAMEWIN_BUTTON_RIGHT, 0); FRAMEWIN_AddMinButton(hFrame, FRAMEWIN_BUTTON_RIGHT, 1); FRAMEWIN_SetFont(hFrame, &GUI_Font13_ASCII); hListBox = LISTBOX_CreateAsChild(_asLang, WM_GetClientWindow(hFrame), 0, 0, 0, 0, WM_CF_SHOW | WM_SF_ANCHOR_LEFT | WM_SF_ANCHOR_TOP | WM_SF_ANCHOR_RIGHT | WM_SF_ANCHOR_BOTTOM); WM_SetFocus(hListBox); LISTBOX_SetFont(hListBox, pFont); GUIDEMO_Wait(); for (i = 0; (i < 10) && !GUIDEMO_CheckCancel(); i++) { LISTBOX_IncSel(hListBox); GUIDEMO_Delay(250); } for (i = 0; (i < 10) && !GUIDEMO_CheckCancel(); i++) { LISTBOX_DecSel(hListBox); GUIDEMO_Delay(250); } GUIDEMO_Delay(500); LISTBOX_Delete(hListBox); FRAMEWIN_Delete(hFrame); WM_SetDesktopColor(DesktopColorOld); }
/********************************************************************* * * 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_Handle LISTBOX_CreateIndirect(const GUI_WIDGET_CREATE_INFO* pCreateInfo, WM_HWIN hWinParent, int x0, int y0, WM_CALLBACK* cb) { LISTBOX_Handle hThis; GUI_USE_PARA(cb); hThis = LISTBOX_CreateAsChild(0, hWinParent, pCreateInfo->x0 + x0, pCreateInfo->y0 + y0, pCreateInfo->xSize, pCreateInfo->ySize, pCreateInfo->Flags); if (hThis) { LISTBOX_Obj* pObj = LISTBOX_H2P(hThis); INIT_ID(pObj); pObj->Widget.Id = pCreateInfo->Id; pObj->Widget.State = LISTBOX_STATE_INACTIVE; } return hThis; }
LISTBOX_Handle LISTBOX_Create( const GUI_ConstString* ppText, int x0, int y0, int xsize, int ysize, int Flags) { return LISTBOX_CreateAsChild(ppText, WM_HWIN_NULL /*hWin*/, x0, y0, xsize, ysize, Flags); }