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.

219 lines
6.7 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: drawfrm.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Window Frame Drawing Routines. (aka wmframe.c)
  7. *
  8. * History:
  9. * 10-22-90 MikeHar Ported functions from Win 3.0 sources.
  10. * 13-Feb-1991 mikeke Added Revalidation code
  11. \***************************************************************************/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. /***************************************************************************\
  15. * BitBltSysBmp
  16. *
  17. \***************************************************************************/
  18. BOOL FAR BitBltSysBmp(
  19. HDC hdc,
  20. int x,
  21. int y,
  22. UINT i
  23. )
  24. {
  25. BOOL bRet;
  26. POEMBITMAPINFO pOem = gpsi->oembmi + i;
  27. bRet = GreBitBlt(hdc,
  28. x,
  29. y,
  30. pOem->cx,
  31. pOem->cy,
  32. HDCBITS(),
  33. pOem->x,
  34. pOem->y,
  35. SRCCOPY,
  36. 0);
  37. /*
  38. * If the UI language is Hebrew we do not want to mirror the ? mark only
  39. * Then redraw ? with out the button frame.
  40. */
  41. if (HEBREW_UI_LANGID() && MIRRORED_HDC(hdc)) {
  42. if ((i >= OBI_HELP) && (i <= OBI_HELP_H)) {
  43. if (i == OBI_HELP_D) {
  44. x = x + SYSMET(CXEDGE);
  45. }
  46. bRet = GreBitBlt(hdc,
  47. x,
  48. y+SYSMET(CXEDGE),
  49. pOem->cx-SYSMET(CXEDGE)*2,
  50. pOem->cy-SYSMET(CXEDGE)*2,
  51. HDCBITS(),
  52. pOem->x+SYSMET(CXEDGE),
  53. pOem->y+SYSMET(CXEDGE),
  54. SRCCOPY|NOMIRRORBITMAP,
  55. 0);
  56. }
  57. }
  58. return bRet;
  59. }
  60. /***************************************************************************\
  61. * xxxDrawWindowFrame
  62. *
  63. * History:
  64. * 10-24-90 MikeHar Ported from WaWaWaWindows.
  65. \***************************************************************************/
  66. void xxxDrawWindowFrame(
  67. PWND pwnd,
  68. HDC hdc,
  69. UINT wFlags)
  70. {
  71. RECT rcClip;
  72. int cxFrame, cyFrame;
  73. UINT wDCFlags = DC_NC;
  74. CheckLock(pwnd);
  75. /*
  76. * If we are minimized, or if a parent is minimized or invisible,
  77. * we've got nothing to draw.
  78. */
  79. if (!IsVisible(pwnd) ||
  80. (TestWF(pwnd, WFNONCPAINT) && !TestWF(pwnd, WFMENUDRAW)) ||
  81. EqualRect(&pwnd->rcWindow, &pwnd->rcClient)) {
  82. return;
  83. }
  84. /*
  85. * If the update rgn is not NULL, we may have to invalidate the bits saved.
  86. */
  87. // if (TRUE) {
  88. if (pwnd->hrgnUpdate > NULL || GreGetClipBox(hdc, &rcClip, TRUE) != NULLREGION) {
  89. RECT rcWindow;
  90. int cBorders;
  91. if (TestWF(pwnd, WFMINIMIZED) && !TestWF(pwnd, WFNONCPAINT)) {
  92. if (TestWF(pwnd, WFFRAMEON))
  93. wDCFlags |= DC_ACTIVE;
  94. if (wFlags & DF_HUNGREDRAW)
  95. wDCFlags |= DC_NOSENDMSG;
  96. xxxDrawCaptionBar(pwnd, hdc, wDCFlags);
  97. return;
  98. }
  99. cxFrame = cyFrame = cBorders =
  100. GetWindowBorders(pwnd->style, pwnd->ExStyle, TRUE, FALSE);
  101. cxFrame *= SYSMET(CXBORDER);
  102. cyFrame *= SYSMET(CYBORDER);
  103. GetRect(pwnd, &rcWindow, GRECT_WINDOW | GRECT_WINDOWCOORDS);
  104. InflateRect(&rcWindow, -cxFrame, -cyFrame);
  105. /*
  106. * If the menu style is present, draw it.
  107. */
  108. if (TestWF(pwnd, WFMPRESENT) && !(wFlags & DF_HUNGREDRAW)) {
  109. rcWindow.top += xxxMenuBarDraw(pwnd, hdc, cxFrame, cyFrame);
  110. }
  111. /*
  112. * Draw the title bar if the window has a caption or any window
  113. * borders. Punt if the NONCPAINT bit is set, because that means
  114. * we're going to draw the frame a little bit later.
  115. */
  116. if ((TestWF(pwnd, WFBORDERMASK) != 0
  117. || TestWF(pwnd, WEFDLGMODALFRAME))
  118. || TestWF(pwnd, WFSIZEBOX)
  119. || TestWF(pwnd, WEFWINDOWEDGE)
  120. || TestWF(pwnd, WEFSTATICEDGE)
  121. && !TestWF(pwnd, WFNONCPAINT))
  122. {
  123. if (wFlags & DF_HUNGREDRAW)
  124. wDCFlags |= DC_NOSENDMSG;
  125. if (wFlags & DF_ACTIVE)
  126. wDCFlags |= DC_ACTIVE;
  127. xxxDrawCaptionBar(pwnd, hdc, wDCFlags | DC_NOVISIBLE);
  128. }
  129. //
  130. // Subtract out caption if present.
  131. //
  132. rcWindow.top += GetCaptionHeight(pwnd);
  133. //
  134. // Draw client edge
  135. //
  136. if (TestWF(pwnd, WFCEPRESENT)) {
  137. cxFrame += SYSMET(CXEDGE);
  138. cyFrame += SYSMET(CYEDGE);
  139. DrawEdge(hdc, &rcWindow, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
  140. }
  141. //
  142. // Since scrolls don't have to use tricks to overlap the window
  143. // border anymore, we don't have to worry about borders.
  144. //
  145. if (TestWF(pwnd, WFVPRESENT) && !(wFlags & DF_HUNGREDRAW)) {
  146. if (TestWF(pwnd, WFHPRESENT)) {
  147. // This accounts for client borders.
  148. DrawSize(pwnd, hdc, cxFrame, cyFrame);
  149. }
  150. xxxDrawScrollBar(pwnd, hdc, TRUE);
  151. }
  152. if (TestWF(pwnd, WFHPRESENT) && !(wFlags & DF_HUNGREDRAW))
  153. xxxDrawScrollBar(pwnd, hdc, FALSE);
  154. }
  155. }
  156. /***************************************************************************\
  157. * xxxRedrawFrame
  158. *
  159. * Called by scrollbars and menus to redraw a windows scroll bar or menu.
  160. *
  161. * History:
  162. * 10-24-90 MikeHar Ported from WaWaWaWindows.
  163. \***************************************************************************/
  164. void xxxRedrawFrame(
  165. PWND pwnd)
  166. {
  167. CheckLock(pwnd);
  168. /*
  169. * We always want to call xxxSetWindowPos, even if invisible or iconic,
  170. * because we need to make sure the WM_NCCALCSIZE message gets sent.
  171. */
  172. xxxSetWindowPos(pwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER |
  173. SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME);
  174. }
  175. void xxxRedrawFrameAndHook(
  176. PWND pwnd)
  177. {
  178. CheckLock(pwnd);
  179. /*
  180. * We always want to call xxxSetWindowPos, even if invisible or iconic,
  181. * because we need to make sure the WM_NCCALCSIZE message gets sent.
  182. */
  183. xxxSetWindowPos(pwnd, NULL, 0, 0, 0, 0, SWP_NOZORDER |
  184. SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME);
  185. if ( IsTrayWindow(pwnd) ) {
  186. HWND hw = HWq(pwnd);
  187. xxxCallHook(HSHELL_REDRAW, (WPARAM)hw, 0L, WH_SHELL);
  188. PostShellHookMessages(HSHELL_REDRAW, (LPARAM)hw);
  189. }
  190. }