2 * User Interface Functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1997 Bertho A. Stultiens
8 #include "wine/winuser16.h"
10 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(graphics)
15 static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
16 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
18 /* These tables are used in:
19 * UITOOLS_DrawDiagEdge()
20 * UITOOLS_DrawRectEdge()
22 static const char LTInnerNormal[] = {
24 -1, COLOR_BTNHIGHLIGHT, COLOR_BTNHIGHLIGHT, -1,
25 -1, COLOR_3DDKSHADOW, COLOR_3DDKSHADOW, -1,
29 static const char LTOuterNormal[] = {
30 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
31 COLOR_BTNHIGHLIGHT, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
32 COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
33 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1
36 static const char RBInnerNormal[] = {
38 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
39 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
43 static const char RBOuterNormal[] = {
44 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
45 COLOR_BTNSHADOW, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
46 COLOR_3DLIGHT, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
47 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1
50 static const char LTInnerSoft[] = {
52 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
53 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
57 static const char LTOuterSoft[] = {
58 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
59 COLOR_3DLIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
60 COLOR_BTNSHADOW, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
61 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1
64 #define RBInnerSoft RBInnerNormal /* These are the same */
65 #define RBOuterSoft RBOuterNormal
67 static const char LTRBOuterMono[] = {
68 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
69 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
70 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
71 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
74 static const char LTRBInnerMono[] = {
76 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
77 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
78 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
81 static const char LTRBOuterFlat[] = {
82 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
83 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
84 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
85 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
88 static const char LTRBInnerFlat[] = {
90 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
91 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
92 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
95 /***********************************************************************
96 * UITOOLS_DrawDiagEdge
98 * Same as DrawEdge invoked with BF_DIAGONAL
100 * 03-Dec-1997: Changed by Bertho Stultiens
102 * See also comments with UITOOLS_DrawRectEdge()
104 static BOOL UITOOLS95_DrawDiagEdge(HDC hdc, LPRECT rc,
105 UINT uType, UINT uFlags)
109 HPEN InnerPen, OuterPen;
114 int Width = rc->right - rc->left;
115 int Height= rc->bottom - rc->top;
116 int SmallDiam = Width > Height ? Height : Width;
117 BOOL retval = !( ((uType & BDR_INNER) == BDR_INNER
118 || (uType & BDR_OUTER) == BDR_OUTER)
119 && !(uFlags & (BF_FLAT|BF_MONO)) );
120 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
121 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
124 OuterPen = InnerPen = (HPEN)GetStockObject(NULL_PEN);
125 SavePen = (HPEN)SelectObject(hdc, InnerPen);
126 spx = spy = epx = epy = 0; /* Satisfy the compiler... */
128 /* Determine the colors of the edges */
131 InnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
132 OuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
134 else if(uFlags & BF_FLAT)
136 InnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
137 OuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
139 else if(uFlags & BF_SOFT)
141 if(uFlags & BF_BOTTOM)
143 InnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
144 OuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
148 InnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
149 OuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
154 if(uFlags & BF_BOTTOM)
156 InnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
157 OuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
161 InnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
162 OuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
166 if(InnerI != -1) InnerPen = GetSysColorPen(InnerI);
167 if(OuterI != -1) OuterPen = GetSysColorPen(OuterI);
169 MoveToEx(hdc, 0, 0, &SavePoint);
171 /* Don't ask me why, but this is what is visible... */
172 /* This must be possible to do much simpler, but I fail to */
173 /* see the logic in the MS implementation (sigh...). */
174 /* So, this might look a bit brute force here (and it is), but */
175 /* it gets the job done;) */
177 switch(uFlags & BF_RECT)
183 /* Left bottom endpoint */
185 spx = epx + SmallDiam;
187 spy = epy - SmallDiam;
192 /* Left top endpoint */
194 spx = epx + SmallDiam;
196 spy = epy + SmallDiam;
202 case BF_RIGHT|BF_LEFT:
203 case BF_RIGHT|BF_LEFT|BF_TOP:
204 case BF_BOTTOM|BF_TOP:
205 case BF_BOTTOM|BF_TOP|BF_LEFT:
206 case BF_BOTTOMRIGHT|BF_LEFT:
207 case BF_BOTTOMRIGHT|BF_TOP:
209 /* Right top endpoint */
211 epx = spx + SmallDiam;
213 epy = spy - SmallDiam;
217 MoveToEx(hdc, spx, spy, NULL);
218 SelectObject(hdc, OuterPen);
219 LineTo(hdc, epx, epy);
221 SelectObject(hdc, InnerPen);
223 switch(uFlags & (BF_RECT|BF_DIAGONAL))
225 case BF_DIAGONAL_ENDBOTTOMLEFT:
226 case (BF_DIAGONAL|BF_BOTTOM):
228 case (BF_DIAGONAL|BF_LEFT):
229 MoveToEx(hdc, spx-1, spy, NULL);
230 LineTo(hdc, epx, epy-1);
231 Points[0].x = spx-add;
233 Points[1].x = rc->left;
234 Points[1].y = rc->top;
236 Points[2].y = epy-1-add;
237 Points[3] = Points[2];
240 case BF_DIAGONAL_ENDBOTTOMRIGHT:
241 MoveToEx(hdc, spx-1, spy, NULL);
242 LineTo(hdc, epx, epy+1);
243 Points[0].x = spx-add;
245 Points[1].x = rc->left;
246 Points[1].y = rc->bottom-1;
248 Points[2].y = epy+1+add;
249 Points[3] = Points[2];
252 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP):
253 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP|BF_LEFT):
254 case BF_DIAGONAL_ENDTOPRIGHT:
255 case (BF_DIAGONAL|BF_RIGHT|BF_TOP|BF_LEFT):
256 MoveToEx(hdc, spx+1, spy, NULL);
257 LineTo(hdc, epx, epy+1);
259 Points[0].y = epy+1+add;
260 Points[1].x = rc->right-1;
261 Points[1].y = rc->top+add;
262 Points[2].x = rc->right-1;
263 Points[2].y = rc->bottom-1;
264 Points[3].x = spx+add;
268 case BF_DIAGONAL_ENDTOPLEFT:
269 MoveToEx(hdc, spx, spy-1, NULL);
270 LineTo(hdc, epx+1, epy);
271 Points[0].x = epx+1+add;
273 Points[1].x = rc->right-1;
274 Points[1].y = rc->top;
275 Points[2].x = rc->right-1;
276 Points[2].y = rc->bottom-1-add;
278 Points[3].y = spy-add;
281 case (BF_DIAGONAL|BF_TOP):
282 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP):
283 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP|BF_LEFT):
284 MoveToEx(hdc, spx+1, spy-1, NULL);
285 LineTo(hdc, epx, epy);
288 Points[1].x = rc->right-1;
289 Points[1].y = rc->top;
290 Points[2].x = rc->right-1;
291 Points[2].y = rc->bottom-1-add;
292 Points[3].x = spx+add;
293 Points[3].y = spy-add;
296 case (BF_DIAGONAL|BF_RIGHT):
297 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT):
298 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT|BF_BOTTOM):
299 MoveToEx(hdc, spx, spy, NULL);
300 LineTo(hdc, epx-1, epy+1);
303 Points[1].x = rc->left;
304 Points[1].y = rc->top+add;
305 Points[2].x = epx-1-add;
306 Points[2].y = epy+1+add;
307 Points[3] = Points[2];
311 /* Fill the interior if asked */
312 if((uFlags & BF_MIDDLE) && retval)
315 HBRUSH hb = GetSysColorBrush(uFlags & BF_MONO ? COLOR_WINDOW
318 HPEN hp = GetSysColorPen(uFlags & BF_MONO ? COLOR_WINDOW
320 hbsave = (HBRUSH)SelectObject(hdc, hb);
321 hpsave = (HPEN)SelectObject(hdc, hp);
322 Polygon(hdc, Points, 4);
323 SelectObject(hdc, hbsave);
324 SelectObject(hdc, hpsave);
327 /* Adjust rectangle if asked */
328 if(uFlags & BF_ADJUST)
330 if(uFlags & BF_LEFT) rc->left += add;
331 if(uFlags & BF_RIGHT) rc->right -= add;
332 if(uFlags & BF_TOP) rc->top += add;
333 if(uFlags & BF_BOTTOM) rc->bottom -= add;
337 SelectObject(hdc, SavePen);
338 MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
343 /***********************************************************************
344 * UITOOLS_DrawRectEdge
346 * Same as DrawEdge invoked without BF_DIAGONAL
348 * 23-Nov-1997: Changed by Bertho Stultiens
350 * Well, I started testing this and found out that there are a few things
351 * that weren't quite as win95. The following rewrite should reproduce
352 * win95 results completely.
353 * The colorselection is table-driven to avoid awfull if-statements.
354 * The table below show the color settings.
356 * Pen selection table for uFlags = 0
358 * uType | LTI | LTO | RBI | RBO
359 * ------+-------+-------+-------+-------
360 * 0000 | x | x | x | x
361 * 0001 | x | 22 | x | 21
362 * 0010 | x | 16 | x | 20
363 * 0011 | x | x | x | x
364 * ------+-------+-------+-------+-------
365 * 0100 | x | 20 | x | 16
366 * 0101 | 20 | 22 | 16 | 21
367 * 0110 | 20 | 16 | 16 | 20
368 * 0111 | x | x | x | x
369 * ------+-------+-------+-------+-------
370 * 1000 | x | 21 | x | 22
371 * 1001 | 21 | 22 | 22 | 21
372 * 1010 | 21 | 16 | 22 | 20
373 * 1011 | x | x | x | x
374 * ------+-------+-------+-------+-------
375 * 1100 | x | x | x | x
376 * 1101 | x | x (22)| x | x (21)
377 * 1110 | x | x (16)| x | x (20)
378 * 1111 | x | x | x | x
380 * Pen selection table for uFlags = BF_SOFT
382 * uType | LTI | LTO | RBI | RBO
383 * ------+-------+-------+-------+-------
384 * 0000 | x | x | x | x
385 * 0001 | x | 20 | x | 21
386 * 0010 | x | 21 | x | 20
387 * 0011 | x | x | x | x
388 * ------+-------+-------+-------+-------
389 * 0100 | x | 22 | x | 16
390 * 0101 | 22 | 20 | 16 | 21
391 * 0110 | 22 | 21 | 16 | 20
392 * 0111 | x | x | x | x
393 * ------+-------+-------+-------+-------
394 * 1000 | x | 16 | x | 22
395 * 1001 | 16 | 20 | 22 | 21
396 * 1010 | 16 | 21 | 22 | 20
397 * 1011 | x | x | x | x
398 * ------+-------+-------+-------+-------
399 * 1100 | x | x | x | x
400 * 1101 | x | x (20)| x | x (21)
401 * 1110 | x | x (21)| x | x (20)
402 * 1111 | x | x | x | x
404 * x = don't care; (n) = is what win95 actually uses
405 * LTI = left Top Inner line
406 * LTO = left Top Outer line
407 * RBI = Right Bottom Inner line
408 * RBO = Right Bottom Outer line
410 * 16 = COLOR_BTNSHADOW
411 * 20 = COLOR_BTNHIGHLIGHT
412 * 21 = COLOR_3DDKSHADOW
417 static BOOL UITOOLS95_DrawRectEdge(HDC hdc, LPRECT rc,
418 UINT uType, UINT uFlags)
420 char LTInnerI, LTOuterI;
421 char RBInnerI, RBOuterI;
422 HPEN LTInnerPen, LTOuterPen;
423 HPEN RBInnerPen, RBOuterPen;
424 RECT InnerRect = *rc;
431 BOOL retval = !( ((uType & BDR_INNER) == BDR_INNER
432 || (uType & BDR_OUTER) == BDR_OUTER)
433 && !(uFlags & (BF_FLAT|BF_MONO)) );
436 LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN)GetStockObject(NULL_PEN);
437 SavePen = (HPEN)SelectObject(hdc, LTInnerPen);
439 /* Determine the colors of the edges */
442 LTInnerI = RBInnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
443 LTOuterI = RBOuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
445 else if(uFlags & BF_FLAT)
447 LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
448 LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
450 /* Bertho Stultiens states above that this function exactly matches win95
451 * In win98 BF_FLAT rectangels have an inner border same color as the
452 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
453 * I don't know I go with Bertho and just sets it for win98 until proven
455 * Dennis Björklund, 10 June, 99
457 if( TWEAK_WineLook == WIN98_LOOK && LTInnerI != -1 )
458 LTInnerI = RBInnerI = COLOR_BTNFACE;
460 else if(uFlags & BF_SOFT)
462 LTInnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
463 LTOuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
464 RBInnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
465 RBOuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
469 LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
470 LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
471 RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
472 RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
475 if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
476 if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
477 if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
478 if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
480 if(LTInnerI != -1) LTInnerPen = GetSysColorPen(LTInnerI);
481 if(LTOuterI != -1) LTOuterPen = GetSysColorPen(LTOuterI);
482 if(RBInnerI != -1) RBInnerPen = GetSysColorPen(RBInnerI);
483 if(RBOuterI != -1) RBOuterPen = GetSysColorPen(RBOuterI);
485 MoveToEx(hdc, 0, 0, &SavePoint);
487 /* Draw the outer edge */
488 SelectObject(hdc, LTOuterPen);
491 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
492 LineTo(hdc, InnerRect.right, InnerRect.top);
496 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
497 LineTo(hdc, InnerRect.left, InnerRect.bottom);
499 SelectObject(hdc, RBOuterPen);
500 if(uFlags & BF_BOTTOM)
502 MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
503 LineTo(hdc, InnerRect.left-1, InnerRect.bottom-1);
505 if(uFlags & BF_RIGHT)
507 MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
508 LineTo(hdc, InnerRect.right-1, InnerRect.top-1);
511 /* Draw the inner edge */
512 SelectObject(hdc, LTInnerPen);
515 MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
516 LineTo(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
520 MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
521 LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
523 SelectObject(hdc, RBInnerPen);
524 if(uFlags & BF_BOTTOM)
526 MoveToEx(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
527 LineTo(hdc, InnerRect.left-1+LBpenplus, InnerRect.bottom-2);
529 if(uFlags & BF_RIGHT)
531 MoveToEx(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
532 LineTo(hdc, InnerRect.right-2, InnerRect.top-1+RTpenplus);
535 if( ((uFlags & BF_MIDDLE) && retval) || (uFlags & BF_ADJUST) )
537 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
538 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
540 if(uFlags & BF_LEFT) InnerRect.left += add;
541 if(uFlags & BF_RIGHT) InnerRect.right -= add;
542 if(uFlags & BF_TOP) InnerRect.top += add;
543 if(uFlags & BF_BOTTOM) InnerRect.bottom -= add;
545 if((uFlags & BF_MIDDLE) && retval)
547 FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?
548 COLOR_WINDOW : COLOR_BTNFACE));
551 if(uFlags & BF_ADJUST)
556 SelectObject(hdc, SavePen);
557 MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
562 /**********************************************************************
563 * DrawEdge16 (USER.659)
565 BOOL16 WINAPI DrawEdge16( HDC16 hdc, LPRECT16 rc, UINT16 edge, UINT16 flags )
570 CONV_RECT16TO32( rc, &rect32 );
571 ret = DrawEdge( hdc, &rect32, edge, flags );
572 CONV_RECT32TO16( &rect32, rc );
576 /**********************************************************************
577 * DrawEdge32 (USER32.155)
579 BOOL WINAPI DrawEdge( HDC hdc, LPRECT rc, UINT edge, UINT flags )
581 TRACE("%04x %d,%d-%d,%d %04x %04x\n",
582 hdc, rc->left, rc->top, rc->right, rc->bottom, edge, flags );
584 if(flags & BF_DIAGONAL)
585 return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
587 return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
591 /************************************************************************
592 * UITOOLS_MakeSquareRect
594 * Utility to create a square rectangle and returning the width
596 static int UITOOLS_MakeSquareRect(LPRECT src, LPRECT dst)
598 int Width = src->right - src->left;
599 int Height = src->bottom - src->top;
600 int SmallDiam = Width > Height ? Height : Width;
604 /* Make it a square box */
605 if(Width < Height) /* SmallDiam == Width */
607 dst->top += (Height-Width)/2;
608 dst->bottom = dst->top + SmallDiam;
610 else if(Width > Height) /* SmallDiam == Height */
612 dst->left += (Width-Height)/2;
613 dst->right = dst->left + SmallDiam;
620 /************************************************************************
621 * UITOOLS_DFC_ButtonPush
623 * Draw a push button coming from DrawFrameControl()
625 * Does a pretty good job in emulating MS behavior. Some quirks are
626 * however there because MS uses a TrueType font (Marlett) to draw
629 static BOOL UITOOLS95_DFC_ButtonPush(HDC dc, LPRECT r, UINT uFlags)
634 if(uFlags & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
639 if(uFlags & DFCS_CHECKED)
641 if(uFlags & DFCS_MONO)
642 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
644 UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
646 if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
648 HBITMAP hbm = CreateBitmap(8, 8, 1, 1, wPattern_AA55);
650 HBRUSH hb = CreatePatternBrush(hbm);
652 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
653 hbsave = (HBRUSH)SelectObject(dc, hb);
654 PatBlt(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
655 SelectObject(dc, hbsave);
661 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
666 if(uFlags & DFCS_MONO)
668 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
669 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
673 UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
677 /* Adjust rectangle if asked */
678 if(uFlags & DFCS_ADJUSTRECT)
690 /************************************************************************
691 * UITOOLS_DFC_ButtonChcek
693 * Draw a check/3state button coming from DrawFrameControl()
695 * Does a pretty good job in emulating MS behavior. Some quirks are
696 * however there because MS uses a TrueType font (Marlett) to draw
699 #define DFC_CHECKPOINTSMAX 6
701 static BOOL UITOOLS95_DFC_ButtonCheck(HDC dc, LPRECT r, UINT uFlags)
704 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
705 int BorderShrink = SmallDiam / 16;
707 if(BorderShrink < 1) BorderShrink = 1;
709 /* FIXME: The FillRect() sequence doesn't work for sizes less than */
710 /* 4 pixels in diameter. Not really a problem but it isn't M$'s */
711 /* 100% equivalent. */
712 if(uFlags & (DFCS_FLAT|DFCS_MONO))
714 FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOWFRAME));
715 myr.left += 2 * BorderShrink;
716 myr.right -= 2 * BorderShrink;
717 myr.top += 2 * BorderShrink;
718 myr.bottom -= 2 * BorderShrink;
722 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
723 myr.right -= BorderShrink;
724 myr.bottom -= BorderShrink;
725 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNSHADOW));
726 myr.left += BorderShrink;
727 myr.top += BorderShrink;
728 FillRect(dc, &myr, GetSysColorBrush(COLOR_3DLIGHT));
729 myr.right -= BorderShrink;
730 myr.bottom -= BorderShrink;
731 FillRect(dc, &myr, GetSysColorBrush(COLOR_3DDKSHADOW));
732 myr.left += BorderShrink;
733 myr.top += BorderShrink;
736 if(uFlags & (DFCS_INACTIVE|DFCS_PUSHED))
738 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
740 else if(uFlags & DFCS_CHECKED)
742 if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
744 HBITMAP hbm = CreateBitmap(8, 8, 1, 1, wPattern_AA55);
746 HBRUSH hb = CreatePatternBrush(hbm);
748 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
749 hbsave = (HBRUSH)SelectObject(dc, hb);
750 PatBlt(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
751 SelectObject(dc, hbsave);
757 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
762 FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOW));
765 if(uFlags & DFCS_CHECKED)
767 POINT CheckPoints[DFC_CHECKPOINTSMAX];
772 /* FIXME: This comes very close to M$'s checkmark, but not */
773 /* exactly... When small or large there is a few pixels */
774 /* shift. Not bad, but could be better :) */
775 UITOOLS_MakeSquareRect(r, &myr);
776 CheckPoints[0].x = myr.left + 253*SmallDiam/1000;
777 CheckPoints[0].y = myr.top + 345*SmallDiam/1000;
778 CheckPoints[1].x = myr.left + 409*SmallDiam/1000;
779 CheckPoints[1].y = CheckPoints[0].y + (CheckPoints[1].x-CheckPoints[0].x);
780 CheckPoints[2].x = myr.left + 690*SmallDiam/1000;
781 CheckPoints[2].y = CheckPoints[1].y - (CheckPoints[2].x-CheckPoints[1].x);
782 CheckPoints[3].x = CheckPoints[2].x;
783 CheckPoints[3].y = CheckPoints[2].y + 3*SmallDiam/16;
784 CheckPoints[4].x = CheckPoints[1].x;
785 CheckPoints[4].y = CheckPoints[1].y + 3*SmallDiam/16;
786 CheckPoints[5].x = CheckPoints[0].x;
787 CheckPoints[5].y = CheckPoints[0].y + 3*SmallDiam/16;
789 i = (uFlags & DFCS_INACTIVE) || (uFlags & 0xff) == DFCS_BUTTON3STATE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
790 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
791 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
792 Polygon(dc, CheckPoints, DFC_CHECKPOINTSMAX);
793 SelectObject(dc, hpsave);
794 SelectObject(dc, hbsave);
800 /************************************************************************
801 * UITOOLS_DFC_ButtonRadio
803 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
805 * Does a pretty good job in emulating MS behavior. Some quirks are
806 * however there because MS uses a TrueType font (Marlett) to draw
809 static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
813 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
814 int BorderShrink = SmallDiam / 16;
820 if(BorderShrink < 1) BorderShrink = 1;
822 if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
824 FillRect(dc, r, (HBRUSH)GetStockObject(BLACK_BRUSH));
828 ye = myr.top + SmallDiam - SmallDiam/2;
830 xc = myr.left + SmallDiam - SmallDiam/2;
831 yc = myr.top + SmallDiam - SmallDiam/2;
833 /* Define bounding box */
835 myr.left = xc - i+i/2;
836 myr.right = xc + i/2;
837 myr.top = yc - i+i/2;
838 myr.bottom = yc + i/2;
840 if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
842 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
843 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
844 SelectObject(dc, hbsave);
848 if(uFlags & (DFCS_FLAT|DFCS_MONO))
850 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_WINDOWFRAME));
851 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
852 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
853 SelectObject(dc, hbsave);
854 SelectObject(dc, hpsave);
858 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
859 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
860 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
862 SelectObject(dc, GetSysColorPen(COLOR_BTNSHADOW));
863 SelectObject(dc, GetSysColorBrush(COLOR_BTNSHADOW));
864 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
866 myr.left += BorderShrink;
867 myr.right -= BorderShrink;
868 myr.top += BorderShrink;
869 myr.bottom -= BorderShrink;
871 SelectObject(dc, GetSysColorPen(COLOR_3DLIGHT));
872 SelectObject(dc, GetSysColorBrush(COLOR_3DLIGHT));
873 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
875 SelectObject(dc, GetSysColorPen(COLOR_3DDKSHADOW));
876 SelectObject(dc, GetSysColorBrush(COLOR_3DDKSHADOW));
877 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
878 SelectObject(dc, hbsave);
879 SelectObject(dc, hpsave);
883 myr.left = xc - i+i/2;
884 myr.right = xc + i/2;
885 myr.top = yc - i+i/2;
886 myr.bottom = yc + i/2;
887 i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
888 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
889 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
890 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
891 SelectObject(dc, hbsave);
892 SelectObject(dc, hpsave);
895 if(uFlags & DFCS_CHECKED)
899 myr.left = xc - i+i/2;
900 myr.right = xc + i/2;
901 myr.top = yc - i+i/2;
902 myr.bottom = yc + i/2;
904 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
905 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
906 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
907 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
908 SelectObject(dc, hpsave);
909 SelectObject(dc, hbsave);
912 /* FIXME: M$ has a polygon in the center at relative points: */
913 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
917 /* when the button is unchecked. The reason for it is unknown. The */
918 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
919 /* least 3 times (it looks like a clip-region when you see it happen). */
920 /* I do not really see a reason why this should be implemented. If you */
921 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
927 /***********************************************************************
928 * UITOOLS_DrawFrameButton
930 static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT uState)
932 switch(uState & 0xff)
934 case DFCS_BUTTONPUSH:
935 return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
937 case DFCS_BUTTONCHECK:
938 case DFCS_BUTTON3STATE:
939 return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
941 case DFCS_BUTTONRADIOIMAGE:
942 case DFCS_BUTTONRADIOMASK:
943 case DFCS_BUTTONRADIO:
944 return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
947 WARN("Invalid button state=0x%04x\n", uState);
953 /***********************************************************************
954 * UITOOLS_DrawFrameCaption
956 * Draw caption buttons (win95), coming from DrawFrameControl()
959 static BOOL UITOOLS95_DrawFrameCaption(HDC dc, LPRECT r, UINT uFlags)
966 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr)-2;
971 int xc = (myr.left+myr.right)/2;
972 int yc = (myr.top+myr.bottom)/2;
980 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
982 switch(uFlags & 0xff)
984 case DFCS_CAPTIONCLOSE:
985 edge = 328*SmallDiam/1000;
986 move = 95*SmallDiam/1000;
987 Line1[0].x = Line2[0].x = Line1[1].x = Line2[1].x = xc - edge;
988 Line1[2].y = Line2[5].y = Line1[1].y = Line2[4].y = yc - edge;
989 Line1[3].x = Line2[3].x = Line1[4].x = Line2[4].x = xc + edge;
990 Line1[5].y = Line2[2].y = Line1[4].y = Line2[1].y = yc + edge;
991 Line1[2].x = Line2[2].x = Line1[1].x + move;
992 Line1[0].y = Line2[3].y = Line1[1].y + move;
993 Line1[5].x = Line2[5].x = Line1[4].x - move;
994 Line1[3].y = Line2[0].y = Line1[4].y - move;
999 case DFCS_CAPTIONHELP:
1000 /* This one breaks the flow */
1001 /* FIXME: We need the Marlett font in order to get this right. */
1003 hf = CreateFontA(-SmallDiam, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
1004 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
1005 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "System");
1006 alignsave = SetTextAlign(dc, TA_TOP|TA_LEFT);
1007 bksave = SetBkMode(dc, TRANSPARENT);
1008 clrsave = GetTextColor(dc);
1009 hfsave = (HFONT)SelectObject(dc, hf);
1010 GetTextExtentPoint32A(dc, str, 1, &size);
1012 if(uFlags & DFCS_INACTIVE)
1014 SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
1015 TextOutA(dc, xc-size.cx/2+1, yc-size.cy/2+1, str, 1);
1017 SetTextColor(dc, GetSysColor(uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
1018 TextOutA(dc, xc-size.cx/2, yc-size.cy/2, str, 1);
1020 SelectObject(dc, hfsave);
1021 SetTextColor(dc, clrsave);
1022 SetBkMode(dc, bksave);
1023 SetTextAlign(dc, alignsave);
1027 case DFCS_CAPTIONMIN:
1028 Line1[0].x = Line1[3].x = myr.left + 96*SmallDiam/750+2;
1029 Line1[1].x = Line1[2].x = Line1[0].x + 372*SmallDiam/750;
1030 Line1[0].y = Line1[1].y = myr.top + 563*SmallDiam/750+1;
1031 Line1[2].y = Line1[3].y = Line1[0].y + 92*SmallDiam/750;
1036 case DFCS_CAPTIONMAX:
1037 edge = 47*SmallDiam/750;
1038 Line1[0].x = Line1[5].x = myr.left + 57*SmallDiam/750+3;
1039 Line1[0].y = Line1[1].y = myr.top + 143*SmallDiam/750+1;
1040 Line1[1].x = Line1[2].x = Line1[0].x + 562*SmallDiam/750;
1041 Line1[5].y = Line1[4].y = Line1[0].y + 93*SmallDiam/750;
1042 Line1[2].y = Line1[3].y = Line1[0].y + 513*SmallDiam/750;
1043 Line1[3].x = Line1[4].x = Line1[1].x - edge;
1045 Line2[0].x = Line2[5].x = Line1[0].x;
1046 Line2[3].x = Line2[4].x = Line1[1].x;
1047 Line2[1].x = Line2[2].x = Line1[0].x + edge;
1048 Line2[0].y = Line2[1].y = Line1[0].y;
1049 Line2[4].y = Line2[5].y = Line1[2].y;
1050 Line2[2].y = Line2[3].y = Line1[2].y - edge;
1055 case DFCS_CAPTIONRESTORE:
1056 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1057 edge = 47*SmallDiam/750;
1058 move = 420*SmallDiam/750;
1059 Line1[0].x = Line1[9].x = myr.left + 198*SmallDiam/750+2;
1060 Line1[0].y = Line1[1].y = myr.top + 169*SmallDiam/750+1;
1061 Line1[6].y = Line1[7].y = Line1[0].y + 93*SmallDiam/750;
1062 Line1[7].x = Line1[8].x = Line1[0].x + edge;
1063 Line1[1].x = Line1[2].x = Line1[0].x + move;
1064 Line1[5].x = Line1[6].x = Line1[1].x - edge;
1065 Line1[9].y = Line1[8].y = Line1[0].y + 187*SmallDiam/750;
1066 Line1[2].y = Line1[3].y = Line1[0].y + 327*SmallDiam/750;
1067 Line1[4].y = Line1[5].y = Line1[2].y - edge;
1068 Line1[3].x = Line1[4].x = Line1[2].x - 140*SmallDiam/750;
1070 Line2[1].x = Line2[2].x = Line1[3].x;
1071 Line2[7].x = Line2[8].x = Line2[1].x - edge;
1072 Line2[0].x = Line2[9].x = Line2[3].x = Line2[4].x = Line2[1].x - move;
1073 Line2[5].x = Line2[6].x = Line2[0].x + edge;
1074 Line2[0].y = Line2[1].y = Line1[9].y;
1075 Line2[4].y = Line2[5].y = Line2[8].y = Line2[9].y = Line2[0].y + 93*SmallDiam/750;
1076 Line2[2].y = Line2[3].y = Line2[0].y + 327*SmallDiam/750;
1077 Line2[6].y = Line2[7].y = Line2[2].y - edge;
1083 WARN("Invalid caption; flags=0x%04x\n", uFlags);
1087 /* Here the drawing takes place */
1088 if(uFlags & DFCS_INACTIVE)
1090 /* If we have an inactive button, then you see a shadow */
1091 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
1092 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
1093 Polygon(dc, Line1, Line1N);
1095 Polygon(dc, Line2, Line2N);
1096 SelectObject(dc, hpsave);
1097 SelectObject(dc, hbsave);
1100 /* Correct for the shadow shift */
1101 for(i = 0; i < Line1N; i++)
1106 for(i = 0; i < Line2N; i++)
1112 /* Make the final picture */
1113 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1114 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
1115 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
1117 Polygon(dc, Line1, Line1N);
1119 Polygon(dc, Line2, Line2N);
1120 SelectObject(dc, hpsave);
1121 SelectObject(dc, hbsave);
1127 /************************************************************************
1128 * UITOOLS_DrawFrameScroll
1130 * Draw a scroll-bar control coming from DrawFrameControl()
1132 static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags)
1136 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2;
1138 HBRUSH hbsave, hb, hb2;
1139 HPEN hpsave, hp, hp2;
1140 int tri = 290*SmallDiam/1000 - 1;
1144 * This fixes a problem with really tiny "scroll" buttons. In particular
1145 * with the updown control.
1146 * Making sure that the arrow is as least 3 pixels wide (or high).
1151 switch(uFlags & 0xff)
1153 case DFCS_SCROLLCOMBOBOX:
1154 case DFCS_SCROLLDOWN:
1155 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1156 Line[2].y = myr.top + 687*SmallDiam/1000 + 1;
1157 Line[0].x = Line[2].x - tri;
1158 Line[1].x = Line[2].x + tri;
1159 Line[0].y = Line[1].y = Line[2].y - tri;
1163 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1164 Line[2].y = myr.bottom - (687*SmallDiam/1000 + 1);
1165 Line[0].x = Line[2].x - tri;
1166 Line[1].x = Line[2].x + tri;
1167 Line[0].y = Line[1].y = Line[2].y + tri;
1170 case DFCS_SCROLLLEFT:
1171 Line[2].x = myr.right - (687*SmallDiam/1000 + 1);
1172 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1173 Line[0].y = Line[2].y - tri;
1174 Line[1].y = Line[2].y + tri;
1175 Line[0].x = Line[1].x = Line[2].x + tri;
1178 case DFCS_SCROLLRIGHT:
1179 Line[2].x = myr.left + 687*SmallDiam/1000 + 1;
1180 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1181 Line[0].y = Line[2].y - tri;
1182 Line[1].y = Line[2].y + tri;
1183 Line[0].x = Line[1].x = Line[2].x - tri;
1186 case DFCS_SCROLLSIZEGRIP:
1187 /* This one breaks the flow... */
1188 UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
1189 hpsave = (HPEN)SelectObject(dc, GetStockObject(NULL_PEN));
1190 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH));
1191 if(uFlags & (DFCS_MONO|DFCS_FLAT))
1193 hp = hp2 = GetSysColorPen(COLOR_WINDOWFRAME);
1194 hb = hb2 = GetSysColorBrush(COLOR_WINDOWFRAME);
1198 hp = GetSysColorPen(COLOR_BTNHIGHLIGHT);
1199 hp2 = GetSysColorPen(COLOR_BTNSHADOW);
1200 hb = GetSysColorBrush(COLOR_BTNHIGHLIGHT);
1201 hb2 = GetSysColorBrush(COLOR_BTNSHADOW);
1203 Line[0].x = Line[1].x = r->right-1;
1204 Line[2].y = Line[3].y = r->bottom-1;
1205 d46 = 46*SmallDiam/750;
1206 d93 = 93*SmallDiam/750;
1208 i = 586*SmallDiam/750;
1209 Line[0].y = r->bottom - i - 1;
1210 Line[3].x = r->right - i - 1;
1211 Line[1].y = Line[0].y + d46;
1212 Line[2].x = Line[3].x + d46;
1213 SelectObject(dc, hb);
1214 SelectObject(dc, hp);
1215 Polygon(dc, Line, 4);
1217 Line[1].y++; Line[2].x++;
1218 Line[0].y = Line[1].y + d93;
1219 Line[3].x = Line[2].x + d93;
1220 SelectObject(dc, hb2);
1221 SelectObject(dc, hp2);
1222 Polygon(dc, Line, 4);
1224 i = 398*SmallDiam/750;
1225 Line[0].y = r->bottom - i - 1;
1226 Line[3].x = r->right - i - 1;
1227 Line[1].y = Line[0].y + d46;
1228 Line[2].x = Line[3].x + d46;
1229 SelectObject(dc, hb);
1230 SelectObject(dc, hp);
1231 Polygon(dc, Line, 4);
1233 Line[1].y++; Line[2].x++;
1234 Line[0].y = Line[1].y + d93;
1235 Line[3].x = Line[2].x + d93;
1236 SelectObject(dc, hb2);
1237 SelectObject(dc, hp2);
1238 Polygon(dc, Line, 4);
1240 i = 210*SmallDiam/750;
1241 Line[0].y = r->bottom - i - 1;
1242 Line[3].x = r->right - i - 1;
1243 Line[1].y = Line[0].y + d46;
1244 Line[2].x = Line[3].x + d46;
1245 SelectObject(dc, hb);
1246 SelectObject(dc, hp);
1247 Polygon(dc, Line, 4);
1249 Line[1].y++; Line[2].x++;
1250 Line[0].y = Line[1].y + d93;
1251 Line[3].x = Line[2].x + d93;
1252 SelectObject(dc, hb2);
1253 SelectObject(dc, hp2);
1254 Polygon(dc, Line, 4);
1256 SelectObject(dc, hpsave);
1257 SelectObject(dc, hbsave);
1261 WARN("Invalid scroll; flags=0x%04x\n", uFlags);
1265 /* Here do the real scroll-bar controls end up */
1266 if( ! (uFlags & (0xff00 & ~DFCS_ADJUSTRECT)) )
1267 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1268 /* want for the normal scroll-arrow button. */
1269 UITOOLS95_DrawRectEdge( dc, r, EDGE_RAISED, (uFlags&DFCS_ADJUSTRECT) | BF_MIDDLE | BF_RECT);
1271 UITOOLS95_DFC_ButtonPush(dc, r, (uFlags & 0xff00) );
1273 if(uFlags & DFCS_INACTIVE)
1275 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
1276 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
1277 Polygon(dc, Line, 3);
1278 SelectObject(dc, hpsave);
1279 SelectObject(dc, hbsave);
1282 if( (uFlags & DFCS_INACTIVE) || !(uFlags & DFCS_PUSHED) )
1283 for(i = 0; i < 3; i++)
1289 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1290 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
1291 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
1292 Polygon(dc, Line, 3);
1293 SelectObject(dc, hpsave);
1294 SelectObject(dc, hbsave);
1299 /************************************************************************
1300 * UITOOLS_DrawFrameMenu
1302 * Draw a menu control coming from DrawFrameControl()
1304 static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
1308 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
1316 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1317 /* use anything else. I think I tried all sys-colors to change things */
1318 /* without luck. It seems as if this behavior is inherited from the */
1319 /* win31 DFC() implementation... (you remember, B/W menus). */
1321 FillRect(dc, r, (HBRUSH)GetStockObject(WHITE_BRUSH));
1323 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
1324 hpsave = (HPEN)SelectObject(dc, GetStockObject(BLACK_PEN));
1326 switch(uFlags & 0xff)
1328 case DFCS_MENUARROW:
1329 i = 187*SmallDiam/750;
1330 Points[2].x = myr.left + 468*SmallDiam/750;
1331 Points[2].y = myr.top + 352*SmallDiam/750+1;
1332 Points[0].y = Points[2].y - i;
1333 Points[1].y = Points[2].y + i;
1334 Points[0].x = Points[1].x = Points[2].x - i;
1335 Polygon(dc, Points, 3);
1338 case DFCS_MENUBULLET:
1340 ye = myr.top + SmallDiam - SmallDiam/2;
1341 xc = myr.left + SmallDiam - SmallDiam/2;
1342 yc = myr.top + SmallDiam - SmallDiam/2;
1343 i = 234*SmallDiam/750;
1345 myr.left = xc - i+i/2;
1346 myr.right = xc + i/2;
1347 myr.top = yc - i+i/2;
1348 myr.bottom = yc + i/2;
1349 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
1352 case DFCS_MENUCHECK:
1353 Points[0].x = myr.left + 253*SmallDiam/1000;
1354 Points[0].y = myr.top + 445*SmallDiam/1000;
1355 Points[1].x = myr.left + 409*SmallDiam/1000;
1356 Points[1].y = Points[0].y + (Points[1].x-Points[0].x);
1357 Points[2].x = myr.left + 690*SmallDiam/1000;
1358 Points[2].y = Points[1].y - (Points[2].x-Points[1].x);
1359 Points[3].x = Points[2].x;
1360 Points[3].y = Points[2].y + 3*SmallDiam/16;
1361 Points[4].x = Points[1].x;
1362 Points[4].y = Points[1].y + 3*SmallDiam/16;
1363 Points[5].x = Points[0].x;
1364 Points[5].y = Points[0].y + 3*SmallDiam/16;
1365 Polygon(dc, Points, 6);
1369 WARN("Invalid menu; flags=0x%04x\n", uFlags);
1374 SelectObject(dc, hpsave);
1375 SelectObject(dc, hbsave);
1380 /**********************************************************************
1381 * DrawFrameControl16 (USER.656)
1383 BOOL16 WINAPI DrawFrameControl16( HDC16 hdc, LPRECT16 rc, UINT16 uType,
1389 CONV_RECT16TO32( rc, &rect32 );
1390 ret = DrawFrameControl( hdc, &rect32, uType, uState );
1391 CONV_RECT32TO16( &rect32, rc );
1396 /**********************************************************************
1397 * DrawFrameControl32 (USER32.158)
1399 BOOL WINAPI DrawFrameControl( HDC hdc, LPRECT rc, UINT uType,
1402 /* Win95 doesn't support drawing in other mapping modes */
1403 if(GetMapMode(hdc) != MM_TEXT)
1409 return UITOOLS95_DrawFrameButton(hdc, rc, uState);
1411 return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
1413 return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
1415 return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
1417 WARN("(%x,%p,%d,%x), bad type!\n",
1418 hdc,rc,uType,uState );