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
12 * Copyright 1993, 1994 Alexandre Julliard
13 * Copyright 2002 Bill Medland
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 /* INCLUDES *******************************************************************/
34 #include <wine/debug.h>
36 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
38 /* GLOBALS *******************************************************************/
40 static const WORD wPattern_AA55
[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
41 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
43 /* These tables are used in:
44 * UITOOLS_DrawDiagEdge()
45 * UITOOLS_DrawRectEdge()
47 static const signed char LTInnerNormal
[] = {
49 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
50 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
54 static const signed char LTOuterNormal
[] = {
55 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
56 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
57 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
58 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
61 static const signed char RBInnerNormal
[] = {
63 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
64 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
68 static const signed char RBOuterNormal
[] = {
69 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
70 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
71 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
72 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
75 static const signed char LTInnerSoft
[] = {
77 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
78 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
82 static const signed char LTOuterSoft
[] = {
83 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
84 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
85 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
86 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
89 #define RBInnerSoft RBInnerNormal /* These are the same */
90 #define RBOuterSoft RBOuterNormal
92 static const signed char LTRBOuterMono
[] = {
93 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
94 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
95 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
96 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
99 static const signed char LTRBInnerMono
[] = {
101 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
102 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
103 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
106 static const signed char LTRBOuterFlat
[] = {
107 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
108 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
109 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
110 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
113 static const signed char LTRBInnerFlat
[] = {
115 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
116 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
117 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
119 /* FUNCTIONS *****************************************************************/
122 HBRUSH WINAPI
GetSysColorBrush(int nIndex
);
124 /* Ported from WINE20020904 */
125 /* Same as DrawEdge invoked with BF_DIAGONAL */
126 static BOOL
IntDrawDiagEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
)
129 signed char InnerI
, OuterI
;
130 HPEN InnerPen
, OuterPen
;
135 int Width
= rc
->right
- rc
->left
;
136 int Height
= rc
->bottom
- rc
->top
;
137 int SmallDiam
= Width
> Height
? Height
: Width
;
138 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
139 || (uType
& BDR_OUTER
) == BDR_OUTER
)
140 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
141 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
142 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
145 OuterPen
= InnerPen
= (HPEN
)GetStockObject(NULL_PEN
);
146 SavePen
= (HPEN
)SelectObject(hdc
, InnerPen
);
147 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
149 /* Determine the colors of the edges */
152 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
153 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
155 else if(uFlags
& BF_FLAT
)
157 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
158 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
160 else if(uFlags
& BF_SOFT
)
162 if(uFlags
& BF_BOTTOM
)
164 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
165 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
169 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
170 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
175 if(uFlags
& BF_BOTTOM
)
177 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
178 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
182 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
183 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
188 InnerPen
= GetStockObject(DC_PEN
);
190 OuterPen
= GetStockObject(DC_PEN
);
192 MoveToEx(hdc
, 0, 0, &SavePoint
);
194 /* Don't ask me why, but this is what is visible... */
195 /* This must be possible to do much simpler, but I fail to */
196 /* see the logic in the MS implementation (sigh...). */
197 /* So, this might look a bit brute force here (and it is), but */
198 /* it gets the job done;) */
200 switch(uFlags
& BF_RECT
)
206 /* Left bottom endpoint */
208 spx
= epx
+ SmallDiam
;
210 spy
= epy
- SmallDiam
;
215 /* Left top endpoint */
217 spx
= epx
+ SmallDiam
;
219 spy
= epy
+ SmallDiam
;
225 case BF_RIGHT
|BF_LEFT
:
226 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
227 case BF_BOTTOM
|BF_TOP
:
228 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
229 case BF_BOTTOMRIGHT
|BF_LEFT
:
230 case BF_BOTTOMRIGHT
|BF_TOP
:
232 /* Right top endpoint */
234 epx
= spx
+ SmallDiam
;
236 epy
= spy
- SmallDiam
;
240 MoveToEx(hdc
, spx
, spy
, NULL
);
241 SelectObject(hdc
, OuterPen
);
242 SetDCPenColor(hdc
, GetSysColor(OuterI
));
243 LineTo(hdc
, epx
, epy
);
245 SelectObject(hdc
, InnerPen
);
246 SetDCPenColor(hdc
, GetSysColor(InnerI
));
248 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
250 case BF_DIAGONAL_ENDBOTTOMLEFT
:
251 case (BF_DIAGONAL
|BF_BOTTOM
):
253 case (BF_DIAGONAL
|BF_LEFT
):
254 MoveToEx(hdc
, spx
-1, spy
, NULL
);
255 LineTo(hdc
, epx
, epy
-1);
256 Points
[0].x
= spx
-add
;
258 Points
[1].x
= rc
->left
;
259 Points
[1].y
= rc
->top
;
261 Points
[2].y
= epy
-1-add
;
262 Points
[3] = Points
[2];
265 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
266 MoveToEx(hdc
, spx
-1, spy
, NULL
);
267 LineTo(hdc
, epx
, epy
+1);
268 Points
[0].x
= spx
-add
;
270 Points
[1].x
= rc
->left
;
271 Points
[1].y
= rc
->bottom
-1;
273 Points
[2].y
= epy
+1+add
;
274 Points
[3] = Points
[2];
277 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
278 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
279 case BF_DIAGONAL_ENDTOPRIGHT
:
280 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
281 MoveToEx(hdc
, spx
+1, spy
, NULL
);
282 LineTo(hdc
, epx
, epy
+1);
284 Points
[0].y
= epy
+1+add
;
285 Points
[1].x
= rc
->right
-1;
286 Points
[1].y
= rc
->top
+add
;
287 Points
[2].x
= rc
->right
-1;
288 Points
[2].y
= rc
->bottom
-1;
289 Points
[3].x
= spx
+add
;
293 case BF_DIAGONAL_ENDTOPLEFT
:
294 MoveToEx(hdc
, spx
, spy
-1, NULL
);
295 LineTo(hdc
, epx
+1, epy
);
296 Points
[0].x
= epx
+1+add
;
298 Points
[1].x
= rc
->right
-1;
299 Points
[1].y
= rc
->top
;
300 Points
[2].x
= rc
->right
-1;
301 Points
[2].y
= rc
->bottom
-1-add
;
303 Points
[3].y
= spy
-add
;
306 case (BF_DIAGONAL
|BF_TOP
):
307 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
308 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
309 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
310 LineTo(hdc
, epx
, epy
);
313 Points
[1].x
= rc
->right
-1;
314 Points
[1].y
= rc
->top
;
315 Points
[2].x
= rc
->right
-1;
316 Points
[2].y
= rc
->bottom
-1-add
;
317 Points
[3].x
= spx
+add
;
318 Points
[3].y
= spy
-add
;
321 case (BF_DIAGONAL
|BF_RIGHT
):
322 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
323 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
324 MoveToEx(hdc
, spx
, spy
, NULL
);
325 LineTo(hdc
, epx
-1, epy
+1);
328 Points
[1].x
= rc
->left
;
329 Points
[1].y
= rc
->top
+add
;
330 Points
[2].x
= epx
-1-add
;
331 Points
[2].y
= epy
+1+add
;
332 Points
[3] = Points
[2];
336 /* Fill the interior if asked */
337 if((uFlags
& BF_MIDDLE
) && retval
)
341 hbsave
= (HBRUSH
)SelectObject(hdc
, GetStockObject(DC_BRUSH
));
342 hpsave
= (HPEN
)SelectObject(hdc
, GetStockObject(DC_PEN
));
343 SetDCBrushColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
344 SetDCPenColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
345 Polygon(hdc
, Points
, 4);
346 SelectObject(hdc
, hbsave
);
347 SelectObject(hdc
, hpsave
);
350 /* Adjust rectangle if asked */
351 if(uFlags
& BF_ADJUST
)
355 if(uFlags
& BF_RIGHT
)
359 if(uFlags
& BF_BOTTOM
)
364 SelectObject(hdc
, SavePen
);
365 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
370 /* Ported from WINE20020904 */
371 /* Same as DrawEdge invoked without BF_DIAGONAL
373 * 23-Nov-1997: Changed by Bertho Stultiens
375 * Well, I started testing this and found out that there are a few things
376 * that weren't quite as win95. The following rewrite should reproduce
377 * win95 results completely.
378 * The colorselection is table-driven to avoid awfull if-statements.
379 * The table below show the color settings.
381 * Pen selection table for uFlags = 0
383 * uType | LTI | LTO | RBI | RBO
384 * ------+-------+-------+-------+-------
385 * 0000 | x | x | x | x
386 * 0001 | x | 22 | x | 21
387 * 0010 | x | 16 | x | 20
388 * 0011 | x | x | x | x
389 * ------+-------+-------+-------+-------
390 * 0100 | x | 20 | x | 16
391 * 0101 | 20 | 22 | 16 | 21
392 * 0110 | 20 | 16 | 16 | 20
393 * 0111 | x | x | x | x
394 * ------+-------+-------+-------+-------
395 * 1000 | x | 21 | x | 22
396 * 1001 | 21 | 22 | 22 | 21
397 * 1010 | 21 | 16 | 22 | 20
398 * 1011 | x | x | x | x
399 * ------+-------+-------+-------+-------
400 * 1100 | x | x | x | x
401 * 1101 | x | x (22)| x | x (21)
402 * 1110 | x | x (16)| x | x (20)
403 * 1111 | x | x | x | x
405 * Pen selection table for uFlags = BF_SOFT
407 * uType | LTI | LTO | RBI | RBO
408 * ------+-------+-------+-------+-------
409 * 0000 | x | x | x | x
410 * 0001 | x | 20 | x | 21
411 * 0010 | x | 21 | x | 20
412 * 0011 | x | x | x | x
413 * ------+-------+-------+-------+-------
414 * 0100 | x | 22 | x | 16
415 * 0101 | 22 | 20 | 16 | 21
416 * 0110 | 22 | 21 | 16 | 20
417 * 0111 | x | x | x | x
418 * ------+-------+-------+-------+-------
419 * 1000 | x | 16 | x | 22
420 * 1001 | 16 | 20 | 22 | 21
421 * 1010 | 16 | 21 | 22 | 20
422 * 1011 | x | x | x | x
423 * ------+-------+-------+-------+-------
424 * 1100 | x | x | x | x
425 * 1101 | x | x (20)| x | x (21)
426 * 1110 | x | x (21)| x | x (20)
427 * 1111 | x | x | x | x
429 * x = don't care; (n) = is what win95 actually uses
430 * LTI = left Top Inner line
431 * LTO = left Top Outer line
432 * RBI = Right Bottom Inner line
433 * RBO = Right Bottom Outer line
435 * 16 = COLOR_BTNSHADOW
436 * 20 = COLOR_BTNHIGHLIGHT
437 * 21 = COLOR_3DDKSHADOW
440 static BOOL
IntDrawRectEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
)
442 signed char LTInnerI
, LTOuterI
;
443 signed char RBInnerI
, RBOuterI
;
444 HPEN LTInnerPen
, LTOuterPen
;
445 HPEN RBInnerPen
, RBOuterPen
;
446 RECT InnerRect
= *rc
;
453 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
454 || (uType
& BDR_OUTER
) == BDR_OUTER
)
455 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
457 LTInnerPen
= LTOuterPen
= RBInnerPen
= RBOuterPen
= (HPEN
)GetStockObject(NULL_PEN
);
458 SavePen
= (HPEN
)SelectObject(hdc
, LTInnerPen
);
460 /* Determine the colors of the edges */
463 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
464 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
466 else if(uFlags
& BF_FLAT
)
468 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
469 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
471 /* Bertho Stultiens states above that this function exactly matches win95
472 * In win98 BF_FLAT rectangles have an inner border same color as the
473 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
474 * I don't know I go with Bertho and just sets it for win98 until proven
476 * Dennis Björklund, 10 June, 99
479 LTInnerI
= RBInnerI
= COLOR_BTNFACE
;
481 else if(uFlags
& BF_SOFT
)
483 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
484 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
485 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
486 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
490 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
491 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
492 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
493 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
496 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
)
498 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
)
500 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
)
502 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
)
506 LTInnerPen
= GetStockObject(DC_PEN
);
508 LTOuterPen
= GetStockObject(DC_PEN
);
510 RBInnerPen
= GetStockObject(DC_PEN
);
512 RBOuterPen
= GetStockObject(DC_PEN
);
513 if((uFlags
& BF_MIDDLE
) && retval
)
515 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
516 COLOR_WINDOW
: COLOR_BTNFACE
));
518 MoveToEx(hdc
, 0, 0, &SavePoint
);
520 /* Draw the outer edge */
521 SelectObject(hdc
, LTOuterPen
);
522 SetDCPenColor(hdc
, GetSysColor(LTOuterI
));
525 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
526 LineTo(hdc
, InnerRect
.right
, InnerRect
.top
);
530 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
531 LineTo(hdc
, InnerRect
.left
, InnerRect
.bottom
);
533 SelectObject(hdc
, RBOuterPen
);
534 SetDCPenColor(hdc
, GetSysColor(RBOuterI
));
535 if(uFlags
& BF_BOTTOM
)
537 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.bottom
-1, NULL
);
538 LineTo(hdc
, InnerRect
.right
, InnerRect
.bottom
-1);
540 if(uFlags
& BF_RIGHT
)
542 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.top
, NULL
);
543 LineTo(hdc
, InnerRect
.right
-1, InnerRect
.bottom
);
546 /* Draw the inner edge */
547 SelectObject(hdc
, LTInnerPen
);
548 SetDCPenColor(hdc
, GetSysColor(LTInnerI
));
551 MoveToEx(hdc
, InnerRect
.left
+LTpenplus
, InnerRect
.top
+1, NULL
);
552 LineTo(hdc
, InnerRect
.right
-RTpenplus
, InnerRect
.top
+1);
556 MoveToEx(hdc
, InnerRect
.left
+1, InnerRect
.top
+LTpenplus
, NULL
);
557 LineTo(hdc
, InnerRect
.left
+1, InnerRect
.bottom
-LBpenplus
);
559 SelectObject(hdc
, RBInnerPen
);
560 SetDCPenColor(hdc
, GetSysColor(RBInnerI
));
561 if(uFlags
& BF_BOTTOM
)
563 MoveToEx(hdc
, InnerRect
.left
+LBpenplus
, InnerRect
.bottom
-2, NULL
);
564 LineTo(hdc
, InnerRect
.right
-RBpenplus
, InnerRect
.bottom
-2);
566 if(uFlags
& BF_RIGHT
)
568 MoveToEx(hdc
, InnerRect
.right
-2, InnerRect
.top
+RTpenplus
, NULL
);
569 LineTo(hdc
, InnerRect
.right
-2, InnerRect
.bottom
-RBpenplus
);
572 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
574 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
575 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
578 InnerRect
.left
+= add
;
579 if(uFlags
& BF_RIGHT
)
580 InnerRect
.right
-= add
;
582 InnerRect
.top
+= add
;
583 if(uFlags
& BF_BOTTOM
)
584 InnerRect
.bottom
-= add
;
586 if(uFlags
& BF_ADJUST
)
591 SelectObject(hdc
, SavePen
);
592 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
596 /* Ported from WINE20020904 */
597 /* Utility to create a square rectangle and returning the width */
598 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
600 int Width
= src
->right
- src
->left
;
601 int Height
= src
->bottom
- src
->top
;
602 int SmallDiam
= Width
> Height
? Height
: Width
;
606 /* Make it a square box */
607 if(Width
< Height
) /* SmallDiam == Width */
609 dst
->top
+= (Height
-Width
)/2;
610 dst
->bottom
= dst
->top
+ SmallDiam
;
612 else if(Width
> Height
) /* SmallDiam == Height */
614 dst
->left
+= (Width
-Height
)/2;
615 dst
->right
= dst
->left
+ SmallDiam
;
621 /* Ported from WINE20020904 */
622 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
624 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
626 HBITMAP hbm
= CreateBitmap(8, 8, 1, 1, wPattern_AA55
);
628 HBRUSH hb
= CreatePatternBrush(hbm
);
631 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
632 bg
= SetBkColor(dc
, RGB(255, 255, 255));
633 hbsave
= (HBRUSH
)SelectObject(dc
, hb
);
634 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
635 SelectObject(dc
, hbsave
);
642 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
646 /* Ported from WINE20020904 */
647 /* Draw a push button coming from DrawFrameControl()
649 * Does a pretty good job in emulating MS behavior. Some quirks are
650 * however there because MS uses a TrueType font (Marlett) to draw
653 * FIXME: This looks a little bit strange, needs to be rewritten completely
654 * (several quirks with adjust, DFCS_CHECKED aso)
656 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
661 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
666 if(uFlags
& DFCS_CHECKED
)
668 if(uFlags
& DFCS_MONO
)
669 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
671 IntDrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
);
673 UITOOLS_DrawCheckedRect( dc
, &myr
);
677 if(uFlags
& DFCS_MONO
)
679 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
680 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
684 IntDrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
| BF_SOFT
);
688 /* Adjust rectangle if asked */
689 if(uFlags
& DFCS_ADJUSTRECT
)
700 static BOOL
UITOOLS95_DFC_ButtonCheckRadio(HDC dc
, LPRECT r
, UINT uFlags
, BOOL Radio
)
703 HFONT hFont
, hOldFont
;
705 TCHAR OutRight
, OutLeft
, InRight
, InLeft
, Center
;
709 OutRight
= 'j'; // Outer right
710 OutLeft
= 'k'; // Outer left
711 InRight
= 'l'; // inner left
712 InLeft
= 'm'; // inner right
713 Center
= 'n'; // center
716 OutRight
= 'c'; // Outer right
717 OutLeft
= 'd'; // Outer left
718 InRight
= 'e'; // inner left
719 InLeft
= 'f'; // inner right
720 Center
= 'g'; // center
723 ZeroMemory(&lf
, sizeof(LOGFONTW
));
724 lf
.lfHeight
= r
->top
- r
->bottom
;
726 lf
.lfWeight
= FW_NORMAL
;
727 lf
.lfCharSet
= DEFAULT_CHARSET
;
728 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
729 hFont
= CreateFontIndirect(&lf
);
730 hOldFont
= SelectObject(dc
, hFont
);
732 if(Radio
&& ((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
))
734 SetBkMode(dc
, OPAQUE
);
735 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
736 TextOut(dc
, r
->left
, r
->top
, &Center
, 1);
737 SetBkMode(dc
, TRANSPARENT
);
738 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
739 TextOut(dc
, r
->left
, r
->top
, &OutRight
, 1);
740 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
741 TextOut(dc
, r
->left
, r
->top
, &OutLeft
, 1);
745 SetBkMode(dc
, TRANSPARENT
);
747 /* Center section, white for active, grey for inactive */
748 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
749 SetTextColor(dc
, GetSysColor(i
));
750 TextOut(dc
, r
->left
, r
->top
, &Center
, 1);
752 if(uFlags
& (DFCS_FLAT
| DFCS_MONO
))
754 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
755 TextOut(dc
, r
->left
, r
->top
, &OutRight
, 1);
756 TextOut(dc
, r
->left
, r
->top
, &OutLeft
, 1);
757 TextOut(dc
, r
->left
, r
->top
, &InRight
, 1);
758 TextOut(dc
, r
->left
, r
->top
, &InLeft
, 1);
762 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
763 TextOut(dc
, r
->left
, r
->top
, &OutRight
, 1);
764 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
765 TextOut(dc
, r
->left
, r
->top
, &OutLeft
, 1);
766 SetTextColor(dc
, GetSysColor(COLOR_3DDKSHADOW
));
767 TextOut(dc
, r
->left
, r
->top
, &InRight
, 1);
768 SetTextColor(dc
, GetSysColor(COLOR_3DLIGHT
));
769 TextOut(dc
, r
->left
, r
->top
, &InLeft
, 1);
773 if(uFlags
& DFCS_CHECKED
)
775 TCHAR Check
= (Radio
) ? 'i' : 'b';
777 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
778 TextOut(dc
, r
->left
, r
->top
, &Check
, 1);
781 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
782 SelectObject(dc
, hOldFont
);
788 /* Ported from WINE20020904 */
789 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
791 switch(uState
& 0xff)
793 case DFCS_BUTTONPUSH
:
794 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
796 case DFCS_BUTTONCHECK
:
797 case DFCS_BUTTON3STATE
:
798 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, FALSE
);
800 case DFCS_BUTTONRADIOIMAGE
:
801 case DFCS_BUTTONRADIOMASK
:
802 case DFCS_BUTTONRADIO
:
803 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, TRUE
);
807 DbgPrint("Invalid button state=0x%04x\n", uState);
814 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
817 HFONT hFont
, hOldFont
;
822 switch(uFlags
& 0xff)
824 case DFCS_CAPTIONCLOSE
:
827 case DFCS_CAPTIONHELP
:
830 case DFCS_CAPTIONMIN
:
833 case DFCS_CAPTIONMAX
:
836 case DFCS_CAPTIONRESTORE
:
842 IntDrawRectEdge(dc
,r
,(uFlags
&DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, BF_RECT
| BF_MIDDLE
| BF_SOFT
);
843 ZeroMemory(&lf
, sizeof(LOGFONTW
));
844 UITOOLS_MakeSquareRect(r
, &myr
);
849 if(uFlags
& DFCS_PUSHED
)
850 OffsetRect(&myr
,1,1);
851 lf
.lfHeight
= myr
.bottom
- myr
.top
;
853 lf
.lfWeight
= FW_NORMAL
;
854 lf
.lfCharSet
= DEFAULT_CHARSET
;
855 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
856 hFont
= CreateFontIndirect(&lf
);
857 /* save font and text color */
858 hOldFont
= SelectObject(dc
, hFont
);
859 clrsave
= GetTextColor(dc
);
860 bkmode
= GetBkMode(dc
);
861 /* set color and drawing mode */
862 SetBkMode(dc
, TRANSPARENT
);
863 if(uFlags
& DFCS_INACTIVE
)
866 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
867 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
869 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
870 /* draw selected symbol */
871 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
872 /* restore previous settings */
873 SetTextColor(dc
, clrsave
);
874 SelectObject(dc
, hOldFont
);
875 SetBkMode(dc
, bkmode
);
880 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
883 HFONT hFont
, hOldFont
;
888 switch(uFlags
& 0xff)
890 case DFCS_SCROLLCOMBOBOX
:
891 case DFCS_SCROLLDOWN
:
899 case DFCS_SCROLLLEFT
:
903 case DFCS_SCROLLRIGHT
:
907 case DFCS_SCROLLSIZEGRIP
:
908 case DFCS_SCROLLSIZEGRIPRIGHT
:
909 ZeroMemory(&lf
, sizeof(LOGFONTW
));
910 UITOOLS_MakeSquareRect(r
, &myr
);
911 lf
.lfHeight
= myr
.bottom
- myr
.top
;
913 lf
.lfWeight
= FW_NORMAL
;
914 lf
.lfCharSet
= DEFAULT_CHARSET
;
915 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
916 hFont
= CreateFontIndirect(&lf
);
917 /* save font and text color */
918 hOldFont
= SelectObject(dc
, hFont
);
919 clrsave
= GetTextColor(dc
);
920 bkmode
= GetBkMode(dc
);
921 /* set color and drawing mode */
922 SetBkMode(dc
, TRANSPARENT
);
923 if (!(uFlags
& (DFCS_MONO
| DFCS_FLAT
)))
925 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
926 /* draw selected symbol */
927 Symbol
= ((uFlags
& 0xff) == DFCS_SCROLLSIZEGRIP
) ? 'o' : 'x';
928 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
929 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
931 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
932 /* draw selected symbol */
933 Symbol
= ((uFlags
& 0xff) == DFCS_SCROLLSIZEGRIP
) ? 'p' : 'y';
934 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
935 /* restore previous settings */
936 SetTextColor(dc
, clrsave
);
937 SelectObject(dc
, hOldFont
);
938 SetBkMode(dc
, bkmode
);
944 IntDrawRectEdge(dc
, r
, (uFlags
& DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
);
945 ZeroMemory(&lf
, sizeof(LOGFONTW
));
946 UITOOLS_MakeSquareRect(r
, &myr
);
951 if(uFlags
& DFCS_PUSHED
)
952 OffsetRect(&myr
,1,1);
953 lf
.lfHeight
= myr
.bottom
- myr
.top
;
955 lf
.lfWeight
= FW_NORMAL
;
956 lf
.lfCharSet
= DEFAULT_CHARSET
;
957 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
958 hFont
= CreateFontIndirect(&lf
);
959 /* save font and text color */
960 hOldFont
= SelectObject(dc
, hFont
);
961 clrsave
= GetTextColor(dc
);
962 bkmode
= GetBkMode(dc
);
963 /* set color and drawing mode */
964 SetBkMode(dc
, TRANSPARENT
);
965 if(uFlags
& DFCS_INACTIVE
)
968 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
969 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
971 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
972 /* draw selected symbol */
973 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
974 /* restore previous settings */
975 SetTextColor(dc
, clrsave
);
976 SelectObject(dc
, hOldFont
);
977 SetBkMode(dc
, bkmode
);
982 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
985 HFONT hFont
, hOldFont
;
987 switch(uFlags
& 0xff)
993 case DFCS_MENUARROWRIGHT
:
994 Symbol
= 'w'; // FIXME: needs to confirm
997 case DFCS_MENUBULLET
:
1001 case DFCS_MENUCHECK
:
1007 DbgPrint("Invalid menu; flags=0x%04x\n", uFlags);
1011 /* acquire ressources only if valid menu */
1012 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1013 lf
.lfHeight
= r
->bottom
- r
->top
;
1015 lf
.lfWeight
= FW_NORMAL
;
1016 lf
.lfCharSet
= DEFAULT_CHARSET
;
1017 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
1018 hFont
= CreateFontIndirect(&lf
);
1020 hOldFont
= SelectObject(dc
, hFont
);
1021 // FIXME selecting color doesn't work
1023 if(uFlags
& DFCS_INACTIVE
)
1026 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
1027 TextOut(dc
, r
->left
+ 1, r
->top
+ 1, &Symbol
, 1);
1029 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
1031 /* draw selected symbol */
1032 TextOut(dc
, r
->left
, r
->top
, &Symbol
, 1);
1033 /* restore previous settings */
1034 SelectObject(dc
, hOldFont
);
1035 DeleteObject(hFont
);
1044 GRAYSTRINGPROC lpOutputFunc
,
1053 // AG: Mostly implemented, but probably won't work properly or return
1054 // correct error codes. I doubt it grays strings either... Untested!
1056 BOOL success
= FALSE
;
1058 HBITMAP MemBMP
= NULL
,
1060 HBRUSH OldBrush
= NULL
;
1061 HFONT OldFont
= NULL
;
1063 COLORREF ForeColor
, BackColor
;
1065 ForeColor
= SetTextColor(hDC
, RGB(0, 0, 0));
1066 BackColor
= SetBkColor(hDC
, RGB(255, 255, 255));
1071 // The documentation is a little vague on what exactly should happen
1072 // here. Something about using the same brush for window text???
1073 hBrush
= (HBRUSH
) GetCurrentObject(hDC
, OBJ_BRUSH
);
1076 if ((nCount
== -1) && (! lpOutputFunc
))
1081 // TODO: calculate the length (easy enough)
1084 nCount
= lstrlenW((WCHAR
*)lpData
);
1086 nCount
= lstrlenA((CHAR
*)lpData
);
1089 if (! nWidth
|| ! nHeight
)
1092 // TODO: calculate the rect
1095 success
= GetTextExtentPoint32W(hDC
, (WCHAR
*) lpData
, nCount
, &s
);
1097 success
= GetTextExtentPoint32A(hDC
, (CHAR
*) lpData
, nCount
, &s
);
1099 if (! success
) goto cleanup
;
1101 if (! nWidth
) nWidth
= s
.cx
;
1102 if (! nHeight
) nHeight
= s
.cy
;
1105 SetRect(&r
, X
, Y
, X
+ nWidth
, Y
+ nHeight
);
1107 MemDC
= CreateCompatibleDC(hDC
);
1108 if (! MemDC
) goto cleanup
;
1109 MemBMP
= CreateBitmap(nWidth
, nHeight
, 1, 1, NULL
);
1110 if (! MemBMP
) goto cleanup
;
1111 OldBMP
= SelectObject(MemDC
, MemBMP
);
1112 if (! OldBMP
) goto cleanup
;
1113 OldFont
= SelectObject(MemDC
, GetCurrentObject(hDC
, OBJ_FONT
));
1114 if (! OldFont
) goto cleanup
;
1115 OldBrush
= SelectObject(MemDC
, hBrush
);
1116 if (! OldBrush
) goto cleanup
;
1118 if (! BitBlt(MemDC
, 0, 0, nWidth
, nHeight
, hDC
, X
, Y
, SRCCOPY
)) goto cleanup
;
1120 SetTextColor(MemDC
, RGB(255, 255, 255));
1121 SetBkColor(MemDC
, RGB(0, 0, 0));
1125 success
= lpOutputFunc(MemDC
, lpData
, nCount
); // Set brush etc first?
1127 if ((nCount
== -1) && (! success
))
1129 // Don't gray (documented behaviour)
1130 success
= (BOOL
) BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
);
1137 success
= TextOutW(MemDC
, 0, 0, (WCHAR
*) lpData
, nCount
);
1139 success
= TextOutA(MemDC
, 0, 0, (CHAR
*) lpData
, nCount
);
1141 if (! success
) goto cleanup
;
1143 PatBlt(MemDC
, 0, 0, nWidth
, nHeight
, PATCOPY
);
1144 // This is how WINE does it: (but we should have our own graying brush already)
1145 // hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
1146 // PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
1147 // SelectObject(memdc, hbsave);
1150 if (! BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
)) goto cleanup
;
1153 SetTextColor(hDC
, ForeColor
);
1154 SetBkColor(hDC
, BackColor
);
1158 if (OldFont
) SelectObject(MemDC
, OldFont
);
1159 if (OldBrush
) SelectObject(MemDC
, OldBrush
);
1160 if (OldBMP
) SelectObject(MemDC
, OldBMP
);
1161 if (MemBMP
) DeleteObject(MemBMP
);
1168 /**********************************************************************
1169 * PAINTING_DrawStateJam
1171 * Jams in the requested type in the dc
1173 static BOOL
PAINTING_DrawStateJam(HDC hdc
, UINT opcode
,
1174 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1175 LPRECT rc
, UINT dtflags
, BOOL unicode
)
1180 INT cx
= rc
->right
- rc
->left
;
1181 INT cy
= rc
->bottom
- rc
->top
;
1186 case DST_PREFIXTEXT
:
1188 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1190 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1193 return DrawIconEx(hdc
, rc
->left
, rc
->top
, (HICON
)lp
, cx
, cy
, 0, NULL
, DI_NORMAL
);
1196 memdc
= CreateCompatibleDC(hdc
);
1199 hbmsave
= (HBITMAP
)SelectObject(memdc
, (HBITMAP
)lp
);
1205 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
1206 SelectObject(memdc
, hbmsave
);
1214 /* DRAWSTATEPROC assumes that it draws at the center of coordinates */
1216 OffsetViewportOrgEx(hdc
, rc
->left
, rc
->top
, NULL
);
1217 bRet
= func(hdc
, lp
, wp
, cx
, cy
);
1218 /* Restore origin */
1219 OffsetViewportOrgEx(hdc
, -rc
->left
, -rc
->top
, NULL
);
1231 IntDrawState(HDC hdc
, HBRUSH hbr
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1232 INT x
, INT y
, INT cx
, INT cy
, UINT flags
, BOOL unicode
)
1234 HBITMAP hbm
, hbmsave
;
1236 HBRUSH hbsave
, hbrtmp
= 0;
1239 UINT dtflags
= DT_NOCLIP
;
1241 UINT opcode
= flags
& 0xf;
1245 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
1248 len
= lstrlenW((LPWSTR
)lp
);
1250 len
= lstrlenA((LPSTR
)lp
);
1253 /* Find out what size the image has if not given by caller */
1263 case DST_PREFIXTEXT
:
1265 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
1267 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
1273 if(!GetIconInfo((HICON
)lp
, &ici
))
1275 if(!GetObjectW(ici
.hbmColor
, sizeof(bm
), &bm
))
1282 if(!GetObjectW((HBITMAP
)lp
, sizeof(bm
), &bm
))
1288 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1303 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1304 dtflags
|= DT_RIGHT
;
1305 if(opcode
== DST_TEXT
)
1306 dtflags
|= DT_NOPREFIX
;
1307 else if(opcode
== DST_PREFIXTEXT
)
1309 if (flags
& DSS_HIDEPREFIX
)
1310 dtflags
|= DT_HIDEPREFIX
;
1311 if (flags
& DSS_PREFIXONLY
)
1312 dtflags
|= DT_PREFIXONLY
;
1315 /* For DSS_NORMAL we just jam in the image and return */
1316 if((flags
& 0x79f0) == DSS_NORMAL
)
1318 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1321 /* For all other states we need to convert the image to B/W in a local bitmap */
1322 /* before it is displayed */
1323 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1324 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1325 hbm
= NULL
; hbmsave
= NULL
;
1326 memdc
= NULL
; hbsave
= NULL
;
1327 retval
= FALSE
; /* assume failure */
1329 /* From here on we must use "goto cleanup" when something goes wrong */
1330 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1333 memdc
= CreateCompatibleDC(hdc
);
1336 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
1339 rc
.left
= rc
.top
= 0;
1342 if(!FillRect(memdc
, &rc
, (HBRUSH
)GetStockObject(WHITE_BRUSH
)))
1344 SetBkColor(memdc
, RGB(255, 255, 255));
1345 SetTextColor(memdc
, RGB(0, 0, 0));
1346 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1348 /* DST_COMPLEX may draw text as well,
1349 * so we must be sure that correct font is selected
1351 if(!hfsave
&& (opcode
<= DST_PREFIXTEXT
))
1353 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1355 SelectObject(memdc
, hfsave
);
1359 /* This state cause the image to be dithered */
1360 if(flags
& DSS_UNION
)
1363 hbsave
= (HBRUSH
)SelectObject(memdc
, CACHE_GetPattern55AABrush());
1366 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1367 SelectObject(memdc
, hbsave
);
1375 if (flags
& DSS_DISABLED
)
1376 hbrtmp
= CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT
));
1377 else if (flags
& DSS_DEFAULT
)
1378 hbrtmp
= CreateSolidBrush(GetSysColor(COLOR_3DSHADOW
));
1380 /* Draw light or dark shadow */
1381 if (flags
& (DSS_DISABLED
|DSS_DEFAULT
))
1385 hbsave
= (HBRUSH
)SelectObject(hdc
, hbrtmp
);
1388 if(!BitBlt(hdc
, x
+1, y
+1, cx
, cy
, memdc
, 0, 0, 0x00B8074A))
1390 SelectObject(hdc
, hbsave
);
1391 DeleteObject(hbrtmp
);
1395 if (flags
& DSS_DISABLED
)
1397 hbr
= hbrtmp
= CreateSolidBrush(GetSysColor(COLOR_3DSHADOW
));
1403 hbr
= (HBRUSH
)GetStockObject(BLACK_BRUSH
);
1406 hbsave
= (HBRUSH
)SelectObject(hdc
, hbr
);
1408 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A))
1411 retval
= TRUE
; /* We succeeded */
1414 SetTextColor(hdc
, fg
);
1415 SetBkColor(hdc
, bg
);
1418 SelectObject(hdc
, hbsave
);
1420 SelectObject(memdc
, hbmsave
);
1422 DeleteObject(hbrtmp
);
1435 RealDrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1437 if (GetMapMode(hDC
) != MM_TEXT
)
1443 return UITOOLS95_DrawFrameButton(hDC
, rc
, uState
);
1445 return UITOOLS95_DrawFrameCaption(hDC
, rc
, uState
);
1447 return UITOOLS95_DrawFrameMenu(hDC
, rc
, uState
);
1454 return UITOOLS95_DrawFrameScroll(hDC
, rc
, uState
);
1460 DrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1462 BOOL Hook
, Ret
= FALSE
;
1466 Hook
= BeginIfHookedUserApiHook();
1468 /* Bypass SEH and go direct. */
1469 if (!Hook
) return RealDrawFrameControl(hDC
, rc
, uType
, uState
);
1473 Ret
= guah
.DrawFrameControl(hDC
, rc
, uType
, uState
);
1475 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1489 DrawEdge(HDC hDC
, LPRECT rc
, UINT edge
, UINT flags
)
1491 if (flags
& BF_DIAGONAL
)
1492 return IntDrawDiagEdge(hDC
, rc
, edge
, flags
);
1494 return IntDrawRectEdge(hDC
, rc
, edge
, flags
);
1501 GrayStringA(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1502 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1504 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, FALSE
);
1511 GrayStringW(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1512 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1514 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, TRUE
);
1521 InvertRect(HDC hDC
, CONST RECT
*lprc
)
1523 return PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1524 lprc
->bottom
- lprc
->top
, DSTINVERT
);
1531 FrameRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1536 if ((r
.right
<= r
.left
) || (r
.bottom
<= r
.top
)) return 0;
1537 if (!(oldbrush
= SelectObject(hDC
, hbr
))) return 0;
1539 PatBlt(hDC
, r
.left
, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1540 PatBlt(hDC
, r
.right
- 1, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1541 PatBlt(hDC
, r
.left
, r
.top
, r
.right
- r
.left
, 1, PATCOPY
);
1542 PatBlt(hDC
, r
.left
, r
.bottom
- 1, r
.right
- r
.left
, 1, PATCOPY
);
1544 SelectObject(hDC
, oldbrush
);
1552 FlashWindow(HWND hWnd
, BOOL bInvert
)
1554 FLASHWINFO FlashWndInfo
;
1556 FlashWndInfo
.cbSize
= sizeof(FLASHWINFO
);
1557 FlashWndInfo
.hwnd
= hWnd
;
1558 FlashWndInfo
.dwFlags
= !bInvert
? 0 : (FLASHW_TRAY
| FLASHW_CAPTION
);
1559 FlashWndInfo
.uCount
= 1;
1560 FlashWndInfo
.dwTimeout
= 0;
1562 return NtUserFlashWindowEx(&FlashWndInfo
);
1569 FillRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1573 if (hbr
<= (HBRUSH
)(COLOR_MENUBAR
+ 1))
1575 hbr
= GetSysColorBrush(PtrToUlong(hbr
) - 1);
1577 if ((prevhbr
= SelectObject(hDC
, hbr
)) == NULL
)
1581 PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1582 lprc
->bottom
- lprc
->top
, PATCOPY
);
1583 SelectObject(hDC
, prevhbr
);
1591 DrawFocusRect(HDC hdc
, CONST RECT
*rect
)
1593 static HBRUSH hFocusRectBrush
= NULL
;
1597 if(!hFocusRectBrush
)
1599 static HBITMAP hFocusPattern
= NULL
;
1600 const DWORD Pattern
[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
1602 hFocusPattern
= CreateBitmap(8, 8, 1, 1, Pattern
);
1603 hFocusRectBrush
= CreatePatternBrush(hFocusPattern
);
1606 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH
, 0, &cx
, 0);
1607 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT
, 0, &cy
, 0);
1609 OldObj
= SelectObject(hdc
, hFocusRectBrush
);
1612 PatBlt(hdc
, rect
->left
, rect
->top
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1614 PatBlt(hdc
, rect
->left
, rect
->bottom
- cy
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1616 PatBlt(hdc
, rect
->left
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1618 PatBlt(hdc
, rect
->right
- cx
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1620 SelectObject(hdc
, OldObj
);
1628 DrawStateA(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1629 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1631 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, FALSE
);
1638 DrawStateW(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1639 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1641 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, TRUE
);