2 * ReactOS User32 Library
3 * - Various drawing functions
5 * Copyright 2001 Casper S. Hournstroup
6 * Copyright 2003 Andrew Greenwood
7 * Copyright 2003 Filip Navara
8 * Copyright 2009 Matthias Kupfer
9 * Copyright 2017 Katayama Hirofumi MZ
13 * Copyright 1993, 1994 Alexandre Julliard
14 * Copyright 2002 Bill Medland
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 /* INCLUDES *******************************************************************/
35 #include <wine/debug.h>
37 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
39 /* GLOBALS *******************************************************************/
41 /* These tables are used in:
42 * UITOOLS_DrawDiagEdge()
43 * UITOOLS_DrawRectEdge()
45 static const signed char LTInnerNormal
[] = {
47 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
48 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
52 static const signed char LTOuterNormal
[] = {
53 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
54 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
55 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
56 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
59 static const signed char RBInnerNormal
[] = {
61 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
62 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
66 static const signed char RBOuterNormal
[] = {
67 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
68 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
69 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
70 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
73 static const signed char LTInnerSoft
[] = {
75 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
76 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
80 static const signed char LTOuterSoft
[] = {
81 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
82 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
83 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
84 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
87 #define RBInnerSoft RBInnerNormal /* These are the same */
88 #define RBOuterSoft RBOuterNormal
90 static const signed char LTRBOuterMono
[] = {
91 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
92 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
93 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
94 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
97 static const signed char LTRBInnerMono
[] = {
99 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
100 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
101 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
104 static const signed char LTRBOuterFlat
[] = {
105 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
106 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
107 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
108 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
111 static const signed char LTRBInnerFlat
[] = {
113 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
114 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
115 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
117 /* FUNCTIONS *****************************************************************/
120 HBRUSH WINAPI
GetSysColorBrush(int nIndex
);
122 /* Ported from WINE20020904 */
123 /* Same as DrawEdge invoked with BF_DIAGONAL */
124 static BOOL
IntDrawDiagEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
)
127 signed char InnerI
, OuterI
;
128 HPEN InnerPen
, OuterPen
;
133 int Width
= rc
->right
- rc
->left
;
134 int Height
= rc
->bottom
- rc
->top
;
135 int SmallDiam
= Width
> Height
? Height
: Width
;
136 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
137 || (uType
& BDR_OUTER
) == BDR_OUTER
)
138 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
139 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
140 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
143 OuterPen
= InnerPen
= (HPEN
)GetStockObject(NULL_PEN
);
144 SavePen
= (HPEN
)SelectObject(hdc
, InnerPen
);
145 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
147 /* Determine the colors of the edges */
150 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
151 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
153 else if(uFlags
& BF_FLAT
)
155 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
156 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
158 else if(uFlags
& BF_SOFT
)
160 if(uFlags
& BF_BOTTOM
)
162 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
163 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
167 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
168 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
173 if(uFlags
& BF_BOTTOM
)
175 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
176 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
180 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
181 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
185 if(InnerI
!= -1) InnerPen
= GetStockObject(DC_PEN
);
186 if(OuterI
!= -1) OuterPen
= GetStockObject(DC_PEN
);
188 MoveToEx(hdc
, 0, 0, &SavePoint
);
190 /* Don't ask me why, but this is what is visible... */
191 /* This must be possible to do much simpler, but I fail to */
192 /* see the logic in the MS implementation (sigh...). */
193 /* So, this might look a bit brute force here (and it is), but */
194 /* it gets the job done;) */
196 switch(uFlags
& BF_RECT
)
202 /* Left bottom endpoint */
204 spx
= epx
+ SmallDiam
;
206 spy
= epy
- SmallDiam
;
211 /* Left top endpoint */
213 spx
= epx
+ SmallDiam
;
215 spy
= epy
+ SmallDiam
;
221 case BF_RIGHT
|BF_LEFT
:
222 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
223 case BF_BOTTOM
|BF_TOP
:
224 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
225 case BF_BOTTOMRIGHT
|BF_LEFT
:
226 case BF_BOTTOMRIGHT
|BF_TOP
:
228 /* Right top endpoint */
230 epx
= spx
+ SmallDiam
;
232 epy
= spy
- SmallDiam
;
236 MoveToEx(hdc
, spx
, spy
, NULL
);
237 SelectObject(hdc
, OuterPen
);
238 SetDCPenColor(hdc
, GetSysColor(OuterI
));
239 LineTo(hdc
, epx
, epy
);
241 SelectObject(hdc
, InnerPen
);
242 SetDCPenColor(hdc
, GetSysColor(InnerI
));
244 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
246 case BF_DIAGONAL_ENDBOTTOMLEFT
:
247 case (BF_DIAGONAL
|BF_BOTTOM
):
249 case (BF_DIAGONAL
|BF_LEFT
):
250 MoveToEx(hdc
, spx
-1, spy
, NULL
);
251 LineTo(hdc
, epx
, epy
-1);
252 Points
[0].x
= spx
-add
;
254 Points
[1].x
= rc
->left
;
255 Points
[1].y
= rc
->top
;
257 Points
[2].y
= epy
-1-add
;
258 Points
[3] = Points
[2];
261 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
262 MoveToEx(hdc
, spx
-1, spy
, NULL
);
263 LineTo(hdc
, epx
, epy
+1);
264 Points
[0].x
= spx
-add
;
266 Points
[1].x
= rc
->left
;
267 Points
[1].y
= rc
->bottom
-1;
269 Points
[2].y
= epy
+1+add
;
270 Points
[3] = Points
[2];
273 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
274 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
275 case BF_DIAGONAL_ENDTOPRIGHT
:
276 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
277 MoveToEx(hdc
, spx
+1, spy
, NULL
);
278 LineTo(hdc
, epx
, epy
+1);
280 Points
[0].y
= epy
+1+add
;
281 Points
[1].x
= rc
->right
-1;
282 Points
[1].y
= rc
->top
+add
;
283 Points
[2].x
= rc
->right
-1;
284 Points
[2].y
= rc
->bottom
-1;
285 Points
[3].x
= spx
+add
;
289 case BF_DIAGONAL_ENDTOPLEFT
:
290 MoveToEx(hdc
, spx
, spy
-1, NULL
);
291 LineTo(hdc
, epx
+1, epy
);
292 Points
[0].x
= epx
+1+add
;
294 Points
[1].x
= rc
->right
-1;
295 Points
[1].y
= rc
->top
;
296 Points
[2].x
= rc
->right
-1;
297 Points
[2].y
= rc
->bottom
-1-add
;
299 Points
[3].y
= spy
-add
;
302 case (BF_DIAGONAL
|BF_TOP
):
303 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
304 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
305 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
306 LineTo(hdc
, epx
, epy
);
309 Points
[1].x
= rc
->right
-1;
310 Points
[1].y
= rc
->top
;
311 Points
[2].x
= rc
->right
-1;
312 Points
[2].y
= rc
->bottom
-1-add
;
313 Points
[3].x
= spx
+add
;
314 Points
[3].y
= spy
-add
;
317 case (BF_DIAGONAL
|BF_RIGHT
):
318 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
319 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
320 MoveToEx(hdc
, spx
, spy
, NULL
);
321 LineTo(hdc
, epx
-1, epy
+1);
324 Points
[1].x
= rc
->left
;
325 Points
[1].y
= rc
->top
+add
;
326 Points
[2].x
= epx
-1-add
;
327 Points
[2].y
= epy
+1+add
;
328 Points
[3] = Points
[2];
332 /* Fill the interior if asked */
333 if((uFlags
& BF_MIDDLE
) && retval
)
337 hbsave
= (HBRUSH
)SelectObject(hdc
, GetStockObject(DC_BRUSH
));
338 hpsave
= (HPEN
)SelectObject(hdc
, GetStockObject(DC_PEN
));
339 SetDCBrushColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
340 SetDCPenColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
341 Polygon(hdc
, Points
, 4);
342 SelectObject(hdc
, hbsave
);
343 SelectObject(hdc
, hpsave
);
346 /* Adjust rectangle if asked */
347 if(uFlags
& BF_ADJUST
)
349 if(uFlags
& BF_LEFT
) rc
->left
+= add
;
350 if(uFlags
& BF_RIGHT
) rc
->right
-= add
;
351 if(uFlags
& BF_TOP
) rc
->top
+= add
;
352 if(uFlags
& BF_BOTTOM
) rc
->bottom
-= add
;
356 SelectObject(hdc
, SavePen
);
357 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
362 /* Ported from WINE20020904 */
363 /* Same as DrawEdge invoked without BF_DIAGONAL
365 * 23-Nov-1997: Changed by Bertho Stultiens
366 * The width parameter sets the width of each outer and inner edge.
368 * Well, I started testing this and found out that there are a few things
369 * that weren't quite as win95. The following rewrite should reproduce
370 * win95 results completely.
371 * The colorselection is table-driven to avoid awfull if-statements.
372 * The table below show the color settings.
374 * Pen selection table for uFlags = 0
376 * uType | LTI | LTO | RBI | RBO
377 * ------+-------+-------+-------+-------
378 * 0000 | x | x | x | x
379 * 0001 | x | 22 | x | 21
380 * 0010 | x | 16 | x | 20
381 * 0011 | x | x | x | x
382 * ------+-------+-------+-------+-------
383 * 0100 | x | 20 | x | 16
384 * 0101 | 20 | 22 | 16 | 21
385 * 0110 | 20 | 16 | 16 | 20
386 * 0111 | x | x | x | x
387 * ------+-------+-------+-------+-------
388 * 1000 | x | 21 | x | 22
389 * 1001 | 21 | 22 | 22 | 21
390 * 1010 | 21 | 16 | 22 | 20
391 * 1011 | x | x | x | x
392 * ------+-------+-------+-------+-------
393 * 1100 | x | x | x | x
394 * 1101 | x | x (22)| x | x (21)
395 * 1110 | x | x (16)| x | x (20)
396 * 1111 | x | x | x | x
398 * Pen selection table for uFlags = BF_SOFT
400 * uType | LTI | LTO | RBI | RBO
401 * ------+-------+-------+-------+-------
402 * 0000 | x | x | x | x
403 * 0001 | x | 20 | x | 21
404 * 0010 | x | 21 | x | 20
405 * 0011 | x | x | x | x
406 * ------+-------+-------+-------+-------
407 * 0100 | x | 22 | x | 16
408 * 0101 | 22 | 20 | 16 | 21
409 * 0110 | 22 | 21 | 16 | 20
410 * 0111 | x | x | x | x
411 * ------+-------+-------+-------+-------
412 * 1000 | x | 16 | x | 22
413 * 1001 | 16 | 20 | 22 | 21
414 * 1010 | 16 | 21 | 22 | 20
415 * 1011 | x | x | x | x
416 * ------+-------+-------+-------+-------
417 * 1100 | x | x | x | x
418 * 1101 | x | x (20)| x | x (21)
419 * 1110 | x | x (21)| x | x (20)
420 * 1111 | x | x | x | x
422 * x = don't care; (n) = is what win95 actually uses
423 * LTI = left Top Inner line
424 * LTO = left Top Outer line
425 * RBI = Right Bottom Inner line
426 * RBO = Right Bottom Outer line
428 * 16 = COLOR_BTNSHADOW
429 * 20 = COLOR_BTNHIGHLIGHT
430 * 21 = COLOR_3DDKSHADOW
433 static BOOL
IntDrawRectEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
, UINT width
)
435 signed char LTInnerI
, LTOuterI
;
436 signed char RBInnerI
, RBOuterI
;
437 HBRUSH lti_brush
, lto_brush
, rbi_brush
, rbo_brush
;
438 RECT InnerRect
= *rc
, fill_rect
;
439 int lbi_offset
= 0, lti_offset
= 0, rti_offset
= 0, rbi_offset
= 0;
440 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
441 || (uType
& BDR_OUTER
) == BDR_OUTER
)
442 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
444 lti_brush
= lto_brush
= rbi_brush
= rbo_brush
= GetStockObject(NULL_BRUSH
);
446 /* Determine the colors of the edges */
449 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
450 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
452 else if(uFlags
& BF_FLAT
)
454 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
455 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
457 /* Bertho Stultiens states above that this function exactly matches win95
458 * In win98 BF_FLAT rectangles have an inner border same color as the
459 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
460 * I don't know I go with Bertho and just sets it for win98 until proven
462 * Dennis Björklund, 10 June, 99
464 if( LTInnerI
!= -1 ) LTInnerI
= RBInnerI
= COLOR_BTNFACE
;
466 else if(uFlags
& BF_SOFT
)
468 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
469 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
470 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
471 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
475 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
476 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
477 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
478 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
481 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
) lbi_offset
= width
;
482 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
) rti_offset
= width
;
483 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
) rbi_offset
= width
;
484 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
) lti_offset
= width
;
486 if(LTInnerI
!= -1) lti_brush
= GetSysColorBrush(LTInnerI
);
487 if(LTOuterI
!= -1) lto_brush
= GetSysColorBrush(LTOuterI
);
488 if(RBInnerI
!= -1) rbi_brush
= GetSysColorBrush(RBInnerI
);
489 if(RBOuterI
!= -1) rbo_brush
= GetSysColorBrush(RBOuterI
);
491 /* Draw the outer edge */
494 fill_rect
= InnerRect
;
495 fill_rect
.bottom
= fill_rect
.top
+ width
;
496 FillRect( hdc
, &fill_rect
, lto_brush
);
500 fill_rect
= InnerRect
;
501 fill_rect
.right
= fill_rect
.left
+ width
;
502 FillRect( hdc
, &fill_rect
, lto_brush
);
504 if(uFlags
& BF_BOTTOM
)
506 fill_rect
= InnerRect
;
507 fill_rect
.top
= fill_rect
.bottom
- width
;
508 FillRect( hdc
, &fill_rect
, rbo_brush
);
510 if(uFlags
& BF_RIGHT
)
512 fill_rect
= InnerRect
;
513 fill_rect
.left
= fill_rect
.right
- width
;
514 FillRect( hdc
, &fill_rect
, rbo_brush
);
517 /* Draw the inner edge */
520 SetRect( &fill_rect
, InnerRect
.left
+ lti_offset
, InnerRect
.top
+ width
,
521 InnerRect
.right
- rti_offset
, InnerRect
.top
+ 2 * width
);
522 FillRect( hdc
, &fill_rect
, lti_brush
);
526 SetRect( &fill_rect
, InnerRect
.left
+ width
, InnerRect
.top
+ lti_offset
,
527 InnerRect
.left
+ 2 * width
, InnerRect
.bottom
- lbi_offset
);
528 FillRect( hdc
, &fill_rect
, lti_brush
);
530 if(uFlags
& BF_BOTTOM
)
532 SetRect( &fill_rect
, InnerRect
.left
+ lbi_offset
, InnerRect
.bottom
- 2 * width
,
533 InnerRect
.right
- rbi_offset
, InnerRect
.bottom
- width
);
534 FillRect( hdc
, &fill_rect
, rbi_brush
);
536 if(uFlags
& BF_RIGHT
)
538 SetRect( &fill_rect
, InnerRect
.right
- 2 * width
, InnerRect
.top
+ rti_offset
,
539 InnerRect
.right
- width
, InnerRect
.bottom
- rbi_offset
);
540 FillRect( hdc
, &fill_rect
, rbi_brush
);
543 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
545 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? width
: 0)
546 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? width
: 0);
548 if(uFlags
& BF_LEFT
) InnerRect
.left
+= add
;
549 if(uFlags
& BF_RIGHT
) InnerRect
.right
-= add
;
550 if(uFlags
& BF_TOP
) InnerRect
.top
+= add
;
551 if(uFlags
& BF_BOTTOM
) InnerRect
.bottom
-= add
;
553 if((uFlags
& BF_MIDDLE
) && retval
)
555 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
556 COLOR_WINDOW
: COLOR_BTNFACE
));
559 if(uFlags
& BF_ADJUST
)
566 /* Ported from WINE20020904 */
567 /* Utility to create a square rectangle and returning the width */
568 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
570 int Width
= src
->right
- src
->left
;
571 int Height
= src
->bottom
- src
->top
;
572 int SmallDiam
= Width
> Height
? Height
: Width
;
576 /* Make it a square box */
577 if(Width
< Height
) /* SmallDiam == Width */
579 dst
->top
+= (Height
-Width
)/2;
580 dst
->bottom
= dst
->top
+ SmallDiam
;
582 else if(Width
> Height
) /* SmallDiam == Height */
584 dst
->left
+= (Width
-Height
)/2;
585 dst
->right
= dst
->left
+ SmallDiam
;
591 /* Ported from WINE20020904 */
592 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
594 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
599 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
600 bg
= SetBkColor(dc
, RGB(255, 255, 255));
601 hbsave
= (HBRUSH
)SelectObject(dc
, gpsi
->hbrGray
);
602 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
603 SelectObject(dc
, hbsave
);
608 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
612 /* Ported from WINE20020904 */
613 /* Draw a push button coming from DrawFrameControl()
615 * Does a pretty good job in emulating MS behavior. Some quirks are
616 * however there because MS uses a TrueType font (Marlett) to draw
619 * FIXME: This looks a little bit strange, needs to be rewritten completely
620 * (several quirks with adjust, DFCS_CHECKED aso)
622 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
627 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
632 if(uFlags
& DFCS_CHECKED
)
634 if(uFlags
& DFCS_MONO
)
635 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
, 1);
637 IntDrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
, 1);
639 UITOOLS_DrawCheckedRect( dc
, &myr
);
643 if(uFlags
& DFCS_MONO
)
645 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
, 1);
646 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
650 IntDrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
| BF_SOFT
, 1);
654 /* Adjust rectangle if asked */
655 if(uFlags
& DFCS_ADJUSTRECT
)
656 InflateRect(r
, -2, -2);
661 static BOOL
UITOOLS95_DFC_ButtonCheckRadio(HDC dc
, LPRECT r
, UINT uFlags
, BOOL Radio
)
664 HFONT hFont
, hOldFont
;
666 TCHAR OutRight
, OutLeft
, InRight
, InLeft
, Center
;
667 INT X
, Y
, Width
, Height
, Shorter
;
668 INT BkMode
= GetBkMode(dc
);
669 COLORREF TextColor
= GetTextColor(dc
);
671 Width
= r
->right
- r
->left
;
672 Height
= r
->bottom
- r
->top
;
673 Shorter
= (Width
< Height
) ? Width
: Height
;
674 X
= r
->left
+ (Width
- Shorter
) / 2;
675 Y
= r
->top
+ (Height
- Shorter
) / 2;
679 OutRight
= 'j'; // Outer right
680 OutLeft
= 'k'; // Outer left
681 InRight
= 'l'; // inner left
682 InLeft
= 'm'; // inner right
683 Center
= 'n'; // center
687 OutRight
= 'c'; // Outer right
688 OutLeft
= 'd'; // Outer left
689 InRight
= 'e'; // inner left
690 InLeft
= 'f'; // inner right
691 Center
= 'g'; // center
694 ZeroMemory(&lf
, sizeof(LOGFONTW
));
695 lf
.lfHeight
= Shorter
;
696 lf
.lfCharSet
= DEFAULT_CHARSET
;
697 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
698 if (Radio
&& ((uFlags
& 0xFF) == DFCS_BUTTONRADIOMASK
))
700 lf
.lfQuality
= NONANTIALIASED_QUALITY
;
702 hFont
= CreateFontIndirect(&lf
);
703 hOldFont
= SelectObject(dc
, hFont
);
705 if (Radio
&& ((uFlags
& 0xFF) == DFCS_BUTTONRADIOMASK
))
708 // FIXME: improve font rendering
710 HGDIOBJ hbrOld
, hpenOld
;
711 FillRect(dc
, r
, (HBRUSH
)GetStockObject(WHITE_BRUSH
));
712 SetRect(&Rect
, X
, Y
, X
+ Shorter
, Y
+ Shorter
);
713 InflateRect(&Rect
, -(Shorter
* 8) / 54, -(Shorter
* 8) / 54);
714 hbrOld
= SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
715 hpenOld
= SelectObject(dc
, GetStockObject(NULL_PEN
));
716 Ellipse(dc
, Rect
.left
, Rect
.top
, Rect
.right
, Rect
.bottom
);
717 SelectObject(dc
, hbrOld
);
718 SelectObject(dc
, hpenOld
);
720 SetBkMode(dc
, OPAQUE
);
721 SetBkColor(dc
, RGB(255, 255, 255));
722 SetTextColor(dc
, RGB(0, 0, 0));
723 TextOut(dc
, X
, Y
, &Center
, 1);
724 SetBkMode(dc
, TRANSPARENT
);
725 TextOut(dc
, X
, Y
, &OutRight
, 1);
726 TextOut(dc
, X
, Y
, &OutLeft
, 1);
727 TextOut(dc
, X
, Y
, &InRight
, 1);
728 TextOut(dc
, X
, Y
, &InLeft
, 1);
733 SetBkMode(dc
, TRANSPARENT
);
735 /* Center section, white for active, grey for inactive */
736 if ((uFlags
& (DFCS_INACTIVE
| DFCS_PUSHED
)))
740 SetTextColor(dc
, GetSysColor(i
));
741 TextOut(dc
, X
, Y
, &Center
, 1);
743 if (uFlags
& (DFCS_FLAT
| DFCS_MONO
))
745 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
746 TextOut(dc
, X
, Y
, &OutRight
, 1);
747 TextOut(dc
, X
, Y
, &OutLeft
, 1);
748 TextOut(dc
, X
, Y
, &InRight
, 1);
749 TextOut(dc
, X
, Y
, &InLeft
, 1);
753 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
754 TextOut(dc
, X
, Y
, &OutRight
, 1);
755 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
756 TextOut(dc
, X
, Y
, &OutLeft
, 1);
757 SetTextColor(dc
, GetSysColor(COLOR_3DDKSHADOW
));
758 TextOut(dc
, X
, Y
, &InRight
, 1);
759 SetTextColor(dc
, GetSysColor(COLOR_3DLIGHT
));
760 TextOut(dc
, X
, Y
, &InLeft
, 1);
763 if (uFlags
& DFCS_CHECKED
)
765 TCHAR Check
= (Radio
) ? 'i' : 'b';
767 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
768 TextOut(dc
, X
, Y
, &Check
, 1);
772 SelectObject(dc
, hOldFont
);
775 SetTextColor(dc
, TextColor
);
776 SetBkMode(dc
, BkMode
);
781 /* Ported from WINE20020904 */
782 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
784 switch(uState
& 0xff)
786 case DFCS_BUTTONPUSH
:
787 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
789 case DFCS_BUTTONCHECK
:
790 case DFCS_BUTTON3STATE
:
791 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, FALSE
);
793 case DFCS_BUTTONRADIOIMAGE
:
794 case DFCS_BUTTONRADIOMASK
:
795 case DFCS_BUTTONRADIO
:
796 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, TRUE
);
800 DbgPrint("Invalid button state=0x%04x\n", uState);
807 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
810 HFONT hFont
, hOldFont
;
815 switch(uFlags
& 0xff)
817 case DFCS_CAPTIONCLOSE
:
820 case DFCS_CAPTIONHELP
:
823 case DFCS_CAPTIONMIN
:
826 case DFCS_CAPTIONMAX
:
829 case DFCS_CAPTIONRESTORE
:
833 WARN("Invalid caption; flags=0x%04x\n", uFlags
);
836 IntDrawRectEdge(dc
,r
,(uFlags
&DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, BF_RECT
| BF_MIDDLE
| BF_SOFT
, 1);
837 ZeroMemory(&lf
, sizeof(LOGFONTW
));
838 UITOOLS_MakeSquareRect(r
, &myr
);
843 if(uFlags
& DFCS_PUSHED
)
844 OffsetRect(&myr
,1,1);
845 lf
.lfHeight
= myr
.bottom
- myr
.top
;
847 lf
.lfWeight
= FW_NORMAL
;
848 lf
.lfCharSet
= DEFAULT_CHARSET
;
849 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
850 hFont
= CreateFontIndirect(&lf
);
851 /* save font and text color */
852 hOldFont
= SelectObject(dc
, hFont
);
853 clrsave
= GetTextColor(dc
);
854 bkmode
= GetBkMode(dc
);
855 /* set color and drawing mode */
856 SetBkMode(dc
, TRANSPARENT
);
857 if(uFlags
& DFCS_INACTIVE
)
860 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
861 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
863 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
864 /* draw selected symbol */
865 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
866 /* restore previous settings */
867 SetTextColor(dc
, clrsave
);
868 SelectObject(dc
, hOldFont
);
869 SetBkMode(dc
, bkmode
);
874 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
877 HFONT hFont
, hOldFont
;
882 switch(uFlags
& 0xff)
884 case DFCS_SCROLLCOMBOBOX
:
885 case DFCS_SCROLLDOWN
:
893 case DFCS_SCROLLLEFT
:
897 case DFCS_SCROLLRIGHT
:
901 case DFCS_SCROLLSIZEGRIP
:
902 case DFCS_SCROLLSIZEGRIPRIGHT
:
903 ZeroMemory(&lf
, sizeof(LOGFONTW
));
904 UITOOLS_MakeSquareRect(r
, &myr
);
905 lf
.lfHeight
= myr
.bottom
- myr
.top
;
907 lf
.lfWeight
= FW_NORMAL
;
908 lf
.lfCharSet
= DEFAULT_CHARSET
;
909 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
910 hFont
= CreateFontIndirect(&lf
);
911 /* save font and text color */
912 hOldFont
= SelectObject(dc
, hFont
);
913 clrsave
= GetTextColor(dc
);
914 bkmode
= GetBkMode(dc
);
915 /* set color and drawing mode */
916 SetBkMode(dc
, TRANSPARENT
);
917 if (!(uFlags
& (DFCS_MONO
| DFCS_FLAT
)))
919 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
920 /* draw selected symbol */
921 Symbol
= ((uFlags
& 0xff) == DFCS_SCROLLSIZEGRIP
) ? 'o' : 'x';
922 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
923 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
925 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
926 /* draw selected symbol */
927 Symbol
= ((uFlags
& 0xff) == DFCS_SCROLLSIZEGRIP
) ? 'p' : 'y';
928 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
929 /* restore previous settings */
930 SetTextColor(dc
, clrsave
);
931 SelectObject(dc
, hOldFont
);
932 SetBkMode(dc
, bkmode
);
936 WARN("Invalid scroll; flags=0x%04x\n", uFlags
);
939 IntDrawRectEdge(dc
, r
, (uFlags
& DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
, 1);
940 ZeroMemory(&lf
, sizeof(LOGFONTW
));
941 UITOOLS_MakeSquareRect(r
, &myr
);
946 if(uFlags
& DFCS_PUSHED
)
947 OffsetRect(&myr
,1,1);
948 lf
.lfHeight
= myr
.bottom
- myr
.top
;
950 lf
.lfWeight
= FW_NORMAL
;
951 lf
.lfCharSet
= DEFAULT_CHARSET
;
952 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
953 hFont
= CreateFontIndirect(&lf
);
954 /* save font and text color */
955 hOldFont
= SelectObject(dc
, hFont
);
956 clrsave
= GetTextColor(dc
);
957 bkmode
= GetBkMode(dc
);
958 /* set color and drawing mode */
959 SetBkMode(dc
, TRANSPARENT
);
960 if(uFlags
& DFCS_INACTIVE
)
963 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
964 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
966 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
967 /* draw selected symbol */
968 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
969 /* restore previous settings */
970 SetTextColor(dc
, clrsave
);
971 SelectObject(dc
, hOldFont
);
972 SetBkMode(dc
, bkmode
);
977 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
980 HFONT hFont
, hOldFont
;
982 switch(uFlags
& 0xff)
984 case DFCS_MENUARROWUP
:
988 case DFCS_MENUARROWDOWN
:
996 case DFCS_MENUARROWRIGHT
:
997 Symbol
= 'w'; // FIXME: needs to confirm
1000 case DFCS_MENUBULLET
:
1004 case DFCS_MENUCHECK
:
1009 WARN("Invalid menu; flags=0x%04x\n", uFlags
);
1012 /* acquire ressources only if valid menu */
1013 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1014 lf
.lfHeight
= r
->bottom
- r
->top
;
1016 lf
.lfWeight
= FW_NORMAL
;
1017 lf
.lfCharSet
= DEFAULT_CHARSET
;
1018 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
1019 hFont
= CreateFontIndirect(&lf
);
1021 hOldFont
= SelectObject(dc
, hFont
);
1023 if ((uFlags
& 0xff) == DFCS_MENUARROWUP
||
1024 (uFlags
& 0xff) == DFCS_MENUARROWDOWN
)
1027 if (uFlags
& DFCS_INACTIVE
)
1030 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
1031 TextOut(dc
, r
->left
+ 1, r
->top
+ 1, &Symbol
, 1);
1034 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
1036 /* draw selected symbol */
1037 TextOut(dc
, r
->left
, r
->top
, &Symbol
, 1);
1038 /* restore previous settings */
1039 SelectObject(dc
, hOldFont
);
1040 DeleteObject(hFont
);
1049 GRAYSTRINGPROC lpOutputFunc
,
1058 // AG: Mostly implemented, but probably won't work properly or return
1059 // correct error codes. I doubt it grays strings either... Untested!
1061 BOOL success
= FALSE
;
1064 HBITMAP MemBMP
= NULL
, OldBMP
= NULL
;
1065 HBRUSH OldBrush
= NULL
;
1066 HFONT OldFont
= NULL
;
1068 COLORREF ForeColor
, BackColor
;
1070 ForeColor
= SetTextColor(hDC
, RGB(0, 0, 0));
1071 BackColor
= SetBkColor(hDC
, RGB(255, 255, 255));
1075 // The documentation is a little vague on what exactly should happen
1076 // here. Something about using the same brush for window text???
1077 hBrush
= (HBRUSH
) GetCurrentObject(hDC
, OBJ_BRUSH
);
1080 if ((nCount
== -1) && (! lpOutputFunc
))
1085 // TODO: calculate the length (easy enough)
1088 nCount
= lstrlenW((WCHAR
*)lpData
);
1090 nCount
= lstrlenA((CHAR
*)lpData
);
1093 if (! nWidth
|| ! nHeight
)
1096 // TODO: calculate the rect
1099 success
= GetTextExtentPoint32W(hDC
, (WCHAR
*) lpData
, nCount
, &s
);
1101 success
= GetTextExtentPoint32A(hDC
, (CHAR
*) lpData
, nCount
, &s
);
1103 if (! success
) goto cleanup
;
1105 if (! nWidth
) nWidth
= s
.cx
;
1106 if (! nHeight
) nHeight
= s
.cy
;
1109 SetRect(&r
, X
, Y
, X
+ nWidth
, Y
+ nHeight
);
1111 MemDC
= CreateCompatibleDC(hDC
);
1112 if (! MemDC
) goto cleanup
;
1113 MemBMP
= CreateBitmap(nWidth
, nHeight
, 1, 1, NULL
);
1114 if (! MemBMP
) goto cleanup
;
1115 OldBMP
= SelectObject(MemDC
, MemBMP
);
1116 if (! OldBMP
) goto cleanup
;
1117 OldFont
= SelectObject(MemDC
, GetCurrentObject(hDC
, OBJ_FONT
));
1118 if (! OldFont
) goto cleanup
;
1119 OldBrush
= SelectObject(MemDC
, hBrush
);
1120 if (! OldBrush
) goto cleanup
;
1122 if (! BitBlt(MemDC
, 0, 0, nWidth
, nHeight
, hDC
, X
, Y
, SRCCOPY
)) goto cleanup
;
1124 SetTextColor(MemDC
, RGB(255, 255, 255));
1125 SetBkColor(MemDC
, RGB(0, 0, 0));
1129 success
= lpOutputFunc(MemDC
, lpData
, nCount
); // Set brush etc first?
1131 if ((nCount
== -1) && (! success
))
1133 // Don't gray (documented behaviour)
1134 success
= (BOOL
) BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
);
1141 success
= TextOutW(MemDC
, 0, 0, (WCHAR
*) lpData
, nCount
);
1143 success
= TextOutA(MemDC
, 0, 0, (CHAR
*) lpData
, nCount
);
1145 if (! success
) goto cleanup
;
1147 hbsave
= (HBRUSH
)SelectObject(MemDC
, gpsi
->hbrGray
);
1148 PatBlt(MemDC
, 0, 0, nWidth
, nHeight
, 0x000A0329);
1149 SelectObject(MemDC
, hbsave
);
1152 if (! BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
)) goto cleanup
;
1155 SetTextColor(hDC
, ForeColor
);
1156 SetBkColor(hDC
, BackColor
);
1160 if (OldFont
) SelectObject(MemDC
, OldFont
);
1161 if (OldBrush
) SelectObject(MemDC
, OldBrush
);
1162 if (OldBMP
) SelectObject(MemDC
, OldBMP
);
1163 if (MemBMP
) DeleteObject(MemBMP
);
1170 /**********************************************************************
1171 * PAINTING_DrawStateJam
1173 * Jams in the requested type in the dc
1175 static BOOL
PAINTING_DrawStateJam(HDC hdc
, UINT opcode
,
1176 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1177 LPRECT rc
, UINT dtflags
, BOOL unicode
)
1182 INT cx
= rc
->right
- rc
->left
;
1183 INT cy
= rc
->bottom
- rc
->top
;
1188 case DST_PREFIXTEXT
:
1190 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1192 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1195 return DrawIconEx(hdc
, rc
->left
, rc
->top
, (HICON
)lp
, cx
, cy
, 0, NULL
, DI_NORMAL
);
1198 memdc
= CreateCompatibleDC(hdc
);
1201 hbmsave
= (HBITMAP
)SelectObject(memdc
, (HBITMAP
)lp
);
1207 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
1208 SelectObject(memdc
, hbmsave
);
1216 /* DRAWSTATEPROC assumes that it draws at the center of coordinates */
1218 OffsetViewportOrgEx(hdc
, rc
->left
, rc
->top
, NULL
);
1219 bRet
= func(hdc
, lp
, wp
, cx
, cy
);
1220 /* Restore origin */
1221 OffsetViewportOrgEx(hdc
, -rc
->left
, -rc
->top
, NULL
);
1233 IntDrawState(HDC hdc
, HBRUSH hbr
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1234 INT x
, INT y
, INT cx
, INT cy
, UINT flags
, BOOL unicode
)
1236 HBITMAP hbm
, hbmsave
;
1238 HBRUSH hbsave
, hbrtmp
= 0;
1241 UINT dtflags
= DT_NOCLIP
;
1243 UINT opcode
= flags
& 0xf;
1247 HFONT hFontOriginal
, hNaaFont
= NULL
;
1249 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
1252 len
= lstrlenW((LPWSTR
)lp
);
1254 len
= lstrlenA((LPSTR
)lp
);
1257 hFontOriginal
= GetCurrentObject(hdc
, OBJ_FONT
);
1258 if (flags
& (DSS_MONO
| DSS_DISABLED
))
1260 /* Create a non-antialiased font */
1261 GetObjectW(hFontOriginal
, sizeof(lf
), &lf
);
1262 lf
.lfQuality
= NONANTIALIASED_QUALITY
;
1263 hNaaFont
= CreateFontIndirectW(&lf
);
1266 /* Find out what size the image has if not given by caller */
1275 case DST_PREFIXTEXT
:
1277 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
1279 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
1285 if(!get_icon_size((HICON
)lp
, &s
))
1290 if(!GetObjectW((HBITMAP
)lp
, sizeof(bm
), &bm
))
1296 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1300 ERR("Invalid opcode: %u\n", opcode
);
1308 SetRect(&rc
, x
, y
, x
+ cx
, y
+ cy
);
1310 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1311 dtflags
|= DT_RIGHT
;
1312 if(opcode
== DST_TEXT
)
1313 dtflags
|= DT_NOPREFIX
;
1314 else if(opcode
== DST_PREFIXTEXT
)
1316 if (flags
& DSS_HIDEPREFIX
)
1317 dtflags
|= DT_HIDEPREFIX
;
1318 if (flags
& DSS_PREFIXONLY
)
1319 dtflags
|= DT_PREFIXONLY
;
1322 /* For DSS_NORMAL we just jam in the image and return */
1323 if((flags
& 0x79f0) == DSS_NORMAL
)
1325 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1328 /* For all other states we need to convert the image to B/W in a local bitmap */
1329 /* before it is displayed */
1330 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1331 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1332 hbm
= NULL
; hbmsave
= NULL
;
1333 memdc
= NULL
; hbsave
= NULL
;
1334 retval
= FALSE
; /* assume failure */
1336 /* From here on we must use "goto cleanup" when something goes wrong */
1337 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1338 if(!hbm
) goto cleanup
;
1339 memdc
= CreateCompatibleDC(hdc
);
1340 if(!memdc
) goto cleanup
;
1341 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
1342 if(!hbmsave
) goto cleanup
;
1343 SetRect(&rc
, 0, 0, cx
, cy
);
1344 if(!FillRect(memdc
, &rc
, (HBRUSH
)GetStockObject(WHITE_BRUSH
))) goto cleanup
;
1345 SetBkColor(memdc
, RGB(255, 255, 255));
1346 SetTextColor(memdc
, RGB(0, 0, 0));
1348 hfsave
= (HFONT
)SelectObject(memdc
, hNaaFont
);
1350 hfsave
= (HFONT
)SelectObject(memdc
, hFontOriginal
);
1351 SetLayout( memdc
, GetLayout( hdc
));
1353 /* DST_COMPLEX may draw text as well,
1354 * so we must be sure that correct font is selected
1356 if(!hfsave
&& (opcode
<= DST_PREFIXTEXT
)) goto cleanup
;
1357 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1358 if(hfsave
) SelectObject(memdc
, hfsave
);
1359 if (hNaaFont
) DeleteObject(hNaaFont
);
1360 if(!tmp
) goto cleanup
;
1362 /* This state cause the image to be dithered */
1363 if(flags
& DSS_UNION
)
1365 hbsave
= (HBRUSH
)SelectObject(memdc
, gpsi
->hbrGray
);
1366 if(!hbsave
) goto cleanup
;
1367 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1368 SelectObject(memdc
, hbsave
);
1369 if(!tmp
) goto cleanup
;
1372 if (flags
& DSS_DISABLED
)
1373 hbrtmp
= GetSysColorBrush(COLOR_3DHILIGHT
);
1374 else if (flags
& DSS_DEFAULT
)
1375 hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1377 /* Draw light or dark shadow */
1378 if (flags
& (DSS_DISABLED
|DSS_DEFAULT
))
1380 if(!hbrtmp
) goto cleanup
;
1381 hbsave
= (HBRUSH
)SelectObject(hdc
, hbrtmp
);
1382 if(!hbsave
) goto cleanup
;
1383 if(!BitBlt(hdc
, x
+1, y
+1, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1384 SelectObject(hdc
, hbsave
);
1387 if (flags
& DSS_DISABLED
)
1389 hbr
= hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1390 if(!hbrtmp
) goto cleanup
;
1394 hbr
= (HBRUSH
)GetStockObject(BLACK_BRUSH
);
1397 hbsave
= (HBRUSH
)SelectObject(hdc
, hbr
);
1399 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1401 retval
= TRUE
; /* We succeeded */
1404 SetTextColor(hdc
, fg
);
1405 SetBkColor(hdc
, bg
);
1407 if(hbsave
) SelectObject(hdc
, hbsave
);
1408 if(hbmsave
) SelectObject(memdc
, hbmsave
);
1409 if(hbm
) DeleteObject(hbm
);
1410 if(memdc
) DeleteDC(memdc
);
1419 RealDrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1421 if (GetMapMode(hDC
) != MM_TEXT
)
1427 return UITOOLS95_DrawFrameButton(hDC
, rc
, uState
);
1429 return UITOOLS95_DrawFrameCaption(hDC
, rc
, uState
);
1431 return UITOOLS95_DrawFrameMenu(hDC
, rc
, uState
);
1438 return UITOOLS95_DrawFrameScroll(hDC
, rc
, uState
);
1444 DrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1446 BOOL Hook
, Ret
= FALSE
;
1450 Hook
= BeginIfHookedUserApiHook();
1452 /* Bypass SEH and go direct. */
1453 if (!Hook
) return RealDrawFrameControl(hDC
, rc
, uType
, uState
);
1457 Ret
= guah
.DrawFrameControl(hDC
, rc
, uType
, uState
);
1459 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1473 DrawEdge(HDC hDC
, LPRECT rc
, UINT edge
, UINT flags
)
1475 if (flags
& BF_DIAGONAL
)
1476 return IntDrawDiagEdge(hDC
, rc
, edge
, flags
);
1478 return IntDrawRectEdge(hDC
, rc
, edge
, flags
, 1);
1485 GrayStringA(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1486 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1488 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, FALSE
);
1495 GrayStringW(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1496 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1498 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, TRUE
);
1505 InvertRect(HDC hDC
, CONST RECT
*lprc
)
1507 return PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1508 lprc
->bottom
- lprc
->top
, DSTINVERT
);
1515 FrameRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1520 if (IsRectEmpty(&r
)) return 0;
1521 if (!(oldbrush
= SelectObject(hDC
, hbr
))) return 0;
1523 PatBlt(hDC
, r
.left
, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1524 PatBlt(hDC
, r
.right
- 1, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1525 PatBlt(hDC
, r
.left
, r
.top
, r
.right
- r
.left
, 1, PATCOPY
);
1526 PatBlt(hDC
, r
.left
, r
.bottom
- 1, r
.right
- r
.left
, 1, PATCOPY
);
1528 SelectObject(hDC
, oldbrush
);
1536 FlashWindow(HWND hWnd
, BOOL bInvert
)
1538 FLASHWINFO FlashWndInfo
;
1540 FlashWndInfo
.cbSize
= sizeof(FLASHWINFO
);
1541 FlashWndInfo
.hwnd
= hWnd
;
1542 FlashWndInfo
.dwFlags
= !bInvert
? 0 : (FLASHW_TRAY
| FLASHW_CAPTION
);
1543 FlashWndInfo
.uCount
= 1;
1544 FlashWndInfo
.dwTimeout
= 0;
1546 return NtUserFlashWindowEx(&FlashWndInfo
);
1553 FillRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1556 HBRUSH prevhbr
= NULL
;
1558 /* Select brush if specified */
1561 /* Handle system colors */
1562 if (hbr
<= (HBRUSH
)(COLOR_MENUBAR
+ 1))
1563 hbr
= GetSysColorBrush(PtrToUlong(hbr
) - 1);
1565 prevhbr
= SelectObject(hDC
, hbr
);
1566 if (prevhbr
== NULL
)
1570 Ret
= PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1571 lprc
->bottom
- lprc
->top
, PATCOPY
);
1573 /* Select old brush */
1575 SelectObject(hDC
, prevhbr
);
1584 DrawFocusRect(HDC hdc
, CONST RECT
*rect
)
1589 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH
, 0, &cx
, 0);
1590 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT
, 0, &cy
, 0);
1592 OldObj
= SelectObject(hdc
, gpsi
->hbrGray
);
1595 PatBlt(hdc
, rect
->left
, rect
->top
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1597 PatBlt(hdc
, rect
->left
, rect
->bottom
- cy
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1599 PatBlt(hdc
, rect
->left
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1601 PatBlt(hdc
, rect
->right
- cx
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1603 SelectObject(hdc
, OldObj
);
1611 DrawStateA(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1612 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1614 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, FALSE
);
1621 DrawStateW(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1622 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1624 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, TRUE
);