/********************************************************************* * * _ToggleFullScreenMode * * Purpose: * This routine switches between full screen mode and normal mode by hiding or showing the * widgets of the dialog, enlarging/shrinking the graph widget and modifying some other * attributes of the dialog widgets. */ static void _ToggleFullScreenMode(WM_HWIN hDlg) { static int FullScreenMode; static GUI_RECT Rect; static unsigned ScalePos; WM_HWIN hGraph, hButton; hGraph = WM_GetDialogItem(hDlg, GUI_ID_GRAPH0); hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0); FullScreenMode ^= 1; if (FullScreenMode) { /* Enter the full screen mode */ WM_HWIN hClient; GUI_RECT RectInside; hClient = WM_GetClientWindow(hDlg); BUTTON_SetText(hButton, "Back"); WM_MoveWindow(hButton, 0, 11); FRAMEWIN_SetTitleVis(hDlg, 0); WM_GetInsideRectEx(hClient, &RectInside); WM_GetWindowRectEx(hGraph, &Rect); WM_ForEachDesc(hClient, _ForEach, &FullScreenMode); /* Hide all descendants */ WM_SetWindowPos(hGraph, WM_GetWindowOrgX(hClient), WM_GetWindowOrgX(hClient), RectInside.x1, RectInside.y1); ScalePos = GRAPH_SCALE_SetPos(_hScaleH, RectInside.y1 - 105); } else { /* Return to normal mode */ BUTTON_SetText(hButton, "Full Screen"); WM_MoveWindow(hButton, 0, -11); WM_ForEachDesc(WM_GetClientWindow(hDlg), _ForEach, &FullScreenMode); /* Show all descendants */ WM_SetWindowPos(hGraph, Rect.x0, Rect.y0, Rect.x1 - Rect.x0 + 1, Rect.y1 - Rect.y0 + 1); FRAMEWIN_SetTitleVis(hDlg, 1); GRAPH_SCALE_SetPos(_hScaleH, ScalePos); } }
/********************************************************************* * * WM_GetInsideRectExScrollbar * Purpose: Return the inside rectangle in client coordinates. The inside rectangle is the client rectangle minus the effect, which typically reduces the rectangle by 0 - 3 pixels on either side (2 for the standard 3D effect). */ void WM_GetInsideRectExScrollbar(WM_HWIN hWin, GUI_RECT* pRect) { GUI_RECT rWin, rInside, rScrollbar; WM_HWIN hBarV, hBarH; U16 WinFlags; if (hWin) { if (pRect) { hBarH = WM_GetDialogItem(hWin, GUI_ID_HSCROLL); hBarV = WM_GetDialogItem(hWin, GUI_ID_VSCROLL); WM_GetWindowRectEx(hWin, &rWin); /* The entire window in screen coordinates */ WM_GetInsideRectEx(hWin, &rInside); if (hBarV) { WM_GetWindowRectEx(hBarV, &rScrollbar); GUI_MoveRect(&rScrollbar, -rWin.x0, -rWin.y0); WinFlags = WM_GetFlags(hBarV); if ((WinFlags & WM_SF_ANCHOR_RIGHT) && (WinFlags & WM_SF_ISVIS)) { rInside.x1 = rScrollbar.x0 - 1; } } if (hBarH) { WM_GetWindowRectEx(hBarH, &rScrollbar); GUI_MoveRect(&rScrollbar, -rWin.x0, -rWin.y0); WinFlags = WM_GetFlags(hBarH); if ((WinFlags & WM_SF_ANCHOR_BOTTOM) && (WinFlags & WM_SF_ISVIS)) { rInside.y1 = rScrollbar.y0 - 1; } } *pRect = rInside; } } }
/********************************************************************* * * SCROLLBAR_CreateEx */ SCROLLBAR_Handle SCROLLBAR_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id) { SCROLLBAR_Handle hObj; WM_LOCK(); /* Set defaults if necessary */ if ((xsize == 0) && (ysize == 0)) { GUI_RECT Rect; WM_GetInsideRectEx(hParent, &Rect); if (ExFlags & SCROLLBAR_CF_VERTICAL) { xsize = SCROLLBAR__DefaultWidth; x0 = Rect.x1 + 1 - xsize; y0 = Rect.y0; ysize = Rect.y1 - Rect.y0 + 1; } else { ysize = SCROLLBAR__DefaultWidth; y0 = Rect.y1 + 1 - ysize; x0 = Rect.x0; xsize = Rect.x1 - Rect.x0 + 1; } } /* Create the window */ hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, _SCROLLBAR_Callback, sizeof(SCROLLBAR_Obj) - sizeof(WM_Obj)); if (hObj) { SCROLLBAR_Obj* pObj = SCROLLBAR_H2P(hObj); U16 InitState; /* Handle SpecialFlags */ InitState = 0; if (ExFlags & SCROLLBAR_CF_VERTICAL) { InitState |= WIDGET_CF_VERTICAL; } if (ExFlags & SCROLLBAR_CF_FOCUSSABLE) { InitState |= WIDGET_STATE_FOCUSSABLE; } if ((Id != GUI_ID_HSCROLL) && (Id != GUI_ID_VSCROLL)) { InitState |= WIDGET_STATE_FOCUSSABLE; } /* init widget specific variables */ WIDGET__Init(&pObj->Widget, Id, InitState); /* init member variables */ SCROLLBAR_INIT_ID(pObj); pObj->aBkColor[0] = SCROLLBAR__aDefaultBkColor[0]; pObj->aBkColor[1] = SCROLLBAR__aDefaultBkColor[1]; pObj->aColor[0] = SCROLLBAR__aDefaultColor[0]; pObj->aColor[1] = SCROLLBAR__aDefaultColor[1]; pObj->NumItems = 100; pObj->PageSize = 10; pObj->v = 0; SCROLLBAR__InvalidatePartner(hObj); } else { GUI_DEBUG_ERROROUT_IF(hObj==0, "SCROLLBAR_Create failed") } WM_UNLOCK(); return hObj; }
/********************************************************************* * * _OwnerDraw * * Purpose: * This is the owner draw function. * It allows complete customization of how the items in the listbox are * drawn. A command specifies what the function should do; * The minimum is to react to the draw command (WIDGET_ITEM_DRAW); * If the item x-size differs from the default, then this information * needs to be returned in reaction to WIDGET_ITEM_GET_XSIZE. * To insure compatibility with future version, all unhandled commands * must call the default routine LISTBOX_OwnerDraw. */ static int _OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) { WM_HWIN hWin; int Index; hWin = pDrawItemInfo->hWin; Index = pDrawItemInfo->ItemIndex; switch (pDrawItemInfo->Cmd) { case WIDGET_ITEM_GET_XSIZE: return _GetItemSizeX(hWin, Index); case WIDGET_ITEM_GET_YSIZE: return _GetItemSizeY(hWin, Index); case WIDGET_ITEM_DRAW: { int MultiSel, Sel, YSize, FontDistY; int IsDisabled, IsSelected; int ColorIndex = 0; char acBuffer[100]; const GUI_BITMAP * pBm; const GUI_FONT* pOldFont = 0; GUI_COLOR aColor[4] = {GUI_BLACK, GUI_WHITE, GUI_WHITE, GUI_GRAY}; GUI_COLOR aBkColor[4] = {GUI_WHITE, GUI_GRAY, GUI_BLUE, 0xC0C0C0}; IsDisabled = LISTBOX_GetItemDisabled(pDrawItemInfo->hWin, pDrawItemInfo->ItemIndex); IsSelected = LISTBOX_GetItemSel(hWin, Index); MultiSel = LISTBOX_GetMulti(hWin); Sel = LISTBOX_GetSel(hWin); YSize = _GetItemSizeY(hWin, Index); /* Calculate color index */ if (MultiSel) { if (IsDisabled) { ColorIndex = 3; } else { ColorIndex = (IsSelected) ? 2 : 0; } } else { if (IsDisabled) { ColorIndex = 3; } else { if (pDrawItemInfo->ItemIndex == Sel) { ColorIndex = WM_HasFocus(pDrawItemInfo->hWin) ? 2 : 1; } else { ColorIndex = 0; } } } /* Draw item */ GUI_SetBkColor(aBkColor[ColorIndex]); GUI_SetColor (aColor[ColorIndex]); LISTBOX_GetItemText(pDrawItemInfo->hWin, pDrawItemInfo->ItemIndex, acBuffer, sizeof(acBuffer)); GUI_Clear(); if ((ColorIndex == 1) || (ColorIndex == 2)) { pOldFont = GUI_SetFont(&GUI_Font13B_1); } FontDistY = GUI_GetFontDistY(); GUI_DispStringAt(acBuffer, pDrawItemInfo->x0 + bmSmilie0.XSize + 16, pDrawItemInfo->y0 + (YSize - FontDistY) / 2); if (pOldFont) { GUI_SetFont(pOldFont); } GUI_DispCEOL(); /* Draw bitmap */ pBm = MultiSel ? IsSelected ? &bmSmilie1 : &bmSmilie0 : (pDrawItemInfo->ItemIndex == Sel) ? &bmSmilie1 : &bmSmilie0; GUI_DrawBitmap(pBm, pDrawItemInfo->x0 + 7, pDrawItemInfo->y0 + (YSize - pBm->YSize) / 2); /* Draw focus rectangle */ if (MultiSel && (pDrawItemInfo->ItemIndex == Sel)) { GUI_RECT rFocus; GUI_RECT rInside; WM_GetInsideRectEx(pDrawItemInfo->hWin, &rInside); rFocus.x0 = pDrawItemInfo->x0; rFocus.y0 = pDrawItemInfo->y0; rFocus.x1 = rInside.x1; rFocus.y1 = pDrawItemInfo->y0 + YSize - 1; GUI_SetColor(GUI_WHITE - aBkColor[ColorIndex]); GUI_DrawFocusRect(&rFocus, 0); } } break; default: return LISTBOX_OwnerDraw(pDrawItemInfo); } return 0; }
/********************************************************************* * * WM_GetInsideRect */ void WM_GetInsideRect(GUI_RECT* pRect) { WM_GetInsideRectEx(GUI_Context.hAWin, pRect); }