/********************************************************************* * * _CalcBorderRect * * Calculates the border rect of the client area. */ static void _CalcBorderRect(MULTIPAGE_Obj* pObj, GUI_RECT* pRect) { WM__GetClientRectWin(&pObj->Widget.Win, pRect); if (pObj->Align & MULTIPAGE_ALIGN_BOTTOM) { pRect->y1 -= GUI_GetYSizeOfFont(pObj->Font) + 6; } else { pRect->y0 += GUI_GetYSizeOfFont(pObj->Font) + 6; } }
/********************************************************************* * * _CalcClientRect * * Calculates the rect of the client area. */ static void _CalcClientRect(MULTIPAGE_Obj* pObj, GUI_RECT* pRect) { WIDGET__GetInsideRect(&pObj->Widget, pRect); if (pObj->Align & MULTIPAGE_ALIGN_BOTTOM) { pRect->y1 -= GUI_GetYSizeOfFont(pObj->Font) + 6; } else { pRect->y0 += GUI_GetYSizeOfFont(pObj->Font) + 6; } }
static void CalcPositions( FRAMEWIN_Handle hObj) { if (hObj) { FRAMEWIN_Obj * pObj = FRAMEWIN_H2P(hObj); int TitleHeight; int FontSize = GUI_GetYSizeOfFont(pObj->pFont); int xsize = WM_GetWindowSizeX(hObj); int ysize = WM_GetWindowSizeY(hObj); TitleHeight = _DefaultCaptionSize; /* Make sure defaults are o.k. for us */ if (FontSize + 2 >= TitleHeight) TitleHeight = FontSize + 2; /* Set object properties accordingly */ pObj->rClient.x0 = _DefaultBorderSize; pObj->rClient.x1 = xsize - _DefaultBorderSize - 1; pObj->rClient.y0 = _DefaultBorderSize + FRAMEWIN_IBORDER_DEFAULT + TitleHeight; pObj->rClient.y1 = ysize - _DefaultBorderSize - 1; pObj->FrameSize = _DefaultBorderSize; pObj->TitleHeight = TitleHeight; if (pObj->hClient) { WM_MoveTo (pObj->hClient, pObj->rClient.x0 + pObj->Widget.Win.Rect.x0, pObj->rClient.y0 + pObj->Widget.Win.Rect.y0); WM_SetSize(pObj->hClient, pObj->rClient.x1 - pObj->rClient.x0 + 1, pObj->rClient.y1 - pObj->rClient.y0 + 1); } } }
/********************************************************************* * * _GetTextRect */ static void _GetTextRect(MULTIPAGE_Obj* pObj, GUI_RECT* pRect) { GUI_RECT rBorder; int Width, Height; Height = GUI_GetYSizeOfFont(pObj->Font) + 6; _CalcBorderRect(pObj, &rBorder); /* Calculate Y-Position of text item */ if (pObj->Align & MULTIPAGE_ALIGN_BOTTOM) { pRect->y0 = rBorder.y1; } else { pRect->y0 = 0; } pRect->y1 = pRect->y0 + Height; /* Calculate width of text items */ if (pObj->Widget.State & MULTIPAGE_STATE_SCROLLMODE) { Width = rBorder.x1 - ((Height * 3) >> 1) - 3; } else {
/********************************************************************* * * MESSAGEBOX_Create */ WM_HWIN MESSAGEBOX_Create(const char * sMessage, const char * sCaption, int Flags) { GUI_WIDGET_CREATE_INFO _aDialogCreate[3]; /* 0: FrameWin, 1: Text, 2: Button */ int BorderSize = FRAMEWIN_GetDefaultBorderSize(); /* Default border size of frame window */ int xSizeFrame = MESSAGEBOX_XSIZEOK + 2 * BorderSize + MESSAGEBOX_BORDER * 2; /* XSize of frame window */ int ySizeFrame; /* YSize of frame window */ int x0, y0; /* Position of frame window */ int xSizeMessage; /* Length in pixels of message */ int xSizeCaption; /* Length in pixels of caption */ int ySizeCaption; /* YSize of caption */ int ySizeMessage; /* YSize of message */ WM_HWIN hBox; GUI_RECT Rect; const GUI_FONT GUI_UNI_PTR * pOldFont; /* Zeroinit variables */ memset(_aDialogCreate, 0, sizeof(_aDialogCreate)); /* Get dimension of message */ pOldFont = GUI_SetFont(TEXT_GetDefaultFont()); GUI_GetTextExtend(&Rect, sMessage, 255); xSizeMessage = Rect.x1 - Rect.x0 + MESSAGEBOX_BORDER * 2; ySizeMessage = Rect.y1 - Rect.y0 + 1; if (xSizeFrame < (xSizeMessage + 4 + MESSAGEBOX_BORDER * 2)) { xSizeFrame = xSizeMessage + 4 + MESSAGEBOX_BORDER * 2; } ySizeCaption = GUI_GetYSizeOfFont(FRAMEWIN_GetDefaultFont()); ySizeFrame = ySizeMessage + /* size of message */ MESSAGEBOX_YSIZEOK + /* size of button */ ySizeCaption + /* caption size */ MESSAGEBOX_BORDER * 3 + /* inner border - text, text - button, button - bottom */ BorderSize * 2 + /* top & bottom border */ 1; /* inner border */ /* Get xsize of caption */ xSizeCaption = GUI_GetStringDistX(sCaption); if (xSizeFrame < xSizeCaption + BorderSize * 2) { xSizeFrame = xSizeCaption + BorderSize * 2; } /* Check maximum */ if (xSizeFrame > LCD_GET_XSIZE()) { xSizeFrame = LCD_GET_XSIZE(); } if (ySizeFrame > LCD_GET_YSIZE()) { ySizeFrame = LCD_GET_YSIZE(); } /* Calculate position of framewin */ x0 = GUI_OrgX + (LCD_GET_XSIZE() - xSizeFrame) / 2; y0 = GUI_OrgY + (LCD_GET_YSIZE() - ySizeFrame) / 2; /* restore modified Context */ GUI_SetFont(pOldFont); /* Fill frame win resource */ _aDialogCreate[0].pfCreateIndirect = FRAMEWIN_CreateIndirect; _aDialogCreate[0].pName = sCaption; _aDialogCreate[0].x0 = x0; _aDialogCreate[0].y0 = y0; _aDialogCreate[0].xSize = xSizeFrame; _aDialogCreate[0].ySize = ySizeFrame; if (Flags & GUI_MESSAGEBOX_CF_MOVEABLE) { _aDialogCreate[0].Flags = FRAMEWIN_CF_MOVEABLE; } /* Fill text resource */ _aDialogCreate[1].pfCreateIndirect = TEXT_CreateIndirect; _aDialogCreate[1].pName = sMessage; _aDialogCreate[1].x0 = (xSizeFrame - xSizeMessage - BorderSize * 2) / 2; _aDialogCreate[1].y0 = MESSAGEBOX_BORDER; _aDialogCreate[1].xSize = xSizeMessage; _aDialogCreate[1].ySize = ySizeMessage; _aDialogCreate[1].Para = GUI_TA_TOP | GUI_TA_HCENTER; /* Fill button resource */ _aDialogCreate[2].pfCreateIndirect = BUTTON_CreateIndirect; _aDialogCreate[2].pName = "OK"; _aDialogCreate[2].Id = GUI_ID_OK; _aDialogCreate[2].x0 = (xSizeFrame - MESSAGEBOX_XSIZEOK - BorderSize * 2) / 2; _aDialogCreate[2].y0 = MESSAGEBOX_BORDER * 2 + ySizeMessage; _aDialogCreate[2].xSize = MESSAGEBOX_XSIZEOK; _aDialogCreate[2].ySize = MESSAGEBOX_YSIZEOK; /* Create dialog */ hBox = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), MESSAGEBOX_Callback, 0, 0, 0); if (Flags & GUI_MESSAGEBOX_CF_MODAL) { WM_MakeModal(hBox); } return hBox; }