2 * User Interface Functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1997 Bertho A. Stultiens
11 DEFAULT_DEBUG_CHANNEL(graphics
)
13 static const WORD wPattern_AA55
[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
14 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
16 /* These tables are used in:
17 * UITOOLS_DrawDiagEdge()
18 * UITOOLS_DrawRectEdge()
20 static const char LTInnerNormal
[] = {
22 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
23 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
27 static const char LTOuterNormal
[] = {
28 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
29 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
30 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
31 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
34 static const char RBInnerNormal
[] = {
36 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
37 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
41 static const char RBOuterNormal
[] = {
42 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
43 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
44 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
45 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
48 static const char LTInnerSoft
[] = {
50 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
51 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
55 static const char LTOuterSoft
[] = {
56 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
57 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
58 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
59 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
62 #define RBInnerSoft RBInnerNormal /* These are the same */
63 #define RBOuterSoft RBOuterNormal
65 static const char LTRBOuterMono
[] = {
66 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
67 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
68 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
69 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
72 static const char LTRBInnerMono
[] = {
74 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
75 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
76 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
79 static const char LTRBOuterFlat
[] = {
80 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
81 COLOR_WINDOWFRAME
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
82 COLOR_WINDOWFRAME
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
83 COLOR_WINDOWFRAME
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
86 static const char LTRBInnerFlat
[] = {
88 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
89 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
90 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
93 /***********************************************************************
94 * UITOOLS_DrawDiagEdge
96 * Same as DrawEdge invoked with BF_DIAGONAL
98 * 03-Dec-1997: Changed by Bertho Stultiens
100 * See also comments with UITOOLS_DrawRectEdge()
102 static BOOL
UITOOLS95_DrawDiagEdge(HDC hdc
, LPRECT rc
,
103 UINT uType
, UINT uFlags
)
107 HPEN InnerPen
, OuterPen
;
112 int Width
= rc
->right
- rc
->left
;
113 int Height
= rc
->bottom
- rc
->top
;
114 int SmallDiam
= Width
> Height
? Height
: Width
;
115 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
116 || (uType
& BDR_OUTER
) == BDR_OUTER
)
117 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
118 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
119 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
122 OuterPen
= InnerPen
= (HPEN
)GetStockObject(NULL_PEN
);
123 SavePen
= (HPEN
)SelectObject(hdc
, InnerPen
);
124 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
126 /* Determine the colors of the edges */
129 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
130 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
132 else if(uFlags
& BF_FLAT
)
134 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
135 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
137 else if(uFlags
& BF_SOFT
)
139 if(uFlags
& BF_BOTTOM
)
141 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
142 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
146 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
147 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
152 if(uFlags
& BF_BOTTOM
)
154 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
155 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
159 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
160 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
164 if(InnerI
!= -1) InnerPen
= GetSysColorPen(InnerI
);
165 if(OuterI
!= -1) OuterPen
= GetSysColorPen(OuterI
);
167 MoveToEx(hdc
, 0, 0, &SavePoint
);
169 /* Don't ask me why, but this is what is visible... */
170 /* This must be possible to do much simpler, but I fail to */
171 /* see the logic in the MS implementation (sigh...). */
172 /* So, this might look a bit brute force here (and it is), but */
173 /* it gets the job done;) */
175 switch(uFlags
& BF_RECT
)
181 /* Left bottom endpoint */
183 spx
= epx
+ SmallDiam
;
185 spy
= epy
- SmallDiam
;
190 /* Left top endpoint */
192 spx
= epx
+ SmallDiam
;
194 spy
= epy
+ SmallDiam
;
200 case BF_RIGHT
|BF_LEFT
:
201 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
202 case BF_BOTTOM
|BF_TOP
:
203 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
204 case BF_BOTTOMRIGHT
|BF_LEFT
:
205 case BF_BOTTOMRIGHT
|BF_TOP
:
207 /* Right top endpoint */
209 epx
= spx
+ SmallDiam
;
211 epy
= spy
- SmallDiam
;
215 MoveToEx(hdc
, spx
, spy
, NULL
);
216 SelectObject(hdc
, OuterPen
);
217 LineTo(hdc
, epx
, epy
);
219 SelectObject(hdc
, InnerPen
);
221 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
223 case BF_DIAGONAL_ENDBOTTOMLEFT
:
224 case (BF_DIAGONAL
|BF_BOTTOM
):
226 case (BF_DIAGONAL
|BF_LEFT
):
227 MoveToEx(hdc
, spx
-1, spy
, NULL
);
228 LineTo(hdc
, epx
, epy
-1);
229 Points
[0].x
= spx
-add
;
231 Points
[1].x
= rc
->left
;
232 Points
[1].y
= rc
->top
;
234 Points
[2].y
= epy
-1-add
;
235 Points
[3] = Points
[2];
238 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
239 MoveToEx(hdc
, spx
-1, spy
, NULL
);
240 LineTo(hdc
, epx
, epy
+1);
241 Points
[0].x
= spx
-add
;
243 Points
[1].x
= rc
->left
;
244 Points
[1].y
= rc
->bottom
-1;
246 Points
[2].y
= epy
+1+add
;
247 Points
[3] = Points
[2];
250 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
251 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
252 case BF_DIAGONAL_ENDTOPRIGHT
:
253 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
254 MoveToEx(hdc
, spx
+1, spy
, NULL
);
255 LineTo(hdc
, epx
, epy
+1);
257 Points
[0].y
= epy
+1+add
;
258 Points
[1].x
= rc
->right
-1;
259 Points
[1].y
= rc
->top
+add
;
260 Points
[2].x
= rc
->right
-1;
261 Points
[2].y
= rc
->bottom
-1;
262 Points
[3].x
= spx
+add
;
266 case BF_DIAGONAL_ENDTOPLEFT
:
267 MoveToEx(hdc
, spx
, spy
-1, NULL
);
268 LineTo(hdc
, epx
+1, epy
);
269 Points
[0].x
= epx
+1+add
;
271 Points
[1].x
= rc
->right
-1;
272 Points
[1].y
= rc
->top
;
273 Points
[2].x
= rc
->right
-1;
274 Points
[2].y
= rc
->bottom
-1-add
;
276 Points
[3].y
= spy
-add
;
279 case (BF_DIAGONAL
|BF_TOP
):
280 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
281 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
282 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
283 LineTo(hdc
, epx
, epy
);
286 Points
[1].x
= rc
->right
-1;
287 Points
[1].y
= rc
->top
;
288 Points
[2].x
= rc
->right
-1;
289 Points
[2].y
= rc
->bottom
-1-add
;
290 Points
[3].x
= spx
+add
;
291 Points
[3].y
= spy
-add
;
294 case (BF_DIAGONAL
|BF_RIGHT
):
295 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
296 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
297 MoveToEx(hdc
, spx
, spy
, NULL
);
298 LineTo(hdc
, epx
-1, epy
+1);
301 Points
[1].x
= rc
->left
;
302 Points
[1].y
= rc
->top
+add
;
303 Points
[2].x
= epx
-1-add
;
304 Points
[2].y
= epy
+1+add
;
305 Points
[3] = Points
[2];
309 /* Fill the interior if asked */
310 if((uFlags
& BF_MIDDLE
) && retval
)
313 HBRUSH hb
= GetSysColorBrush(uFlags
& BF_MONO
? COLOR_WINDOW
316 HPEN hp
= GetSysColorPen(uFlags
& BF_MONO
? COLOR_WINDOW
318 hbsave
= (HBRUSH
)SelectObject(hdc
, hb
);
319 hpsave
= (HPEN
)SelectObject(hdc
, hp
);
320 Polygon(hdc
, Points
, 4);
321 SelectObject(hdc
, hbsave
);
322 SelectObject(hdc
, hpsave
);
325 /* Adjust rectangle if asked */
326 if(uFlags
& BF_ADJUST
)
328 if(uFlags
& BF_LEFT
) rc
->left
+= add
;
329 if(uFlags
& BF_RIGHT
) rc
->right
-= add
;
330 if(uFlags
& BF_TOP
) rc
->top
+= add
;
331 if(uFlags
& BF_BOTTOM
) rc
->bottom
-= add
;
335 SelectObject(hdc
, SavePen
);
336 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
341 /***********************************************************************
342 * UITOOLS_DrawRectEdge
344 * Same as DrawEdge invoked without BF_DIAGONAL
346 * 23-Nov-1997: Changed by Bertho Stultiens
348 * Well, I started testing this and found out that there are a few things
349 * that weren't quite as win95. The following rewrite should reproduce
350 * win95 results completely.
351 * The colorselection is table-driven to avoid awfull if-statements.
352 * The table below show the color settings.
354 * Pen selection table for uFlags = 0
356 * uType | LTI | LTO | RBI | RBO
357 * ------+-------+-------+-------+-------
358 * 0000 | x | x | x | x
359 * 0001 | x | 22 | x | 21
360 * 0010 | x | 16 | x | 20
361 * 0011 | x | x | x | x
362 * ------+-------+-------+-------+-------
363 * 0100 | x | 20 | x | 16
364 * 0101 | 20 | 22 | 16 | 21
365 * 0110 | 20 | 16 | 16 | 20
366 * 0111 | x | x | x | x
367 * ------+-------+-------+-------+-------
368 * 1000 | x | 21 | x | 22
369 * 1001 | 21 | 22 | 22 | 21
370 * 1010 | 21 | 16 | 22 | 20
371 * 1011 | x | x | x | x
372 * ------+-------+-------+-------+-------
373 * 1100 | x | x | x | x
374 * 1101 | x | x (22)| x | x (21)
375 * 1110 | x | x (16)| x | x (20)
376 * 1111 | x | x | x | x
378 * Pen selection table for uFlags = BF_SOFT
380 * uType | LTI | LTO | RBI | RBO
381 * ------+-------+-------+-------+-------
382 * 0000 | x | x | x | x
383 * 0001 | x | 20 | x | 21
384 * 0010 | x | 21 | x | 20
385 * 0011 | x | x | x | x
386 * ------+-------+-------+-------+-------
387 * 0100 | x | 22 | x | 16
388 * 0101 | 22 | 20 | 16 | 21
389 * 0110 | 22 | 21 | 16 | 20
390 * 0111 | x | x | x | x
391 * ------+-------+-------+-------+-------
392 * 1000 | x | 16 | x | 22
393 * 1001 | 16 | 20 | 22 | 21
394 * 1010 | 16 | 21 | 22 | 20
395 * 1011 | x | x | x | x
396 * ------+-------+-------+-------+-------
397 * 1100 | x | x | x | x
398 * 1101 | x | x (20)| x | x (21)
399 * 1110 | x | x (21)| x | x (20)
400 * 1111 | x | x | x | x
402 * x = don't care; (n) = is what win95 actually uses
403 * LTI = left Top Inner line
404 * LTO = left Top Outer line
405 * RBI = Right Bottom Inner line
406 * RBO = Right Bottom Outer line
408 * 16 = COLOR_BTNSHADOW
409 * 20 = COLOR_BTNHIGHLIGHT
410 * 21 = COLOR_3DDKSHADOW
415 static BOOL
UITOOLS95_DrawRectEdge(HDC hdc
, LPRECT rc
,
416 UINT uType
, UINT uFlags
)
418 char LTInnerI
, LTOuterI
;
419 char RBInnerI
, RBOuterI
;
420 HPEN LTInnerPen
, LTOuterPen
;
421 HPEN RBInnerPen
, RBOuterPen
;
422 RECT InnerRect
= *rc
;
429 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
430 || (uType
& BDR_OUTER
) == BDR_OUTER
)
431 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
434 LTInnerPen
= LTOuterPen
= RBInnerPen
= RBOuterPen
= (HPEN
)GetStockObject(NULL_PEN
);
435 SavePen
= (HPEN
)SelectObject(hdc
, LTInnerPen
);
437 /* Determine the colors of the edges */
440 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
441 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
443 else if(uFlags
& BF_FLAT
)
445 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
446 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
448 else if(uFlags
& BF_SOFT
)
450 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
451 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
452 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
453 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
457 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
458 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
459 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
460 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
463 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
) LBpenplus
= 1;
464 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
) RTpenplus
= 1;
465 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
) RBpenplus
= 1;
466 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
) LTpenplus
= 1;
468 if(LTInnerI
!= -1) LTInnerPen
= GetSysColorPen(LTInnerI
);
469 if(LTOuterI
!= -1) LTOuterPen
= GetSysColorPen(LTOuterI
);
470 if(RBInnerI
!= -1) RBInnerPen
= GetSysColorPen(RBInnerI
);
471 if(RBOuterI
!= -1) RBOuterPen
= GetSysColorPen(RBOuterI
);
473 if((uFlags
& BF_MIDDLE
) && retval
)
475 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
476 COLOR_WINDOW
: COLOR_BTNFACE
));
479 MoveToEx(hdc
, 0, 0, &SavePoint
);
481 /* Draw the outer edge */
482 SelectObject(hdc
, LTOuterPen
);
485 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
486 LineTo(hdc
, InnerRect
.right
, InnerRect
.top
);
490 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
491 LineTo(hdc
, InnerRect
.left
, InnerRect
.bottom
);
493 SelectObject(hdc
, RBOuterPen
);
494 if(uFlags
& BF_BOTTOM
)
496 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.bottom
-1, NULL
);
497 LineTo(hdc
, InnerRect
.left
-1, InnerRect
.bottom
-1);
499 if(uFlags
& BF_RIGHT
)
501 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.bottom
-1, NULL
);
502 LineTo(hdc
, InnerRect
.right
-1, InnerRect
.top
-1);
505 /* Draw the inner edge */
506 SelectObject(hdc
, LTInnerPen
);
509 MoveToEx(hdc
, InnerRect
.left
+LTpenplus
, InnerRect
.top
+1, NULL
);
510 LineTo(hdc
, InnerRect
.right
-RTpenplus
, InnerRect
.top
+1);
514 MoveToEx(hdc
, InnerRect
.left
+1, InnerRect
.top
+LTpenplus
, NULL
);
515 LineTo(hdc
, InnerRect
.left
+1, InnerRect
.bottom
-LBpenplus
);
517 SelectObject(hdc
, RBInnerPen
);
518 if(uFlags
& BF_BOTTOM
)
520 MoveToEx(hdc
, InnerRect
.right
-1-RBpenplus
, InnerRect
.bottom
-2, NULL
);
521 LineTo(hdc
, InnerRect
.left
-1+LBpenplus
, InnerRect
.bottom
-2);
523 if(uFlags
& BF_RIGHT
)
525 MoveToEx(hdc
, InnerRect
.right
-2, InnerRect
.bottom
-1-RBpenplus
, NULL
);
526 LineTo(hdc
, InnerRect
.right
-2, InnerRect
.top
-1+RTpenplus
);
529 /* Adjust rectangle if asked */
530 if(uFlags
& BF_ADJUST
)
532 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
533 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
534 if(uFlags
& BF_LEFT
) rc
->left
+= add
;
535 if(uFlags
& BF_RIGHT
) rc
->right
-= add
;
536 if(uFlags
& BF_TOP
) rc
->top
+= add
;
537 if(uFlags
& BF_BOTTOM
) rc
->bottom
-= add
;
541 SelectObject(hdc
, SavePen
);
542 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
547 /**********************************************************************
548 * DrawEdge16 (USER.659)
550 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
555 CONV_RECT16TO32( rc
, &rect32
);
556 ret
= DrawEdge( hdc
, &rect32
, edge
, flags
);
557 CONV_RECT32TO16( &rect32
, rc
);
561 /**********************************************************************
562 * DrawEdge32 (USER32.155)
564 BOOL WINAPI
DrawEdge( HDC hdc
, LPRECT rc
, UINT edge
, UINT flags
)
566 TRACE(graphics
, "%04x %d,%d-%d,%d %04x %04x\n",
567 hdc
, rc
->left
, rc
->top
, rc
->right
, rc
->bottom
, edge
, flags
);
569 if(flags
& BF_DIAGONAL
)
570 return UITOOLS95_DrawDiagEdge(hdc
, rc
, edge
, flags
);
572 return UITOOLS95_DrawRectEdge(hdc
, rc
, edge
, flags
);
576 /************************************************************************
577 * UITOOLS_MakeSquareRect
579 * Utility to create a square rectangle and returning the width
581 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
583 int Width
= src
->right
- src
->left
;
584 int Height
= src
->bottom
- src
->top
;
585 int SmallDiam
= Width
> Height
? Height
: Width
;
589 /* Make it a square box */
590 if(Width
< Height
) /* SmallDiam == Width */
592 dst
->top
+= (Height
-Width
)/2;
593 dst
->bottom
= dst
->top
+ SmallDiam
;
595 else if(Width
> Height
) /* SmallDiam == Height */
597 dst
->left
+= (Width
-Height
)/2;
598 dst
->right
= dst
->left
+ SmallDiam
;
605 /************************************************************************
606 * UITOOLS_DFC_ButtonPush
608 * Draw a push button coming from DrawFrameControl()
610 * Does a pretty good job in emulating MS behavior. Some quirks are
611 * however there because MS uses a TrueType font (Marlett) to draw
614 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
619 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
624 if(uFlags
& DFCS_CHECKED
)
626 if(uFlags
& DFCS_MONO
)
627 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
629 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
);
631 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
633 HBITMAP hbm
= CreateBitmap(8, 8, 1, 1, wPattern_AA55
);
635 HBRUSH hb
= CreatePatternBrush(hbm
);
637 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
638 hbsave
= (HBRUSH
)SelectObject(dc
, hb
);
639 PatBlt(dc
, myr
.left
, myr
.top
, myr
.right
-myr
.left
, myr
.bottom
-myr
.top
, 0x00FA0089);
640 SelectObject(dc
, hbsave
);
646 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
651 if(uFlags
& DFCS_MONO
)
653 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
654 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
658 UITOOLS95_DrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
|BF_SOFT
| BF_RECT
);
662 /* Adjust rectangle if asked */
663 if(uFlags
& DFCS_ADJUSTRECT
)
675 /************************************************************************
676 * UITOOLS_DFC_ButtonChcek
678 * Draw a check/3state button coming from DrawFrameControl()
680 * Does a pretty good job in emulating MS behavior. Some quirks are
681 * however there because MS uses a TrueType font (Marlett) to draw
684 #define DFC_CHECKPOINTSMAX 6
686 static BOOL
UITOOLS95_DFC_ButtonCheck(HDC dc
, LPRECT r
, UINT uFlags
)
689 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
690 int BorderShrink
= SmallDiam
/ 16;
692 if(BorderShrink
< 1) BorderShrink
= 1;
694 /* FIXME: The FillRect() sequence doesn't work for sizes less than */
695 /* 4 pixels in diameter. Not really a problem but it isn't M$'s */
696 /* 100% equivalent. */
697 if(uFlags
& (DFCS_FLAT
|DFCS_MONO
))
699 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_WINDOWFRAME
));
700 myr
.left
+= 2 * BorderShrink
;
701 myr
.right
-= 2 * BorderShrink
;
702 myr
.top
+= 2 * BorderShrink
;
703 myr
.bottom
-= 2 * BorderShrink
;
707 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
708 myr
.right
-= BorderShrink
;
709 myr
.bottom
-= BorderShrink
;
710 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNSHADOW
));
711 myr
.left
+= BorderShrink
;
712 myr
.top
+= BorderShrink
;
713 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_3DLIGHT
));
714 myr
.right
-= BorderShrink
;
715 myr
.bottom
-= BorderShrink
;
716 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_3DDKSHADOW
));
717 myr
.left
+= BorderShrink
;
718 myr
.top
+= BorderShrink
;
721 if(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
))
723 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
725 else if(uFlags
& DFCS_CHECKED
)
727 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
729 HBITMAP hbm
= CreateBitmap(8, 8, 1, 1, wPattern_AA55
);
731 HBRUSH hb
= CreatePatternBrush(hbm
);
733 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
734 hbsave
= (HBRUSH
)SelectObject(dc
, hb
);
735 PatBlt(dc
, myr
.left
, myr
.top
, myr
.right
-myr
.left
, myr
.bottom
-myr
.top
, 0x00FA0089);
736 SelectObject(dc
, hbsave
);
742 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
747 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_WINDOW
));
750 if(uFlags
& DFCS_CHECKED
)
752 POINT CheckPoints
[DFC_CHECKPOINTSMAX
];
757 /* FIXME: This comes very close to M$'s checkmark, but not */
758 /* exactly... When small or large there is a few pixels */
759 /* shift. Not bad, but could be better :) */
760 UITOOLS_MakeSquareRect(r
, &myr
);
761 CheckPoints
[0].x
= myr
.left
+ 253*SmallDiam
/1000;
762 CheckPoints
[0].y
= myr
.top
+ 345*SmallDiam
/1000;
763 CheckPoints
[1].x
= myr
.left
+ 409*SmallDiam
/1000;
764 CheckPoints
[1].y
= CheckPoints
[0].y
+ (CheckPoints
[1].x
-CheckPoints
[0].x
);
765 CheckPoints
[2].x
= myr
.left
+ 690*SmallDiam
/1000;
766 CheckPoints
[2].y
= CheckPoints
[1].y
- (CheckPoints
[2].x
-CheckPoints
[1].x
);
767 CheckPoints
[3].x
= CheckPoints
[2].x
;
768 CheckPoints
[3].y
= CheckPoints
[2].y
+ 3*SmallDiam
/16;
769 CheckPoints
[4].x
= CheckPoints
[1].x
;
770 CheckPoints
[4].y
= CheckPoints
[1].y
+ 3*SmallDiam
/16;
771 CheckPoints
[5].x
= CheckPoints
[0].x
;
772 CheckPoints
[5].y
= CheckPoints
[0].y
+ 3*SmallDiam
/16;
774 i
= (uFlags
& DFCS_INACTIVE
) || (uFlags
& 0xff) == DFCS_BUTTON3STATE
? COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
775 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
776 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
777 Polygon(dc
, CheckPoints
, DFC_CHECKPOINTSMAX
);
778 SelectObject(dc
, hpsave
);
779 SelectObject(dc
, hbsave
);
785 /************************************************************************
786 * UITOOLS_DFC_ButtonRadio
788 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
790 * Does a pretty good job in emulating MS behavior. Some quirks are
791 * however there because MS uses a TrueType font (Marlett) to draw
794 static BOOL
UITOOLS95_DFC_ButtonRadio(HDC dc
, LPRECT r
, UINT uFlags
)
798 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
799 int BorderShrink
= SmallDiam
/ 16;
805 if(BorderShrink
< 1) BorderShrink
= 1;
807 if((uFlags
& 0xff) == DFCS_BUTTONRADIOIMAGE
)
809 FillRect(dc
, r
, (HBRUSH
)GetStockObject(BLACK_BRUSH
));
813 ye
= myr
.top
+ SmallDiam
- SmallDiam
/2;
815 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
816 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
818 /* Define bounding box */
820 myr
.left
= xc
- i
+i
/2;
821 myr
.right
= xc
+ i
/2;
822 myr
.top
= yc
- i
+i
/2;
823 myr
.bottom
= yc
+ i
/2;
825 if((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
)
827 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
828 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
829 SelectObject(dc
, hbsave
);
833 if(uFlags
& (DFCS_FLAT
|DFCS_MONO
))
835 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_WINDOWFRAME
));
836 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_WINDOWFRAME
));
837 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
838 SelectObject(dc
, hbsave
);
839 SelectObject(dc
, hpsave
);
843 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
844 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
845 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.left
-1, myr
.bottom
, myr
.right
-1, myr
.top
);
847 SelectObject(dc
, GetSysColorPen(COLOR_BTNSHADOW
));
848 SelectObject(dc
, GetSysColorBrush(COLOR_BTNSHADOW
));
849 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.right
+1, myr
.top
, myr
.left
+1, myr
.bottom
);
851 myr
.left
+= BorderShrink
;
852 myr
.right
-= BorderShrink
;
853 myr
.top
+= BorderShrink
;
854 myr
.bottom
-= BorderShrink
;
856 SelectObject(dc
, GetSysColorPen(COLOR_3DLIGHT
));
857 SelectObject(dc
, GetSysColorBrush(COLOR_3DLIGHT
));
858 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.left
-1, myr
.bottom
, myr
.right
-1, myr
.top
);
860 SelectObject(dc
, GetSysColorPen(COLOR_3DDKSHADOW
));
861 SelectObject(dc
, GetSysColorBrush(COLOR_3DDKSHADOW
));
862 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.right
+1, myr
.top
, myr
.left
+1, myr
.bottom
);
863 SelectObject(dc
, hbsave
);
864 SelectObject(dc
, hpsave
);
868 myr
.left
= xc
- i
+i
/2;
869 myr
.right
= xc
+ i
/2;
870 myr
.top
= yc
- i
+i
/2;
871 myr
.bottom
= yc
+ i
/2;
872 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
873 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
874 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
875 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
876 SelectObject(dc
, hbsave
);
877 SelectObject(dc
, hpsave
);
880 if(uFlags
& DFCS_CHECKED
)
884 myr
.left
= xc
- i
+i
/2;
885 myr
.right
= xc
+ i
/2;
886 myr
.top
= yc
- i
+i
/2;
887 myr
.bottom
= yc
+ i
/2;
889 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
890 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
891 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
892 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
893 SelectObject(dc
, hpsave
);
894 SelectObject(dc
, hbsave
);
897 /* FIXME: M$ has a polygon in the center at relative points: */
898 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
902 /* when the button is unchecked. The reason for it is unknown. The */
903 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
904 /* least 3 times (it looks like a clip-region when you see it happen). */
905 /* I do not really see a reason why this should be implemented. If you */
906 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
912 /***********************************************************************
913 * UITOOLS_DrawFrameButton
915 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
917 switch(uState
& 0xff)
919 case DFCS_BUTTONPUSH
:
920 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
922 case DFCS_BUTTONCHECK
:
923 case DFCS_BUTTON3STATE
:
924 return UITOOLS95_DFC_ButtonCheck(hdc
, rc
, uState
);
926 case DFCS_BUTTONRADIOIMAGE
:
927 case DFCS_BUTTONRADIOMASK
:
928 case DFCS_BUTTONRADIO
:
929 return UITOOLS95_DFC_ButtonRadio(hdc
, rc
, uState
);
932 WARN(graphics
, "Invalid button state=0x%04x\n", uState
);
938 /***********************************************************************
939 * UITOOLS_DrawFrameCaption
941 * Draw caption buttons (win95), coming from DrawFrameControl()
944 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
951 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
)-2;
956 int xc
= (myr
.left
+myr
.right
)/2;
957 int yc
= (myr
.top
+myr
.bottom
)/2;
965 UITOOLS95_DFC_ButtonPush(dc
, r
, uFlags
& 0xff00);
967 switch(uFlags
& 0xff)
969 case DFCS_CAPTIONCLOSE
:
970 edge
= 328*SmallDiam
/1000;
971 move
= 95*SmallDiam
/1000;
972 Line1
[0].x
= Line2
[0].x
= Line1
[1].x
= Line2
[1].x
= xc
- edge
;
973 Line1
[2].y
= Line2
[5].y
= Line1
[1].y
= Line2
[4].y
= yc
- edge
;
974 Line1
[3].x
= Line2
[3].x
= Line1
[4].x
= Line2
[4].x
= xc
+ edge
;
975 Line1
[5].y
= Line2
[2].y
= Line1
[4].y
= Line2
[1].y
= yc
+ edge
;
976 Line1
[2].x
= Line2
[2].x
= Line1
[1].x
+ move
;
977 Line1
[0].y
= Line2
[3].y
= Line1
[1].y
+ move
;
978 Line1
[5].x
= Line2
[5].x
= Line1
[4].x
- move
;
979 Line1
[3].y
= Line2
[0].y
= Line1
[4].y
- move
;
984 case DFCS_CAPTIONHELP
:
985 /* This one breaks the flow */
986 /* FIXME: We need the Marlett font in order to get this right. */
988 hf
= CreateFontA(-SmallDiam
, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
,
989 ANSI_CHARSET
, OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
,
990 DEFAULT_QUALITY
, FIXED_PITCH
|FF_DONTCARE
, "System");
991 alignsave
= SetTextAlign(dc
, TA_TOP
|TA_LEFT
);
992 bksave
= SetBkMode(dc
, TRANSPARENT
);
993 clrsave
= GetTextColor(dc
);
994 hfsave
= (HFONT
)SelectObject(dc
, hf
);
995 GetTextExtentPoint32A(dc
, str
, 1, &size
);
997 if(uFlags
& DFCS_INACTIVE
)
999 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
1000 TextOutA(dc
, xc
-size
.cx
/2+1, yc
-size
.cy
/2+1, str
, 1);
1002 SetTextColor(dc
, GetSysColor(uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
1003 TextOutA(dc
, xc
-size
.cx
/2, yc
-size
.cy
/2, str
, 1);
1005 SelectObject(dc
, hfsave
);
1006 SetTextColor(dc
, clrsave
);
1007 SetBkMode(dc
, bksave
);
1008 SetTextAlign(dc
, alignsave
);
1012 case DFCS_CAPTIONMIN
:
1013 Line1
[0].x
= Line1
[3].x
= myr
.left
+ 96*SmallDiam
/750+2;
1014 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ 372*SmallDiam
/750;
1015 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 563*SmallDiam
/750+1;
1016 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 92*SmallDiam
/750;
1021 case DFCS_CAPTIONMAX
:
1022 edge
= 47*SmallDiam
/750;
1023 Line1
[0].x
= Line1
[5].x
= myr
.left
+ 57*SmallDiam
/750+3;
1024 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 143*SmallDiam
/750+1;
1025 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ 562*SmallDiam
/750;
1026 Line1
[5].y
= Line1
[4].y
= Line1
[0].y
+ 93*SmallDiam
/750;
1027 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 513*SmallDiam
/750;
1028 Line1
[3].x
= Line1
[4].x
= Line1
[1].x
- edge
;
1030 Line2
[0].x
= Line2
[5].x
= Line1
[0].x
;
1031 Line2
[3].x
= Line2
[4].x
= Line1
[1].x
;
1032 Line2
[1].x
= Line2
[2].x
= Line1
[0].x
+ edge
;
1033 Line2
[0].y
= Line2
[1].y
= Line1
[0].y
;
1034 Line2
[4].y
= Line2
[5].y
= Line1
[2].y
;
1035 Line2
[2].y
= Line2
[3].y
= Line1
[2].y
- edge
;
1040 case DFCS_CAPTIONRESTORE
:
1041 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1042 edge
= 47*SmallDiam
/750;
1043 move
= 420*SmallDiam
/750;
1044 Line1
[0].x
= Line1
[9].x
= myr
.left
+ 198*SmallDiam
/750+2;
1045 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 169*SmallDiam
/750+1;
1046 Line1
[6].y
= Line1
[7].y
= Line1
[0].y
+ 93*SmallDiam
/750;
1047 Line1
[7].x
= Line1
[8].x
= Line1
[0].x
+ edge
;
1048 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ move
;
1049 Line1
[5].x
= Line1
[6].x
= Line1
[1].x
- edge
;
1050 Line1
[9].y
= Line1
[8].y
= Line1
[0].y
+ 187*SmallDiam
/750;
1051 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 327*SmallDiam
/750;
1052 Line1
[4].y
= Line1
[5].y
= Line1
[2].y
- edge
;
1053 Line1
[3].x
= Line1
[4].x
= Line1
[2].x
- 140*SmallDiam
/750;
1055 Line2
[1].x
= Line2
[2].x
= Line1
[3].x
;
1056 Line2
[7].x
= Line2
[8].x
= Line2
[1].x
- edge
;
1057 Line2
[0].x
= Line2
[9].x
= Line2
[3].x
= Line2
[4].x
= Line2
[1].x
- move
;
1058 Line2
[5].x
= Line2
[6].x
= Line2
[0].x
+ edge
;
1059 Line2
[0].y
= Line2
[1].y
= Line1
[9].y
;
1060 Line2
[4].y
= Line2
[5].y
= Line2
[8].y
= Line2
[9].y
= Line2
[0].y
+ 93*SmallDiam
/750;
1061 Line2
[2].y
= Line2
[3].y
= Line2
[0].y
+ 327*SmallDiam
/750;
1062 Line2
[6].y
= Line2
[7].y
= Line2
[2].y
- edge
;
1068 WARN(graphics
, "Invalid caption; flags=0x%04x\n", uFlags
);
1072 /* Here the drawing takes place */
1073 if(uFlags
& DFCS_INACTIVE
)
1075 /* If we have an inactive button, then you see a shadow */
1076 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1077 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
1078 Polygon(dc
, Line1
, Line1N
);
1080 Polygon(dc
, Line2
, Line2N
);
1081 SelectObject(dc
, hpsave
);
1082 SelectObject(dc
, hbsave
);
1085 /* Correct for the shadow shift */
1086 for(i
= 0; i
< Line1N
; i
++)
1091 for(i
= 0; i
< Line2N
; i
++)
1097 /* Make the final picture */
1098 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1099 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
1100 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
1102 Polygon(dc
, Line1
, Line1N
);
1104 Polygon(dc
, Line2
, Line2N
);
1105 SelectObject(dc
, hpsave
);
1106 SelectObject(dc
, hbsave
);
1112 /************************************************************************
1113 * UITOOLS_DrawFrameScroll
1115 * Draw a scroll-bar control coming from DrawFrameControl()
1117 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
1121 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
) - 2;
1123 HBRUSH hbsave
, hb
, hb2
;
1124 HPEN hpsave
, hp
, hp2
;
1125 int tri
= 310*SmallDiam
/1000;
1128 switch(uFlags
& 0xff)
1130 case DFCS_SCROLLCOMBOBOX
:
1131 case DFCS_SCROLLDOWN
:
1132 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1133 Line
[2].y
= myr
.top
+ 687*SmallDiam
/1000 + 1;
1134 Line
[0].x
= Line
[2].x
- tri
;
1135 Line
[1].x
= Line
[2].x
+ tri
;
1136 Line
[0].y
= Line
[1].y
= Line
[2].y
- tri
;
1140 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1141 Line
[2].y
= myr
.top
+ 313*SmallDiam
/1000 + 1;
1142 Line
[0].x
= Line
[2].x
- tri
;
1143 Line
[1].x
= Line
[2].x
+ tri
;
1144 Line
[0].y
= Line
[1].y
= Line
[2].y
+ tri
;
1147 case DFCS_SCROLLLEFT
:
1148 Line
[2].x
= myr
.left
+ 313*SmallDiam
/1000 + 1;
1149 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1150 Line
[0].y
= Line
[2].y
- tri
;
1151 Line
[1].y
= Line
[2].y
+ tri
;
1152 Line
[0].x
= Line
[1].x
= Line
[2].x
+ tri
;
1155 case DFCS_SCROLLRIGHT
:
1156 Line
[2].x
= myr
.left
+ 687*SmallDiam
/1000 + 1;
1157 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1158 Line
[0].y
= Line
[2].y
- tri
;
1159 Line
[1].y
= Line
[2].y
+ tri
;
1160 Line
[0].x
= Line
[1].x
= Line
[2].x
- tri
;
1163 case DFCS_SCROLLSIZEGRIP
:
1164 /* This one breaks the flow... */
1165 UITOOLS95_DrawRectEdge(dc
, r
, EDGE_BUMP
, BF_MIDDLE
| ((uFlags
&(DFCS_MONO
|DFCS_FLAT
)) ? BF_MONO
: 0));
1166 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(NULL_PEN
));
1167 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(NULL_BRUSH
));
1168 if(uFlags
& (DFCS_MONO
|DFCS_FLAT
))
1170 hp
= hp2
= GetSysColorPen(COLOR_WINDOWFRAME
);
1171 hb
= hb2
= GetSysColorBrush(COLOR_WINDOWFRAME
);
1175 hp
= GetSysColorPen(COLOR_BTNHIGHLIGHT
);
1176 hp2
= GetSysColorPen(COLOR_BTNSHADOW
);
1177 hb
= GetSysColorBrush(COLOR_BTNHIGHLIGHT
);
1178 hb2
= GetSysColorBrush(COLOR_BTNSHADOW
);
1180 Line
[0].x
= Line
[1].x
= r
->right
-1;
1181 Line
[2].y
= Line
[3].y
= r
->bottom
-1;
1182 d46
= 46*SmallDiam
/750;
1183 d93
= 93*SmallDiam
/750;
1185 i
= 586*SmallDiam
/750;
1186 Line
[0].y
= r
->bottom
- i
- 1;
1187 Line
[3].x
= r
->right
- i
- 1;
1188 Line
[1].y
= Line
[0].y
+ d46
;
1189 Line
[2].x
= Line
[3].x
+ d46
;
1190 SelectObject(dc
, hb
);
1191 SelectObject(dc
, hp
);
1192 Polygon(dc
, Line
, 4);
1194 Line
[1].y
++; Line
[2].x
++;
1195 Line
[0].y
= Line
[1].y
+ d93
;
1196 Line
[3].x
= Line
[2].x
+ d93
;
1197 SelectObject(dc
, hb2
);
1198 SelectObject(dc
, hp2
);
1199 Polygon(dc
, Line
, 4);
1201 i
= 398*SmallDiam
/750;
1202 Line
[0].y
= r
->bottom
- i
- 1;
1203 Line
[3].x
= r
->right
- i
- 1;
1204 Line
[1].y
= Line
[0].y
+ d46
;
1205 Line
[2].x
= Line
[3].x
+ d46
;
1206 SelectObject(dc
, hb
);
1207 SelectObject(dc
, hp
);
1208 Polygon(dc
, Line
, 4);
1210 Line
[1].y
++; Line
[2].x
++;
1211 Line
[0].y
= Line
[1].y
+ d93
;
1212 Line
[3].x
= Line
[2].x
+ d93
;
1213 SelectObject(dc
, hb2
);
1214 SelectObject(dc
, hp2
);
1215 Polygon(dc
, Line
, 4);
1217 i
= 210*SmallDiam
/750;
1218 Line
[0].y
= r
->bottom
- i
- 1;
1219 Line
[3].x
= r
->right
- i
- 1;
1220 Line
[1].y
= Line
[0].y
+ d46
;
1221 Line
[2].x
= Line
[3].x
+ d46
;
1222 SelectObject(dc
, hb
);
1223 SelectObject(dc
, hp
);
1224 Polygon(dc
, Line
, 4);
1226 Line
[1].y
++; Line
[2].x
++;
1227 Line
[0].y
= Line
[1].y
+ d93
;
1228 Line
[3].x
= Line
[2].x
+ d93
;
1229 SelectObject(dc
, hb2
);
1230 SelectObject(dc
, hp2
);
1231 Polygon(dc
, Line
, 4);
1233 SelectObject(dc
, hpsave
);
1234 SelectObject(dc
, hbsave
);
1238 WARN(graphics
, "Invalid scroll; flags=0x%04x\n", uFlags
);
1242 /* Here do the real scroll-bar controls end up */
1243 UITOOLS95_DFC_ButtonPush(dc
, r
, uFlags
& 0xff00);
1245 if(uFlags
& DFCS_INACTIVE
)
1247 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1248 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
1249 Polygon(dc
, Line
, 3);
1250 SelectObject(dc
, hpsave
);
1251 SelectObject(dc
, hbsave
);
1254 for(i
= 0; i
< 3; i
++)
1260 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1261 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
1262 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
1263 Polygon(dc
, Line
, 3);
1264 SelectObject(dc
, hpsave
);
1265 SelectObject(dc
, hbsave
);
1270 /************************************************************************
1271 * UITOOLS_DrawFrameMenu
1273 * Draw a menu control coming from DrawFrameControl()
1275 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
1279 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
1287 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1288 /* use anything else. I think I tried all sys-colors to change things */
1289 /* without luck. It seems as if this behavior is inherited from the */
1290 /* win31 DFC() implementation... (you remember, B/W menus). */
1292 FillRect(dc
, r
, (HBRUSH
)GetStockObject(WHITE_BRUSH
));
1294 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
1295 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(BLACK_PEN
));
1297 switch(uFlags
& 0xff)
1299 case DFCS_MENUARROW
:
1300 i
= 187*SmallDiam
/750;
1301 Points
[2].x
= myr
.left
+ 468*SmallDiam
/750;
1302 Points
[2].y
= myr
.top
+ 352*SmallDiam
/750+1;
1303 Points
[0].y
= Points
[2].y
- i
;
1304 Points
[1].y
= Points
[2].y
+ i
;
1305 Points
[0].x
= Points
[1].x
= Points
[2].x
- i
;
1306 Polygon(dc
, Points
, 3);
1309 case DFCS_MENUBULLET
:
1311 ye
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1312 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
1313 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1314 i
= 234*SmallDiam
/750;
1316 myr
.left
= xc
- i
+i
/2;
1317 myr
.right
= xc
+ i
/2;
1318 myr
.top
= yc
- i
+i
/2;
1319 myr
.bottom
= yc
+ i
/2;
1320 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
1323 case DFCS_MENUCHECK
:
1324 Points
[0].x
= myr
.left
+ 253*SmallDiam
/1000;
1325 Points
[0].y
= myr
.top
+ 445*SmallDiam
/1000;
1326 Points
[1].x
= myr
.left
+ 409*SmallDiam
/1000;
1327 Points
[1].y
= Points
[0].y
+ (Points
[1].x
-Points
[0].x
);
1328 Points
[2].x
= myr
.left
+ 690*SmallDiam
/1000;
1329 Points
[2].y
= Points
[1].y
- (Points
[2].x
-Points
[1].x
);
1330 Points
[3].x
= Points
[2].x
;
1331 Points
[3].y
= Points
[2].y
+ 3*SmallDiam
/16;
1332 Points
[4].x
= Points
[1].x
;
1333 Points
[4].y
= Points
[1].y
+ 3*SmallDiam
/16;
1334 Points
[5].x
= Points
[0].x
;
1335 Points
[5].y
= Points
[0].y
+ 3*SmallDiam
/16;
1336 Polygon(dc
, Points
, 6);
1340 WARN(graphics
, "Invalid menu; flags=0x%04x\n", uFlags
);
1345 SelectObject(dc
, hpsave
);
1346 SelectObject(dc
, hbsave
);
1351 /**********************************************************************
1352 * DrawFrameControl16 (USER.656)
1354 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
,
1360 CONV_RECT16TO32( rc
, &rect32
);
1361 ret
= DrawFrameControl( hdc
, &rect32
, uType
, uState
);
1362 CONV_RECT32TO16( &rect32
, rc
);
1367 /**********************************************************************
1368 * DrawFrameControl32 (USER32.158)
1370 BOOL WINAPI
DrawFrameControl( HDC hdc
, LPRECT rc
, UINT uType
,
1373 /* Win95 doesn't support drawing in other mapping modes */
1374 if(GetMapMode(hdc
) != MM_TEXT
)
1380 return UITOOLS95_DrawFrameButton(hdc
, rc
, uState
);
1382 return UITOOLS95_DrawFrameCaption(hdc
, rc
, uState
);
1384 return UITOOLS95_DrawFrameMenu(hdc
, rc
, uState
);
1386 return UITOOLS95_DrawFrameScroll(hdc
, rc
, uState
);
1388 WARN(graphics
, "(%x,%p,%d,%x), bad type!\n",
1389 hdc
,rc
,uType
,uState
);