/********************************************************************* * * FRAMEWIN_AddMenu */ void FRAMEWIN_AddMenu(FRAMEWIN_Handle hObj, WM_HWIN hMenu) { if (hObj) { FRAMEWIN_Obj* pObj; WM_LOCK(); pObj = FRAMEWIN_H2P(hObj); if (pObj) { int TitleHeight, BorderSize, IBorderSize = 0; int x0, y0, xSize; TitleHeight = FRAMEWIN__CalcTitleHeight(pObj); BorderSize = pObj->Props.BorderSize; if (pObj->Widget.State & FRAMEWIN_SF_TITLEVIS) { IBorderSize = pObj->Props.IBorderSize; } x0 = BorderSize; y0 = BorderSize + TitleHeight + IBorderSize; xSize = WM__GetWindowSizeX(&pObj->Widget.Win); xSize -= BorderSize * 2; pObj->hMenu = hMenu; if (pObj->cb) { MENU_SetOwner(hMenu, pObj->hClient); } MENU_Attach(hMenu, hObj, x0, y0, xSize, 0, 0); WM_SetAnchor(hMenu, WM_CF_ANCHOR_LEFT | WM_CF_ANCHOR_RIGHT); FRAMEWIN__UpdatePositions(pObj); FRAMEWIN_Invalidate(hObj); } WM_UNLOCK(); } }
/********************************************************************* * * DROPDOWN__AdjustHeight */ void DROPDOWN__AdjustHeight(DROPDOWN_Handle hObj, DROPDOWN_Obj* pObj) { int Height; Height = pObj->TextHeight; if (!Height) { Height = GUI_GetYDistOfFont(pObj->Props.pFont); } Height += pObj->Widget.pEffect->EffectSize + 2 * pObj->Props.TextBorderSize; WM_SetSize(hObj, WM__GetWindowSizeX(&pObj->Widget.Win), Height); }
/********************************************************************* * * WM_GetWindowSizeX Return width of window in pixels */ int WM_GetWindowSizeX(WM_HWIN hWin) { int r; WM_Obj* pWin; WM_LOCK(); hWin = _GetDefaultWin(hWin); pWin = WM_H2P(hWin); r = WM__GetWindowSizeX(pWin); WM_UNLOCK(); return r; }
/********************************************************************* * * 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(); } }