* Sync up to trunk HEAD (r62502).
[reactos.git] / dll / cpl / desk / draw.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Display Control Panel
4 * FILE: dll/cpl/desk/draw.c
5 * PURPOSE: Providing drawing functions
6 *
7 * PROGRAMMERS: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
8 */
9
10 #include "desk.h"
11
12 #define MENU_BAR_ITEMS_SPACE (12)
13
14 /******************************************************************************/
15
16 static const signed char LTInnerNormal[] = {
17 -1, -1, -1, -1,
18 -1, COLOR_BTNHIGHLIGHT, COLOR_BTNHIGHLIGHT, -1,
19 -1, COLOR_3DDKSHADOW, COLOR_3DDKSHADOW, -1,
20 -1, -1, -1, -1
21 };
22
23 static const signed char LTOuterNormal[] = {
24 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
25 COLOR_BTNHIGHLIGHT, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
26 COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
27 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1
28 };
29
30 static const signed char RBInnerNormal[] = {
31 -1, -1, -1, -1,
32 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
33 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
34 -1, -1, -1, -1
35 };
36
37 static const signed char RBOuterNormal[] = {
38 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
39 COLOR_BTNSHADOW, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
40 COLOR_3DLIGHT, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
41 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1
42 };
43
44 static const signed char LTRBOuterMono[] = {
45 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
46 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
47 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
48 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
49 };
50
51 static const signed char LTRBInnerMono[] = {
52 -1, -1, -1, -1,
53 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
54 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
55 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
56 };
57
58 static BOOL
59 MyIntDrawRectEdge(HDC hdc, LPRECT rc, UINT uType, UINT uFlags, COLOR_SCHEME *scheme)
60 {
61 signed char LTInnerI, LTOuterI;
62 signed char RBInnerI, RBOuterI;
63 HPEN LTInnerPen, LTOuterPen;
64 HPEN RBInnerPen, RBOuterPen;
65 RECT InnerRect = *rc;
66 POINT SavePoint;
67 HPEN SavePen;
68 int LBpenplus = 0;
69 int LTpenplus = 0;
70 int RTpenplus = 0;
71 int RBpenplus = 0;
72 /* Init some vars */
73 LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN)GetStockObject(NULL_PEN);
74 SavePen = (HPEN)SelectObject(hdc, LTInnerPen);
75
76 /* Determine the colors of the edges */
77 LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
78 LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
79 RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
80 RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
81
82 if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT)
83 LBpenplus = 1;
84 if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT)
85 RTpenplus = 1;
86 if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT)
87 RBpenplus = 1;
88 if((uFlags & BF_TOPLEFT) == BF_TOPLEFT)
89 LTpenplus = 1;
90
91 if(LTInnerI != -1)
92 LTInnerPen = GetStockObject(DC_PEN);
93 if(LTOuterI != -1)
94 LTOuterPen = GetStockObject(DC_PEN);
95 if(RBInnerI != -1)
96 RBInnerPen = GetStockObject(DC_PEN);
97 if(RBOuterI != -1)
98 RBOuterPen = GetStockObject(DC_PEN);
99 {
100 HBRUSH hbr;
101
102 if((uFlags & MY_BF_ACTIVEBORDER))
103 hbr = CreateSolidBrush(scheme->crColor[COLOR_ACTIVEBORDER]);
104 else
105 hbr = CreateSolidBrush(scheme->crColor[COLOR_BTNFACE]);
106 FillRect(hdc, &InnerRect, hbr);
107 DeleteObject(hbr);
108 }
109 MoveToEx(hdc, 0, 0, &SavePoint);
110
111 /* Draw the outer edge */
112 SelectObject(hdc, LTOuterPen);
113 SetDCPenColor(hdc, scheme->crColor[LTOuterI]);
114 if(uFlags & BF_TOP)
115 {
116 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
117 LineTo(hdc, InnerRect.right, InnerRect.top);
118 }
119 if(uFlags & BF_LEFT)
120 {
121 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
122 LineTo(hdc, InnerRect.left, InnerRect.bottom);
123 }
124 SelectObject(hdc, RBOuterPen);
125 SetDCPenColor(hdc, scheme->crColor[RBOuterI]);
126 if(uFlags & BF_BOTTOM)
127 {
128 MoveToEx(hdc, InnerRect.left, InnerRect.bottom-1, NULL);
129 LineTo(hdc, InnerRect.right, InnerRect.bottom-1);
130 }
131 if(uFlags & BF_RIGHT)
132 {
133 MoveToEx(hdc, InnerRect.right-1, InnerRect.top, NULL);
134 LineTo(hdc, InnerRect.right-1, InnerRect.bottom);
135 }
136
137 /* Draw the inner edge */
138 SelectObject(hdc, LTInnerPen);
139 SetDCPenColor(hdc, scheme->crColor[LTInnerI]);
140 if(uFlags & BF_TOP)
141 {
142 MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
143 LineTo(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
144 }
145 if(uFlags & BF_LEFT)
146 {
147 MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
148 LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
149 }
150 SelectObject(hdc, RBInnerPen);
151 SetDCPenColor(hdc, scheme->crColor[RBInnerI]);
152 if(uFlags & BF_BOTTOM)
153 {
154 MoveToEx(hdc, InnerRect.left+LBpenplus, InnerRect.bottom-2, NULL);
155 LineTo(hdc, InnerRect.right-RBpenplus, InnerRect.bottom-2);
156 }
157 if(uFlags & BF_RIGHT)
158 {
159 MoveToEx(hdc, InnerRect.right-2, InnerRect.top+RTpenplus, NULL);
160 LineTo(hdc, InnerRect.right-2, InnerRect.bottom-RBpenplus);
161 }
162
163 if (uFlags & BF_ADJUST)
164 {
165 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
166 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
167
168 if(uFlags & BF_LEFT)
169 InnerRect.left += add;
170 if(uFlags & BF_RIGHT)
171 InnerRect.right -= add;
172 if(uFlags & BF_TOP)
173 InnerRect.top += add;
174 if(uFlags & BF_BOTTOM)
175 InnerRect.bottom -= add;
176
177 if(uFlags & BF_ADJUST)
178 *rc = InnerRect;
179 }
180
181 /* Cleanup */
182 SelectObject(hdc, SavePen);
183 MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
184 return TRUE;
185 }
186
187 static BOOL
188 MyDrawFrameButton(HDC hdc, LPRECT rc, UINT uState, COLOR_SCHEME *scheme)
189 {
190 UINT edge;
191 if(uState & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
192 edge = EDGE_SUNKEN;
193 else
194 edge = EDGE_RAISED;
195 return MyIntDrawRectEdge(hdc, rc, edge, (uState & DFCS_FLAT) | BF_RECT | BF_SOFT, scheme);
196 }
197
198 static int
199 MyMakeSquareRect(LPRECT src, LPRECT dst)
200 {
201 int Width = src->right - src->left;
202 int Height = src->bottom - src->top;
203 int SmallDiam = Width > Height ? Height : Width;
204
205 *dst = *src;
206
207 /* Make it a square box */
208 if (Width < Height) /* SmallDiam == Width */
209 {
210 dst->top += (Height-Width)/2;
211 dst->bottom = dst->top + SmallDiam;
212 }
213 else if(Width > Height) /* SmallDiam == Height */
214 {
215 dst->left += (Width-Height)/2;
216 dst->right = dst->left + SmallDiam;
217 }
218
219 return SmallDiam;
220 }
221
222 static BOOL
223 MyDrawFrameCaption(HDC dc, LPRECT r, UINT uFlags, COLOR_SCHEME *scheme)
224 {
225 LOGFONT lf;
226 HFONT hFont, hOldFont;
227 COLORREF clrsave;
228 RECT myr;
229 INT bkmode;
230 TCHAR Symbol;
231 switch(uFlags & 0xff)
232 {
233 case DFCS_CAPTIONCLOSE:
234 Symbol = 'r';
235 break;
236 case DFCS_CAPTIONHELP:
237 Symbol = 's';
238 break;
239 case DFCS_CAPTIONMIN:
240 Symbol = '0';
241 break;
242 case DFCS_CAPTIONMAX:
243 Symbol = '1';
244 break;
245 case DFCS_CAPTIONRESTORE:
246 Symbol = '2';
247 break;
248 }
249 MyIntDrawRectEdge(dc, r, (uFlags & DFCS_PUSHED) ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT | BF_MIDDLE | BF_SOFT, scheme);
250 ZeroMemory(&lf, sizeof(LOGFONT));
251 MyMakeSquareRect(r, &myr);
252 myr.left += 1;
253 myr.top += 1;
254 myr.right -= 1;
255 myr.bottom -= 1;
256 if(uFlags & DFCS_PUSHED)
257 OffsetRect(&myr,1,1);
258 lf.lfHeight = myr.bottom - myr.top;
259 lf.lfWidth = 0;
260 lf.lfWeight = FW_NORMAL;
261 lf.lfCharSet = DEFAULT_CHARSET;
262 lstrcpy(lf.lfFaceName, TEXT("Marlett"));
263 hFont = CreateFontIndirect(&lf);
264 /* Save font and text color */
265 hOldFont = SelectObject(dc, hFont);
266 clrsave = GetTextColor(dc);
267 bkmode = GetBkMode(dc);
268 /* Set color and drawing mode */
269 SetBkMode(dc, TRANSPARENT);
270 if(uFlags & DFCS_INACTIVE)
271 {
272 /* Draw shadow */
273 SetTextColor(dc, scheme->crColor[COLOR_BTNHIGHLIGHT]);
274 TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1);
275 }
276 SetTextColor(dc, scheme->crColor[(uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT]);
277 /* Draw selected symbol */
278 TextOut(dc, myr.left, myr.top, &Symbol, 1);
279 /* Restore previous settings */
280 SetTextColor(dc, clrsave);
281 SelectObject(dc, hOldFont);
282 SetBkMode(dc, bkmode);
283 DeleteObject(hFont);
284 return TRUE;
285 }
286
287 /******************************************************************************/
288
289 static BOOL
290 MyDrawFrameScroll(HDC dc, LPRECT r, UINT uFlags, COLOR_SCHEME *scheme)
291 {
292 LOGFONT lf;
293 HFONT hFont, hOldFont;
294 COLORREF clrsave;
295 RECT myr;
296 INT bkmode;
297 TCHAR Symbol;
298 switch(uFlags & 0xff)
299 {
300 case DFCS_SCROLLCOMBOBOX:
301 case DFCS_SCROLLDOWN:
302 Symbol = '6';
303 break;
304
305 case DFCS_SCROLLUP:
306 Symbol = '5';
307 break;
308
309 case DFCS_SCROLLLEFT:
310 Symbol = '3';
311 break;
312
313 case DFCS_SCROLLRIGHT:
314 Symbol = '4';
315 break;
316 }
317 MyIntDrawRectEdge(dc, r, (uFlags & DFCS_PUSHED) ? EDGE_SUNKEN : EDGE_RAISED, (uFlags&DFCS_FLAT) | BF_MIDDLE | BF_RECT, scheme);
318 ZeroMemory(&lf, sizeof(LOGFONT));
319 MyMakeSquareRect(r, &myr);
320 myr.left += 1;
321 myr.top += 1;
322 myr.right -= 1;
323 myr.bottom -= 1;
324 if(uFlags & DFCS_PUSHED)
325 OffsetRect(&myr,1,1);
326 lf.lfHeight = myr.bottom - myr.top;
327 lf.lfWidth = 0;
328 lf.lfWeight = FW_NORMAL;
329 lf.lfCharSet = DEFAULT_CHARSET;
330 lstrcpy(lf.lfFaceName, TEXT("Marlett"));
331 hFont = CreateFontIndirect(&lf);
332 /* Save font and text color */
333 hOldFont = SelectObject(dc, hFont);
334 clrsave = GetTextColor(dc);
335 bkmode = GetBkMode(dc);
336 /* Set color and drawing mode */
337 SetBkMode(dc, TRANSPARENT);
338 if(uFlags & DFCS_INACTIVE)
339 {
340 /* Draw shadow */
341 SetTextColor(dc, scheme->crColor[COLOR_BTNHIGHLIGHT]);
342 TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1);
343 }
344 SetTextColor(dc, scheme->crColor[(uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT]);
345 /* Draw selected symbol */
346 TextOut(dc, myr.left, myr.top, &Symbol, 1);
347 /* restore previous settings */
348 SetTextColor(dc, clrsave);
349 SelectObject(dc, hOldFont);
350 SetBkMode(dc, bkmode);
351 DeleteObject(hFont);
352 return TRUE;
353 }
354
355 BOOL
356 MyDrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState, COLOR_SCHEME *scheme)
357 {
358 switch(uType)
359 {
360 case DFC_BUTTON:
361 return MyDrawFrameButton(hDC, rc, uState, scheme);
362 case DFC_CAPTION:
363 return MyDrawFrameCaption(hDC, rc, uState, scheme);
364 case DFC_SCROLL:
365 return MyDrawFrameScroll(hDC, rc, uState, scheme);
366 }
367 return FALSE;
368 }
369
370 BOOL
371 MyDrawEdge(HDC hDC, LPRECT rc, UINT edge, UINT flags, COLOR_SCHEME *scheme)
372 {
373 return MyIntDrawRectEdge(hDC, rc, edge, flags, scheme);
374 }
375
376 VOID
377 MyDrawCaptionButtons(HDC hdc, LPRECT lpRect, BOOL bMinMax, int x, COLOR_SCHEME *scheme)
378 {
379 RECT rc3;
380 RECT rc4;
381 RECT rc5;
382
383 rc3.left = lpRect->right - 2 - x;
384 rc3.top = lpRect->top + 2;
385 rc3.right = lpRect->right - 2;
386 rc3.bottom = lpRect->bottom - 2;
387
388 MyDrawFrameControl(hdc, &rc3, DFC_CAPTION, DFCS_CAPTIONCLOSE, scheme);
389
390 if (bMinMax)
391 {
392 rc4.left = rc3.left - x - 2;
393 rc4.top = rc3.top;
394 rc4.right = rc3.right - x - 2;
395 rc4.bottom = rc3.bottom;
396
397 MyDrawFrameControl(hdc, &rc4, DFC_CAPTION, DFCS_CAPTIONMAX, scheme);
398
399 rc5.left = rc4.left - x;
400 rc5.top = rc4.top;
401 rc5.right = rc4.right - x;
402 rc5.bottom = rc4.bottom;
403
404 MyDrawFrameControl(hdc, &rc5, DFC_CAPTION, DFCS_CAPTIONMIN, scheme);
405 }
406 }
407
408 VOID
409 MyDrawScrollbar(HDC hdc, LPRECT rc, HBRUSH hbrScrollbar, COLOR_SCHEME *scheme)
410 {
411 RECT rcTop;
412 RECT rcBottom;
413 RECT rcMiddle;
414 int width;
415
416 width = rc->right - rc->left;
417
418 rcTop.left = rc->left;
419 rcTop.right = rc->right;
420 rcTop.top = rc->top;
421 rcTop.bottom = rc->top + width;
422
423 rcMiddle.left = rc->left;
424 rcMiddle.right = rc->right;
425 rcMiddle.top = rc->top + width;
426 rcMiddle.bottom = rc->bottom - width;
427
428 rcBottom.left = rc->left;
429 rcBottom.right = rc->right;
430 rcBottom.top = rc->bottom - width;
431 rcBottom.bottom = rc->bottom;
432
433 MyDrawFrameControl(hdc, &rcTop, DFC_SCROLL, DFCS_SCROLLUP, scheme);
434 MyDrawFrameControl(hdc, &rcBottom, DFC_SCROLL, DFCS_SCROLLDOWN, scheme);
435
436 FillRect(hdc, &rcMiddle, hbrScrollbar);
437 }
438
439 /******************************************************************************/
440
441 BOOL
442 MyDrawCaptionTemp(HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, HICON hIcon, LPCWSTR str, UINT uFlags, COLOR_SCHEME *scheme)
443 {
444 //ULONG Height;
445 //UINT VCenter, Padding;
446 //LONG ButtonWidth;
447 HBRUSH hbr;
448 HGDIOBJ hFontOld;
449 RECT rc;
450
451 //Height = scheme->Size[SIZE_CAPTION_Y] - 1;
452 //VCenter = (rect->bottom - rect->top) / 2;
453 //Padding = VCenter - (Height / 2);
454
455 //ButtonWidth = scheme->Size[SIZE_SIZE_X] - 2;
456
457 if (uFlags & DC_GRADIENT)
458 {
459 GRADIENT_RECT gcap = {0, 1};
460 TRIVERTEX vert[2];
461 COLORREF Colors[2];
462
463 Colors[0] = scheme->crColor[((uFlags & DC_ACTIVE) ?
464 COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION)];
465 Colors[1] = scheme->crColor[((uFlags & DC_ACTIVE) ?
466 COLOR_GRADIENTACTIVECAPTION : COLOR_GRADIENTINACTIVECAPTION)];
467
468 vert[0].x = rect->left;
469 vert[0].y = rect->top;
470 vert[0].Red = (WORD)Colors[0]<<8;
471 vert[0].Green = (WORD)Colors[0] & 0xFF00;
472 vert[0].Blue = (WORD)(Colors[0]>>8) & 0xFF00;
473 vert[0].Alpha = 0;
474
475 vert[1].x = rect->right;
476 vert[1].y = rect->bottom;
477 vert[1].Red = (WORD)Colors[1]<<8;
478 vert[1].Green = (WORD)Colors[1] & 0xFF00;
479 vert[1].Blue = (WORD)(Colors[1]>>8) & 0xFF00;
480 vert[1].Alpha = 0;
481
482 GdiGradientFill(hdc, vert, 2, &gcap, 1, GRADIENT_FILL_RECT_H);
483 }
484 else
485 {
486 if (uFlags & DC_ACTIVE)
487 hbr = CreateSolidBrush(scheme->crColor[COLOR_ACTIVECAPTION]);
488 else
489 hbr = CreateSolidBrush(scheme->crColor[COLOR_INACTIVECAPTION]);
490 FillRect(hdc, rect, hbr);
491 DeleteObject(hbr);
492 }
493
494 hFontOld = SelectObject(hdc, hFont);
495 SetBkMode(hdc, TRANSPARENT);
496 if (uFlags & DC_ACTIVE)
497 SetTextColor(hdc, scheme->crColor[COLOR_CAPTIONTEXT]);
498 else
499 SetTextColor(hdc, scheme->crColor[COLOR_INACTIVECAPTIONTEXT]);
500 rc.left = rect->left + 2;
501 rc.top = rect->top;
502 rc.right = rect->right;
503 rc.bottom = rect->bottom;
504 DrawTextW(hdc, str, -1, &rc, DT_SINGLELINE | DT_VCENTER);
505 SelectObject(hdc, hFontOld);
506 return TRUE;
507 }
508
509 /******************************************************************************/
510
511 DWORD
512 MyDrawMenuBarTemp(HWND Wnd, HDC DC, LPRECT Rect, HMENU Menu, HFONT Font, COLOR_SCHEME *scheme)
513 {
514 HBRUSH hbr;
515 HPEN hPen;
516 HGDIOBJ hPenOld, hFontOld;
517 BOOL flat_menu;
518 INT i, bkgnd, x;
519 RECT rect;
520 WCHAR Text[128];
521 UINT uFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE;
522
523 flat_menu = scheme->bFlatMenus;
524
525 if (flat_menu)
526 hbr = CreateSolidBrush(scheme->crColor[COLOR_MENUBAR]);
527 else
528 hbr = CreateSolidBrush(scheme->crColor[COLOR_MENU]);
529 FillRect(DC, Rect, hbr);
530 DeleteObject(hbr);
531
532 hPen = CreatePen(PS_SOLID, 0, scheme->crColor[COLOR_3DFACE]);
533 hPenOld = SelectObject(DC, hPen);
534 MoveToEx(DC, Rect->left, Rect->bottom - 1, NULL);
535 LineTo(DC, Rect->right, Rect->bottom - 1);
536 SelectObject(DC, hPenOld);
537 DeleteObject(hPen);
538
539 bkgnd = (flat_menu ? COLOR_MENUBAR : COLOR_MENU);
540 x = Rect->left;
541 hFontOld = SelectObject(DC, Font);
542 for(i = 0; i < 3; i++)
543 {
544 GetMenuStringW(Menu, i, Text, 128, MF_BYPOSITION);
545
546 rect.left = rect.right = x;
547 rect.top = Rect->top;
548 rect.bottom = Rect->bottom;
549 DrawTextW(DC, Text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
550 rect.bottom = Rect->bottom;
551 rect.right += MENU_BAR_ITEMS_SPACE;
552 x += rect.right - rect.left;
553
554 if (i == 2)
555 {
556 if (flat_menu)
557 {
558 SetTextColor(DC, scheme->crColor[COLOR_HIGHLIGHTTEXT]);
559 SetBkColor(DC, scheme->crColor[COLOR_HIGHLIGHT]);
560
561 InflateRect (&rect, -1, -1);
562 hbr = CreateSolidBrush(scheme->crColor[COLOR_MENUHILIGHT]);
563 FillRect(DC, &rect, hbr);
564 DeleteObject(hbr);
565
566 InflateRect (&rect, 1, 1);
567 hbr = CreateSolidBrush(scheme->crColor[COLOR_HIGHLIGHT]);
568 FrameRect(DC, &rect, hbr);
569 DeleteObject(hbr);
570 }
571 else
572 {
573 SetTextColor(DC, scheme->crColor[COLOR_MENUTEXT]);
574 SetBkColor(DC, scheme->crColor[COLOR_MENU]);
575 DrawEdge(DC, &rect, BDR_SUNKENOUTER, BF_RECT);
576 }
577 }
578 else
579 {
580 if (i == 1)
581 SetTextColor(DC, scheme->crColor[COLOR_GRAYTEXT]);
582 else
583 SetTextColor(DC, scheme->crColor[COLOR_MENUTEXT]);
584
585 SetBkColor(DC, scheme->crColor[bkgnd]);
586 hbr = CreateSolidBrush(scheme->crColor[bkgnd]);
587 FillRect(DC, &rect, hbr);
588 DeleteObject(hbr);
589 }
590
591 SetBkMode(DC, TRANSPARENT);
592
593 rect.left += MENU_BAR_ITEMS_SPACE / 2;
594 rect.right -= MENU_BAR_ITEMS_SPACE / 2;
595
596 if (i == 1)
597 {
598 ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
599 SetTextColor(DC, RGB(0xff, 0xff, 0xff));
600 DrawTextW(DC, Text, -1, &rect, uFormat);
601 --rect.left; --rect.top; --rect.right; --rect.bottom;
602 SetTextColor(DC, RGB(0x80, 0x80, 0x80));
603 }
604 DrawTextW(DC, Text, -1, &rect, uFormat);
605 }
606 SelectObject(DC, hFontOld);
607
608 return TRUE;
609 }