/********************************************************************* * * 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(); } }
/********************************************************************* * * _RestoreMaximized */ static void _RestoreMaximized(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) { /* When window was maximized, restore it */ if (pObj->Flags & FRAMEWIN_SF_MAXIMIZED) { GUI_RECT r = pObj->rRestore; WM_MoveTo(hObj, r.x0, r.y0); WM_SetSize(hObj, r.x1 - r.x0 + 1, r.y1 - r.y0 + 1); FRAMEWIN__UpdatePositions(pObj); pObj->Flags &= ~FRAMEWIN_SF_MAXIMIZED; _InvalidateButton(pObj, GUI_ID_MAXIMIZE); } }
/********************************************************************* * * FRAMEWIN_SetFont */ void FRAMEWIN_SetFont(FRAMEWIN_Handle hObj, const GUI_FONT GUI_UNI_PTR * pFont) { GUI_LOCK(); if (hObj) { FRAMEWIN_Obj* pObj = FRAMEWIN_H2P(hObj); int OldHeight = FRAMEWIN__CalcTitleHeight(pObj); pObj->Props.pFont = pFont; FRAMEWIN__UpdatePositions(pObj); FRAMEWIN__UpdateButtons(pObj, OldHeight); FRAMEWIN_Invalidate(hObj); } GUI_UNLOCK(); }
/********************************************************************* * * _RestoreMinimized */ static void _RestoreMinimized(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) { /* When window was minimized, restore it */ if (pObj->Flags & FRAMEWIN_SF_MINIMIZED) { int OldHeight = 1 + pObj->Widget.Win.Rect.y1 - pObj->Widget.Win.Rect.y0; int NewHeight = 1 + pObj->rRestore.y1 - pObj->rRestore.y0; WM_ResizeWindow(hObj, 0, NewHeight - OldHeight); WM_ShowWindow(pObj->hClient); WM_ShowWindow(pObj->hMenu); FRAMEWIN__UpdatePositions(pObj); pObj->Flags &= ~FRAMEWIN_SF_MINIMIZED; _InvalidateButton(pObj, GUI_ID_MINIMIZE); } }
/********************************************************************* * * _MinimizeFramewin */ static void _MinimizeFramewin(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) { _RestoreMaximized(hObj, pObj); /* When window is not minimized, minimize it */ if ((pObj->Flags & FRAMEWIN_SF_MINIMIZED) == 0) { int OldHeight = pObj->Widget.Win.Rect.y1 - pObj->Widget.Win.Rect.y0 + 1; int NewHeight = FRAMEWIN__CalcTitleHeight(pObj) + pObj->Widget.pEffect->EffectSize * 2 + 2; pObj->rRestore = pObj->Widget.Win.Rect; WM_HideWindow(pObj->hClient); WM_HideWindow(pObj->hMenu); WM_ResizeWindow(hObj, 0, NewHeight - OldHeight); FRAMEWIN__UpdatePositions(pObj); pObj->Flags |= FRAMEWIN_SF_MINIMIZED; _InvalidateButton(pObj, GUI_ID_MINIMIZE); } }
/********************************************************************* * * _MaximizeFramewin */ static void _MaximizeFramewin(FRAMEWIN_Handle hObj, FRAMEWIN_Obj* pObj) { _RestoreMinimized(hObj, pObj); /* When window is not maximized, maximize it */ if ((pObj->Flags & FRAMEWIN_SF_MAXIMIZED) == 0) { WM_HWIN hParent = pObj->Widget.Win.hParent; WM_Obj* pParent = WM_H2P(hParent); GUI_RECT r = pParent->Rect; if (pParent->hParent == 0) { r.x1 = LCD_GetXSize(); r.y1 = LCD_GetYSize(); } pObj->rRestore = pObj->Widget.Win.Rect; WM_MoveTo(hObj, r.x0, r.y0); WM_SetSize(hObj, r.x1 - r.x0 + 1, r.y1 - r.y0 + 1); FRAMEWIN__UpdatePositions(pObj); pObj->Flags |= FRAMEWIN_SF_MAXIMIZED; _InvalidateButton(pObj, GUI_ID_MAXIMIZE); } }