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
;
619 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
621 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
623 HBITMAP hbm
= CreateBitmap(8, 8, 1, 1, wPattern_AA55
);
625 HBRUSH hb
= CreatePatternBrush(hbm
);
628 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
629 bg
= SetBkColor(dc
, RGB(255, 255, 255));
630 hbsave
= (HBRUSH
)SelectObject(dc
, hb
);
631 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
632 SelectObject(dc
, hbsave
);
639 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
643 /************************************************************************
644 * UITOOLS_DFC_ButtonPush
646 * Draw a push button coming from DrawFrameControl()
648 * Does a pretty good job in emulating MS behavior. Some quirks are
649 * however there because MS uses a TrueType font (Marlett) to draw
652 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
657 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
662 if(uFlags
& DFCS_CHECKED
)
664 if(uFlags
& DFCS_MONO
)
665 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
667 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
);
669 UITOOLS_DrawCheckedRect( dc
, &myr
);
673 if(uFlags
& DFCS_MONO
)
675 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
676 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
680 UITOOLS95_DrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
|BF_SOFT
| BF_RECT
);
684 /* Adjust rectangle if asked */
685 if(uFlags
& DFCS_ADJUSTRECT
)
697 /************************************************************************
698 * UITOOLS_DFC_ButtonChcek
700 * Draw a check/3state button coming from DrawFrameControl()
702 * Does a pretty good job in emulating MS behavior. Some quirks are
703 * however there because MS uses a TrueType font (Marlett) to draw
706 #define DFC_CHECKPOINTSMAX 6
708 static BOOL
UITOOLS95_DFC_ButtonCheck(HDC dc
, LPRECT r
, UINT uFlags
)
711 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
712 UINT flags
= BF_RECT
| BF_ADJUST
;
714 if(uFlags
& DFCS_FLAT
) flags
|= BF_FLAT
;
715 else if(uFlags
& DFCS_MONO
) flags
|= BF_MONO
;
717 UITOOLS95_DrawRectEdge( dc
, &myr
, EDGE_SUNKEN
, flags
);
719 if(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
))
720 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
721 else if( (uFlags
& DFCS_BUTTON3STATE
) && (uFlags
& DFCS_CHECKED
) )
722 UITOOLS_DrawCheckedRect( dc
, &myr
);
725 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_WINDOW
));
728 if(uFlags
& DFCS_CHECKED
)
730 POINT CheckPoints
[DFC_CHECKPOINTSMAX
];
735 /* FIXME: This comes very close to M$'s checkmark, but not */
736 /* exactly... When small or large there is a few pixels */
737 /* shift. Not bad, but could be better :) */
738 UITOOLS_MakeSquareRect(r
, &myr
);
739 CheckPoints
[0].x
= myr
.left
+ 253*SmallDiam
/1000;
740 CheckPoints
[0].y
= myr
.top
+ 345*SmallDiam
/1000;
741 CheckPoints
[1].x
= myr
.left
+ 409*SmallDiam
/1000;
742 CheckPoints
[1].y
= CheckPoints
[0].y
+ (CheckPoints
[1].x
-CheckPoints
[0].x
);
743 CheckPoints
[2].x
= myr
.left
+ 690*SmallDiam
/1000;
744 CheckPoints
[2].y
= CheckPoints
[1].y
- (CheckPoints
[2].x
-CheckPoints
[1].x
);
745 CheckPoints
[3].x
= CheckPoints
[2].x
;
746 CheckPoints
[3].y
= CheckPoints
[2].y
+ 3*SmallDiam
/16;
747 CheckPoints
[4].x
= CheckPoints
[1].x
;
748 CheckPoints
[4].y
= CheckPoints
[1].y
+ 3*SmallDiam
/16;
749 CheckPoints
[5].x
= CheckPoints
[0].x
;
750 CheckPoints
[5].y
= CheckPoints
[0].y
+ 3*SmallDiam
/16;
752 i
= (uFlags
& DFCS_INACTIVE
) || (uFlags
& 0xff) == DFCS_BUTTON3STATE
? COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
753 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
754 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
755 Polygon(dc
, CheckPoints
, DFC_CHECKPOINTSMAX
);
756 SelectObject(dc
, hpsave
);
757 SelectObject(dc
, hbsave
);
763 /************************************************************************
764 * UITOOLS_DFC_ButtonRadio
766 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
768 * Does a pretty good job in emulating MS behavior. Some quirks are
769 * however there because MS uses a TrueType font (Marlett) to draw
772 static BOOL
UITOOLS95_DFC_ButtonRadio(HDC dc
, LPRECT r
, UINT uFlags
)
776 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
777 int BorderShrink
= SmallDiam
/ 16;
783 if(BorderShrink
< 1) BorderShrink
= 1;
785 if((uFlags
& 0xff) == DFCS_BUTTONRADIOIMAGE
)
787 FillRect(dc
, r
, (HBRUSH
)GetStockObject(BLACK_BRUSH
));
791 ye
= myr
.top
+ SmallDiam
- SmallDiam
/2;
793 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
794 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
796 /* Define bounding box */
798 myr
.left
= xc
- i
+i
/2;
799 myr
.right
= xc
+ i
/2;
800 myr
.top
= yc
- i
+i
/2;
801 myr
.bottom
= yc
+ i
/2;
803 if((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
)
805 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
806 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
807 SelectObject(dc
, hbsave
);
811 if(uFlags
& (DFCS_FLAT
|DFCS_MONO
))
813 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_WINDOWFRAME
));
814 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_WINDOWFRAME
));
815 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
816 SelectObject(dc
, hbsave
);
817 SelectObject(dc
, hpsave
);
821 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
822 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
823 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.left
-1, myr
.bottom
, myr
.right
-1, myr
.top
);
825 SelectObject(dc
, GetSysColorPen(COLOR_BTNSHADOW
));
826 SelectObject(dc
, GetSysColorBrush(COLOR_BTNSHADOW
));
827 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.right
+1, myr
.top
, myr
.left
+1, myr
.bottom
);
829 myr
.left
+= BorderShrink
;
830 myr
.right
-= BorderShrink
;
831 myr
.top
+= BorderShrink
;
832 myr
.bottom
-= BorderShrink
;
834 SelectObject(dc
, GetSysColorPen(COLOR_3DLIGHT
));
835 SelectObject(dc
, GetSysColorBrush(COLOR_3DLIGHT
));
836 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.left
-1, myr
.bottom
, myr
.right
-1, myr
.top
);
838 SelectObject(dc
, GetSysColorPen(COLOR_3DDKSHADOW
));
839 SelectObject(dc
, GetSysColorBrush(COLOR_3DDKSHADOW
));
840 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, myr
.right
+1, myr
.top
, myr
.left
+1, myr
.bottom
);
841 SelectObject(dc
, hbsave
);
842 SelectObject(dc
, hpsave
);
846 myr
.left
= xc
- i
+i
/2;
847 myr
.right
= xc
+ i
/2;
848 myr
.top
= yc
- i
+i
/2;
849 myr
.bottom
= yc
+ i
/2;
850 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
851 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
852 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
853 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
854 SelectObject(dc
, hbsave
);
855 SelectObject(dc
, hpsave
);
858 if(uFlags
& DFCS_CHECKED
)
862 myr
.left
= xc
- i
+i
/2;
863 myr
.right
= xc
+ i
/2;
864 myr
.top
= yc
- i
+i
/2;
865 myr
.bottom
= yc
+ i
/2;
867 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
868 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
869 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
870 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
871 SelectObject(dc
, hpsave
);
872 SelectObject(dc
, hbsave
);
875 /* FIXME: M$ has a polygon in the center at relative points: */
876 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
880 /* when the button is unchecked. The reason for it is unknown. The */
881 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
882 /* least 3 times (it looks like a clip-region when you see it happen). */
883 /* I do not really see a reason why this should be implemented. If you */
884 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
890 /***********************************************************************
891 * UITOOLS_DrawFrameButton
893 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
895 switch(uState
& 0xff)
897 case DFCS_BUTTONPUSH
:
898 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
900 case DFCS_BUTTONCHECK
:
901 case DFCS_BUTTON3STATE
:
902 return UITOOLS95_DFC_ButtonCheck(hdc
, rc
, uState
);
904 case DFCS_BUTTONRADIOIMAGE
:
905 case DFCS_BUTTONRADIOMASK
:
906 case DFCS_BUTTONRADIO
:
907 return UITOOLS95_DFC_ButtonRadio(hdc
, rc
, uState
);
910 WARN("Invalid button state=0x%04x\n", uState
);
916 /***********************************************************************
917 * UITOOLS_DrawFrameCaption
919 * Draw caption buttons (win95), coming from DrawFrameControl()
922 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
929 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
)-2;
934 int xc
= (myr
.left
+myr
.right
)/2;
935 int yc
= (myr
.top
+myr
.bottom
)/2;
943 UITOOLS95_DFC_ButtonPush(dc
, r
, uFlags
& 0xff00);
945 switch(uFlags
& 0xff)
947 case DFCS_CAPTIONCLOSE
:
948 edge
= 328*SmallDiam
/1000;
949 move
= 95*SmallDiam
/1000;
950 Line1
[0].x
= Line2
[0].x
= Line1
[1].x
= Line2
[1].x
= xc
- edge
;
951 Line1
[2].y
= Line2
[5].y
= Line1
[1].y
= Line2
[4].y
= yc
- edge
;
952 Line1
[3].x
= Line2
[3].x
= Line1
[4].x
= Line2
[4].x
= xc
+ edge
;
953 Line1
[5].y
= Line2
[2].y
= Line1
[4].y
= Line2
[1].y
= yc
+ edge
;
954 Line1
[2].x
= Line2
[2].x
= Line1
[1].x
+ move
;
955 Line1
[0].y
= Line2
[3].y
= Line1
[1].y
+ move
;
956 Line1
[5].x
= Line2
[5].x
= Line1
[4].x
- move
;
957 Line1
[3].y
= Line2
[0].y
= Line1
[4].y
- move
;
962 case DFCS_CAPTIONHELP
:
963 /* This one breaks the flow */
964 /* FIXME: We need the Marlett font in order to get this right. */
966 hf
= CreateFontA(-SmallDiam
, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
,
967 ANSI_CHARSET
, OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
,
968 DEFAULT_QUALITY
, FIXED_PITCH
|FF_DONTCARE
, "System");
969 alignsave
= SetTextAlign(dc
, TA_TOP
|TA_LEFT
);
970 bksave
= SetBkMode(dc
, TRANSPARENT
);
971 clrsave
= GetTextColor(dc
);
972 hfsave
= (HFONT
)SelectObject(dc
, hf
);
973 GetTextExtentPoint32A(dc
, str
, 1, &size
);
975 if(uFlags
& DFCS_INACTIVE
)
977 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
978 TextOutA(dc
, xc
-size
.cx
/2+1, yc
-size
.cy
/2+1, str
, 1);
980 SetTextColor(dc
, GetSysColor(uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
981 TextOutA(dc
, xc
-size
.cx
/2, yc
-size
.cy
/2, str
, 1);
983 SelectObject(dc
, hfsave
);
984 SetTextColor(dc
, clrsave
);
985 SetBkMode(dc
, bksave
);
986 SetTextAlign(dc
, alignsave
);
990 case DFCS_CAPTIONMIN
:
991 Line1
[0].x
= Line1
[3].x
= myr
.left
+ 96*SmallDiam
/750+2;
992 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ 372*SmallDiam
/750;
993 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 563*SmallDiam
/750+1;
994 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 92*SmallDiam
/750;
999 case DFCS_CAPTIONMAX
:
1000 edge
= 47*SmallDiam
/750;
1001 Line1
[0].x
= Line1
[5].x
= myr
.left
+ 57*SmallDiam
/750+3;
1002 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 143*SmallDiam
/750+1;
1003 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ 562*SmallDiam
/750;
1004 Line1
[5].y
= Line1
[4].y
= Line1
[0].y
+ 93*SmallDiam
/750;
1005 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 513*SmallDiam
/750;
1006 Line1
[3].x
= Line1
[4].x
= Line1
[1].x
- edge
;
1008 Line2
[0].x
= Line2
[5].x
= Line1
[0].x
;
1009 Line2
[3].x
= Line2
[4].x
= Line1
[1].x
;
1010 Line2
[1].x
= Line2
[2].x
= Line1
[0].x
+ edge
;
1011 Line2
[0].y
= Line2
[1].y
= Line1
[0].y
;
1012 Line2
[4].y
= Line2
[5].y
= Line1
[2].y
;
1013 Line2
[2].y
= Line2
[3].y
= Line1
[2].y
- edge
;
1018 case DFCS_CAPTIONRESTORE
:
1019 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1020 edge
= 47*SmallDiam
/750;
1021 move
= 420*SmallDiam
/750;
1022 Line1
[0].x
= Line1
[9].x
= myr
.left
+ 198*SmallDiam
/750+2;
1023 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 169*SmallDiam
/750+1;
1024 Line1
[6].y
= Line1
[7].y
= Line1
[0].y
+ 93*SmallDiam
/750;
1025 Line1
[7].x
= Line1
[8].x
= Line1
[0].x
+ edge
;
1026 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ move
;
1027 Line1
[5].x
= Line1
[6].x
= Line1
[1].x
- edge
;
1028 Line1
[9].y
= Line1
[8].y
= Line1
[0].y
+ 187*SmallDiam
/750;
1029 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 327*SmallDiam
/750;
1030 Line1
[4].y
= Line1
[5].y
= Line1
[2].y
- edge
;
1031 Line1
[3].x
= Line1
[4].x
= Line1
[2].x
- 140*SmallDiam
/750;
1033 Line2
[1].x
= Line2
[2].x
= Line1
[3].x
;
1034 Line2
[7].x
= Line2
[8].x
= Line2
[1].x
- edge
;
1035 Line2
[0].x
= Line2
[9].x
= Line2
[3].x
= Line2
[4].x
= Line2
[1].x
- move
;
1036 Line2
[5].x
= Line2
[6].x
= Line2
[0].x
+ edge
;
1037 Line2
[0].y
= Line2
[1].y
= Line1
[9].y
;
1038 Line2
[4].y
= Line2
[5].y
= Line2
[8].y
= Line2
[9].y
= Line2
[0].y
+ 93*SmallDiam
/750;
1039 Line2
[2].y
= Line2
[3].y
= Line2
[0].y
+ 327*SmallDiam
/750;
1040 Line2
[6].y
= Line2
[7].y
= Line2
[2].y
- edge
;
1046 WARN("Invalid caption; flags=0x%04x\n", uFlags
);
1050 /* Here the drawing takes place */
1051 if(uFlags
& DFCS_INACTIVE
)
1053 /* If we have an inactive button, then you see a shadow */
1054 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1055 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
1056 Polygon(dc
, Line1
, Line1N
);
1058 Polygon(dc
, Line2
, Line2N
);
1059 SelectObject(dc
, hpsave
);
1060 SelectObject(dc
, hbsave
);
1063 /* Correct for the shadow shift */
1064 for(i
= 0; i
< Line1N
; i
++)
1069 for(i
= 0; i
< Line2N
; i
++)
1075 /* Make the final picture */
1076 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1077 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
1078 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
1080 Polygon(dc
, Line1
, Line1N
);
1082 Polygon(dc
, Line2
, Line2N
);
1083 SelectObject(dc
, hpsave
);
1084 SelectObject(dc
, hbsave
);
1090 /************************************************************************
1091 * UITOOLS_DrawFrameScroll
1093 * Draw a scroll-bar control coming from DrawFrameControl()
1095 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
1099 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
) - 2;
1101 HBRUSH hbsave
, hb
, hb2
;
1102 HPEN hpsave
, hp
, hp2
;
1103 int tri
= 290*SmallDiam
/1000 - 1;
1107 * This fixes a problem with really tiny "scroll" buttons. In particular
1108 * with the updown control.
1109 * Making sure that the arrow is as least 3 pixels wide (or high).
1114 switch(uFlags
& 0xff)
1116 case DFCS_SCROLLCOMBOBOX
:
1117 case DFCS_SCROLLDOWN
:
1118 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1119 Line
[2].y
= myr
.top
+ 687*SmallDiam
/1000 + 1;
1120 Line
[0].x
= Line
[2].x
- tri
;
1121 Line
[1].x
= Line
[2].x
+ tri
;
1122 Line
[0].y
= Line
[1].y
= Line
[2].y
- tri
;
1126 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1127 Line
[2].y
= myr
.bottom
- (687*SmallDiam
/1000 + 1);
1128 Line
[0].x
= Line
[2].x
- tri
;
1129 Line
[1].x
= Line
[2].x
+ tri
;
1130 Line
[0].y
= Line
[1].y
= Line
[2].y
+ tri
;
1133 case DFCS_SCROLLLEFT
:
1134 Line
[2].x
= myr
.right
- (687*SmallDiam
/1000 + 1);
1135 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1136 Line
[0].y
= Line
[2].y
- tri
;
1137 Line
[1].y
= Line
[2].y
+ tri
;
1138 Line
[0].x
= Line
[1].x
= Line
[2].x
+ tri
;
1141 case DFCS_SCROLLRIGHT
:
1142 Line
[2].x
= myr
.left
+ 687*SmallDiam
/1000 + 1;
1143 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1144 Line
[0].y
= Line
[2].y
- tri
;
1145 Line
[1].y
= Line
[2].y
+ tri
;
1146 Line
[0].x
= Line
[1].x
= Line
[2].x
- tri
;
1149 case DFCS_SCROLLSIZEGRIP
:
1150 /* This one breaks the flow... */
1151 UITOOLS95_DrawRectEdge(dc
, r
, EDGE_BUMP
, BF_MIDDLE
| ((uFlags
&(DFCS_MONO
|DFCS_FLAT
)) ? BF_MONO
: 0));
1152 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(NULL_PEN
));
1153 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(NULL_BRUSH
));
1154 if(uFlags
& (DFCS_MONO
|DFCS_FLAT
))
1156 hp
= hp2
= GetSysColorPen(COLOR_WINDOWFRAME
);
1157 hb
= hb2
= GetSysColorBrush(COLOR_WINDOWFRAME
);
1161 hp
= GetSysColorPen(COLOR_BTNHIGHLIGHT
);
1162 hp2
= GetSysColorPen(COLOR_BTNSHADOW
);
1163 hb
= GetSysColorBrush(COLOR_BTNHIGHLIGHT
);
1164 hb2
= GetSysColorBrush(COLOR_BTNSHADOW
);
1166 Line
[0].x
= Line
[1].x
= r
->right
-1;
1167 Line
[2].y
= Line
[3].y
= r
->bottom
-1;
1168 d46
= 46*SmallDiam
/750;
1169 d93
= 93*SmallDiam
/750;
1171 i
= 586*SmallDiam
/750;
1172 Line
[0].y
= r
->bottom
- i
- 1;
1173 Line
[3].x
= r
->right
- i
- 1;
1174 Line
[1].y
= Line
[0].y
+ d46
;
1175 Line
[2].x
= Line
[3].x
+ d46
;
1176 SelectObject(dc
, hb
);
1177 SelectObject(dc
, hp
);
1178 Polygon(dc
, Line
, 4);
1180 Line
[1].y
++; Line
[2].x
++;
1181 Line
[0].y
= Line
[1].y
+ d93
;
1182 Line
[3].x
= Line
[2].x
+ d93
;
1183 SelectObject(dc
, hb2
);
1184 SelectObject(dc
, hp2
);
1185 Polygon(dc
, Line
, 4);
1187 i
= 398*SmallDiam
/750;
1188 Line
[0].y
= r
->bottom
- i
- 1;
1189 Line
[3].x
= r
->right
- i
- 1;
1190 Line
[1].y
= Line
[0].y
+ d46
;
1191 Line
[2].x
= Line
[3].x
+ d46
;
1192 SelectObject(dc
, hb
);
1193 SelectObject(dc
, hp
);
1194 Polygon(dc
, Line
, 4);
1196 Line
[1].y
++; Line
[2].x
++;
1197 Line
[0].y
= Line
[1].y
+ d93
;
1198 Line
[3].x
= Line
[2].x
+ d93
;
1199 SelectObject(dc
, hb2
);
1200 SelectObject(dc
, hp2
);
1201 Polygon(dc
, Line
, 4);
1203 i
= 210*SmallDiam
/750;
1204 Line
[0].y
= r
->bottom
- i
- 1;
1205 Line
[3].x
= r
->right
- i
- 1;
1206 Line
[1].y
= Line
[0].y
+ d46
;
1207 Line
[2].x
= Line
[3].x
+ d46
;
1208 SelectObject(dc
, hb
);
1209 SelectObject(dc
, hp
);
1210 Polygon(dc
, Line
, 4);
1212 Line
[1].y
++; Line
[2].x
++;
1213 Line
[0].y
= Line
[1].y
+ d93
;
1214 Line
[3].x
= Line
[2].x
+ d93
;
1215 SelectObject(dc
, hb2
);
1216 SelectObject(dc
, hp2
);
1217 Polygon(dc
, Line
, 4);
1219 SelectObject(dc
, hpsave
);
1220 SelectObject(dc
, hbsave
);
1224 WARN("Invalid scroll; flags=0x%04x\n", uFlags
);
1228 /* Here do the real scroll-bar controls end up */
1229 if( ! (uFlags
& (0xff00 & ~DFCS_ADJUSTRECT
)) )
1230 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1231 /* want for the normal scroll-arrow button. */
1232 UITOOLS95_DrawRectEdge( dc
, r
, EDGE_RAISED
, (uFlags
&DFCS_ADJUSTRECT
) | BF_MIDDLE
| BF_RECT
);
1234 UITOOLS95_DFC_ButtonPush(dc
, r
, (uFlags
& 0xff00) );
1236 if(uFlags
& DFCS_INACTIVE
)
1238 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1239 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
1240 Polygon(dc
, Line
, 3);
1241 SelectObject(dc
, hpsave
);
1242 SelectObject(dc
, hbsave
);
1245 if( (uFlags
& DFCS_INACTIVE
) || !(uFlags
& DFCS_PUSHED
) )
1246 for(i
= 0; i
< 3; i
++)
1252 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1253 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
1254 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
1255 Polygon(dc
, Line
, 3);
1256 SelectObject(dc
, hpsave
);
1257 SelectObject(dc
, hbsave
);
1262 /************************************************************************
1263 * UITOOLS_DrawFrameMenu
1265 * Draw a menu control coming from DrawFrameControl()
1267 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
1271 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
1279 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1280 /* use anything else. I think I tried all sys-colors to change things */
1281 /* without luck. It seems as if this behavior is inherited from the */
1282 /* win31 DFC() implementation... (you remember, B/W menus). */
1284 FillRect(dc
, r
, (HBRUSH
)GetStockObject(WHITE_BRUSH
));
1286 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
1287 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(BLACK_PEN
));
1289 switch(uFlags
& 0xff)
1291 case DFCS_MENUARROW
:
1292 i
= 187*SmallDiam
/750;
1293 Points
[2].x
= myr
.left
+ 468*SmallDiam
/750;
1294 Points
[2].y
= myr
.top
+ 352*SmallDiam
/750+1;
1295 Points
[0].y
= Points
[2].y
- i
;
1296 Points
[1].y
= Points
[2].y
+ i
;
1297 Points
[0].x
= Points
[1].x
= Points
[2].x
- i
;
1298 Polygon(dc
, Points
, 3);
1301 case DFCS_MENUBULLET
:
1303 ye
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1304 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
1305 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1306 i
= 234*SmallDiam
/750;
1308 myr
.left
= xc
- i
+i
/2;
1309 myr
.right
= xc
+ i
/2;
1310 myr
.top
= yc
- i
+i
/2;
1311 myr
.bottom
= yc
+ i
/2;
1312 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
1315 case DFCS_MENUCHECK
:
1316 Points
[0].x
= myr
.left
+ 253*SmallDiam
/1000;
1317 Points
[0].y
= myr
.top
+ 445*SmallDiam
/1000;
1318 Points
[1].x
= myr
.left
+ 409*SmallDiam
/1000;
1319 Points
[1].y
= Points
[0].y
+ (Points
[1].x
-Points
[0].x
);
1320 Points
[2].x
= myr
.left
+ 690*SmallDiam
/1000;
1321 Points
[2].y
= Points
[1].y
- (Points
[2].x
-Points
[1].x
);
1322 Points
[3].x
= Points
[2].x
;
1323 Points
[3].y
= Points
[2].y
+ 3*SmallDiam
/16;
1324 Points
[4].x
= Points
[1].x
;
1325 Points
[4].y
= Points
[1].y
+ 3*SmallDiam
/16;
1326 Points
[5].x
= Points
[0].x
;
1327 Points
[5].y
= Points
[0].y
+ 3*SmallDiam
/16;
1328 Polygon(dc
, Points
, 6);
1332 WARN("Invalid menu; flags=0x%04x\n", uFlags
);
1337 SelectObject(dc
, hpsave
);
1338 SelectObject(dc
, hbsave
);
1343 /**********************************************************************
1344 * DrawFrameControl16 (USER.656)
1346 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
,
1352 CONV_RECT16TO32( rc
, &rect32
);
1353 ret
= DrawFrameControl( hdc
, &rect32
, uType
, uState
);
1354 CONV_RECT32TO16( &rect32
, rc
);
1359 /**********************************************************************
1360 * DrawFrameControl32 (USER32.158)
1362 BOOL WINAPI
DrawFrameControl( HDC hdc
, LPRECT rc
, UINT uType
,
1365 /* Win95 doesn't support drawing in other mapping modes */
1366 if(GetMapMode(hdc
) != MM_TEXT
)
1372 return UITOOLS95_DrawFrameButton(hdc
, rc
, uState
);
1374 return UITOOLS95_DrawFrameCaption(hdc
, rc
, uState
);
1376 return UITOOLS95_DrawFrameMenu(hdc
, rc
, uState
);
1378 return UITOOLS95_DrawFrameScroll(hdc
, rc
, uState
);
1380 WARN("(%x,%p,%d,%x), bad type!\n",
1381 hdc
,rc
,uType
,uState
);