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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WINE_NO_INLINE_RECT
29 #include "user_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(graphics
);
35 /* These tables are used in:
36 * UITOOLS_DrawDiagEdge()
37 * UITOOLS_DrawRectEdge()
39 static const signed char LTInnerNormal
[] = {
41 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
42 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
46 static const signed char LTOuterNormal
[] = {
47 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
48 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
49 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
50 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
53 static const signed char RBInnerNormal
[] = {
55 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
56 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
60 static const signed char RBOuterNormal
[] = {
61 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
62 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
63 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
64 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
67 static const signed char LTInnerSoft
[] = {
69 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
70 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
74 static const signed char LTOuterSoft
[] = {
75 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
76 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
77 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
78 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
81 #define RBInnerSoft RBInnerNormal /* These are the same */
82 #define RBOuterSoft RBOuterNormal
84 static const signed char LTRBOuterMono
[] = {
85 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
86 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
87 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
88 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
91 static const signed char LTRBInnerMono
[] = {
93 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
94 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
95 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
98 static const signed char LTRBOuterFlat
[] = {
99 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
100 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
101 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
102 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
105 static const signed char LTRBInnerFlat
[] = {
107 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
108 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
109 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
113 #define COLOR_MAX COLOR_MENUBAR
116 /***********************************************************************
117 * set_control_clipping
119 * Set clipping for a builtin control that uses CS_PARENTDC.
120 * Return the previous clip region if any.
122 HRGN
set_control_clipping( HDC hdc
, const RECT
*rect
)
125 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
127 if (GetClipRgn( hdc
, hrgn
) != 1)
129 DeleteObject( hrgn
);
132 DPtoLP( hdc
, (POINT
*)&rc
, 2 );
133 if (GetLayout( hdc
) & LAYOUT_RTL
) /* compensate for the shifting done by IntersectClipRect */
138 IntersectClipRect( hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
142 /***********************************************************************
143 * UITOOLS_DrawDiagEdge
145 * Same as DrawEdge invoked with BF_DIAGONAL
147 * 03-Dec-1997: Changed by Bertho Stultiens
149 * See also comments with UITOOLS_DrawRectEdge()
151 static BOOL
UITOOLS95_DrawDiagEdge(HDC hdc
, LPRECT rc
,
152 UINT uType
, UINT uFlags
)
155 signed char InnerI
, OuterI
;
156 HPEN InnerPen
, OuterPen
;
161 int Width
= rc
->right
- rc
->left
;
162 int Height
= rc
->bottom
- rc
->top
;
163 int SmallDiam
= Width
> Height
? Height
: Width
;
164 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
165 || (uType
& BDR_OUTER
) == BDR_OUTER
)
166 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
167 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
168 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
171 OuterPen
= InnerPen
= GetStockObject(NULL_PEN
);
172 SavePen
= SelectObject(hdc
, InnerPen
);
173 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
175 /* Determine the colors of the edges */
178 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
179 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
181 else if(uFlags
& BF_FLAT
)
183 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
184 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
186 else if(uFlags
& BF_SOFT
)
188 if(uFlags
& BF_BOTTOM
)
190 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
191 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
195 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
196 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
201 if(uFlags
& BF_BOTTOM
)
203 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
204 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
208 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
209 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
213 if(InnerI
!= -1) InnerPen
= SYSCOLOR_GetPen(InnerI
);
214 if(OuterI
!= -1) OuterPen
= SYSCOLOR_GetPen(OuterI
);
216 MoveToEx(hdc
, 0, 0, &SavePoint
);
218 /* Don't ask me why, but this is what is visible... */
219 /* This must be possible to do much simpler, but I fail to */
220 /* see the logic in the MS implementation (sigh...). */
221 /* So, this might look a bit brute force here (and it is), but */
222 /* it gets the job done;) */
224 switch(uFlags
& BF_RECT
)
230 /* Left bottom endpoint */
232 spx
= epx
+ SmallDiam
;
234 spy
= epy
- SmallDiam
;
239 /* Left top endpoint */
241 spx
= epx
+ SmallDiam
;
243 spy
= epy
+ SmallDiam
;
249 case BF_RIGHT
|BF_LEFT
:
250 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
251 case BF_BOTTOM
|BF_TOP
:
252 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
253 case BF_BOTTOMRIGHT
|BF_LEFT
:
254 case BF_BOTTOMRIGHT
|BF_TOP
:
256 /* Right top endpoint */
258 epx
= spx
+ SmallDiam
;
260 epy
= spy
- SmallDiam
;
264 MoveToEx(hdc
, spx
, spy
, NULL
);
265 SelectObject(hdc
, OuterPen
);
266 LineTo(hdc
, epx
, epy
);
268 SelectObject(hdc
, InnerPen
);
270 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
272 case BF_DIAGONAL_ENDBOTTOMLEFT
:
273 case (BF_DIAGONAL
|BF_BOTTOM
):
275 case (BF_DIAGONAL
|BF_LEFT
):
276 MoveToEx(hdc
, spx
-1, spy
, NULL
);
277 LineTo(hdc
, epx
, epy
-1);
278 Points
[0].x
= spx
-add
;
280 Points
[1].x
= rc
->left
;
281 Points
[1].y
= rc
->top
;
283 Points
[2].y
= epy
-1-add
;
284 Points
[3] = Points
[2];
287 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
288 MoveToEx(hdc
, spx
-1, spy
, NULL
);
289 LineTo(hdc
, epx
, epy
+1);
290 Points
[0].x
= spx
-add
;
292 Points
[1].x
= rc
->left
;
293 Points
[1].y
= rc
->bottom
-1;
295 Points
[2].y
= epy
+1+add
;
296 Points
[3] = Points
[2];
299 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
300 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
301 case BF_DIAGONAL_ENDTOPRIGHT
:
302 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
303 MoveToEx(hdc
, spx
+1, spy
, NULL
);
304 LineTo(hdc
, epx
, epy
+1);
306 Points
[0].y
= epy
+1+add
;
307 Points
[1].x
= rc
->right
-1;
308 Points
[1].y
= rc
->top
+add
;
309 Points
[2].x
= rc
->right
-1;
310 Points
[2].y
= rc
->bottom
-1;
311 Points
[3].x
= spx
+add
;
315 case BF_DIAGONAL_ENDTOPLEFT
:
316 MoveToEx(hdc
, spx
, spy
-1, NULL
);
317 LineTo(hdc
, epx
+1, epy
);
318 Points
[0].x
= epx
+1+add
;
320 Points
[1].x
= rc
->right
-1;
321 Points
[1].y
= rc
->top
;
322 Points
[2].x
= rc
->right
-1;
323 Points
[2].y
= rc
->bottom
-1-add
;
325 Points
[3].y
= spy
-add
;
328 case (BF_DIAGONAL
|BF_TOP
):
329 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
330 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
331 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
332 LineTo(hdc
, epx
, epy
);
335 Points
[1].x
= rc
->right
-1;
336 Points
[1].y
= rc
->top
;
337 Points
[2].x
= rc
->right
-1;
338 Points
[2].y
= rc
->bottom
-1-add
;
339 Points
[3].x
= spx
+add
;
340 Points
[3].y
= spy
-add
;
343 case (BF_DIAGONAL
|BF_RIGHT
):
344 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
345 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
346 MoveToEx(hdc
, spx
, spy
, NULL
);
347 LineTo(hdc
, epx
-1, epy
+1);
350 Points
[1].x
= rc
->left
;
351 Points
[1].y
= rc
->top
+add
;
352 Points
[2].x
= epx
-1-add
;
353 Points
[2].y
= epy
+1+add
;
354 Points
[3] = Points
[2];
358 /* Fill the interior if asked */
359 if((uFlags
& BF_MIDDLE
) && retval
)
362 HBRUSH hb
= GetSysColorBrush(uFlags
& BF_MONO
? COLOR_WINDOW
365 HPEN hp
= SYSCOLOR_GetPen(uFlags
& BF_MONO
? COLOR_WINDOW
367 hbsave
= SelectObject(hdc
, hb
);
368 hpsave
= SelectObject(hdc
, hp
);
369 Polygon(hdc
, Points
, 4);
370 SelectObject(hdc
, hbsave
);
371 SelectObject(hdc
, hpsave
);
374 /* Adjust rectangle if asked */
375 if(uFlags
& BF_ADJUST
)
377 if(uFlags
& BF_LEFT
) rc
->left
+= add
;
378 if(uFlags
& BF_RIGHT
) rc
->right
-= add
;
379 if(uFlags
& BF_TOP
) rc
->top
+= add
;
380 if(uFlags
& BF_BOTTOM
) rc
->bottom
-= add
;
384 SelectObject(hdc
, SavePen
);
385 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
390 /***********************************************************************
391 * UITOOLS_DrawRectEdge
393 * Same as DrawEdge invoked without BF_DIAGONAL
394 * The width parameter sets the width of each outer and inner edge.
396 * 23-Nov-1997: Changed by Bertho Stultiens
398 * Well, I started testing this and found out that there are a few things
399 * that weren't quite as win95. The following rewrite should reproduce
400 * win95 results completely.
401 * The colorselection is table-driven to avoid awful if-statements.
402 * The table below show the color settings.
404 * Pen selection table for uFlags = 0
406 * uType | LTI | LTO | RBI | RBO
407 * ------+-------+-------+-------+-------
408 * 0000 | x | x | x | x
409 * 0001 | x | 22 | x | 21
410 * 0010 | x | 16 | x | 20
411 * 0011 | x | x | x | x
412 * ------+-------+-------+-------+-------
413 * 0100 | x | 20 | x | 16
414 * 0101 | 20 | 22 | 16 | 21
415 * 0110 | 20 | 16 | 16 | 20
416 * 0111 | x | x | x | x
417 * ------+-------+-------+-------+-------
418 * 1000 | x | 21 | x | 22
419 * 1001 | 21 | 22 | 22 | 21
420 * 1010 | 21 | 16 | 22 | 20
421 * 1011 | x | x | x | x
422 * ------+-------+-------+-------+-------
423 * 1100 | x | x | x | x
424 * 1101 | x | x (22)| x | x (21)
425 * 1110 | x | x (16)| x | x (20)
426 * 1111 | x | x | x | x
428 * Pen selection table for uFlags = BF_SOFT
430 * uType | LTI | LTO | RBI | RBO
431 * ------+-------+-------+-------+-------
432 * 0000 | x | x | x | x
433 * 0001 | x | 20 | x | 21
434 * 0010 | x | 21 | x | 20
435 * 0011 | x | x | x | x
436 * ------+-------+-------+-------+-------
437 * 0100 | x | 22 | x | 16
438 * 0101 | 22 | 20 | 16 | 21
439 * 0110 | 22 | 21 | 16 | 20
440 * 0111 | x | x | x | x
441 * ------+-------+-------+-------+-------
442 * 1000 | x | 16 | x | 22
443 * 1001 | 16 | 20 | 22 | 21
444 * 1010 | 16 | 21 | 22 | 20
445 * 1011 | x | x | x | x
446 * ------+-------+-------+-------+-------
447 * 1100 | x | x | x | x
448 * 1101 | x | x (20)| x | x (21)
449 * 1110 | x | x (21)| x | x (20)
450 * 1111 | x | x | x | x
452 * x = don't care; (n) = is what win95 actually uses
453 * LTI = left Top Inner line
454 * LTO = left Top Outer line
455 * RBI = Right Bottom Inner line
456 * RBO = Right Bottom Outer line
458 * 16 = COLOR_BTNSHADOW
459 * 20 = COLOR_BTNHIGHLIGHT
460 * 21 = COLOR_3DDKSHADOW
465 static BOOL
UITOOLS95_DrawRectEdge(HDC hdc
, LPRECT rc
,
466 UINT uType
, UINT uFlags
, UINT width
)
468 signed char LTInnerI
, LTOuterI
;
469 signed char RBInnerI
, RBOuterI
;
470 HBRUSH lti_brush
, lto_brush
, rbi_brush
, rbo_brush
;
471 RECT InnerRect
= *rc
, fill_rect
;
472 int lbi_offset
= 0, lti_offset
= 0, rti_offset
= 0, rbi_offset
= 0;
473 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
474 || (uType
& BDR_OUTER
) == BDR_OUTER
)
475 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
477 lti_brush
= lto_brush
= rbi_brush
= rbo_brush
= GetStockObject(NULL_BRUSH
);
479 /* Determine the colors of the edges */
482 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
483 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
485 else if(uFlags
& BF_FLAT
)
487 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
488 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
490 if( LTInnerI
!= -1 ) LTInnerI
= RBInnerI
= COLOR_BTNFACE
;
492 else if(uFlags
& BF_SOFT
)
494 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
495 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
496 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
497 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
501 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
502 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
503 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
504 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
507 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
) lbi_offset
= width
;
508 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
) rti_offset
= width
;
509 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
) rbi_offset
= width
;
510 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
) lti_offset
= width
;
512 if(LTInnerI
!= -1) lti_brush
= GetSysColorBrush(LTInnerI
);
513 if(LTOuterI
!= -1) lto_brush
= GetSysColorBrush(LTOuterI
);
514 if(RBInnerI
!= -1) rbi_brush
= GetSysColorBrush(RBInnerI
);
515 if(RBOuterI
!= -1) rbo_brush
= GetSysColorBrush(RBOuterI
);
517 /* Draw the outer edge */
520 fill_rect
= InnerRect
;
521 fill_rect
.bottom
= fill_rect
.top
+ width
;
522 FillRect( hdc
, &fill_rect
, lto_brush
);
526 fill_rect
= InnerRect
;
527 fill_rect
.right
= fill_rect
.left
+ width
;
528 FillRect( hdc
, &fill_rect
, lto_brush
);
530 if(uFlags
& BF_BOTTOM
)
532 fill_rect
= InnerRect
;
533 fill_rect
.top
= fill_rect
.bottom
- width
;
534 FillRect( hdc
, &fill_rect
, rbo_brush
);
536 if(uFlags
& BF_RIGHT
)
538 fill_rect
= InnerRect
;
539 fill_rect
.left
= fill_rect
.right
- width
;
540 FillRect( hdc
, &fill_rect
, rbo_brush
);
543 /* Draw the inner edge */
546 SetRect( &fill_rect
, InnerRect
.left
+ lti_offset
, InnerRect
.top
+ width
,
547 InnerRect
.right
- rti_offset
, InnerRect
.top
+ 2 * width
);
548 FillRect( hdc
, &fill_rect
, lti_brush
);
552 SetRect( &fill_rect
, InnerRect
.left
+ width
, InnerRect
.top
+ lti_offset
,
553 InnerRect
.left
+ 2 * width
, InnerRect
.bottom
- lbi_offset
);
554 FillRect( hdc
, &fill_rect
, lti_brush
);
556 if(uFlags
& BF_BOTTOM
)
558 SetRect( &fill_rect
, InnerRect
.left
+ lbi_offset
, InnerRect
.bottom
- 2 * width
,
559 InnerRect
.right
- rbi_offset
, InnerRect
.bottom
- width
);
560 FillRect( hdc
, &fill_rect
, rbi_brush
);
562 if(uFlags
& BF_RIGHT
)
564 SetRect( &fill_rect
, InnerRect
.right
- 2 * width
, InnerRect
.top
+ rti_offset
,
565 InnerRect
.right
- width
, InnerRect
.bottom
- rbi_offset
);
566 FillRect( hdc
, &fill_rect
, rbi_brush
);
569 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
571 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? width
: 0)
572 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? width
: 0);
574 if(uFlags
& BF_LEFT
) InnerRect
.left
+= add
;
575 if(uFlags
& BF_RIGHT
) InnerRect
.right
-= add
;
576 if(uFlags
& BF_TOP
) InnerRect
.top
+= add
;
577 if(uFlags
& BF_BOTTOM
) InnerRect
.bottom
-= add
;
579 if((uFlags
& BF_MIDDLE
) && retval
)
581 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
582 COLOR_WINDOW
: COLOR_BTNFACE
));
585 if(uFlags
& BF_ADJUST
)
593 /**********************************************************************
594 * DrawEdge (USER32.@)
596 BOOL WINAPI
DrawEdge( HDC hdc
, LPRECT rc
, UINT edge
, UINT flags
)
598 TRACE("%p %s %04x %04x\n", hdc
, wine_dbgstr_rect(rc
), edge
, flags
);
600 if(flags
& BF_DIAGONAL
)
601 return UITOOLS95_DrawDiagEdge(hdc
, rc
, edge
, flags
);
603 return UITOOLS95_DrawRectEdge(hdc
, rc
, edge
, flags
, 1);
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))
642 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
643 bg
= SetBkColor(dc
, RGB(255, 255, 255));
644 hbsave
= SelectObject(dc
, SYSCOLOR_Get55AABrush());
645 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
646 SelectObject(dc
, hbsave
);
651 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
655 /************************************************************************
656 * UITOOLS_DFC_ButtonPush
658 * Draw a push button coming from DrawFrameControl()
660 * Does a pretty good job in emulating MS behavior. Some quirks are
661 * however there because MS uses a TrueType font (Marlett) to draw
664 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
669 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
674 if(uFlags
& DFCS_CHECKED
)
676 if(uFlags
& DFCS_MONO
)
677 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
, 1);
679 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
, 1);
681 if (!(uFlags
& DFCS_TRANSPARENT
))
682 UITOOLS_DrawCheckedRect( dc
, &myr
);
686 if(uFlags
& DFCS_MONO
)
688 UITOOLS95_DrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
, 1);
689 if (!(uFlags
& DFCS_TRANSPARENT
))
690 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
694 UITOOLS95_DrawRectEdge(dc
, r
, edge
, (uFlags
& DFCS_FLAT
) |
695 ((uFlags
& DFCS_TRANSPARENT
) ? 0 : BF_MIDDLE
) | BF_RECT
| BF_SOFT
, 1);
699 /* Adjust rectangle if asked */
700 if(uFlags
& DFCS_ADJUSTRECT
)
701 InflateRect(r
, -2, -2);
707 /************************************************************************
708 * UITOOLS_DFC_ButtonCheck
710 * Draw a check/3state button coming from DrawFrameControl()
712 * Does a pretty good job in emulating MS behavior. Some quirks are
713 * however there because MS uses a TrueType font (Marlett) to draw
717 static BOOL
UITOOLS95_DFC_ButtonCheck(HDC dc
, LPRECT r
, UINT uFlags
)
720 UINT flags
= BF_RECT
| BF_ADJUST
;
722 UITOOLS_MakeSquareRect(r
, &myr
);
724 if(uFlags
& DFCS_FLAT
) flags
|= BF_FLAT
;
725 else if(uFlags
& DFCS_MONO
) flags
|= BF_MONO
;
727 UITOOLS95_DrawRectEdge( dc
, &myr
, EDGE_SUNKEN
, flags
, max( (myr
.right
- myr
.left
+ 8) / 16, 1) );
729 if (!(uFlags
& DFCS_TRANSPARENT
))
731 if(uFlags
& (DFCS_INACTIVE
| DFCS_PUSHED
))
732 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
733 else if( (uFlags
& DFCS_BUTTON3STATE
) && (uFlags
& DFCS_CHECKED
) )
734 UITOOLS_DrawCheckedRect( dc
, &myr
);
736 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_WINDOW
));
739 if(uFlags
& DFCS_CHECKED
)
744 int color
= (uFlags
& DFCS_INACTIVE
) || (uFlags
& 0xff) == DFCS_BUTTON3STATE
?
745 COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
747 pt
[0].x
= myr
.right
- 1;
750 pt
[1].y
= pt
[0].y
+ (myr
.bottom
- myr
.top
) / 3;
751 pt
[2].x
= myr
.left
+ (myr
.right
- myr
.left
) / 3;
752 pt
[2].y
= myr
.bottom
- 1;
753 pt
[3].x
= myr
.left
+ 1;
754 pt
[3].y
= pt
[2].y
- (pt
[2].x
- pt
[3].x
);
756 pt
[4].y
= pt
[3].y
- (myr
.bottom
- myr
.top
) / 3;
758 pt
[5].y
= pt
[2].y
- (myr
.bottom
- myr
.top
) / 3;
760 old_brush
= SelectObject( dc
, GetSysColorBrush( color
) );
761 old_pen
= SelectObject( dc
, GetStockObject( NULL_PEN
));
762 Polygon( dc
, pt
, 6 );
763 SelectObject( dc
, old_brush
);
764 SelectObject( dc
, old_pen
);
770 /************************************************************************
771 * UITOOLS_DFC_ButtonRadio
773 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
775 * Does a pretty good job in emulating MS behavior. Some quirks are
776 * however there because MS uses a TrueType font (Marlett) to draw
779 static BOOL
UITOOLS95_DFC_ButtonRadio(HDC dc
, LPRECT r
, UINT uFlags
)
783 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
784 int BorderShrink
= SmallDiam
/ 16;
789 if(BorderShrink
< 1) BorderShrink
= 1;
791 if((uFlags
& 0xff) == DFCS_BUTTONRADIOIMAGE
)
792 FillRect(dc
, r
, GetStockObject(BLACK_BRUSH
));
793 else if((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
)
794 FillRect(dc
, r
, GetStockObject(WHITE_BRUSH
));
796 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
797 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
799 /* Define bounding box */
801 SetRect(&myr
, xc
- i
+ i
/ 2, yc
- i
+ i
/ 2, xc
+ i
/ 2, yc
+ i
/ 2);
803 if((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
)
805 hbsave
= SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
806 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
807 SelectObject(dc
, hbsave
);
811 if(uFlags
& (DFCS_FLAT
|DFCS_MONO
))
813 hpsave
= SelectObject(dc
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
));
814 hbsave
= SelectObject(dc
, GetSysColorBrush(COLOR_WINDOWFRAME
));
815 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
816 SelectObject(dc
, hbsave
);
817 SelectObject(dc
, hpsave
);
821 hpsave
= SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
));
822 hbsave
= SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
823 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.left
-1, myr
.bottom
, myr
.right
+1, myr
.top
);
825 SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNSHADOW
));
826 SelectObject(dc
, GetSysColorBrush(COLOR_BTNSHADOW
));
827 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.right
+1, myr
.top
, myr
.left
-1, myr
.bottom
);
829 InflateRect(&myr
, -BorderShrink
, -BorderShrink
);
830 SelectObject(dc
, SYSCOLOR_GetPen(COLOR_3DLIGHT
));
831 SelectObject(dc
, GetSysColorBrush(COLOR_3DLIGHT
));
832 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.left
-1, myr
.bottom
, myr
.right
+1, myr
.top
);
834 SelectObject(dc
, SYSCOLOR_GetPen(COLOR_3DDKSHADOW
));
835 SelectObject(dc
, GetSysColorBrush(COLOR_3DDKSHADOW
));
836 Pie(dc
, myr
.left
, myr
.top
, myr
.right
+1, myr
.bottom
+1, myr
.right
+1, myr
.top
, myr
.left
-1, myr
.bottom
);
837 SelectObject(dc
, hbsave
);
838 SelectObject(dc
, hpsave
);
842 SetRect(&myr
, xc
- i
+ i
/ 2, yc
- i
+ i
/ 2, xc
+ i
/ 2, yc
+ i
/ 2);
843 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
844 hpsave
= SelectObject(dc
, SYSCOLOR_GetPen(i
));
845 hbsave
= SelectObject(dc
, GetSysColorBrush(i
));
846 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
847 SelectObject(dc
, hbsave
);
848 SelectObject(dc
, hpsave
);
851 if(uFlags
& DFCS_CHECKED
)
855 SetRect(&myr
, xc
- i
+ i
/ 2, yc
- i
+ i
/ 2, xc
+ i
/ 2, yc
+ i
/ 2);
857 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_WINDOWTEXT
;
858 hbsave
= SelectObject(dc
, GetSysColorBrush(i
));
859 hpsave
= SelectObject(dc
, SYSCOLOR_GetPen(i
));
860 Ellipse(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
);
861 SelectObject(dc
, hpsave
);
862 SelectObject(dc
, hbsave
);
865 /* FIXME: M$ has a polygon in the center at relative points: */
866 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
870 /* when the button is unchecked. The reason for it is unknown. The */
871 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
872 /* least 3 times (it looks like a clip-region when you see it happen). */
873 /* I do not really see a reason why this should be implemented. If you */
874 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
880 /***********************************************************************
881 * UITOOLS_DrawFrameButton
883 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
885 switch(uState
& 0xff)
887 case DFCS_BUTTONPUSH
:
888 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
890 case DFCS_BUTTONCHECK
:
891 case DFCS_BUTTON3STATE
:
892 return UITOOLS95_DFC_ButtonCheck(hdc
, rc
, uState
);
894 case DFCS_BUTTONRADIOIMAGE
:
895 case DFCS_BUTTONRADIOMASK
:
896 case DFCS_BUTTONRADIO
:
897 return UITOOLS95_DFC_ButtonRadio(hdc
, rc
, uState
);
900 WARN("Invalid button state=0x%04x\n", uState
);
906 /***********************************************************************
907 * UITOOLS_DrawFrameCaption
909 * Draw caption buttons (win95), coming from DrawFrameControl()
912 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
915 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
)-2;
917 int colorIdx
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
918 int xc
= (myr
.left
+myr
.right
)/2;
919 int yc
= (myr
.top
+myr
.bottom
)/2;
920 WCHAR str
[] = {0, 0};
926 UITOOLS95_DFC_ButtonPush(dc
, r
, uFlags
& 0xff00);
930 case DFCS_CAPTIONCLOSE
: str
[0] = 0x72; break;
931 case DFCS_CAPTIONHELP
: str
[0] = 0x73; break;
932 case DFCS_CAPTIONMIN
: str
[0] = 0x30; break;
933 case DFCS_CAPTIONMAX
: str
[0] = 0x31; break;
934 case DFCS_CAPTIONRESTORE
: str
[0] = 0x32; break;
936 WARN("Invalid caption; flags=0x%04x\n", uFlags
);
940 hf
= CreateFontW(-SmallDiam
, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
,
941 SYMBOL_CHARSET
, OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
,
942 DEFAULT_QUALITY
, FIXED_PITCH
|FF_DONTCARE
, L
"Marlett");
943 alignsave
= SetTextAlign(dc
, TA_TOP
|TA_LEFT
);
944 bksave
= SetBkMode(dc
, TRANSPARENT
);
945 clrsave
= GetTextColor(dc
);
946 hfsave
= SelectObject(dc
, hf
);
947 GetTextExtentPoint32W(dc
, str
, 1, &size
);
949 if(uFlags
& DFCS_INACTIVE
)
951 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
952 TextOutW(dc
, xc
-size
.cx
/2+1, yc
-size
.cy
/2+1, str
, 1);
954 SetTextColor(dc
, GetSysColor(colorIdx
));
955 TextOutW(dc
, xc
-size
.cx
/2, yc
-size
.cy
/2, str
, 1);
957 SelectObject(dc
, hfsave
);
958 SetTextColor(dc
, clrsave
);
959 SetBkMode(dc
, bksave
);
960 SetTextAlign(dc
, alignsave
);
967 /************************************************************************
968 * UITOOLS_DrawFrameScroll
970 * Draw a scroll-bar control coming from DrawFrameControl()
972 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
976 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
) - 2;
978 HBRUSH hbsave
, hb
, hb2
;
979 HPEN hpsave
, hp
, hp2
;
980 int tri
= 290*SmallDiam
/1000 - 1;
984 * This fixes a problem with really tiny "scroll" buttons. In particular
985 * with the updown control.
986 * Making sure that the arrow is as least 3 pixels wide (or high).
990 switch(uFlags
& 0xff)
992 case DFCS_SCROLLCOMBOBOX
:
993 case DFCS_SCROLLDOWN
:
994 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
995 Line
[2].y
= myr
.top
+ 687*SmallDiam
/1000 + 1;
996 Line
[0].x
= Line
[2].x
- tri
;
997 Line
[1].x
= Line
[2].x
+ tri
;
998 Line
[0].y
= Line
[1].y
= Line
[2].y
- tri
;
1002 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
1003 Line
[2].y
= myr
.bottom
- (687*SmallDiam
/1000 + 1);
1004 Line
[0].x
= Line
[2].x
- tri
;
1005 Line
[1].x
= Line
[2].x
+ tri
;
1006 Line
[0].y
= Line
[1].y
= Line
[2].y
+ tri
;
1009 case DFCS_SCROLLLEFT
:
1010 Line
[2].x
= myr
.right
- (687*SmallDiam
/1000 + 1);
1011 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1012 Line
[0].y
= Line
[2].y
- tri
;
1013 Line
[1].y
= Line
[2].y
+ tri
;
1014 Line
[0].x
= Line
[1].x
= Line
[2].x
+ tri
;
1017 case DFCS_SCROLLRIGHT
:
1018 Line
[2].x
= myr
.left
+ 687*SmallDiam
/1000 + 1;
1019 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
1020 Line
[0].y
= Line
[2].y
- tri
;
1021 Line
[1].y
= Line
[2].y
+ tri
;
1022 Line
[0].x
= Line
[1].x
= Line
[2].x
- tri
;
1025 case DFCS_SCROLLSIZEGRIP
:
1026 /* This one breaks the flow... */
1027 UITOOLS95_DrawRectEdge(dc
, r
, EDGE_BUMP
, BF_MIDDLE
| ((uFlags
&(DFCS_MONO
|DFCS_FLAT
)) ? BF_MONO
: 0), 1);
1028 hpsave
= SelectObject(dc
, GetStockObject(NULL_PEN
));
1029 hbsave
= SelectObject(dc
, GetStockObject(NULL_BRUSH
));
1030 if(uFlags
& (DFCS_MONO
|DFCS_FLAT
))
1032 hp
= hp2
= SYSCOLOR_GetPen(COLOR_WINDOWFRAME
);
1033 hb
= hb2
= GetSysColorBrush(COLOR_WINDOWFRAME
);
1037 hp
= SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
);
1038 hp2
= SYSCOLOR_GetPen(COLOR_BTNSHADOW
);
1039 hb
= GetSysColorBrush(COLOR_BTNHIGHLIGHT
);
1040 hb2
= GetSysColorBrush(COLOR_BTNSHADOW
);
1042 Line
[0].x
= Line
[1].x
= r
->right
-1;
1043 Line
[2].y
= Line
[3].y
= r
->bottom
-1;
1044 d46
= 46*SmallDiam
/750;
1045 d93
= 93*SmallDiam
/750;
1047 i
= 586*SmallDiam
/750;
1048 Line
[0].y
= r
->bottom
- i
- 1;
1049 Line
[3].x
= r
->right
- i
- 1;
1050 Line
[1].y
= Line
[0].y
+ d46
;
1051 Line
[2].x
= Line
[3].x
+ d46
;
1052 SelectObject(dc
, hb
);
1053 SelectObject(dc
, hp
);
1054 Polygon(dc
, Line
, 4);
1056 Line
[1].y
++; Line
[2].x
++;
1057 Line
[0].y
= Line
[1].y
+ d93
;
1058 Line
[3].x
= Line
[2].x
+ d93
;
1059 SelectObject(dc
, hb2
);
1060 SelectObject(dc
, hp2
);
1061 Polygon(dc
, Line
, 4);
1063 i
= 398*SmallDiam
/750;
1064 Line
[0].y
= r
->bottom
- i
- 1;
1065 Line
[3].x
= r
->right
- i
- 1;
1066 Line
[1].y
= Line
[0].y
+ d46
;
1067 Line
[2].x
= Line
[3].x
+ d46
;
1068 SelectObject(dc
, hb
);
1069 SelectObject(dc
, hp
);
1070 Polygon(dc
, Line
, 4);
1072 Line
[1].y
++; Line
[2].x
++;
1073 Line
[0].y
= Line
[1].y
+ d93
;
1074 Line
[3].x
= Line
[2].x
+ d93
;
1075 SelectObject(dc
, hb2
);
1076 SelectObject(dc
, hp2
);
1077 Polygon(dc
, Line
, 4);
1079 i
= 210*SmallDiam
/750;
1080 Line
[0].y
= r
->bottom
- i
- 1;
1081 Line
[3].x
= r
->right
- i
- 1;
1082 Line
[1].y
= Line
[0].y
+ d46
;
1083 Line
[2].x
= Line
[3].x
+ d46
;
1084 SelectObject(dc
, hb
);
1085 SelectObject(dc
, hp
);
1086 Polygon(dc
, Line
, 4);
1088 Line
[1].y
++; Line
[2].x
++;
1089 Line
[0].y
= Line
[1].y
+ d93
;
1090 Line
[3].x
= Line
[2].x
+ d93
;
1091 SelectObject(dc
, hb2
);
1092 SelectObject(dc
, hp2
);
1093 Polygon(dc
, Line
, 4);
1095 SelectObject(dc
, hpsave
);
1096 SelectObject(dc
, hbsave
);
1100 WARN("Invalid scroll; flags=0x%04x\n", uFlags
);
1104 /* Here do the real scroll-bar controls end up */
1105 if( ! (uFlags
& (0xff00 & ~DFCS_ADJUSTRECT
)) )
1106 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1107 /* want for the normal scroll-arrow button. */
1108 UITOOLS95_DrawRectEdge( dc
, r
, EDGE_RAISED
, (uFlags
&DFCS_ADJUSTRECT
) | BF_MIDDLE
| BF_RECT
, 1);
1110 UITOOLS95_DFC_ButtonPush(dc
, r
, (uFlags
& 0xff00) );
1112 if(uFlags
& DFCS_INACTIVE
)
1114 hbsave
= SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1115 hpsave
= SelectObject(dc
, SYSCOLOR_GetPen(COLOR_BTNHIGHLIGHT
));
1116 Polygon(dc
, Line
, 3);
1117 SelectObject(dc
, hpsave
);
1118 SelectObject(dc
, hbsave
);
1121 if( (uFlags
& DFCS_INACTIVE
) || !(uFlags
& DFCS_PUSHED
) )
1122 for(i
= 0; i
< 3; i
++)
1128 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1129 hbsave
= SelectObject(dc
, GetSysColorBrush(i
));
1130 hpsave
= SelectObject(dc
, SYSCOLOR_GetPen(i
));
1131 Polygon(dc
, Line
, 3);
1132 SelectObject(dc
, hpsave
);
1133 SelectObject(dc
, hbsave
);
1138 /************************************************************************
1139 * UITOOLS_DrawFrameMenu
1141 * Draw a menu control coming from DrawFrameControl()
1143 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
1147 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
);
1155 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1156 /* use anything else. I think I tried all sys-colors to change things */
1157 /* without luck. It seems as if this behavior is inherited from the */
1158 /* win31 DFC() implementation... (you remember, B/W menus). */
1160 FillRect(dc
, r
, GetStockObject(WHITE_BRUSH
));
1162 hbsave
= SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
1163 hpsave
= SelectObject(dc
, GetStockObject(BLACK_PEN
));
1165 switch(uFlags
& 0xff)
1167 case DFCS_MENUARROW
:
1168 i
= 187*SmallDiam
/750;
1169 Points
[2].x
= myr
.left
+ 468*SmallDiam
/750;
1170 Points
[2].y
= myr
.top
+ 352*SmallDiam
/750+1;
1171 Points
[0].y
= Points
[2].y
- i
;
1172 Points
[1].y
= Points
[2].y
+ i
;
1173 Points
[0].x
= Points
[1].x
= Points
[2].x
- i
;
1174 Polygon(dc
, Points
, 3);
1177 case DFCS_MENUBULLET
:
1179 ye
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1180 xc
= myr
.left
+ SmallDiam
- SmallDiam
/2;
1181 yc
= myr
.top
+ SmallDiam
- SmallDiam
/2;
1182 i
= 234*SmallDiam
/750;
1184 SetRect(&myr
, xc
- i
+ i
/ 2, yc
- i
+ i
/ 2, xc
+ i
/ 2, yc
+ i
/ 2);
1185 Pie(dc
, myr
.left
, myr
.top
, myr
.right
, myr
.bottom
, xe
, ye
, xe
, ye
);
1188 case DFCS_MENUCHECK
:
1189 Points
[0].x
= myr
.left
+ 253*SmallDiam
/1000;
1190 Points
[0].y
= myr
.top
+ 445*SmallDiam
/1000;
1191 Points
[1].x
= myr
.left
+ 409*SmallDiam
/1000;
1192 Points
[1].y
= Points
[0].y
+ (Points
[1].x
-Points
[0].x
);
1193 Points
[2].x
= myr
.left
+ 690*SmallDiam
/1000;
1194 Points
[2].y
= Points
[1].y
- (Points
[2].x
-Points
[1].x
);
1195 Points
[3].x
= Points
[2].x
;
1196 Points
[3].y
= Points
[2].y
+ 3*SmallDiam
/16;
1197 Points
[4].x
= Points
[1].x
;
1198 Points
[4].y
= Points
[1].y
+ 3*SmallDiam
/16;
1199 Points
[5].x
= Points
[0].x
;
1200 Points
[5].y
= Points
[0].y
+ 3*SmallDiam
/16;
1201 Polygon(dc
, Points
, 6);
1205 WARN("Invalid menu; flags=0x%04x\n", uFlags
);
1210 SelectObject(dc
, hpsave
);
1211 SelectObject(dc
, hbsave
);
1216 /**********************************************************************
1217 * DrawFrameControl (USER32.@)
1219 BOOL WINAPI
DrawFrameControl( HDC hdc
, LPRECT rc
, UINT uType
,
1225 return UITOOLS95_DrawFrameButton(hdc
, rc
, uState
);
1227 return UITOOLS95_DrawFrameCaption(hdc
, rc
, uState
);
1229 return UITOOLS95_DrawFrameMenu(hdc
, rc
, uState
);
1230 /*case DFC_POPUPMENU:
1231 FIXME("DFC_POPUPMENU: not implemented\n");
1234 return UITOOLS95_DrawFrameScroll(hdc
, rc
, uState
);
1236 WARN("(%p,%p,%d,%x), bad type!\n", hdc
,rc
,uType
,uState
);
1242 /***********************************************************************
1243 * SetRect (USER32.@)
1245 BOOL WINAPI
SetRect( LPRECT rect
, INT left
, INT top
,
1246 INT right
, INT bottom
)
1248 if (!rect
) return FALSE
;
1250 rect
->right
= right
;
1252 rect
->bottom
= bottom
;
1257 /***********************************************************************
1258 * SetRectEmpty (USER32.@)
1260 BOOL WINAPI
SetRectEmpty( LPRECT rect
)
1262 if (!rect
) return FALSE
;
1263 rect
->left
= rect
->right
= rect
->top
= rect
->bottom
= 0;
1268 /***********************************************************************
1269 * CopyRect (USER32.@)
1271 BOOL WINAPI
CopyRect( RECT
*dest
, const RECT
*src
)
1273 if (!dest
|| !src
) return FALSE
;
1279 /***********************************************************************
1280 * IsRectEmpty (USER32.@)
1282 * Bug compat: Windows checks for 0 or negative width/height.
1284 BOOL WINAPI
IsRectEmpty( const RECT
*rect
)
1286 if (!rect
) return TRUE
;
1287 return ((rect
->left
>= rect
->right
) || (rect
->top
>= rect
->bottom
));
1291 /***********************************************************************
1292 * PtInRect (USER32.@)
1294 BOOL WINAPI
PtInRect( const RECT
*rect
, POINT pt
)
1296 if (!rect
) return FALSE
;
1297 return ((pt
.x
>= rect
->left
) && (pt
.x
< rect
->right
) &&
1298 (pt
.y
>= rect
->top
) && (pt
.y
< rect
->bottom
));
1302 /***********************************************************************
1303 * OffsetRect (USER32.@)
1305 BOOL WINAPI
OffsetRect( LPRECT rect
, INT x
, INT y
)
1307 if (!rect
) return FALSE
;
1316 /***********************************************************************
1317 * InflateRect (USER32.@)
1319 BOOL WINAPI
InflateRect( LPRECT rect
, INT x
, INT y
)
1321 if (!rect
) return FALSE
;
1330 /***********************************************************************
1331 * IntersectRect (USER32.@)
1333 BOOL WINAPI
IntersectRect( LPRECT dest
, const RECT
*src1
, const RECT
*src2
)
1335 if (!dest
|| !src1
|| !src2
) return FALSE
;
1336 if (IsRectEmpty(src1
) || IsRectEmpty(src2
) ||
1337 (src1
->left
>= src2
->right
) || (src2
->left
>= src1
->right
) ||
1338 (src1
->top
>= src2
->bottom
) || (src2
->top
>= src1
->bottom
))
1340 SetRectEmpty( dest
);
1343 dest
->left
= max( src1
->left
, src2
->left
);
1344 dest
->right
= min( src1
->right
, src2
->right
);
1345 dest
->top
= max( src1
->top
, src2
->top
);
1346 dest
->bottom
= min( src1
->bottom
, src2
->bottom
);
1351 /***********************************************************************
1352 * UnionRect (USER32.@)
1354 BOOL WINAPI
UnionRect( LPRECT dest
, const RECT
*src1
, const RECT
*src2
)
1356 if (!dest
) return FALSE
;
1357 if (IsRectEmpty(src1
))
1359 if (IsRectEmpty(src2
))
1361 SetRectEmpty( dest
);
1368 if (IsRectEmpty(src2
)) *dest
= *src1
;
1371 dest
->left
= min( src1
->left
, src2
->left
);
1372 dest
->right
= max( src1
->right
, src2
->right
);
1373 dest
->top
= min( src1
->top
, src2
->top
);
1374 dest
->bottom
= max( src1
->bottom
, src2
->bottom
);
1381 /***********************************************************************
1382 * EqualRect (USER32.@)
1384 BOOL WINAPI
EqualRect( const RECT
* rect1
, const RECT
* rect2
)
1386 if (!rect1
|| !rect2
) return FALSE
;
1387 return ((rect1
->left
== rect2
->left
) && (rect1
->right
== rect2
->right
) &&
1388 (rect1
->top
== rect2
->top
) && (rect1
->bottom
== rect2
->bottom
));
1392 /***********************************************************************
1393 * SubtractRect (USER32.@)
1395 BOOL WINAPI
SubtractRect( LPRECT dest
, const RECT
*src1
, const RECT
*src2
)
1399 if (!dest
) return FALSE
;
1400 if (IsRectEmpty( src1
))
1402 SetRectEmpty( dest
);
1405 if (IntersectRect( &tmp
, src1
, src2
))
1407 if (EqualRect( &tmp
, src1
))
1409 SetRectEmpty( dest
);
1413 if ((tmp
.top
== dest
->top
) && (tmp
.bottom
== dest
->bottom
))
1415 if (tmp
.left
== dest
->left
) dest
->left
= tmp
.right
;
1416 else if (tmp
.right
== dest
->right
) dest
->right
= tmp
.left
;
1418 else if ((tmp
.left
== dest
->left
) && (tmp
.right
== dest
->right
))
1420 if (tmp
.top
== dest
->top
) dest
->top
= tmp
.bottom
;
1421 else if (tmp
.bottom
== dest
->bottom
) dest
->bottom
= tmp
.top
;
1432 /***********************************************************************
1433 * FillRect (USER32.@)
1435 INT WINAPI
FillRect( HDC hdc
, const RECT
*rect
, HBRUSH hbrush
)
1439 if (hbrush
<= (HBRUSH
) (COLOR_MAX
+ 1)) hbrush
= GetSysColorBrush( HandleToULong(hbrush
) - 1 );
1441 prev_brush
= SelectObject( hdc
, hbrush
);
1442 PatBlt( hdc
, rect
->left
, rect
->top
,
1443 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
1444 if (prev_brush
) SelectObject( hdc
, prev_brush
);
1449 /***********************************************************************
1450 * InvertRect (USER32.@)
1452 BOOL WINAPI
InvertRect( HDC hdc
, const RECT
*rect
)
1454 return PatBlt( hdc
, rect
->left
, rect
->top
,
1455 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
1459 /***********************************************************************
1460 * FrameRect (USER32.@)
1462 INT WINAPI
FrameRect( HDC hdc
, const RECT
*rect
, HBRUSH hbrush
)
1467 if (IsRectEmpty(&r
)) return 0;
1468 if (!(prevBrush
= SelectObject( hdc
, hbrush
))) return 0;
1470 PatBlt( hdc
, r
.left
, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1471 PatBlt( hdc
, r
.right
- 1, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1472 PatBlt( hdc
, r
.left
, r
.top
, r
.right
- r
.left
, 1, PATCOPY
);
1473 PatBlt( hdc
, r
.left
, r
.bottom
- 1, r
.right
- r
.left
, 1, PATCOPY
);
1475 SelectObject( hdc
, prevBrush
);
1480 /***********************************************************************
1481 * DrawFocusRect (USER32.@)
1483 * FIXME: PatBlt(PATINVERT) with background brush.
1485 BOOL WINAPI
DrawFocusRect( HDC hdc
, const RECT
* rc
)
1488 HPEN hOldPen
, hNewPen
;
1489 INT oldDrawMode
, oldBkMode
;
1492 hOldBrush
= SelectObject(hdc
, GetStockObject(NULL_BRUSH
));
1493 lb
.lbStyle
= BS_SOLID
;
1495 hNewPen
= ExtCreatePen(PS_COSMETIC
|PS_ALTERNATE
, 1, &lb
, 0, NULL
);
1496 hOldPen
= SelectObject(hdc
, hNewPen
);
1497 oldDrawMode
= SetROP2(hdc
, R2_NOT
);
1498 oldBkMode
= SetBkMode(hdc
, TRANSPARENT
);
1500 Rectangle(hdc
, rc
->left
, rc
->top
, rc
->right
, rc
->bottom
);
1502 SetBkMode(hdc
, oldBkMode
);
1503 SetROP2(hdc
, oldDrawMode
);
1504 SelectObject(hdc
, hOldPen
);
1505 DeleteObject(hNewPen
);
1506 SelectObject(hdc
, hOldBrush
);
1512 /**********************************************************************
1513 * DrawAnimatedRects (USER32.@)
1515 BOOL WINAPI
DrawAnimatedRects( HWND hwnd
, INT idAni
, const RECT
* lprcFrom
, const RECT
* lprcTo
)
1517 FIXME("(%p,%d,%p,%p): stub\n",hwnd
,idAni
,lprcFrom
,lprcTo
);
1522 /**********************************************************************
1523 * UITOOLS_DrawStateJam
1525 * Jams in the requested type in the dc
1527 static BOOL
UITOOLS_DrawStateJam( HDC hdc
, UINT opcode
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1528 LPRECT rc
, UINT dtflags
, BOOL unicode
)
1533 INT cx
= rc
->right
- rc
->left
;
1534 INT cy
= rc
->bottom
- rc
->top
;
1539 case DST_PREFIXTEXT
:
1541 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1543 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1546 return DrawIconEx(hdc
, rc
->left
, rc
->top
, (HICON
)lp
, 0, 0, 0, NULL
, DI_NORMAL
);
1549 memdc
= CreateCompatibleDC(hdc
);
1550 if(!memdc
) return FALSE
;
1551 hbmsave
= SelectObject(memdc
, (HBITMAP
)lp
);
1557 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
1558 SelectObject(memdc
, hbmsave
);
1565 /* DRAWSTATEPROC assumes that it draws at the center of coordinates */
1567 OffsetViewportOrgEx(hdc
, rc
->left
, rc
->top
, NULL
);
1568 bRet
= func(hdc
, lp
, wp
, cx
, cy
);
1569 /* Restore origin */
1570 OffsetViewportOrgEx(hdc
, -rc
->left
, -rc
->top
, NULL
);
1578 /**********************************************************************
1579 * UITOOLS_DrawState()
1581 static BOOL
UITOOLS_DrawState(HDC hdc
, HBRUSH hbr
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1582 INT x
, INT y
, INT cx
, INT cy
, UINT flags
, BOOL unicode
)
1584 HBITMAP hbm
, hbmsave
;
1586 HBRUSH hbsave
, hbrtmp
= 0;
1589 UINT dtflags
= DT_NOCLIP
;
1591 UINT opcode
= flags
& 0xf;
1595 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
1597 if (!lp
) return FALSE
;
1600 len
= lstrlenW((LPWSTR
)lp
);
1602 len
= strlen((LPSTR
)lp
);
1605 /* Find out what size the image has if not given by caller */
1614 case DST_PREFIXTEXT
:
1616 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
1618 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
1619 if(!retval
) return FALSE
;
1623 if (!get_icon_size( (HICON
)lp
, &s
)) return FALSE
;
1627 if(!GetObjectA((HBITMAP
)lp
, sizeof(bm
), &bm
)) return FALSE
;
1632 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1640 SetRect(&rc
, x
, y
, x
+ cx
, y
+ cy
);
1642 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1643 dtflags
|= DT_RIGHT
;
1644 if(opcode
== DST_TEXT
)
1645 dtflags
|= DT_NOPREFIX
;
1647 /* For DSS_NORMAL we just jam in the image and return */
1648 if((flags
& 0x7ff0) == DSS_NORMAL
)
1650 return UITOOLS_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1653 /* For all other states we need to convert the image to B/W in a local bitmap */
1654 /* before it is displayed */
1655 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1656 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1657 hbm
= NULL
; hbmsave
= NULL
;
1658 memdc
= NULL
; hbsave
= NULL
;
1659 retval
= FALSE
; /* assume failure */
1661 /* From here on we must use "goto cleanup" when something goes wrong */
1662 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1663 if(!hbm
) goto cleanup
;
1664 memdc
= CreateCompatibleDC(hdc
);
1665 if(!memdc
) goto cleanup
;
1666 hbmsave
= SelectObject(memdc
, hbm
);
1667 if(!hbmsave
) goto cleanup
;
1668 SetRect(&rc
, 0, 0, cx
, cy
);
1669 if(!FillRect(memdc
, &rc
, GetStockObject(WHITE_BRUSH
))) goto cleanup
;
1670 SetBkColor(memdc
, RGB(255, 255, 255));
1671 SetTextColor(memdc
, RGB(0, 0, 0));
1672 hfsave
= SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1673 SetLayout( memdc
, GetLayout( hdc
));
1675 /* DST_COMPLEX may draw text as well,
1676 * so we must be sure that correct font is selected
1678 if(!hfsave
&& (opcode
<= DST_PREFIXTEXT
)) goto cleanup
;
1679 tmp
= UITOOLS_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1680 if(hfsave
) SelectObject(memdc
, hfsave
);
1681 if(!tmp
) goto cleanup
;
1683 /* This state cause the image to be dithered */
1684 if(flags
& DSS_UNION
)
1686 hbsave
= SelectObject(memdc
, SYSCOLOR_Get55AABrush());
1687 if(!hbsave
) goto cleanup
;
1688 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1689 SelectObject(memdc
, hbsave
);
1690 if(!tmp
) goto cleanup
;
1693 if (flags
& DSS_DISABLED
)
1694 hbrtmp
= GetSysColorBrush(COLOR_3DHILIGHT
);
1695 else if (flags
& DSS_DEFAULT
)
1696 hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1698 /* Draw light or dark shadow */
1699 if (flags
& (DSS_DISABLED
|DSS_DEFAULT
))
1701 hbsave
= SelectObject(hdc
, hbrtmp
);
1702 if(!hbsave
) goto cleanup
;
1703 if(!BitBlt(hdc
, x
+1, y
+1, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1704 SelectObject(hdc
, hbsave
);
1707 if (flags
& DSS_DISABLED
)
1709 hbr
= GetSysColorBrush(COLOR_3DSHADOW
);
1713 hbr
= GetStockObject(BLACK_BRUSH
);
1716 hbsave
= SelectObject(hdc
, hbr
);
1718 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1720 retval
= TRUE
; /* We succeeded */
1723 SetTextColor(hdc
, fg
);
1724 SetBkColor(hdc
, bg
);
1726 if(hbsave
) SelectObject(hdc
, hbsave
);
1727 if(hbmsave
) SelectObject(memdc
, hbmsave
);
1728 if(hbm
) DeleteObject(hbm
);
1729 if(memdc
) DeleteDC(memdc
);
1734 /**********************************************************************
1735 * DrawStateA (USER32.@)
1737 BOOL WINAPI
DrawStateA(HDC hdc
, HBRUSH hbr
,
1738 DRAWSTATEPROC func
, LPARAM ldata
, WPARAM wdata
,
1739 INT x
, INT y
, INT cx
, INT cy
, UINT flags
)
1741 return UITOOLS_DrawState(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
);
1744 /**********************************************************************
1745 * DrawStateW (USER32.@)
1747 BOOL WINAPI
DrawStateW(HDC hdc
, HBRUSH hbr
,
1748 DRAWSTATEPROC func
, LPARAM ldata
, WPARAM wdata
,
1749 INT x
, INT y
, INT cx
, INT cy
, UINT flags
)
1751 return UITOOLS_DrawState(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, TRUE
);