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.

321 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. fdstleg.c
  5. Abstract:
  6. Routines to support the status bar and legend displays.
  7. Author:
  8. Ted Miller (tedm) 7-Jan-1992
  9. --*/
  10. #include "fdisk.h"
  11. HFONT hFontStatus,hFontLegend;
  12. DWORD dyLegend,wLegendItem;
  13. DWORD dyStatus,dyBorder;
  14. // text for status area
  15. TCHAR StatusTextStat[STATUS_TEXT_SIZE];
  16. TCHAR StatusTextSize[STATUS_TEXT_SIZE];
  17. WCHAR StatusTextDrlt[3];
  18. WCHAR StatusTextType[STATUS_TEXT_SIZE];
  19. WCHAR StatusTextVoll[STATUS_TEXT_SIZE];
  20. TCHAR *LegendLabels[LEGEND_STRING_COUNT];
  21. // whether status bar and legend are currently shown
  22. BOOL StatusBar = TRUE,
  23. Legend = TRUE;
  24. VOID
  25. UpdateStatusBarDisplay(
  26. VOID
  27. )
  28. {
  29. RECT rc;
  30. if(StatusBar) {
  31. GetClientRect(hwndFrame,&rc);
  32. rc.top = rc.bottom - dyStatus;
  33. InvalidateRect(hwndFrame,&rc,FALSE);
  34. }
  35. }
  36. VOID
  37. ClearStatusArea(
  38. VOID
  39. )
  40. {
  41. StatusTextStat[0] = StatusTextSize[0] = 0;
  42. StatusTextVoll[0] = StatusTextType[0] = 0;
  43. StatusTextDrlt[0] = 0;
  44. UpdateStatusBarDisplay();
  45. }
  46. VOID
  47. DrawLegend(
  48. IN HDC hdc,
  49. IN PRECT rc
  50. )
  51. /*++
  52. Routine Description:
  53. This routine draws the legend onto the given device context. The legend
  54. lists the brush styles used to indicate various region types in the
  55. disk graphs.
  56. Arguments:
  57. None.
  58. Return Value:
  59. None.
  60. --*/
  61. {
  62. DWORD i,
  63. left,
  64. delta = GraphWidth / BRUSH_ARRAY_SIZE;
  65. HBRUSH hBrush;
  66. RECT rc1,rc2;
  67. HFONT hfontOld;
  68. SIZE size;
  69. DWORD dx;
  70. COLORREF OldTextColor,OldBkColor;
  71. rc1 = *rc;
  72. rc2 = *rc;
  73. // first draw the background.
  74. hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
  75. rc1.right = rc1.left + GetSystemMetrics(SM_CXSCREEN); // erase it all
  76. FillRect(hdc,&rc1,hBrush);
  77. DeleteObject(hBrush);
  78. // now draw the nice container
  79. rc2.left += 8 * dyBorder;
  80. rc2.right -= 8 * dyBorder;
  81. DrawStatusAreaItem(&rc2,hdc,NULL,FALSE);
  82. // now draw the legend items
  83. SelectObject(hdc,hPenThinSolid);
  84. left = rc2.left + (wLegendItem / 2);
  85. SetBkColor(hdc,GetSysColor(COLOR_BTNFACE));
  86. hfontOld = SelectObject(hdc,hFontLegend);
  87. OldTextColor = SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
  88. SetBkMode(hdc,OPAQUE);
  89. for(i=0; i<BRUSH_ARRAY_SIZE; i++) {
  90. hBrush = SelectObject(hdc,Brushes[i]);
  91. OldBkColor = SetBkColor(hdc,RGB(255,255,255));
  92. Rectangle(hdc,
  93. left,
  94. rc->top + (wLegendItem / 2),
  95. left + wLegendItem,
  96. rc->top + (3 * wLegendItem / 2)
  97. );
  98. SetBkColor(hdc,OldBkColor);
  99. // BUGBUG unicode lstrlen?
  100. GetTextExtentPoint(hdc,LegendLabels[i],lstrlen(LegendLabels[i]),&size);
  101. dx = (DWORD)size.cx;
  102. TextOut(hdc,
  103. left + (3*wLegendItem/2),
  104. rc->top + (wLegendItem / 2) + ((wLegendItem-size.cy)/2),
  105. LegendLabels[i],
  106. lstrlen(LegendLabels[i])
  107. );
  108. #if 0
  109. SelectObject(hdc,Brushes[++i]);
  110. OldBkColor = SetBkColor(hdc,RGB(255,255,255));
  111. Rectangle(hdc,
  112. left,
  113. rc->top + (2 * wLegendItem),
  114. left + wLegendItem,
  115. rc->top + (3 * wLegendItem)
  116. );
  117. SetBkColor(hdc,OldBkColor);
  118. GetTextExtentPoint(hdc,LegendLabels[i],lstrlen(LegendLabels[i]),&size);
  119. TextOut(hdc,
  120. left + (3*wLegendItem/2),
  121. rc->top + (2 * wLegendItem) + ((wLegendItem-size.cy)/2),
  122. LegendLabels[i],
  123. lstrlen(LegendLabels[i])
  124. );
  125. if((DWORD)size.cx > dx) {
  126. dx = (DWORD)size.cx;
  127. }
  128. #endif
  129. left += dx + (5*wLegendItem/2);
  130. if(hBrush) {
  131. SelectObject(hdc,hBrush);
  132. }
  133. }
  134. if(hfontOld) {
  135. SelectObject(hdc,hfontOld);
  136. }
  137. SetTextColor(hdc,OldTextColor);
  138. }
  139. VOID
  140. DrawStatusAreaItem(
  141. IN PRECT rc,
  142. IN HDC hdc,
  143. IN LPTSTR Text,
  144. IN BOOL Unicode
  145. )
  146. /*++
  147. Routine Description:
  148. This routine draws a status area item into a given dc. This
  149. includes drawing the nice shaded button-like container, and
  150. then drawing text within it.
  151. Arguments:
  152. rc - rectangle describing the status area item
  153. hdc - device context into which to draw
  154. Text - optional parameter that if present represents text to
  155. be placed in the item.
  156. Unicode - if TRUE, Text points to a wide character string regardless
  157. of the type of LPTSTR
  158. Return Value:
  159. None.
  160. --*/
  161. {
  162. HBRUSH hBrush;
  163. RECT rcx;
  164. // the shadow
  165. if(hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW))) {
  166. // left edge
  167. rcx.left = rc->left;
  168. rcx.right = rc->left + dyBorder;
  169. rcx.top = rc->top + (2*dyBorder);
  170. rcx.bottom = rc->bottom - (2*dyBorder);
  171. FillRect(hdc,&rcx,hBrush);
  172. // top edge
  173. rcx.right = rc->right;
  174. rcx.bottom = rcx.top + dyBorder;
  175. FillRect(hdc,&rcx,hBrush);
  176. DeleteObject(hBrush);
  177. }
  178. // the highlight
  179. if(hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNHIGHLIGHT))) {
  180. // right edge
  181. rcx.left = rc->right - dyBorder;
  182. rcx.right = rc->right;
  183. rcx.top = rc->top + (2*dyBorder);
  184. rcx.bottom = rc->bottom - (2*dyBorder);
  185. FillRect(hdc,&rcx,hBrush);
  186. // top edge
  187. rcx.left = rc->left;
  188. rcx.right = rc->right;
  189. rcx.top = rc->bottom - (3*dyBorder);
  190. rcx.bottom = rcx.top + dyBorder;
  191. FillRect(hdc,&rcx,hBrush);
  192. DeleteObject(hBrush);
  193. }
  194. if(Text) {
  195. // draw the text
  196. SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
  197. SetBkColor(hdc,GetSysColor(COLOR_BTNFACE));
  198. rcx.top = rc->top + (3*dyBorder);
  199. rcx.bottom = rc->bottom - (3*dyBorder);
  200. rcx.left = rc->left + dyBorder;
  201. rcx.right = rc->right - dyBorder;
  202. if(Unicode && (sizeof(TCHAR) != sizeof(WCHAR))) {
  203. ExtTextOutW(hdc,
  204. rcx.left+(2*dyBorder),
  205. rcx.top,
  206. ETO_OPAQUE | ETO_CLIPPED,
  207. &rcx,
  208. (PWSTR)Text,
  209. lstrlenW((PWSTR)Text),
  210. NULL
  211. );
  212. } else {
  213. ExtTextOut(hdc,
  214. rcx.left+(2*dyBorder),
  215. rcx.top,
  216. ETO_OPAQUE | ETO_CLIPPED,
  217. &rcx,
  218. Text,
  219. lstrlen(Text),
  220. NULL
  221. );
  222. }
  223. }
  224. }