2 * User Interface Functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1997 Bertho A. Stultiens
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/winuser16.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(graphics
);
31 static const WORD wPattern_AA55
[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
32 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
34 /* These tables are used in:
35 * UITOOLS_DrawDiagEdge()
36 * UITOOLS_DrawRectEdge()
38 static const signed char LTInnerNormal
[] = {
40 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
41 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
45 static const signed char LTOuterNormal
[] = {
46 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
47 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
48 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
49 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
52 static const signed char RBInnerNormal
[] = {
54 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
55 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
59 static const signed char RBOuterNormal
[] = {
60 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
61 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
62 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
63 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
66 static const signed char LTInnerSoft
[] = {
68 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
69 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
73 static const signed char LTOuterSoft
[] = {
74 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
75 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
76 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
77 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
80 #define RBInnerSoft RBInnerNormal /* These are the same */
81 #define RBOuterSoft RBOuterNormal
83 static const signed char LTRBOuterMono
[] = {
84 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
85 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
86 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
87 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
90 static const signed char LTRBInnerMono
[] = {
92 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
93 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
94 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
97 static const signed char LTRBOuterFlat
[] = {
98 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
99 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
100 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
101 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
104 static const signed char LTRBInnerFlat
[] = {
106 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
107 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
108 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
111 /***********************************************************************
112 * UITOOLS_DrawDiagEdge
114 * Same as DrawEdge invoked with BF_DIAGONAL
116 * 03-Dec-1997: Changed by Bertho Stultiens
118 * See also comments with UITOOLS_DrawRectEdge()
120 static BOOL
UITOOLS95_DrawDiagEdge(HDC hdc
, LPRECT rc
,
121 UINT uType
, UINT uFlags
)
124 signed char InnerI
, OuterI
;
125 HPEN InnerPen
, OuterPen
;
130 int Width
= rc
->right
- rc
->left
;
131 int Height
= rc
->bottom
- rc
->top
;
132 int SmallDiam
= Width
> Height
? Height
: Width
;
133 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
134 || (uType
& BDR_OUTER
) == BDR_OUTER
)
135 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
136 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
137 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
140 OuterPen
= InnerPen
= (HPEN
)GetStockObject(NULL_PEN
);
141 SavePen
= (HPEN
)SelectObject(hdc
, InnerPen
);
142 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
144 /* Determine the colors of the edges */
147 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
148 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
150 else if(uFlags
& BF_FLAT
)
152 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
153 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
155 else if(uFlags
& BF_SOFT
)
157 if(uFlags
& BF_BOTTOM
)
159 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
160 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
164 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
165 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
170 if(uFlags
& BF_BOTTOM
)
172 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
173 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
177 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
178 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
182 if(InnerI
!= -1) InnerPen
= SYSCOLOR_GetPen(InnerI
);
183 if(OuterI
!= -1) OuterPen
= SYSCOLOR_GetPen(OuterI
);
185 MoveToEx(hdc
, 0, 0, &SavePoint
);
187 /* Don't ask me why, but this is what is visible... */
188 /* This must be possible to do much simpler, but I fail to */
189 /* see the logic in the MS implementation (sigh...). */
190 /* So, this might look a bit brute force here (and it is), but */
191 /* it gets the job done;) */
193 switch(uFlags
& BF_RECT
)
199 /* Left bottom endpoint */
201 spx
= epx
+ SmallDiam
;
203 spy
= epy
- SmallDiam
;
208 /* Left top endpoint */
210 spx
= epx
+ SmallDiam
;
212 spy
= epy
+ SmallDiam
;
218 case BF_RIGHT
|BF_LEFT
:
219 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
220 case BF_BOTTOM
|BF_TOP
:
221 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
222 case BF_BOTTOMRIGHT
|BF_LEFT
:
223 case BF_BOTTOMRIGHT
|BF_TOP
:
225 /* Right top endpoint */
227 epx
= spx
+ SmallDiam
;
229 epy
= spy
- SmallDiam
;
233 MoveToEx(hdc
, spx
, spy
, NULL
);
234 SelectObject(hdc
, OuterPen
);
235 LineTo(hdc
, epx
, epy
);
237 SelectObject(hdc
, InnerPen
);
239 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
241 case BF_DIAGONAL_ENDBOTTOMLEFT
:
242 case (BF_DIAGONAL
|BF_BOTTOM
):
244 case (BF_DIAGONAL
|BF_LEFT
):
245 MoveToEx(hdc
, spx
-1, spy
, NULL
);
246 LineTo(hdc
, epx
, epy
-1);
247 Points
[0].x
= spx
-add
;
249 Points
[1].x
= rc
->left
;
250 Points
[1].y
= rc
->top
;
252 Points
[2].y
= epy
-1-add
;
253 Points
[3] = Points
[2];
256 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
257 MoveToEx(hdc
, spx
-1, spy
, NULL
);
258 LineTo(hdc
, epx
, epy
+1);
259 Points
[0].x
= spx
-add
;
261 Points
[1].x
= rc
->left
;
262 Points
[1].y
= rc
->bottom
-1;
264 Points
[2].y
= epy
+1+add
;
265 Points
[3] = Points
[2];
268 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
269 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
270 case BF_DIAGONAL_ENDTOPRIGHT
:
271 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
272 MoveToEx(hdc
, spx
+1, spy
, NULL
);
273 LineTo(hdc
, epx
, epy
+1);
275 Points
[0].y
= epy
+1+add
;
276 Points
[1].x
= rc
->right
-1;
277 Points
[1].y
= rc
->top
+add
;
278 Points
[2].x
= rc
->right
-1;
279 Points
[2].y
= rc
->bottom
-1;
280 Points
[3].x
= spx
+add
;
284 case BF_DIAGONAL_ENDTOPLEFT
:
285 MoveToEx(hdc
, spx
, spy
-1, NULL
);
286 LineTo(hdc
, epx
+1, epy
);
287 Points
[0].x
= epx
+1+add
;
289 Points
[1].x
= rc
->right
-1;
290 Points
[1].y
= rc
->top
;
291 Points
[2].x
= rc
->right
-1;
292 Points
[2].y
= rc
->bottom
-1-add
;
294 Points
[3].y
= spy
-add
;
297 case (BF_DIAGONAL
|BF_TOP
):
298 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
299 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
300 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
301 LineTo(hdc
, epx
, epy
);
304 Points
[1].x
= rc
->right
-1;
305 Points
[1].y
= rc
->top
;
306 Points
[2].x
= rc
->right
-1;
307 Points
[2].y
= rc
->bottom
-1-add
;
308 Points
[3].x
= spx
+add
;
309 Points
[3].y
= spy
-add
;
312 case (BF_DIAGONAL
|BF_RIGHT
):
313 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
314 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
315 MoveToEx(hdc
, spx
, spy
, NULL
);
316 LineTo(hdc
, epx
-1, epy
+1);
319 Points
[1].x
= rc
->left
;
320 Points
[1].y
= rc
->top
+add
;
321 Points
[2].x
= epx
-1-add
;
322 Points
[2].y
= epy
+1+add
;
323 Points
[3] = Points
[2];
327 /* Fill the interior if asked */
328 if((uFlags
& BF_MIDDLE
) && retval
)
331 HBRUSH hb
= GetSysColorBrush(uFlags
& BF_MONO
? COLOR_WINDOW
334 HPEN hp
= SYSCOLOR_GetPen(uFlags
& BF_MONO
? COLOR_WINDOW
336 hbsave
= (HBRUSH
)SelectObject(hdc
, hb
);
337 hpsave
= (HPEN
)SelectObject(hdc
, hp
);
338 Polygon(hdc
, Points
, 4);
339 SelectObject(hdc
, hbsave
);
340 SelectObject(hdc
, hpsave
);
343 /* Adjust rectangle if asked */
344 if(uFlags
& BF_ADJUST
)
346 if(uFlags
& BF_LEFT
) rc
->left
+= add
;
347 if(uFlags
& BF_RIGHT
) rc
->right
-= add
;
348 if(uFlags
& BF_TOP
) rc
->top
+= add
;
349 if(uFlags
& BF_BOTTOM
) rc
->bottom
-= add
;
353 SelectObject(hdc
, SavePen
);
354 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
359 /***********************************************************************
360 * UITOOLS_DrawRectEdge
362 * Same as DrawEdge invoked without BF_DIAGONAL
364 * 23-Nov-1997: Changed by Bertho Stultiens
366 * Well, I started testing this and found out that there are a few things
367 * that weren't quite as win95. The following rewrite should reproduce
368 * win95 results completely.
369 * The colorselection is table-driven to avoid awfull if-statements.
370 * The table below show the color settings.
372 * Pen selection table for uFlags = 0
374 * uType | LTI | LTO | RBI | RBO
375 * ------+-------+-------+-------+-------
376 * 0000 | x | x | x | x
377 * 0001 | x | 22 | x | 21
378 * 0010 | x | 16 | x | 20
379 * 0011 | x | x | x | x
380 * ------+-------+-------+-------+-------
381 * 0100 | x | 20 | x | 16
382 * 0101 | 20 | 22 | 16 | 21
383 * 0110 | 20 | 16 | 16 | 20
384 * 0111 | x | x | x | x
385 * ------+-------+-------+-------+-------
386 * 1000 | x | 21 | x | 22
387 * 1001 | 21 | 22 | 22 | 21
388 * 1010 | 21 | 16 | 22 | 20
389 * 1011 | x | x | x | x
390 * ------+-------+-------+-------+-------
391 * 1100 | x | x | x | x
392 * 1101 | x | x (22)| x | x (21)
393 * 1110 | x | x (16)| x | x (20)
394 * 1111 | x | x | x | x
396 * Pen selection table for uFlags = BF_SOFT
398 * uType | LTI | LTO | RBI | RBO
399 * ------+-------+-------+-------+-------
400 * 0000 | x | x | x | x
401 * 0001 | x | 20 | x | 21
402 * 0010 | x | 21 | x | 20
403 * 0011 | x | x | x | x
404 * ------+-------+-------+-------+-------
405 * 0100 | x | 22 | x | 16
406 * 0101 | 22 | 20 | 16 | 21
407 * 0110 | 22 | 21 | 16 | 20
408 * 0111 | x | x | x | x
409 * ------+-------+-------+-------+-------
410 * 1000 | x | 16 | x | 22
411 * 1001 | 16 | 20 | 22 | 21
412 * 1010 | 16 | 21 | 22 | 20
413 * 1011 | x | x | x | x
414 * ------+-------+-------+-------+-------
415 * 1100 | x | x | x | x
416 * 1101 | x | x (20)| x | x (21)
417 * 1110 | x | x (21)| x | x (20)
418 * 1111 | x | x | x | x
420 * x = don't care; (n) = is what win95 actually uses
421 * LTI = left Top Inner line
422 * LTO = left Top Outer line
423 * RBI = Right Bottom Inner line
424 * RBO = Right Bottom Outer line
426 * 16 = COLOR_BTNSHADOW
427 * 20 = COLOR_BTNHIGHLIGHT
428 * 21 = COLOR_3DDKSHADOW
433 static BOOL
UITOOLS95_DrawRectEdge(HDC hdc
, LPRECT rc
,
434 UINT uType
, UINT uFlags
)
436 signed char LTInnerI
, LTOuterI
;
437 signed char RBInnerI
, RBOuterI
;
438 HPEN LTInnerPen
, LTOuterPen
;
439 HPEN RBInnerPen
, RBOuterPen
;
440 RECT InnerRect
= *rc
;
447 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
448 || (uType
& BDR_OUTER
) == BDR_OUTER
)
449 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
452 LTInnerPen
= LTOuterPen
= RBInnerPen
= RBOuterPen
= (HPEN
)GetStockObject(NULL_PEN
);
453 SavePen
= (HPEN
)SelectObject(hdc
, LTInnerPen
);
455 /* Determine the colors of the edges */
458 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
459 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
461 else if(uFlags
& BF_FLAT
)
463 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
464 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
466 /* Bertho Stultiens states above that this function exactly matches win95
467 * In win98 BF_FLAT rectangles have an inner border same color as the
468 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
469 * I don't know I go with Bertho and just sets it for win98 until proven
471 * Dennis Björklund, 10 June, 99
473 if( TWEAK_WineLook
== WIN98_LOOK
&& LTInnerI
!= -1 )
474 LTInnerI
= RBInnerI
= COLOR_BTNFACE
;
476 else if(uFlags
& BF_SOFT
)
478 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
479 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
480 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
481 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
485 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
486 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
487 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
488 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
491 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
) LBpenplus
= 1;
492 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
) RTpenplus
= 1;
493 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
) RBpenplus
= 1;
494 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
) LTpenplus
= 1;
496 if(LTInnerI
!= -1) LTInnerPen
= SYSCOLOR_GetPen(LTInnerI
);
497 if(LTOuterI
!= -1) LTOuterPen
= SYSCOLOR_GetPen(LTOuterI
);
498 if(RBInnerI
!= -1) RBInnerPen
= SYSCOLOR_GetPen(RBInnerI
);
499 if(RBOuterI
!= -1) RBOuterPen
= SYSCOLOR_GetPen(RBOuterI
);
501 MoveToEx(hdc
, 0, 0, &SavePoint
);
503 /* Draw the outer edge */
504 SelectObject(hdc
, LTOuterPen
);
507 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
508 LineTo(hdc
, InnerRect
.right
, InnerRect
.top
);
512 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
513 LineTo(hdc
, InnerRect
.left
, InnerRect
.bottom
);
515 SelectObject(hdc
, RBOuterPen
);
516 if(uFlags
& BF_BOTTOM
)
518 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.bottom
-1, NULL
);
519 LineTo(hdc
, InnerRect
.left
-1, InnerRect
.bottom
-1);
521 if(uFlags
& BF_RIGHT
)
523 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.bottom
-1, NULL
);
524 LineTo(hdc
, InnerRect
.right
-1, InnerRect
.top
-1);
527 /* Draw the inner edge */
528 SelectObject(hdc
, LTInnerPen
);
531 MoveToEx(hdc
, InnerRect
.left
+LTpenplus
, InnerRect
.top
+1, NULL
);
532 LineTo(hdc
, InnerRect
.right
-RTpenplus
, InnerRect
.top
+1);
536 MoveToEx(hdc
, InnerRect
.left
+1, InnerRect
.top
+LTpenplus
, NULL
);
537 LineTo(hdc
, InnerRect
.left
+1, InnerRect
.bottom
-LBpenplus
);
539 SelectObject(hdc
, RBInnerPen
);
540 if(uFlags
& BF_BOTTOM
)
542 MoveToEx(hdc
, InnerRect
.right
-1-RBpenplus
, InnerRect
.bottom
-2, NULL
);
543 LineTo(hdc
, InnerRect
.left
-1+LBpenplus
, InnerRect
.bottom
-2);
545 if(uFlags
& BF_RIGHT
)
547 MoveToEx(hdc
, InnerRect
.right
-2, InnerRect
.bottom
-1-RBpenplus
, NULL
);
548 LineTo(hdc
, InnerRect
.right
-2, InnerRect
.top
-1+RTpenplus
);
551 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
553 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
554 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
556 if(uFlags
& BF_LEFT
) InnerRect
.left
+= add
;
557 if(uFlags
& BF_RIGHT
) InnerRect
.right
-= add
;
558 if(uFlags
& BF_TOP
) InnerRect
.top
+= add
;
559 if(uFlags
& BF_BOTTOM
) InnerRect
.bottom
-= add
;
561 if((uFlags
& BF_MIDDLE
) && retval
)
563 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
564 COLOR_WINDOW
: COLOR_BTNFACE
));
567 if(uFlags
& BF_ADJUST
)
572 SelectObject(hdc
, SavePen
);
573 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
578 /**********************************************************************
579 * DrawEdge (USER.659)
581 BOOL16 WINAPI
DrawEdge16( HDC16 hdc
, LPRECT16 rc
, UINT16 edge
, UINT16 flags
)
586 CONV_RECT16TO32( rc
, &rect32
);
587 ret
= DrawEdge( hdc
, &rect32
, edge
, flags
);
588 CONV_RECT32TO16( &rect32
, rc
);
592 /**********************************************************************
593 * DrawEdge (USER32.@)
595 BOOL WINAPI
DrawEdge( HDC hdc
, LPRECT rc
, UINT edge
, UINT flags
)
597 TRACE("%04x %d,%d-%d,%d %04x %04x\n",
598 hdc
, rc
->left
, rc
->top
, rc
->right
, rc
->bottom
, edge
, flags
);
600 if(flags
& BF_DIAGONAL
)
601 return UITOOLS95_DrawDiagEdge(hdc
, rc
, edge
, flags
);
603 return UITOOLS95_DrawRectEdge(hdc
, rc
, edge
, flags
);
607 /************************************************************************
608 * UITOOLS_MakeSquareRect
610 * Utility to create a square rectangle and returning the width
612 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
614 int Width
= src
->right
- src
->left
;
615 int Height
= src
->bottom
- src
->top
;
616 int SmallDiam
= Width
> Height
? Height
: Width
;
620 /* Make it a square box */
621 if(Width
< Height
) /* SmallDiam == Width */
623 dst
->top
+= (Height
-Width
)/2;
624 dst
->bottom
= dst
->top
+ SmallDiam
;
626 else if(Width
> Height
) /* SmallDiam == Height */
628 dst
->left
+= (Width
-Height
)/2;
629 dst
->right
= dst
->left
+ SmallDiam
;
635 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
637 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
639 HBITMAP hbm
= CreateBitmap(8, 8, 1, 1, wPattern_AA55
);
641 HBRUSH hb
= CreatePatternBrush(hbm
);
644 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
645 bg
= SetBkColor(dc
, RGB(255, 255, 255));
646 hbsave
= (HBRUSH
)SelectObject(dc
, hb
);
647 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
648 SelectObject(dc
, hbsave
);
655 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
659 /************************************************************************
660 * UITOOLS_DFC_ButtonPush
662 * Draw a push button coming from DrawFrameControl()
664 * Does a pretty good job in emulating MS behavior. Some quirks are
665 * however there because MS uses a TrueType font (Marlett) to draw
668 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
673 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
678 if(uFlags
& DFCS_CHECKED
)
680 if(uFlags
& DFCS_MONO
)
681 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
683 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
);
685 UITOOLS_DrawCheckedRect( dc
, &myr
);
689 if(uFlags
& DFCS_MONO
)
691 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
692 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
696 UITOOLS95_DrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
);
700 /* Adjust rectangle if asked */
701 if(uFlags
& DFCS_ADJUSTRECT
)
713 /************************************************************************
714 * UITOOLS_DFC_ButtonChcek
716 * Draw a check/3state button coming from DrawFrameControl()
718 * Does a pretty good job in emulating MS behavior. Some quirks are
719 * however there because MS uses a TrueType font (Marlett) to draw
723 static BOOL
UITOOLS95_DFC_ButtonCheck(HDC dc
, LPRECT r
, UINT uFlags
)
726 UINT flags
= BF_RECT
| BF_ADJUST
;
727 UITOOLS_MakeSquareRect(r
, &myr
);
729 if(uFlags
& DFCS_FLAT
) flags
|= BF_FLAT
;
730 else if(uFlags
& DFCS_MONO
) flags
|= BF_MONO
;
732 UITOOLS95_DrawRectEdge( dc
, &myr
, EDGE_SUNKEN
, flags
);
734 if(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
))
735 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
736 else if( (uFlags
& DFCS_BUTTON3STATE
) && (uFlags
& DFCS_CHECKED
) )
737 UITOOLS_DrawCheckedRect( dc
, &myr
);
740 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_WINDOW
));
743 if(uFlags
& DFCS_CHECKED
)
746 i
= (uFlags
& DFCS_INACTIVE
) || (uFlags
& 0xff) == DFCS_BUTTON3STATE
?
747 COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
749 /* draw 7 bars, with h=3w to form the check */
751 bar
.top
= myr
.top
+ 2;
752 for (k
= 0; k
< 7; k
++) {
753 bar
.left
= bar
.left
+ 1;
754 bar
.top
= (k
< 3) ? bar
.top
+ 1 : bar
.top
- 1;
755 bar
.bottom
= bar
.top
+ 3;
756 bar
.right
= bar
.left
+ 1;
757 FillRect(dc
, &bar
, GetSysColorBrush(i
));
764 /************************************************************************
765 * UITOOLS_DFC_ButtonRadio
767 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
769 * Does a pretty good job in emulating MS behavior. Some quirks are
770 * however there because MS uses a TrueType font (Marlett) to draw
773 static BOOL
UITOOLS95_DFC_ButtonRadio(HDC dc
, LPRECT r
, UINT uFlags
)
777 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
778 int BorderShrink
= SmallDiam
/ 16;
783 if(BorderShrink
< 1) BorderShrink
= 1;
785 if((uFlags
& 0xff) == DFCS_BUTTONRADIOIMAGE
)
787 FillRect(dc
, r
, (HBRUSH
)GetStockObject(BLACK_BRUSH
));
790 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
791 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
793 /* Define bounding box */
795 myr
.left
= xc
- i
+i
/2;
796 myr
.right
= xc
+ i
/2;
797 myr
.top
= yc
- i
+i
/2;
798 myr
.bottom
= yc
+ i
/2;
800 if((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
)
802 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
803 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
804 SelectObject(dc
, hbsave
);
808 if(uFlags
& (DFCS_FLAT
|DFCS_MONO
))
810 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
));
811 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_WINDOWFRAME
));
812 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
813 SelectObject(dc
, hbsave
);
814 SelectObject(dc
, hpsave
);
818 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
));
819 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
820 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.left
-1, myr
.bottom
, myr
.right
+1, myr
.top
);
822 SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNSHADOW
));
823 SelectObject(dc
, GetSysColorBrush(COLOR_BTNSHADOW
));
824 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.right
+1, myr
.top
, myr
.left
-1, myr
.bottom
);
826 myr
.left
+= BorderShrink
;
827 myr
.right
-= BorderShrink
;
828 myr
.top
+= BorderShrink
;
829 myr
.bottom
-= BorderShrink
;
831 SelectObject(dc
, SYSCOLOR_GetPen(COLOR_3DLIGHT
));
832 SelectObject(dc
, GetSysColorBrush(COLOR_3DLIGHT
));
833 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.left
-1, myr
.bottom
, myr
.right
+1, myr
.top
);
835 SelectObject(dc
, SYSCOLOR_GetPen(COLOR_3DDKSHADOW
));
836 SelectObject(dc
, GetSysColorBrush(COLOR_3DDKSHADOW
));
837 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.right
+1, myr
.top
, myr
.left
-1, myr
.bottom
);
838 SelectObject(dc
, hbsave
);
839 SelectObject(dc
, hpsave
);
843 myr
.left
= xc
- i
+i
/2;
844 myr
.right
= xc
+ i
/2;
845 myr
.top
= yc
- i
+i
/2;
846 myr
.bottom
= yc
+ i
/2;
847 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
848 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(i
));
849 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
850 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
851 SelectObject(dc
, hbsave
);
852 SelectObject(dc
, hpsave
);
855 if(uFlags
& DFCS_CHECKED
)
859 myr
.left
= xc
- i
+i
/2;
860 myr
.right
= xc
+ i
/2;
861 myr
.top
= yc
- i
+i
/2;
862 myr
.bottom
= yc
+ i
/2;
864 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
865 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
866 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(i
));
867 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
868 SelectObject(dc
, hpsave
);
869 SelectObject(dc
, hbsave
);
872 /* FIXME: M$ has a polygon in the center at relative points: */
873 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
877 /* when the button is unchecked. The reason for it is unknown. The */
878 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
879 /* least 3 times (it looks like a clip-region when you see it happen). */
880 /* I do not really see a reason why this should be implemented. If you */
881 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
887 /***********************************************************************
888 * UITOOLS_DrawFrameButton
890 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
892 switch(uState
& 0xff)
894 case DFCS_BUTTONPUSH
:
895 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
897 case DFCS_BUTTONCHECK
:
898 case DFCS_BUTTON3STATE
:
899 return UITOOLS95_DFC_ButtonCheck(hdc
, rc
, uState
);
901 case DFCS_BUTTONRADIOIMAGE
:
902 case DFCS_BUTTONRADIOMASK
:
903 case DFCS_BUTTONRADIO
:
904 return UITOOLS95_DFC_ButtonRadio(hdc
, rc
, uState
);
907 WARN("Invalid button state=0x%04x\n", uState
);
913 /***********************************************************************
914 * UITOOLS_DrawFrameCaption
916 * Draw caption buttons (win95), coming from DrawFrameControl()
919 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
926 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
)-2;
931 int colorIdx
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
932 int xc
= (myr
.left
+myr
.right
)/2;
933 int yc
= (myr
.top
+myr
.bottom
)/2;
941 UITOOLS95_DFC_ButtonPush(dc
, r
, uFlags
& 0xff00);
943 switch(uFlags
& 0xff)
945 case DFCS_CAPTIONCLOSE
:
947 /* The "X" is made by drawing a series of lines.
948 * The number of lines drawn depends on the size
949 * of the bounding rect. e.g. For a 6x5 inside rect,
950 * two lines are drawn from top-left to bottom-right,
951 * and two lines from top-right to bottom-left.
953 * 0 1 2 3 4 5 0 1 2 3 4 5
959 * Drawing one line for every 6 pixels in width
960 * seems to provide the best proportions.
964 INT width
= myr
.right
- myr
.left
- 5;
965 INT height
= myr
.bottom
- myr
.top
- 6;
966 INT numLines
= (width
/ 6) + 1;
968 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(colorIdx
));
970 start
.x
= myr
.left
+ 2;
971 start
.y
= myr
.top
+ 2;
978 if (uFlags
& DFCS_PUSHED
)
984 /* now use the width of each line */
985 width
-= numLines
- 1;
987 for (i
= 0; i
< numLines
; i
++)
989 MoveToEx(dc
, start
.x
+ i
, start
.y
, &oldPos
);
990 LineTo(dc
, start
.x
+ i
+ width
, start
.y
+ height
);
992 MoveToEx(dc
, start
.x
+ i
, start
.y
+ height
- 1, &oldPos
);
993 LineTo(dc
, start
.x
+ i
+ width
, start
.y
- 1);
996 SelectObject(dc
, hpsave
);
1000 case DFCS_CAPTIONHELP
:
1001 /* This one breaks the flow */
1002 /* FIXME: We need the Marlett font in order to get this right. */
1004 hf
= CreateFontA(-SmallDiam
, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
,
1005 ANSI_CHARSET
, OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
,
1006 DEFAULT_QUALITY
, FIXED_PITCH
|FF_DONTCARE
, "System");
1007 alignsave
= SetTextAlign(dc
, TA_TOP
|TA_LEFT
);
1008 bksave
= SetBkMode(dc
, TRANSPARENT
);
1009 clrsave
= GetTextColor(dc
);
1010 hfsave
= (HFONT
)SelectObject(dc
, hf
);
1011 GetTextExtentPoint32A(dc
, str
, 1, &size
);
1013 if(uFlags
& DFCS_INACTIVE
)
1015 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
1016 TextOutA(dc
, xc
-size
.cx
/2+1, yc
-size
.cy
/2+1, str
, 1);
1018 SetTextColor(dc
, GetSysColor(colorIdx
));
1019 TextOutA(dc
, xc
-size
.cx
/2, yc
-size
.cy
/2, str
, 1);
1021 SelectObject(dc
, hfsave
);
1022 SetTextColor(dc
, clrsave
);
1023 SetBkMode(dc
, bksave
);
1024 SetTextAlign(dc
, alignsave
);
1028 case DFCS_CAPTIONMIN
:
1029 Line1
[0].x
= Line1
[3].x
= myr
.left
+ 96*SmallDiam
/750+2;
1030 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ 372*SmallDiam
/750;
1031 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 563*SmallDiam
/750+1;
1032 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 92*SmallDiam
/750;
1037 case DFCS_CAPTIONMAX
:
1038 edge
= 47*SmallDiam
/750;
1039 Line1
[0].x
= Line1
[5].x
= myr
.left
+ 57*SmallDiam
/750+3;
1040 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 143*SmallDiam
/750+1;
1041 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ 562*SmallDiam
/750;
1042 Line1
[5].y
= Line1
[4].y
= Line1
[0].y
+ 93*SmallDiam
/750;
1043 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 513*SmallDiam
/750;
1044 Line1
[3].x
= Line1
[4].x
= Line1
[1].x
- edge
;
1046 Line2
[0].x
= Line2
[5].x
= Line1
[0].x
;
1047 Line2
[3].x
= Line2
[4].x
= Line1
[1].x
;
1048 Line2
[1].x
= Line2
[2].x
= Line1
[0].x
+ edge
;
1049 Line2
[0].y
= Line2
[1].y
= Line1
[0].y
;
1050 Line2
[4].y
= Line2
[5].y
= Line1
[2].y
;
1051 Line2
[2].y
= Line2
[3].y
= Line1
[2].y
- edge
;
1056 case DFCS_CAPTIONRESTORE
:
1057 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1058 edge
= 47*SmallDiam
/750;
1059 move
= 420*SmallDiam
/750;
1060 Line1
[0].x
= Line1
[9].x
= myr
.left
+ 198*SmallDiam
/750+2;
1061 Line1
[0].y
= Line1
[1].y
= myr
.top
+ 169*SmallDiam
/750+1;
1062 Line1
[6].y
= Line1
[7].y
= Line1
[0].y
+ 93*SmallDiam
/750;
1063 Line1
[7].x
= Line1
[8].x
= Line1
[0].x
+ edge
;
1064 Line1
[1].x
= Line1
[2].x
= Line1
[0].x
+ move
;
1065 Line1
[5].x
= Line1
[6].x
= Line1
[1].x
- edge
;
1066 Line1
[9].y
= Line1
[8].y
= Line1
[0].y
+ 187*SmallDiam
/750;
1067 Line1
[2].y
= Line1
[3].y
= Line1
[0].y
+ 327*SmallDiam
/750;
1068 Line1
[4].y
= Line1
[5].y
= Line1
[2].y
- edge
;
1069 Line1
[3].x
= Line1
[4].x
= Line1
[2].x
- 140*SmallDiam
/750;
1071 Line2
[1].x
= Line2
[2].x
= Line1
[3].x
;
1072 Line2
[7].x
= Line2
[8].x
= Line2
[1].x
- edge
;
1073 Line2
[0].x
= Line2
[9].x
= Line2
[3].x
= Line2
[4].x
= Line2
[1].x
- move
;
1074 Line2
[5].x
= Line2
[6].x
= Line2
[0].x
+ edge
;
1075 Line2
[0].y
= Line2
[1].y
= Line1
[9].y
;
1076 Line2
[4].y
= Line2
[5].y
= Line2
[8].y
= Line2
[9].y
= Line2
[0].y
+ 93*SmallDiam
/750;
1077 Line2
[2].y
= Line2
[3].y
= Line2
[0].y
+ 327*SmallDiam
/750;
1078 Line2
[6].y
= Line2
[7].y
= Line2
[2].y
- edge
;
1084 WARN("Invalid caption; flags=0x%04x\n", uFlags
);
1088 /* Here the drawing takes place */
1089 if(uFlags
& DFCS_INACTIVE
)
1091 /* If we have an inactive button, then you see a shadow */
1092 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1093 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
));
1094 Polygon(dc
, Line1
, Line1N
);
1096 Polygon(dc
, Line2
, Line2N
);
1097 SelectObject(dc
, hpsave
);
1098 SelectObject(dc
, hbsave
);
1101 /* Correct for the shadow shift */
1102 if (!(uFlags
& DFCS_PUSHED
))
1104 for(i
= 0; i
< Line1N
; i
++)
1109 for(i
= 0; i
< Line2N
; i
++)
1116 /* Make the final picture */
1117 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(colorIdx
));
1118 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(colorIdx
));
1120 Polygon(dc
, Line1
, Line1N
);
1122 Polygon(dc
, Line2
, Line2N
);
1123 SelectObject(dc
, hpsave
);
1124 SelectObject(dc
, hbsave
);
1130 /************************************************************************
1131 * UITOOLS_DrawFrameScroll
1133 * Draw a scroll-bar control coming from DrawFrameControl()
1135 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
1139 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
) - 2;
1141 HBRUSH hbsave
, hb
, hb2
;
1142 HPEN hpsave
, hp
, hp2
;
1143 int tri
= 290*SmallDiam
/1000 - 1;
1147 * This fixes a problem with really tiny "scroll" buttons. In particular
1148 * with the updown control.
1149 * Making sure that the arrow is as least 3 pixels wide (or high).
1154 switch(uFlags
& 0xff)
1156 case DFCS_SCROLLCOMBOBOX
:
1157 case DFCS_SCROLLDOWN
:
1158 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1159 Line
[2].y
= myr
.top
+ 687*SmallDiam
/1000 + 1;
1160 Line
[0].x
= Line
[2].x
- tri
;
1161 Line
[1].x
= Line
[2].x
+ tri
;
1162 Line
[0].y
= Line
[1].y
= Line
[2].y
- tri
;
1166 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1167 Line
[2].y
= myr
.bottom
- (687*SmallDiam
/1000 + 1);
1168 Line
[0].x
= Line
[2].x
- tri
;
1169 Line
[1].x
= Line
[2].x
+ tri
;
1170 Line
[0].y
= Line
[1].y
= Line
[2].y
+ tri
;
1173 case DFCS_SCROLLLEFT
:
1174 Line
[2].x
= myr
.right
- (687*SmallDiam
/1000 + 1);
1175 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1176 Line
[0].y
= Line
[2].y
- tri
;
1177 Line
[1].y
= Line
[2].y
+ tri
;
1178 Line
[0].x
= Line
[1].x
= Line
[2].x
+ tri
;
1181 case DFCS_SCROLLRIGHT
:
1182 Line
[2].x
= myr
.left
+ 687*SmallDiam
/1000 + 1;
1183 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1184 Line
[0].y
= Line
[2].y
- tri
;
1185 Line
[1].y
= Line
[2].y
+ tri
;
1186 Line
[0].x
= Line
[1].x
= Line
[2].x
- tri
;
1189 case DFCS_SCROLLSIZEGRIP
:
1190 /* This one breaks the flow... */
1191 UITOOLS95_DrawRectEdge(dc
, r
, EDGE_BUMP
, BF_MIDDLE
| ((uFlags
&(DFCS_MONO
|DFCS_FLAT
)) ? BF_MONO
: 0));
1192 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(NULL_PEN
));
1193 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(NULL_BRUSH
));
1194 if(uFlags
& (DFCS_MONO
|DFCS_FLAT
))
1196 hp
= hp2
= SYSCOLOR_GetPen(COLOR_WINDOWFRAME
);
1197 hb
= hb2
= GetSysColorBrush(COLOR_WINDOWFRAME
);
1201 hp
= SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
);
1202 hp2
= SYSCOLOR_GetPen(COLOR_BTNSHADOW
);
1203 hb
= GetSysColorBrush(COLOR_BTNHIGHLIGHT
);
1204 hb2
= GetSysColorBrush(COLOR_BTNSHADOW
);
1206 Line
[0].x
= Line
[1].x
= r
->right
-1;
1207 Line
[2].y
= Line
[3].y
= r
->bottom
-1;
1208 d46
= 46*SmallDiam
/750;
1209 d93
= 93*SmallDiam
/750;
1211 i
= 586*SmallDiam
/750;
1212 Line
[0].y
= r
->bottom
- i
- 1;
1213 Line
[3].x
= r
->right
- i
- 1;
1214 Line
[1].y
= Line
[0].y
+ d46
;
1215 Line
[2].x
= Line
[3].x
+ d46
;
1216 SelectObject(dc
, hb
);
1217 SelectObject(dc
, hp
);
1218 Polygon(dc
, Line
, 4);
1220 Line
[1].y
++; Line
[2].x
++;
1221 Line
[0].y
= Line
[1].y
+ d93
;
1222 Line
[3].x
= Line
[2].x
+ d93
;
1223 SelectObject(dc
, hb2
);
1224 SelectObject(dc
, hp2
);
1225 Polygon(dc
, Line
, 4);
1227 i
= 398*SmallDiam
/750;
1228 Line
[0].y
= r
->bottom
- i
- 1;
1229 Line
[3].x
= r
->right
- i
- 1;
1230 Line
[1].y
= Line
[0].y
+ d46
;
1231 Line
[2].x
= Line
[3].x
+ d46
;
1232 SelectObject(dc
, hb
);
1233 SelectObject(dc
, hp
);
1234 Polygon(dc
, Line
, 4);
1236 Line
[1].y
++; Line
[2].x
++;
1237 Line
[0].y
= Line
[1].y
+ d93
;
1238 Line
[3].x
= Line
[2].x
+ d93
;
1239 SelectObject(dc
, hb2
);
1240 SelectObject(dc
, hp2
);
1241 Polygon(dc
, Line
, 4);
1243 i
= 210*SmallDiam
/750;
1244 Line
[0].y
= r
->bottom
- i
- 1;
1245 Line
[3].x
= r
->right
- i
- 1;
1246 Line
[1].y
= Line
[0].y
+ d46
;
1247 Line
[2].x
= Line
[3].x
+ d46
;
1248 SelectObject(dc
, hb
);
1249 SelectObject(dc
, hp
);
1250 Polygon(dc
, Line
, 4);
1252 Line
[1].y
++; Line
[2].x
++;
1253 Line
[0].y
= Line
[1].y
+ d93
;
1254 Line
[3].x
= Line
[2].x
+ d93
;
1255 SelectObject(dc
, hb2
);
1256 SelectObject(dc
, hp2
);
1257 Polygon(dc
, Line
, 4);
1259 SelectObject(dc
, hpsave
);
1260 SelectObject(dc
, hbsave
);
1264 WARN("Invalid scroll; flags=0x%04x\n", uFlags
);
1268 /* Here do the real scroll-bar controls end up */
1269 if( ! (uFlags
& (0xff00 & ~DFCS_ADJUSTRECT
)) )
1270 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1271 /* want for the normal scroll-arrow button. */
1272 UITOOLS95_DrawRectEdge( dc
, r
, EDGE_RAISED
, (uFlags
&DFCS_ADJUSTRECT
) | BF_MIDDLE
| BF_RECT
);
1274 UITOOLS95_DFC_ButtonPush(dc
, r
, (uFlags
& 0xff00) );
1276 if(uFlags
& DFCS_INACTIVE
)
1278 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1279 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
));
1280 Polygon(dc
, Line
, 3);
1281 SelectObject(dc
, hpsave
);
1282 SelectObject(dc
, hbsave
);
1285 if( (uFlags
& DFCS_INACTIVE
) || !(uFlags
& DFCS_PUSHED
) )
1286 for(i
= 0; i
< 3; i
++)
1292 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1293 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
1294 hpsave
= (HPEN
)SelectObject(dc
, SYSCOLOR_GetPen(i
));
1295 Polygon(dc
, Line
, 3);
1296 SelectObject(dc
, hpsave
);
1297 SelectObject(dc
, hbsave
);
1302 /************************************************************************
1303 * UITOOLS_DrawFrameMenu
1305 * Draw a menu control coming from DrawFrameControl()
1307 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
1311 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
1319 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1320 /* use anything else. I think I tried all sys-colors to change things */
1321 /* without luck. It seems as if this behavior is inherited from the */
1322 /* win31 DFC() implementation... (you remember, B/W menus). */
1324 FillRect(dc
, r
, (HBRUSH
)GetStockObject(WHITE_BRUSH
));
1326 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
1327 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(BLACK_PEN
));
1329 switch(uFlags
& 0xff)
1331 case DFCS_MENUARROW
:
1332 i
= 187*SmallDiam
/750;
1333 Points
[2].x
= myr
.left
+ 468*SmallDiam
/750;
1334 Points
[2].y
= myr
.top
+ 352*SmallDiam
/750+1;
1335 Points
[0].y
= Points
[2].y
- i
;
1336 Points
[1].y
= Points
[2].y
+ i
;
1337 Points
[0].x
= Points
[1].x
= Points
[2].x
- i
;
1338 Polygon(dc
, Points
, 3);
1341 case DFCS_MENUBULLET
:
1343 ye
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1344 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
1345 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1346 i
= 234*SmallDiam
/750;
1348 myr
.left
= xc
- i
+i
/2;
1349 myr
.right
= xc
+ i
/2;
1350 myr
.top
= yc
- i
+i
/2;
1351 myr
.bottom
= yc
+ i
/2;
1352 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
1355 case DFCS_MENUCHECK
:
1356 Points
[0].x
= myr
.left
+ 253*SmallDiam
/1000;
1357 Points
[0].y
= myr
.top
+ 445*SmallDiam
/1000;
1358 Points
[1].x
= myr
.left
+ 409*SmallDiam
/1000;
1359 Points
[1].y
= Points
[0].y
+ (Points
[1].x
-Points
[0].x
);
1360 Points
[2].x
= myr
.left
+ 690*SmallDiam
/1000;
1361 Points
[2].y
= Points
[1].y
- (Points
[2].x
-Points
[1].x
);
1362 Points
[3].x
= Points
[2].x
;
1363 Points
[3].y
= Points
[2].y
+ 3*SmallDiam
/16;
1364 Points
[4].x
= Points
[1].x
;
1365 Points
[4].y
= Points
[1].y
+ 3*SmallDiam
/16;
1366 Points
[5].x
= Points
[0].x
;
1367 Points
[5].y
= Points
[0].y
+ 3*SmallDiam
/16;
1368 Polygon(dc
, Points
, 6);
1372 WARN("Invalid menu; flags=0x%04x\n", uFlags
);
1377 SelectObject(dc
, hpsave
);
1378 SelectObject(dc
, hbsave
);
1383 /**********************************************************************
1384 * DrawFrameControl (USER.656)
1386 BOOL16 WINAPI
DrawFrameControl16( HDC16 hdc
, LPRECT16 rc
, UINT16 uType
,
1392 CONV_RECT16TO32( rc
, &rect32
);
1393 ret
= DrawFrameControl( hdc
, &rect32
, uType
, uState
);
1394 CONV_RECT32TO16( &rect32
, rc
);
1399 /**********************************************************************
1400 * DrawFrameControl (USER32.@)
1402 BOOL WINAPI
DrawFrameControl( HDC hdc
, LPRECT rc
, UINT uType
,
1405 /* Win95 doesn't support drawing in other mapping modes */
1406 if(GetMapMode(hdc
) != MM_TEXT
)
1412 return UITOOLS95_DrawFrameButton(hdc
, rc
, uState
);
1414 return UITOOLS95_DrawFrameCaption(hdc
, rc
, uState
);
1416 return UITOOLS95_DrawFrameMenu(hdc
, rc
, uState
);
1418 return UITOOLS95_DrawFrameScroll(hdc
, rc
, uState
);
1420 WARN("(%x,%p,%d,%x), bad type!\n",
1421 hdc
,rc
,uType
,uState
);