Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.3 KiB

  1. /*
  2. * PAINT.C
  3. * GizmoBar Version 1.00, Win32 version August 1993
  4. *
  5. * Contains any code related to GizmoBar visuals, primarily
  6. * the WM_PAINT handler.
  7. *
  8. * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9. *
  10. * Kraig Brockschmidt, Software Design Engineer
  11. * Microsoft Systems Developer Relations
  12. *
  13. * Internet : kraigb@microsoft.com
  14. * Compuserve: >INTERNET:kraigb@microsoft.com
  15. */
  16. #include <windows.h>
  17. #include "gizmoint.h"
  18. //In GIZMO.C
  19. extern TOOLDISPLAYDATA tdd;
  20. /*
  21. * GizmoBarPaint
  22. *
  23. * Purpose:
  24. * Handles all WM_PAINT messages for the control and paints either the
  25. * entire thing or just one GizmoBar button if pGB->pGizmoPaint is non-NULL.
  26. *
  27. * Parameters:
  28. * hWnd HWND Handle to the control.
  29. * pGB LPGIZMOBAR control data pointer.
  30. *
  31. * Return Value:
  32. * None
  33. */
  34. void GizmoBarPaint(HWND hWnd, LPGIZMOBAR pGB)
  35. {
  36. PAINTSTRUCT ps;
  37. RECT rc;
  38. HDC hDC;
  39. HBRUSH hBr=NULL;
  40. HPEN hPen=NULL;
  41. hDC=BeginPaint(hWnd, &ps);
  42. GetClientRect(hWnd, &rc);
  43. /*
  44. * The only part of the frame we need to draw is the bottom line,
  45. * so we inflate the rectangle such that all other parts are outside
  46. * the visible region.
  47. */
  48. hBr =CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
  49. if (NULL!=hBr)
  50. SelectObject(hDC, hBr);
  51. hPen=CreatePen(PS_SOLID, 1, GetSysColor(COLOR_WINDOWFRAME));
  52. if (NULL!=hPen)
  53. SelectObject(hDC, hPen);
  54. Rectangle(hDC, rc.left-1, rc.top-1, rc.right+1, rc.bottom);
  55. /*
  56. * All that we have to do to draw the controls is start through the
  57. * list, ignoring anything but buttons, and calling BTTNCUR's
  58. * UIToolButtonDraw for buttons. Since we don't even have to track
  59. * positions of things, we can just use an enum.
  60. */
  61. GizmoPEnum(&pGB->pGizmos, FEnumPaintGizmos, (DWORD)(LPSTR)&ps);
  62. //Clean up
  63. EndPaint(hWnd, &ps);
  64. if (NULL!=hBr)
  65. DeleteObject(hBr);
  66. if (NULL!=hPen)
  67. DeleteObject(hPen);
  68. return;
  69. }
  70. /*
  71. * FEnumPaintGizmos
  72. *
  73. * Purpose:
  74. * Enumeration callback for all the gizmos we know about in order to
  75. * draw them.
  76. *
  77. * Parameters:
  78. * pGizmo LPGIZMO to draw.
  79. * iGizmo UINT index on the GizmoBar of this gizmo.
  80. * dw DWORD extra data passed to GizmoPEnum, in our case
  81. * a pointer to the PAINTSTRUCT.
  82. *
  83. * Return Value:
  84. * BOOL TRUE to continue the enumeration, FALSE otherwise.
  85. */
  86. BOOL FAR PASCAL FEnumPaintGizmos(LPGIZMO pGizmo, UINT iGizmo, DWORD dw)
  87. {
  88. LPPAINTSTRUCT pps=(LPPAINTSTRUCT)dw;
  89. RECT rc, rcI;
  90. //Only draw those marked for repaint.
  91. if ((GIZMOTYPE_DRAWN & pGizmo->iType))
  92. {
  93. SetRect(&rc, pGizmo->x, pGizmo->y, pGizmo->x+pGizmo->dx, pGizmo->y+pGizmo->dy);
  94. //Only draw gizmos in the repaint area
  95. if (IntersectRect(&rcI, &rc, &pps->rcPaint))
  96. {
  97. UIToolButtonDrawTDD(pps->hdc, pGizmo->x, pGizmo->y
  98. , pGizmo->dx, pGizmo->dy, pGizmo->hBmp, pGizmo->cxImage
  99. , pGizmo->cyImage, pGizmo->iBmp, (UINT)pGizmo->uState, &tdd);
  100. }
  101. }
  102. return TRUE;
  103. }