2 * User Interface Functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1997 Bertho A. Stultiens
9 #include "wine/winuser16.h"
12 static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
13 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
15 /* These tables are used in:
16 * UITOOLS_DrawDiagEdge()
17 * UITOOLS_DrawRectEdge()
19 static const char LTInnerNormal[] = {
21 -1, COLOR_BTNHIGHLIGHT, COLOR_BTNHIGHLIGHT, -1,
22 -1, COLOR_3DDKSHADOW, COLOR_3DDKSHADOW, -1,
26 static const char LTOuterNormal[] = {
27 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
28 COLOR_BTNHIGHLIGHT, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
29 COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
30 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1
33 static const char RBInnerNormal[] = {
35 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
36 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
40 static const char RBOuterNormal[] = {
41 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
42 COLOR_BTNSHADOW, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
43 COLOR_3DLIGHT, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
44 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1
47 static const char LTInnerSoft[] = {
49 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
50 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
54 static const char LTOuterSoft[] = {
55 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
56 COLOR_3DLIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
57 COLOR_BTNSHADOW, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
58 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1
61 #define RBInnerSoft RBInnerNormal /* These are the same */
62 #define RBOuterSoft RBOuterNormal
64 static const char LTRBOuterMono[] = {
65 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
66 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
67 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
68 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
71 static const char LTRBInnerMono[] = {
73 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
74 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
75 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
78 static const char LTRBOuterFlat[] = {
79 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
80 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
81 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
82 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
85 static const char LTRBInnerFlat[] = {
87 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
88 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
89 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
92 /***********************************************************************
93 * UITOOLS_DrawDiagEdge
95 * Same as DrawEdge invoked with BF_DIAGONAL
97 * 03-Dec-1997: Changed by Bertho Stultiens
99 * See also comments with UITOOLS_DrawRectEdge()
101 static BOOL32 UITOOLS95_DrawDiagEdge(HDC32 hdc, LPRECT32 rc,
102 UINT32 uType, UINT32 uFlags)
106 HPEN32 InnerPen, OuterPen;
111 int Width = rc->right - rc->left;
112 int Height= rc->bottom - rc->top;
113 int SmallDiam = Width > Height ? Height : Width;
114 BOOL32 retval = !( ((uType & BDR_INNER) == BDR_INNER
115 || (uType & BDR_OUTER) == BDR_OUTER)
116 && !(uFlags & (BF_FLAT|BF_MONO)) );
117 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
118 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
121 OuterPen = InnerPen = (HPEN32)GetStockObject32(NULL_PEN);
122 SavePen = (HPEN32)SelectObject32(hdc, InnerPen);
123 spx = spy = epx = epy = 0; /* Satisfy the compiler... */
125 /* Determine the colors of the edges */
128 InnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
129 OuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
131 else if(uFlags & BF_FLAT)
133 InnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
134 OuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
136 else if(uFlags & BF_SOFT)
138 if(uFlags & BF_BOTTOM)
140 InnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
141 OuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
145 InnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
146 OuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
151 if(uFlags & BF_BOTTOM)
153 InnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
154 OuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
158 InnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
159 OuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
163 if(InnerI != -1) InnerPen = GetSysColorPen32(InnerI);
164 if(OuterI != -1) OuterPen = GetSysColorPen32(OuterI);
166 MoveToEx32(hdc, 0, 0, &SavePoint);
168 /* Don't ask me why, but this is what is visible... */
169 /* This must be possible to do much simpler, but I fail to */
170 /* see the logic in the MS implementation (sigh...). */
171 /* So, this might look a bit brute force here (and it is), but */
172 /* it gets the job done;) */
174 switch(uFlags & BF_RECT)
180 /* Left bottom endpoint */
182 spx = epx + SmallDiam;
184 spy = epy - SmallDiam;
189 /* Left top endpoint */
191 spx = epx + SmallDiam;
193 spy = epy + SmallDiam;
199 case BF_RIGHT|BF_LEFT:
200 case BF_RIGHT|BF_LEFT|BF_TOP:
201 case BF_BOTTOM|BF_TOP:
202 case BF_BOTTOM|BF_TOP|BF_LEFT:
203 case BF_BOTTOMRIGHT|BF_LEFT:
204 case BF_BOTTOMRIGHT|BF_TOP:
206 /* Right top endpoint */
208 epx = spx + SmallDiam;
210 epy = spy - SmallDiam;
214 MoveToEx32(hdc, spx, spy, NULL);
215 SelectObject32(hdc, OuterPen);
216 LineTo32(hdc, epx, epy);
218 SelectObject32(hdc, InnerPen);
220 switch(uFlags & (BF_RECT|BF_DIAGONAL))
222 case BF_DIAGONAL_ENDBOTTOMLEFT:
223 case (BF_DIAGONAL|BF_BOTTOM):
225 case (BF_DIAGONAL|BF_LEFT):
226 MoveToEx32(hdc, spx-1, spy, NULL);
227 LineTo32(hdc, epx, epy-1);
228 Points[0].x = spx-add;
230 Points[1].x = rc->left;
231 Points[1].y = rc->top;
233 Points[2].y = epy-1-add;
234 Points[3] = Points[2];
237 case BF_DIAGONAL_ENDBOTTOMRIGHT:
238 MoveToEx32(hdc, spx-1, spy, NULL);
239 LineTo32(hdc, epx, epy+1);
240 Points[0].x = spx-add;
242 Points[1].x = rc->left;
243 Points[1].y = rc->bottom-1;
245 Points[2].y = epy+1+add;
246 Points[3] = Points[2];
249 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP):
250 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP|BF_LEFT):
251 case BF_DIAGONAL_ENDTOPRIGHT:
252 case (BF_DIAGONAL|BF_RIGHT|BF_TOP|BF_LEFT):
253 MoveToEx32(hdc, spx+1, spy, NULL);
254 LineTo32(hdc, epx, epy+1);
256 Points[0].y = epy+1+add;
257 Points[1].x = rc->right-1;
258 Points[1].y = rc->top+add;
259 Points[2].x = rc->right-1;
260 Points[2].y = rc->bottom-1;
261 Points[3].x = spx+add;
265 case BF_DIAGONAL_ENDTOPLEFT:
266 MoveToEx32(hdc, spx, spy-1, NULL);
267 LineTo32(hdc, epx+1, epy);
268 Points[0].x = epx+1+add;
270 Points[1].x = rc->right-1;
271 Points[1].y = rc->top;
272 Points[2].x = rc->right-1;
273 Points[2].y = rc->bottom-1-add;
275 Points[3].y = spy-add;
278 case (BF_DIAGONAL|BF_TOP):
279 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP):
280 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP|BF_LEFT):
281 MoveToEx32(hdc, spx+1, spy-1, NULL);
282 LineTo32(hdc, epx, epy);
285 Points[1].x = rc->right-1;
286 Points[1].y = rc->top;
287 Points[2].x = rc->right-1;
288 Points[2].y = rc->bottom-1-add;
289 Points[3].x = spx+add;
290 Points[3].y = spy-add;
293 case (BF_DIAGONAL|BF_RIGHT):
294 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT):
295 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT|BF_BOTTOM):
296 MoveToEx32(hdc, spx, spy, NULL);
297 LineTo32(hdc, epx-1, epy+1);
300 Points[1].x = rc->left;
301 Points[1].y = rc->top+add;
302 Points[2].x = epx-1-add;
303 Points[2].y = epy+1+add;
304 Points[3] = Points[2];
308 /* Fill the interior if asked */
309 if((uFlags & BF_MIDDLE) && retval)
312 HBRUSH32 hb = GetSysColorBrush32(uFlags & BF_MONO ? COLOR_WINDOW
315 HPEN32 hp = GetSysColorPen32(uFlags & BF_MONO ? COLOR_WINDOW
317 hbsave = (HBRUSH32)SelectObject32(hdc, hb);
318 hpsave = (HPEN32)SelectObject32(hdc, hp);
319 Polygon32(hdc, Points, 4);
320 SelectObject32(hdc, hbsave);
321 SelectObject32(hdc, hpsave);
324 /* Adjust rectangle if asked */
325 if(uFlags & BF_ADJUST)
327 if(uFlags & BF_LEFT) rc->left += add;
328 if(uFlags & BF_RIGHT) rc->right -= add;
329 if(uFlags & BF_TOP) rc->top += add;
330 if(uFlags & BF_BOTTOM) rc->bottom -= add;
334 SelectObject32(hdc, SavePen);
335 MoveToEx32(hdc, SavePoint.x, SavePoint.y, NULL);
340 /***********************************************************************
341 * UITOOLS_DrawRectEdge
343 * Same as DrawEdge invoked without BF_DIAGONAL
345 * 23-Nov-1997: Changed by Bertho Stultiens
347 * Well, I started testing this and found out that there are a few things
348 * that weren't quite as win95. The following rewrite should reproduce
349 * win95 results completely.
350 * The colorselection is table-driven to avoid awfull if-statements.
351 * The table below show the color settings.
353 * Pen selection table for uFlags = 0
355 * uType | LTI | LTO | RBI | RBO
356 * ------+-------+-------+-------+-------
357 * 0000 | x | x | x | x
358 * 0001 | x | 22 | x | 21
359 * 0010 | x | 16 | x | 20
360 * 0011 | x | x | x | x
361 * ------+-------+-------+-------+-------
362 * 0100 | x | 20 | x | 16
363 * 0101 | 20 | 22 | 16 | 21
364 * 0110 | 20 | 16 | 16 | 20
365 * 0111 | x | x | x | x
366 * ------+-------+-------+-------+-------
367 * 1000 | x | 21 | x | 22
368 * 1001 | 21 | 22 | 22 | 21
369 * 1010 | 21 | 16 | 22 | 20
370 * 1011 | x | x | x | x
371 * ------+-------+-------+-------+-------
372 * 1100 | x | x | x | x
373 * 1101 | x | x (22)| x | x (21)
374 * 1110 | x | x (16)| x | x (20)
375 * 1111 | x | x | x | x
377 * Pen selection table for uFlags = BF_SOFT
379 * uType | LTI | LTO | RBI | RBO
380 * ------+-------+-------+-------+-------
381 * 0000 | x | x | x | x
382 * 0001 | x | 20 | x | 21
383 * 0010 | x | 21 | x | 20
384 * 0011 | x | x | x | x
385 * ------+-------+-------+-------+-------
386 * 0100 | x | 22 | x | 16
387 * 0101 | 22 | 20 | 16 | 21
388 * 0110 | 22 | 21 | 16 | 20
389 * 0111 | x | x | x | x
390 * ------+-------+-------+-------+-------
391 * 1000 | x | 16 | x | 22
392 * 1001 | 16 | 20 | 22 | 21
393 * 1010 | 16 | 21 | 22 | 20
394 * 1011 | x | x | x | x
395 * ------+-------+-------+-------+-------
396 * 1100 | x | x | x | x
397 * 1101 | x | x (20)| x | x (21)
398 * 1110 | x | x (21)| x | x (20)
399 * 1111 | x | x | x | x
401 * x = don't care; (n) = is what win95 actually uses
402 * LTI = left Top Inner line
403 * LTO = left Top Outer line
404 * RBI = Right Bottom Inner line
405 * RBO = Right Bottom Outer line
407 * 16 = COLOR_BTNSHADOW
408 * 20 = COLOR_BTNHIGHLIGHT
409 * 21 = COLOR_3DDKSHADOW
414 static BOOL32 UITOOLS95_DrawRectEdge(HDC32 hdc, LPRECT32 rc,
415 UINT32 uType, UINT32 uFlags)
417 char LTInnerI, LTOuterI;
418 char RBInnerI, RBOuterI;
419 HPEN32 LTInnerPen, LTOuterPen;
420 HPEN32 RBInnerPen, RBOuterPen;
421 RECT32 InnerRect = *rc;
428 BOOL32 retval = !( ((uType & BDR_INNER) == BDR_INNER
429 || (uType & BDR_OUTER) == BDR_OUTER)
430 && !(uFlags & (BF_FLAT|BF_MONO)) );
433 LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN32)GetStockObject32(NULL_PEN);
434 SavePen = (HPEN32)SelectObject32(hdc, LTInnerPen);
436 /* Determine the colors of the edges */
439 LTInnerI = RBInnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
440 LTOuterI = RBOuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
442 else if(uFlags & BF_FLAT)
444 LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
445 LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
447 else if(uFlags & BF_SOFT)
449 LTInnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
450 LTOuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
451 RBInnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
452 RBOuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
456 LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
457 LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
458 RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
459 RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
462 if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
463 if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
464 if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
465 if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
467 if(LTInnerI != -1) LTInnerPen = GetSysColorPen32(LTInnerI);
468 if(LTOuterI != -1) LTOuterPen = GetSysColorPen32(LTOuterI);
469 if(RBInnerI != -1) RBInnerPen = GetSysColorPen32(RBInnerI);
470 if(RBOuterI != -1) RBOuterPen = GetSysColorPen32(RBOuterI);
472 if((uFlags & BF_MIDDLE) && retval)
474 FillRect32(hdc, &InnerRect, GetSysColorBrush32(uFlags & BF_MONO ?
475 COLOR_WINDOW : COLOR_BTNFACE));
478 MoveToEx32(hdc, 0, 0, &SavePoint);
480 /* Draw the outer edge */
481 SelectObject32(hdc, LTOuterPen);
484 MoveToEx32(hdc, InnerRect.left, InnerRect.top, NULL);
485 LineTo32(hdc, InnerRect.right, InnerRect.top);
489 MoveToEx32(hdc, InnerRect.left, InnerRect.top, NULL);
490 LineTo32(hdc, InnerRect.left, InnerRect.bottom);
492 SelectObject32(hdc, RBOuterPen);
493 if(uFlags & BF_BOTTOM)
495 MoveToEx32(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
496 LineTo32(hdc, InnerRect.left-1, InnerRect.bottom-1);
498 if(uFlags & BF_RIGHT)
500 MoveToEx32(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
501 LineTo32(hdc, InnerRect.right-1, InnerRect.top-1);
504 /* Draw the inner edge */
505 SelectObject32(hdc, LTInnerPen);
508 MoveToEx32(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
509 LineTo32(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
513 MoveToEx32(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
514 LineTo32(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
516 SelectObject32(hdc, RBInnerPen);
517 if(uFlags & BF_BOTTOM)
519 MoveToEx32(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
520 LineTo32(hdc, InnerRect.left-1+LBpenplus, InnerRect.bottom-2);
522 if(uFlags & BF_RIGHT)
524 MoveToEx32(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
525 LineTo32(hdc, InnerRect.right-2, InnerRect.top-1+RTpenplus);
528 /* Adjust rectangle if asked */
529 if(uFlags & BF_ADJUST)
531 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
532 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
533 if(uFlags & BF_LEFT) rc->left += add;
534 if(uFlags & BF_RIGHT) rc->right -= add;
535 if(uFlags & BF_TOP) rc->top += add;
536 if(uFlags & BF_BOTTOM) rc->bottom -= add;
540 SelectObject32(hdc, SavePen);
541 MoveToEx32(hdc, SavePoint.x, SavePoint.y, NULL);
546 /**********************************************************************
547 * DrawEdge16 (USER.659)
549 BOOL16 WINAPI DrawEdge16( HDC16 hdc, LPRECT16 rc, UINT16 edge, UINT16 flags )
554 CONV_RECT16TO32( rc, &rect32 );
555 ret = DrawEdge32( hdc, &rect32, edge, flags );
556 CONV_RECT32TO16( &rect32, rc );
560 /**********************************************************************
561 * DrawEdge32 (USER32.155)
563 BOOL32 WINAPI DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
565 TRACE(graphics, "%04x %d,%d-%d,%d %04x %04x\n",
566 hdc, rc->left, rc->top, rc->right, rc->bottom, edge, flags );
568 if(flags & BF_DIAGONAL)
569 return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
571 return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
575 /************************************************************************
576 * UITOOLS_MakeSquareRect
578 * Utility to create a square rectangle and returning the width
580 static int UITOOLS_MakeSquareRect(LPRECT32 src, LPRECT32 dst)
582 int Width = src->right - src->left;
583 int Height = src->bottom - src->top;
584 int SmallDiam = Width > Height ? Height : Width;
588 /* Make it a square box */
589 if(Width < Height) /* SmallDiam == Width */
591 dst->top += (Height-Width)/2;
592 dst->bottom = dst->top + SmallDiam;
594 else if(Width > Height) /* SmallDiam == Height */
596 dst->left += (Width-Height)/2;
597 dst->right = dst->left + SmallDiam;
604 /************************************************************************
605 * UITOOLS_DFC_ButtonPush
607 * Draw a push button coming from DrawFrameControl()
609 * Does a pretty good job in emulating MS behavior. Some quirks are
610 * however there because MS uses a TrueType font (Marlett) to draw
613 static BOOL32 UITOOLS95_DFC_ButtonPush(HDC32 dc, LPRECT32 r, UINT32 uFlags)
618 if(uFlags & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
623 if(uFlags & DFCS_CHECKED)
625 if(uFlags & DFCS_MONO)
626 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
628 UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
630 if(GetSysColor32(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
632 HBITMAP32 hbm = CreateBitmap32(8, 8, 1, 1, wPattern_AA55);
634 HBRUSH32 hb = CreatePatternBrush32(hbm);
636 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
637 hbsave = (HBRUSH32)SelectObject32(dc, hb);
638 PatBlt32(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
639 SelectObject32(dc, hbsave);
645 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
650 if(uFlags & DFCS_MONO)
652 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
653 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
657 UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
661 /* Adjust rectangle if asked */
662 if(uFlags & DFCS_ADJUSTRECT)
674 /************************************************************************
675 * UITOOLS_DFC_ButtonChcek
677 * Draw a check/3state button coming from DrawFrameControl()
679 * Does a pretty good job in emulating MS behavior. Some quirks are
680 * however there because MS uses a TrueType font (Marlett) to draw
683 #define DFC_CHECKPOINTSMAX 6
685 static BOOL32 UITOOLS95_DFC_ButtonCheck(HDC32 dc, LPRECT32 r, UINT32 uFlags)
688 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
689 int BorderShrink = SmallDiam / 16;
691 if(BorderShrink < 1) BorderShrink = 1;
693 /* FIXME: The FillRect() sequence doesn't work for sizes less than */
694 /* 4 pixels in diameter. Not really a problem but it isn't M$'s */
695 /* 100% equivalent. */
696 if(uFlags & (DFCS_FLAT|DFCS_MONO))
698 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_WINDOWFRAME));
699 myr.left += 2 * BorderShrink;
700 myr.right -= 2 * BorderShrink;
701 myr.top += 2 * BorderShrink;
702 myr.bottom -= 2 * BorderShrink;
706 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
707 myr.right -= BorderShrink;
708 myr.bottom -= BorderShrink;
709 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNSHADOW));
710 myr.left += BorderShrink;
711 myr.top += BorderShrink;
712 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_3DLIGHT));
713 myr.right -= BorderShrink;
714 myr.bottom -= BorderShrink;
715 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_3DDKSHADOW));
716 myr.left += BorderShrink;
717 myr.top += BorderShrink;
720 if(uFlags & (DFCS_INACTIVE|DFCS_PUSHED))
722 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
724 else if(uFlags & DFCS_CHECKED)
726 if(GetSysColor32(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
728 HBITMAP32 hbm = CreateBitmap32(8, 8, 1, 1, wPattern_AA55);
730 HBRUSH32 hb = CreatePatternBrush32(hbm);
732 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
733 hbsave = (HBRUSH32)SelectObject32(dc, hb);
734 PatBlt32(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
735 SelectObject32(dc, hbsave);
741 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
746 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_WINDOW));
749 if(uFlags & DFCS_CHECKED)
751 POINT32 CheckPoints[DFC_CHECKPOINTSMAX];
756 /* FIXME: This comes very close to M$'s checkmark, but not */
757 /* exactly... When small or large there is a few pixels */
758 /* shift. Not bad, but could be better :) */
759 UITOOLS_MakeSquareRect(r, &myr);
760 CheckPoints[0].x = myr.left + 253*SmallDiam/1000;
761 CheckPoints[0].y = myr.top + 345*SmallDiam/1000;
762 CheckPoints[1].x = myr.left + 409*SmallDiam/1000;
763 CheckPoints[1].y = CheckPoints[0].y + (CheckPoints[1].x-CheckPoints[0].x);
764 CheckPoints[2].x = myr.left + 690*SmallDiam/1000;
765 CheckPoints[2].y = CheckPoints[1].y - (CheckPoints[2].x-CheckPoints[1].x);
766 CheckPoints[3].x = CheckPoints[2].x;
767 CheckPoints[3].y = CheckPoints[2].y + 3*SmallDiam/16;
768 CheckPoints[4].x = CheckPoints[1].x;
769 CheckPoints[4].y = CheckPoints[1].y + 3*SmallDiam/16;
770 CheckPoints[5].x = CheckPoints[0].x;
771 CheckPoints[5].y = CheckPoints[0].y + 3*SmallDiam/16;
773 i = (uFlags & DFCS_INACTIVE) || (uFlags & 0xff) == DFCS_BUTTON3STATE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
774 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
775 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
776 Polygon32(dc, CheckPoints, DFC_CHECKPOINTSMAX);
777 SelectObject32(dc, hpsave);
778 SelectObject32(dc, hbsave);
784 /************************************************************************
785 * UITOOLS_DFC_ButtonRadio
787 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
789 * Does a pretty good job in emulating MS behavior. Some quirks are
790 * however there because MS uses a TrueType font (Marlett) to draw
793 static BOOL32 UITOOLS95_DFC_ButtonRadio(HDC32 dc, LPRECT32 r, UINT32 uFlags)
797 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
798 int BorderShrink = SmallDiam / 16;
804 if(BorderShrink < 1) BorderShrink = 1;
806 if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
808 FillRect32(dc, r, (HBRUSH32)GetStockObject32(BLACK_BRUSH));
812 ye = myr.top + SmallDiam - SmallDiam/2;
814 xc = myr.left + SmallDiam - SmallDiam/2;
815 yc = myr.top + SmallDiam - SmallDiam/2;
817 /* Define bounding box */
819 myr.left = xc - i+i/2;
820 myr.right = xc + i/2;
821 myr.top = yc - i+i/2;
822 myr.bottom = yc + i/2;
824 if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
826 hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(BLACK_BRUSH));
827 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
828 SelectObject32(dc, hbsave);
832 if(uFlags & (DFCS_FLAT|DFCS_MONO))
834 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_WINDOWFRAME));
835 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_WINDOWFRAME));
836 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
837 SelectObject32(dc, hbsave);
838 SelectObject32(dc, hpsave);
842 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_BTNHIGHLIGHT));
843 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
844 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
846 SelectObject32(dc, GetSysColorPen32(COLOR_BTNSHADOW));
847 SelectObject32(dc, GetSysColorBrush32(COLOR_BTNSHADOW));
848 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
850 myr.left += BorderShrink;
851 myr.right -= BorderShrink;
852 myr.top += BorderShrink;
853 myr.bottom -= BorderShrink;
855 SelectObject32(dc, GetSysColorPen32(COLOR_3DLIGHT));
856 SelectObject32(dc, GetSysColorBrush32(COLOR_3DLIGHT));
857 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
859 SelectObject32(dc, GetSysColorPen32(COLOR_3DDKSHADOW));
860 SelectObject32(dc, GetSysColorBrush32(COLOR_3DDKSHADOW));
861 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
862 SelectObject32(dc, hbsave);
863 SelectObject32(dc, hpsave);
867 myr.left = xc - i+i/2;
868 myr.right = xc + i/2;
869 myr.top = yc - i+i/2;
870 myr.bottom = yc + i/2;
871 i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
872 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
873 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
874 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
875 SelectObject32(dc, hbsave);
876 SelectObject32(dc, hpsave);
879 if(uFlags & DFCS_CHECKED)
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;
888 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
889 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
890 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
891 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
892 SelectObject32(dc, hpsave);
893 SelectObject32(dc, hbsave);
896 /* FIXME: M$ has a polygon in the center at relative points: */
897 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
901 /* when the button is unchecked. The reason for it is unknown. The */
902 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
903 /* least 3 times (it looks like a clip-region when you see it happen). */
904 /* I do not really see a reason why this should be implemented. If you */
905 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
911 /***********************************************************************
912 * UITOOLS_DrawFrameButton
914 static BOOL32 UITOOLS95_DrawFrameButton(HDC32 hdc, LPRECT32 rc, UINT32 uState)
916 switch(uState & 0xff)
918 case DFCS_BUTTONPUSH:
919 return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
921 case DFCS_BUTTONCHECK:
922 case DFCS_BUTTON3STATE:
923 return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
925 case DFCS_BUTTONRADIOIMAGE:
926 case DFCS_BUTTONRADIOMASK:
927 case DFCS_BUTTONRADIO:
928 return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
931 WARN(uitools, "Invalid button state=0x%04x\n", uState);
937 /***********************************************************************
938 * UITOOLS_DrawFrameCaption
940 * Draw caption buttons (win95), coming from DrawFrameControl()
943 static BOOL32 UITOOLS95_DrawFrameCaption(HDC32 dc, LPRECT32 r, UINT32 uFlags)
950 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr)-2;
955 int xc = (myr.left+myr.right)/2;
956 int yc = (myr.top+myr.bottom)/2;
964 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
966 switch(uFlags & 0xff)
968 case DFCS_CAPTIONCLOSE:
969 edge = 328*SmallDiam/1000;
970 move = 95*SmallDiam/1000;
971 Line1[0].x = Line2[0].x = Line1[1].x = Line2[1].x = xc - edge;
972 Line1[2].y = Line2[5].y = Line1[1].y = Line2[4].y = yc - edge;
973 Line1[3].x = Line2[3].x = Line1[4].x = Line2[4].x = xc + edge;
974 Line1[5].y = Line2[2].y = Line1[4].y = Line2[1].y = yc + edge;
975 Line1[2].x = Line2[2].x = Line1[1].x + move;
976 Line1[0].y = Line2[3].y = Line1[1].y + move;
977 Line1[5].x = Line2[5].x = Line1[4].x - move;
978 Line1[3].y = Line2[0].y = Line1[4].y - move;
983 case DFCS_CAPTIONHELP:
984 /* This one breaks the flow */
985 /* FIXME: We need the Marlett font in order to get this right. */
987 hf = CreateFont32A(-SmallDiam, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
988 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
989 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "System");
990 alignsave = SetTextAlign32(dc, TA_TOP|TA_LEFT);
991 bksave = SetBkMode32(dc, TRANSPARENT);
992 clrsave = GetTextColor32(dc);
993 hfsave = (HFONT32)SelectObject32(dc, hf);
994 GetTextExtentPoint32A(dc, str, 1, &size);
996 if(uFlags & DFCS_INACTIVE)
998 SetTextColor32(dc, GetSysColor32(COLOR_BTNHIGHLIGHT));
999 TextOut32A(dc, xc-size.cx/2+1, yc-size.cy/2+1, str, 1);
1001 SetTextColor32(dc, GetSysColor32(uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
1002 TextOut32A(dc, xc-size.cx/2, yc-size.cy/2, str, 1);
1004 SelectObject32(dc, hfsave);
1005 SetTextColor32(dc, clrsave);
1006 SetBkMode32(dc, bksave);
1007 SetTextAlign32(dc, alignsave);
1011 case DFCS_CAPTIONMIN:
1012 Line1[0].x = Line1[3].x = myr.left + 96*SmallDiam/750+2;
1013 Line1[1].x = Line1[2].x = Line1[0].x + 372*SmallDiam/750;
1014 Line1[0].y = Line1[1].y = myr.top + 563*SmallDiam/750+1;
1015 Line1[2].y = Line1[3].y = Line1[0].y + 92*SmallDiam/750;
1020 case DFCS_CAPTIONMAX:
1021 edge = 47*SmallDiam/750;
1022 Line1[0].x = Line1[5].x = myr.left + 57*SmallDiam/750+3;
1023 Line1[0].y = Line1[1].y = myr.top + 143*SmallDiam/750+1;
1024 Line1[1].x = Line1[2].x = Line1[0].x + 562*SmallDiam/750;
1025 Line1[5].y = Line1[4].y = Line1[0].y + 93*SmallDiam/750;
1026 Line1[2].y = Line1[3].y = Line1[0].y + 513*SmallDiam/750;
1027 Line1[3].x = Line1[4].x = Line1[1].x - edge;
1029 Line2[0].x = Line2[5].x = Line1[0].x;
1030 Line2[3].x = Line2[4].x = Line1[1].x;
1031 Line2[1].x = Line2[2].x = Line1[0].x + edge;
1032 Line2[0].y = Line2[1].y = Line1[0].y;
1033 Line2[4].y = Line2[5].y = Line1[2].y;
1034 Line2[2].y = Line2[3].y = Line1[2].y - edge;
1039 case DFCS_CAPTIONRESTORE:
1040 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1041 edge = 47*SmallDiam/750;
1042 move = 420*SmallDiam/750;
1043 Line1[0].x = Line1[9].x = myr.left + 198*SmallDiam/750+2;
1044 Line1[0].y = Line1[1].y = myr.top + 169*SmallDiam/750+1;
1045 Line1[6].y = Line1[7].y = Line1[0].y + 93*SmallDiam/750;
1046 Line1[7].x = Line1[8].x = Line1[0].x + edge;
1047 Line1[1].x = Line1[2].x = Line1[0].x + move;
1048 Line1[5].x = Line1[6].x = Line1[1].x - edge;
1049 Line1[9].y = Line1[8].y = Line1[0].y + 187*SmallDiam/750;
1050 Line1[2].y = Line1[3].y = Line1[0].y + 327*SmallDiam/750;
1051 Line1[4].y = Line1[5].y = Line1[2].y - edge;
1052 Line1[3].x = Line1[4].x = Line1[2].x - 140*SmallDiam/750;
1054 Line2[1].x = Line2[2].x = Line1[3].x;
1055 Line2[7].x = Line2[8].x = Line2[1].x - edge;
1056 Line2[0].x = Line2[9].x = Line2[3].x = Line2[4].x = Line2[1].x - move;
1057 Line2[5].x = Line2[6].x = Line2[0].x + edge;
1058 Line2[0].y = Line2[1].y = Line1[9].y;
1059 Line2[4].y = Line2[5].y = Line2[8].y = Line2[9].y = Line2[0].y + 93*SmallDiam/750;
1060 Line2[2].y = Line2[3].y = Line2[0].y + 327*SmallDiam/750;
1061 Line2[6].y = Line2[7].y = Line2[2].y - edge;
1067 WARN(uitools, "Invalid caption; flags=0x%04x\n", uFlags);
1071 /* Here the drawing takes place */
1072 if(uFlags & DFCS_INACTIVE)
1074 /* If we have an inactive button, then you see a shadow */
1075 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
1076 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_BTNHIGHLIGHT));
1077 Polygon32(dc, Line1, Line1N);
1079 Polygon32(dc, Line2, Line2N);
1080 SelectObject32(dc, hpsave);
1081 SelectObject32(dc, hbsave);
1084 /* Correct for the shadow shift */
1085 for(i = 0; i < Line1N; i++)
1090 for(i = 0; i < Line2N; i++)
1096 /* Make the final picture */
1097 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1098 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
1099 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
1101 Polygon32(dc, Line1, Line1N);
1103 Polygon32(dc, Line2, Line2N);
1104 SelectObject32(dc, hpsave);
1105 SelectObject32(dc, hbsave);
1111 /************************************************************************
1112 * UITOOLS_DrawFrameScroll
1114 * Draw a scroll-bar control coming from DrawFrameControl()
1116 static BOOL32 UITOOLS95_DrawFrameScroll(HDC32 dc, LPRECT32 r, UINT32 uFlags)
1120 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2;
1122 HBRUSH32 hbsave, hb, hb2;
1123 HPEN32 hpsave, hp, hp2;
1124 int tri = 310*SmallDiam/1000;
1127 switch(uFlags & 0xff)
1129 case DFCS_SCROLLCOMBOBOX:
1130 case DFCS_SCROLLDOWN:
1131 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1132 Line[2].y = myr.top + 687*SmallDiam/1000 + 1;
1133 Line[0].x = Line[2].x - tri;
1134 Line[1].x = Line[2].x + tri;
1135 Line[0].y = Line[1].y = Line[2].y - tri;
1139 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1140 Line[2].y = myr.top + 313*SmallDiam/1000 + 1;
1141 Line[0].x = Line[2].x - tri;
1142 Line[1].x = Line[2].x + tri;
1143 Line[0].y = Line[1].y = Line[2].y + tri;
1146 case DFCS_SCROLLLEFT:
1147 Line[2].x = myr.left + 313*SmallDiam/1000 + 1;
1148 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1149 Line[0].y = Line[2].y - tri;
1150 Line[1].y = Line[2].y + tri;
1151 Line[0].x = Line[1].x = Line[2].x + tri;
1154 case DFCS_SCROLLRIGHT:
1155 Line[2].x = myr.left + 687*SmallDiam/1000 + 1;
1156 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1157 Line[0].y = Line[2].y - tri;
1158 Line[1].y = Line[2].y + tri;
1159 Line[0].x = Line[1].x = Line[2].x - tri;
1162 case DFCS_SCROLLSIZEGRIP:
1163 /* This one breaks the flow... */
1164 UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
1165 hpsave = (HPEN32)SelectObject32(dc, GetStockObject32(NULL_PEN));
1166 hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(NULL_BRUSH));
1167 if(uFlags & (DFCS_MONO|DFCS_FLAT))
1169 hp = hp2 = GetSysColorPen32(COLOR_WINDOWFRAME);
1170 hb = hb2 = GetSysColorBrush32(COLOR_WINDOWFRAME);
1174 hp = GetSysColorPen32(COLOR_BTNHIGHLIGHT);
1175 hp2 = GetSysColorPen32(COLOR_BTNSHADOW);
1176 hb = GetSysColorBrush32(COLOR_BTNHIGHLIGHT);
1177 hb2 = GetSysColorBrush32(COLOR_BTNSHADOW);
1179 Line[0].x = Line[1].x = r->right-1;
1180 Line[2].y = Line[3].y = r->bottom-1;
1181 d46 = 46*SmallDiam/750;
1182 d93 = 93*SmallDiam/750;
1184 i = 586*SmallDiam/750;
1185 Line[0].y = r->bottom - i - 1;
1186 Line[3].x = r->right - i - 1;
1187 Line[1].y = Line[0].y + d46;
1188 Line[2].x = Line[3].x + d46;
1189 SelectObject32(dc, hb);
1190 SelectObject32(dc, hp);
1191 Polygon32(dc, Line, 4);
1193 Line[1].y++; Line[2].x++;
1194 Line[0].y = Line[1].y + d93;
1195 Line[3].x = Line[2].x + d93;
1196 SelectObject32(dc, hb2);
1197 SelectObject32(dc, hp2);
1198 Polygon32(dc, Line, 4);
1200 i = 398*SmallDiam/750;
1201 Line[0].y = r->bottom - i - 1;
1202 Line[3].x = r->right - i - 1;
1203 Line[1].y = Line[0].y + d46;
1204 Line[2].x = Line[3].x + d46;
1205 SelectObject32(dc, hb);
1206 SelectObject32(dc, hp);
1207 Polygon32(dc, Line, 4);
1209 Line[1].y++; Line[2].x++;
1210 Line[0].y = Line[1].y + d93;
1211 Line[3].x = Line[2].x + d93;
1212 SelectObject32(dc, hb2);
1213 SelectObject32(dc, hp2);
1214 Polygon32(dc, Line, 4);
1216 i = 210*SmallDiam/750;
1217 Line[0].y = r->bottom - i - 1;
1218 Line[3].x = r->right - i - 1;
1219 Line[1].y = Line[0].y + d46;
1220 Line[2].x = Line[3].x + d46;
1221 SelectObject32(dc, hb);
1222 SelectObject32(dc, hp);
1223 Polygon32(dc, Line, 4);
1225 Line[1].y++; Line[2].x++;
1226 Line[0].y = Line[1].y + d93;
1227 Line[3].x = Line[2].x + d93;
1228 SelectObject32(dc, hb2);
1229 SelectObject32(dc, hp2);
1230 Polygon32(dc, Line, 4);
1232 SelectObject32(dc, hpsave);
1233 SelectObject32(dc, hbsave);
1237 WARN(uitools, "Invalid scroll; flags=0x%04x\n", uFlags);
1241 /* Here do the real scroll-bar controls end up */
1242 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
1244 if(uFlags & DFCS_INACTIVE)
1246 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
1247 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_BTNHIGHLIGHT));
1248 Polygon32(dc, Line, 3);
1249 SelectObject32(dc, hpsave);
1250 SelectObject32(dc, hbsave);
1253 for(i = 0; i < 3; i++)
1259 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1260 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
1261 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
1262 Polygon32(dc, Line, 3);
1263 SelectObject32(dc, hpsave);
1264 SelectObject32(dc, hbsave);
1269 /************************************************************************
1270 * UITOOLS_DrawFrameMenu
1272 * Draw a menu control coming from DrawFrameControl()
1274 static BOOL32 UITOOLS95_DrawFrameMenu(HDC32 dc, LPRECT32 r, UINT32 uFlags)
1278 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
1284 BOOL32 retval = TRUE;
1286 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1287 /* use anything else. I think I tried all sys-colors to change things */
1288 /* without luck. It seems as if this behavior is inherited from the */
1289 /* win31 DFC() implementation... (you remember, B/W menus). */
1291 FillRect32(dc, r, (HBRUSH32)GetStockObject32(WHITE_BRUSH));
1293 hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(BLACK_BRUSH));
1294 hpsave = (HPEN32)SelectObject32(dc, GetStockObject32(BLACK_PEN));
1296 switch(uFlags & 0xff)
1298 case DFCS_MENUARROW:
1299 i = 187*SmallDiam/750;
1300 Points[2].x = myr.left + 468*SmallDiam/750;
1301 Points[2].y = myr.top + 352*SmallDiam/750+1;
1302 Points[0].y = Points[2].y - i;
1303 Points[1].y = Points[2].y + i;
1304 Points[0].x = Points[1].x = Points[2].x - i;
1305 Polygon32(dc, Points, 3);
1308 case DFCS_MENUBULLET:
1310 ye = myr.top + SmallDiam - SmallDiam/2;
1311 xc = myr.left + SmallDiam - SmallDiam/2;
1312 yc = myr.top + SmallDiam - SmallDiam/2;
1313 i = 234*SmallDiam/750;
1315 myr.left = xc - i+i/2;
1316 myr.right = xc + i/2;
1317 myr.top = yc - i+i/2;
1318 myr.bottom = yc + i/2;
1319 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
1322 case DFCS_MENUCHECK:
1323 Points[0].x = myr.left + 253*SmallDiam/1000;
1324 Points[0].y = myr.top + 445*SmallDiam/1000;
1325 Points[1].x = myr.left + 409*SmallDiam/1000;
1326 Points[1].y = Points[0].y + (Points[1].x-Points[0].x);
1327 Points[2].x = myr.left + 690*SmallDiam/1000;
1328 Points[2].y = Points[1].y - (Points[2].x-Points[1].x);
1329 Points[3].x = Points[2].x;
1330 Points[3].y = Points[2].y + 3*SmallDiam/16;
1331 Points[4].x = Points[1].x;
1332 Points[4].y = Points[1].y + 3*SmallDiam/16;
1333 Points[5].x = Points[0].x;
1334 Points[5].y = Points[0].y + 3*SmallDiam/16;
1335 Polygon32(dc, Points, 6);
1339 WARN(uitools, "Invalid menu; flags=0x%04x\n", uFlags);
1344 SelectObject32(dc, hpsave);
1345 SelectObject32(dc, hbsave);
1350 /**********************************************************************
1351 * DrawFrameControl16 (USER.656)
1353 BOOL16 WINAPI DrawFrameControl16( HDC16 hdc, LPRECT16 rc, UINT16 uType,
1359 CONV_RECT16TO32( rc, &rect32 );
1360 ret = DrawFrameControl32( hdc, &rect32, uType, uState );
1361 CONV_RECT32TO16( &rect32, rc );
1366 /**********************************************************************
1367 * DrawFrameControl32 (USER32.158)
1369 BOOL32 WINAPI DrawFrameControl32( HDC32 hdc, LPRECT32 rc, UINT32 uType,
1372 /* Win95 doesn't support drawing in other mapping modes */
1373 if(GetMapMode32(hdc) != MM_TEXT)
1379 return UITOOLS95_DrawFrameButton(hdc, rc, uState);
1381 return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
1383 return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
1385 return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
1387 WARN(uitools, "(%x,%p,%d,%x), bad type!\n",
1388 hdc,rc,uType,uState );