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 /* These tables are used in:
41 * UITOOLS_DrawDiagEdge()
42 * UITOOLS_DrawRectEdge()
44 static const signed char LTInnerNormal
[] = {
46 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
47 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
51 static const signed char LTOuterNormal
[] = {
52 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
53 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
54 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
55 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
58 static const signed char RBInnerNormal
[] = {
60 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
61 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
65 static const signed char RBOuterNormal
[] = {
66 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
67 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
68 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
69 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
72 static const signed char LTInnerSoft
[] = {
74 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
75 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
79 static const signed char LTOuterSoft
[] = {
80 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
81 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
82 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
83 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
86 #define RBInnerSoft RBInnerNormal /* These are the same */
87 #define RBOuterSoft RBOuterNormal
89 static const signed char LTRBOuterMono
[] = {
90 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
91 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
92 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
93 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
96 static const signed char LTRBInnerMono
[] = {
98 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
99 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
100 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
103 static const signed char LTRBOuterFlat
[] = {
104 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
105 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
106 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
107 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
110 static const signed char LTRBInnerFlat
[] = {
112 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
113 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
114 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
116 /* FUNCTIONS *****************************************************************/
119 HBRUSH WINAPI
GetSysColorBrush(int nIndex
);
121 /* Ported from WINE20020904 */
122 /* Same as DrawEdge invoked with BF_DIAGONAL */
123 static BOOL
IntDrawDiagEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
)
126 signed char InnerI
, OuterI
;
127 HPEN InnerPen
, OuterPen
;
132 int Width
= rc
->right
- rc
->left
;
133 int Height
= rc
->bottom
- rc
->top
;
134 int SmallDiam
= Width
> Height
? Height
: Width
;
135 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
136 || (uType
& BDR_OUTER
) == BDR_OUTER
)
137 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
138 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
139 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
142 OuterPen
= InnerPen
= (HPEN
)GetStockObject(NULL_PEN
);
143 SavePen
= (HPEN
)SelectObject(hdc
, InnerPen
);
144 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
146 /* Determine the colors of the edges */
149 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
150 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
152 else if(uFlags
& BF_FLAT
)
154 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
155 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
157 else if(uFlags
& BF_SOFT
)
159 if(uFlags
& BF_BOTTOM
)
161 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
162 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
166 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
167 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
172 if(uFlags
& BF_BOTTOM
)
174 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
175 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
179 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
180 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
185 InnerPen
= GetStockObject(DC_PEN
);
187 OuterPen
= GetStockObject(DC_PEN
);
189 MoveToEx(hdc
, 0, 0, &SavePoint
);
191 /* Don't ask me why, but this is what is visible... */
192 /* This must be possible to do much simpler, but I fail to */
193 /* see the logic in the MS implementation (sigh...). */
194 /* So, this might look a bit brute force here (and it is), but */
195 /* it gets the job done;) */
197 switch(uFlags
& BF_RECT
)
203 /* Left bottom endpoint */
205 spx
= epx
+ SmallDiam
;
207 spy
= epy
- SmallDiam
;
212 /* Left top endpoint */
214 spx
= epx
+ SmallDiam
;
216 spy
= epy
+ SmallDiam
;
222 case BF_RIGHT
|BF_LEFT
:
223 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
224 case BF_BOTTOM
|BF_TOP
:
225 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
226 case BF_BOTTOMRIGHT
|BF_LEFT
:
227 case BF_BOTTOMRIGHT
|BF_TOP
:
229 /* Right top endpoint */
231 epx
= spx
+ SmallDiam
;
233 epy
= spy
- SmallDiam
;
237 MoveToEx(hdc
, spx
, spy
, NULL
);
238 SelectObject(hdc
, OuterPen
);
239 SetDCPenColor(hdc
, GetSysColor(OuterI
));
240 LineTo(hdc
, epx
, epy
);
242 SelectObject(hdc
, InnerPen
);
243 SetDCPenColor(hdc
, GetSysColor(InnerI
));
245 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
247 case BF_DIAGONAL_ENDBOTTOMLEFT
:
248 case (BF_DIAGONAL
|BF_BOTTOM
):
250 case (BF_DIAGONAL
|BF_LEFT
):
251 MoveToEx(hdc
, spx
-1, spy
, NULL
);
252 LineTo(hdc
, epx
, epy
-1);
253 Points
[0].x
= spx
-add
;
255 Points
[1].x
= rc
->left
;
256 Points
[1].y
= rc
->top
;
258 Points
[2].y
= epy
-1-add
;
259 Points
[3] = Points
[2];
262 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
263 MoveToEx(hdc
, spx
-1, spy
, NULL
);
264 LineTo(hdc
, epx
, epy
+1);
265 Points
[0].x
= spx
-add
;
267 Points
[1].x
= rc
->left
;
268 Points
[1].y
= rc
->bottom
-1;
270 Points
[2].y
= epy
+1+add
;
271 Points
[3] = Points
[2];
274 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
275 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
276 case BF_DIAGONAL_ENDTOPRIGHT
:
277 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
278 MoveToEx(hdc
, spx
+1, spy
, NULL
);
279 LineTo(hdc
, epx
, epy
+1);
281 Points
[0].y
= epy
+1+add
;
282 Points
[1].x
= rc
->right
-1;
283 Points
[1].y
= rc
->top
+add
;
284 Points
[2].x
= rc
->right
-1;
285 Points
[2].y
= rc
->bottom
-1;
286 Points
[3].x
= spx
+add
;
290 case BF_DIAGONAL_ENDTOPLEFT
:
291 MoveToEx(hdc
, spx
, spy
-1, NULL
);
292 LineTo(hdc
, epx
+1, epy
);
293 Points
[0].x
= epx
+1+add
;
295 Points
[1].x
= rc
->right
-1;
296 Points
[1].y
= rc
->top
;
297 Points
[2].x
= rc
->right
-1;
298 Points
[2].y
= rc
->bottom
-1-add
;
300 Points
[3].y
= spy
-add
;
303 case (BF_DIAGONAL
|BF_TOP
):
304 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
305 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
306 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
307 LineTo(hdc
, epx
, epy
);
310 Points
[1].x
= rc
->right
-1;
311 Points
[1].y
= rc
->top
;
312 Points
[2].x
= rc
->right
-1;
313 Points
[2].y
= rc
->bottom
-1-add
;
314 Points
[3].x
= spx
+add
;
315 Points
[3].y
= spy
-add
;
318 case (BF_DIAGONAL
|BF_RIGHT
):
319 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
320 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
321 MoveToEx(hdc
, spx
, spy
, NULL
);
322 LineTo(hdc
, epx
-1, epy
+1);
325 Points
[1].x
= rc
->left
;
326 Points
[1].y
= rc
->top
+add
;
327 Points
[2].x
= epx
-1-add
;
328 Points
[2].y
= epy
+1+add
;
329 Points
[3] = Points
[2];
333 /* Fill the interior if asked */
334 if((uFlags
& BF_MIDDLE
) && retval
)
338 hbsave
= (HBRUSH
)SelectObject(hdc
, GetStockObject(DC_BRUSH
));
339 hpsave
= (HPEN
)SelectObject(hdc
, GetStockObject(DC_PEN
));
340 SetDCBrushColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
341 SetDCPenColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
342 Polygon(hdc
, Points
, 4);
343 SelectObject(hdc
, hbsave
);
344 SelectObject(hdc
, hpsave
);
347 /* Adjust rectangle if asked */
348 if(uFlags
& BF_ADJUST
)
352 if(uFlags
& BF_RIGHT
)
356 if(uFlags
& BF_BOTTOM
)
361 SelectObject(hdc
, SavePen
);
362 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
367 /* Ported from WINE20020904 */
368 /* Same as DrawEdge invoked without BF_DIAGONAL
370 * 23-Nov-1997: Changed by Bertho Stultiens
372 * Well, I started testing this and found out that there are a few things
373 * that weren't quite as win95. The following rewrite should reproduce
374 * win95 results completely.
375 * The colorselection is table-driven to avoid awfull if-statements.
376 * The table below show the color settings.
378 * Pen selection table for uFlags = 0
380 * uType | LTI | LTO | RBI | RBO
381 * ------+-------+-------+-------+-------
382 * 0000 | x | x | x | x
383 * 0001 | x | 22 | x | 21
384 * 0010 | x | 16 | x | 20
385 * 0011 | x | x | x | x
386 * ------+-------+-------+-------+-------
387 * 0100 | x | 20 | x | 16
388 * 0101 | 20 | 22 | 16 | 21
389 * 0110 | 20 | 16 | 16 | 20
390 * 0111 | x | x | x | x
391 * ------+-------+-------+-------+-------
392 * 1000 | x | 21 | x | 22
393 * 1001 | 21 | 22 | 22 | 21
394 * 1010 | 21 | 16 | 22 | 20
395 * 1011 | x | x | x | x
396 * ------+-------+-------+-------+-------
397 * 1100 | x | x | x | x
398 * 1101 | x | x (22)| x | x (21)
399 * 1110 | x | x (16)| x | x (20)
400 * 1111 | x | x | x | x
402 * Pen selection table for uFlags = BF_SOFT
404 * uType | LTI | LTO | RBI | RBO
405 * ------+-------+-------+-------+-------
406 * 0000 | x | x | x | x
407 * 0001 | x | 20 | x | 21
408 * 0010 | x | 21 | x | 20
409 * 0011 | x | x | x | x
410 * ------+-------+-------+-------+-------
411 * 0100 | x | 22 | x | 16
412 * 0101 | 22 | 20 | 16 | 21
413 * 0110 | 22 | 21 | 16 | 20
414 * 0111 | x | x | x | x
415 * ------+-------+-------+-------+-------
416 * 1000 | x | 16 | x | 22
417 * 1001 | 16 | 20 | 22 | 21
418 * 1010 | 16 | 21 | 22 | 20
419 * 1011 | x | x | x | x
420 * ------+-------+-------+-------+-------
421 * 1100 | x | x | x | x
422 * 1101 | x | x (20)| x | x (21)
423 * 1110 | x | x (21)| x | x (20)
424 * 1111 | x | x | x | x
426 * x = don't care; (n) = is what win95 actually uses
427 * LTI = left Top Inner line
428 * LTO = left Top Outer line
429 * RBI = Right Bottom Inner line
430 * RBO = Right Bottom Outer line
432 * 16 = COLOR_BTNSHADOW
433 * 20 = COLOR_BTNHIGHLIGHT
434 * 21 = COLOR_3DDKSHADOW
437 static BOOL
IntDrawRectEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
)
439 signed char LTInnerI
, LTOuterI
;
440 signed char RBInnerI
, RBOuterI
;
441 HPEN LTInnerPen
, LTOuterPen
;
442 HPEN RBInnerPen
, RBOuterPen
;
443 RECT InnerRect
= *rc
;
450 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
451 || (uType
& BDR_OUTER
) == BDR_OUTER
)
452 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
454 LTInnerPen
= LTOuterPen
= RBInnerPen
= RBOuterPen
= (HPEN
)GetStockObject(NULL_PEN
);
455 SavePen
= (HPEN
)SelectObject(hdc
, LTInnerPen
);
457 /* Determine the colors of the edges */
460 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
461 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
463 else if(uFlags
& BF_FLAT
)
465 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
466 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
468 /* Bertho Stultiens states above that this function exactly matches win95
469 * In win98 BF_FLAT rectangles have an inner border same color as the
470 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
471 * I don't know I go with Bertho and just sets it for win98 until proven
473 * Dennis Björklund, 10 June, 99
476 LTInnerI
= RBInnerI
= COLOR_BTNFACE
;
478 else if(uFlags
& BF_SOFT
)
480 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
481 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
482 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
483 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
487 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
488 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
489 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
490 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
493 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
)
495 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
)
497 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
)
499 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
)
503 LTInnerPen
= GetStockObject(DC_PEN
);
505 LTOuterPen
= GetStockObject(DC_PEN
);
507 RBInnerPen
= GetStockObject(DC_PEN
);
509 RBOuterPen
= GetStockObject(DC_PEN
);
510 if((uFlags
& BF_MIDDLE
) && retval
)
512 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
513 COLOR_WINDOW
: COLOR_BTNFACE
));
515 MoveToEx(hdc
, 0, 0, &SavePoint
);
517 /* Draw the outer edge */
518 SelectObject(hdc
, LTOuterPen
);
519 SetDCPenColor(hdc
, GetSysColor(LTOuterI
));
522 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
523 LineTo(hdc
, InnerRect
.right
, InnerRect
.top
);
527 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
528 LineTo(hdc
, InnerRect
.left
, InnerRect
.bottom
);
530 SelectObject(hdc
, RBOuterPen
);
531 SetDCPenColor(hdc
, GetSysColor(RBOuterI
));
532 if(uFlags
& BF_BOTTOM
)
534 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.bottom
-1, NULL
);
535 LineTo(hdc
, InnerRect
.right
, InnerRect
.bottom
-1);
537 if(uFlags
& BF_RIGHT
)
539 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.top
, NULL
);
540 LineTo(hdc
, InnerRect
.right
-1, InnerRect
.bottom
);
543 /* Draw the inner edge */
544 SelectObject(hdc
, LTInnerPen
);
545 SetDCPenColor(hdc
, GetSysColor(LTInnerI
));
548 MoveToEx(hdc
, InnerRect
.left
+LTpenplus
, InnerRect
.top
+1, NULL
);
549 LineTo(hdc
, InnerRect
.right
-RTpenplus
, InnerRect
.top
+1);
553 MoveToEx(hdc
, InnerRect
.left
+1, InnerRect
.top
+LTpenplus
, NULL
);
554 LineTo(hdc
, InnerRect
.left
+1, InnerRect
.bottom
-LBpenplus
);
556 SelectObject(hdc
, RBInnerPen
);
557 SetDCPenColor(hdc
, GetSysColor(RBInnerI
));
558 if(uFlags
& BF_BOTTOM
)
560 MoveToEx(hdc
, InnerRect
.left
+LBpenplus
, InnerRect
.bottom
-2, NULL
);
561 LineTo(hdc
, InnerRect
.right
-RBpenplus
, InnerRect
.bottom
-2);
563 if(uFlags
& BF_RIGHT
)
565 MoveToEx(hdc
, InnerRect
.right
-2, InnerRect
.top
+RTpenplus
, NULL
);
566 LineTo(hdc
, InnerRect
.right
-2, InnerRect
.bottom
-RBpenplus
);
569 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
571 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
572 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
575 InnerRect
.left
+= add
;
576 if(uFlags
& BF_RIGHT
)
577 InnerRect
.right
-= add
;
579 InnerRect
.top
+= add
;
580 if(uFlags
& BF_BOTTOM
)
581 InnerRect
.bottom
-= add
;
583 if(uFlags
& BF_ADJUST
)
588 SelectObject(hdc
, SavePen
);
589 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
593 /* Ported from WINE20020904 */
594 /* Utility to create a square rectangle and returning the width */
595 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
597 int Width
= src
->right
- src
->left
;
598 int Height
= src
->bottom
- src
->top
;
599 int SmallDiam
= Width
> Height
? Height
: Width
;
603 /* Make it a square box */
604 if(Width
< Height
) /* SmallDiam == Width */
606 dst
->top
+= (Height
-Width
)/2;
607 dst
->bottom
= dst
->top
+ SmallDiam
;
609 else if(Width
> Height
) /* SmallDiam == Height */
611 dst
->left
+= (Width
-Height
)/2;
612 dst
->right
= dst
->left
+ SmallDiam
;
618 /* Ported from WINE20020904 */
619 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
621 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
626 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
627 bg
= SetBkColor(dc
, RGB(255, 255, 255));
628 hbsave
= (HBRUSH
)SelectObject(dc
, gpsi
->hbrGray
);
629 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
630 SelectObject(dc
, hbsave
);
635 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
639 /* Ported from WINE20020904 */
640 /* Draw a push button coming from DrawFrameControl()
642 * Does a pretty good job in emulating MS behavior. Some quirks are
643 * however there because MS uses a TrueType font (Marlett) to draw
646 * FIXME: This looks a little bit strange, needs to be rewritten completely
647 * (several quirks with adjust, DFCS_CHECKED aso)
649 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
654 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
659 if(uFlags
& DFCS_CHECKED
)
661 if(uFlags
& DFCS_MONO
)
662 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
664 IntDrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
);
666 UITOOLS_DrawCheckedRect( dc
, &myr
);
670 if(uFlags
& DFCS_MONO
)
672 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
);
673 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
677 IntDrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
| BF_SOFT
);
681 /* Adjust rectangle if asked */
682 if(uFlags
& DFCS_ADJUSTRECT
)
693 static BOOL
UITOOLS95_DFC_ButtonCheckRadio(HDC dc
, LPRECT r
, UINT uFlags
, BOOL Radio
)
696 HFONT hFont
, hOldFont
;
698 TCHAR OutRight
, OutLeft
, InRight
, InLeft
, Center
;
702 OutRight
= 'j'; // Outer right
703 OutLeft
= 'k'; // Outer left
704 InRight
= 'l'; // inner left
705 InLeft
= 'm'; // inner right
706 Center
= 'n'; // center
709 OutRight
= 'c'; // Outer right
710 OutLeft
= 'd'; // Outer left
711 InRight
= 'e'; // inner left
712 InLeft
= 'f'; // inner right
713 Center
= 'g'; // center
716 ZeroMemory(&lf
, sizeof(LOGFONTW
));
717 lf
.lfHeight
= r
->top
- r
->bottom
;
719 lf
.lfWeight
= FW_NORMAL
;
720 lf
.lfCharSet
= DEFAULT_CHARSET
;
721 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
722 hFont
= CreateFontIndirect(&lf
);
723 hOldFont
= SelectObject(dc
, hFont
);
725 if(Radio
&& ((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
))
727 SetBkMode(dc
, OPAQUE
);
728 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
729 TextOut(dc
, r
->left
, r
->top
, &Center
, 1);
730 SetBkMode(dc
, TRANSPARENT
);
731 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
732 TextOut(dc
, r
->left
, r
->top
, &OutRight
, 1);
733 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
734 TextOut(dc
, r
->left
, r
->top
, &OutLeft
, 1);
738 SetBkMode(dc
, TRANSPARENT
);
740 /* Center section, white for active, grey for inactive */
741 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
742 SetTextColor(dc
, GetSysColor(i
));
743 TextOut(dc
, r
->left
, r
->top
, &Center
, 1);
745 if(uFlags
& (DFCS_FLAT
| DFCS_MONO
))
747 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
748 TextOut(dc
, r
->left
, r
->top
, &OutRight
, 1);
749 TextOut(dc
, r
->left
, r
->top
, &OutLeft
, 1);
750 TextOut(dc
, r
->left
, r
->top
, &InRight
, 1);
751 TextOut(dc
, r
->left
, r
->top
, &InLeft
, 1);
755 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
756 TextOut(dc
, r
->left
, r
->top
, &OutRight
, 1);
757 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
758 TextOut(dc
, r
->left
, r
->top
, &OutLeft
, 1);
759 SetTextColor(dc
, GetSysColor(COLOR_3DDKSHADOW
));
760 TextOut(dc
, r
->left
, r
->top
, &InRight
, 1);
761 SetTextColor(dc
, GetSysColor(COLOR_3DLIGHT
));
762 TextOut(dc
, r
->left
, r
->top
, &InLeft
, 1);
766 if(uFlags
& DFCS_CHECKED
)
768 TCHAR Check
= (Radio
) ? 'i' : 'b';
770 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
771 TextOut(dc
, r
->left
, r
->top
, &Check
, 1);
774 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
775 SelectObject(dc
, hOldFont
);
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
:
835 IntDrawRectEdge(dc
,r
,(uFlags
&DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, BF_RECT
| BF_MIDDLE
| BF_SOFT
);
836 ZeroMemory(&lf
, sizeof(LOGFONTW
));
837 UITOOLS_MakeSquareRect(r
, &myr
);
842 if(uFlags
& DFCS_PUSHED
)
843 OffsetRect(&myr
,1,1);
844 lf
.lfHeight
= myr
.bottom
- myr
.top
;
846 lf
.lfWeight
= FW_NORMAL
;
847 lf
.lfCharSet
= DEFAULT_CHARSET
;
848 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
849 hFont
= CreateFontIndirect(&lf
);
850 /* save font and text color */
851 hOldFont
= SelectObject(dc
, hFont
);
852 clrsave
= GetTextColor(dc
);
853 bkmode
= GetBkMode(dc
);
854 /* set color and drawing mode */
855 SetBkMode(dc
, TRANSPARENT
);
856 if(uFlags
& DFCS_INACTIVE
)
859 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
860 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
862 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
863 /* draw selected symbol */
864 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
865 /* restore previous settings */
866 SetTextColor(dc
, clrsave
);
867 SelectObject(dc
, hOldFont
);
868 SetBkMode(dc
, bkmode
);
873 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
876 HFONT hFont
, hOldFont
;
881 switch(uFlags
& 0xff)
883 case DFCS_SCROLLCOMBOBOX
:
884 case DFCS_SCROLLDOWN
:
892 case DFCS_SCROLLLEFT
:
896 case DFCS_SCROLLRIGHT
:
900 case DFCS_SCROLLSIZEGRIP
:
901 case DFCS_SCROLLSIZEGRIPRIGHT
:
902 ZeroMemory(&lf
, sizeof(LOGFONTW
));
903 UITOOLS_MakeSquareRect(r
, &myr
);
904 lf
.lfHeight
= myr
.bottom
- myr
.top
;
906 lf
.lfWeight
= FW_NORMAL
;
907 lf
.lfCharSet
= DEFAULT_CHARSET
;
908 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
909 hFont
= CreateFontIndirect(&lf
);
910 /* save font and text color */
911 hOldFont
= SelectObject(dc
, hFont
);
912 clrsave
= GetTextColor(dc
);
913 bkmode
= GetBkMode(dc
);
914 /* set color and drawing mode */
915 SetBkMode(dc
, TRANSPARENT
);
916 if (!(uFlags
& (DFCS_MONO
| DFCS_FLAT
)))
918 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
919 /* draw selected symbol */
920 Symbol
= ((uFlags
& 0xff) == DFCS_SCROLLSIZEGRIP
) ? 'o' : 'x';
921 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
922 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
924 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
925 /* draw selected symbol */
926 Symbol
= ((uFlags
& 0xff) == DFCS_SCROLLSIZEGRIP
) ? 'p' : 'y';
927 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
928 /* restore previous settings */
929 SetTextColor(dc
, clrsave
);
930 SelectObject(dc
, hOldFont
);
931 SetBkMode(dc
, bkmode
);
937 IntDrawRectEdge(dc
, r
, (uFlags
& DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
);
938 ZeroMemory(&lf
, sizeof(LOGFONTW
));
939 UITOOLS_MakeSquareRect(r
, &myr
);
944 if(uFlags
& DFCS_PUSHED
)
945 OffsetRect(&myr
,1,1);
946 lf
.lfHeight
= myr
.bottom
- myr
.top
;
948 lf
.lfWeight
= FW_NORMAL
;
949 lf
.lfCharSet
= DEFAULT_CHARSET
;
950 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
951 hFont
= CreateFontIndirect(&lf
);
952 /* save font and text color */
953 hOldFont
= SelectObject(dc
, hFont
);
954 clrsave
= GetTextColor(dc
);
955 bkmode
= GetBkMode(dc
);
956 /* set color and drawing mode */
957 SetBkMode(dc
, TRANSPARENT
);
958 if(uFlags
& DFCS_INACTIVE
)
961 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
962 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
964 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
965 /* draw selected symbol */
966 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
967 /* restore previous settings */
968 SetTextColor(dc
, clrsave
);
969 SelectObject(dc
, hOldFont
);
970 SetBkMode(dc
, bkmode
);
975 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
978 HFONT hFont
, hOldFont
;
980 switch(uFlags
& 0xff)
986 case DFCS_MENUARROWRIGHT
:
987 Symbol
= 'w'; // FIXME: needs to confirm
990 case DFCS_MENUBULLET
:
1000 DbgPrint("Invalid menu; flags=0x%04x\n", uFlags);
1004 /* acquire ressources only if valid menu */
1005 ZeroMemory(&lf
, sizeof(LOGFONTW
));
1006 lf
.lfHeight
= r
->bottom
- r
->top
;
1008 lf
.lfWeight
= FW_NORMAL
;
1009 lf
.lfCharSet
= DEFAULT_CHARSET
;
1010 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
1011 hFont
= CreateFontIndirect(&lf
);
1013 hOldFont
= SelectObject(dc
, hFont
);
1014 // FIXME selecting color doesn't work
1016 if(uFlags
& DFCS_INACTIVE
)
1019 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
1020 TextOut(dc
, r
->left
+ 1, r
->top
+ 1, &Symbol
, 1);
1022 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
1024 /* draw selected symbol */
1025 TextOut(dc
, r
->left
, r
->top
, &Symbol
, 1);
1026 /* restore previous settings */
1027 SelectObject(dc
, hOldFont
);
1028 DeleteObject(hFont
);
1037 GRAYSTRINGPROC lpOutputFunc
,
1046 // AG: Mostly implemented, but probably won't work properly or return
1047 // correct error codes. I doubt it grays strings either... Untested!
1049 BOOL success
= FALSE
;
1052 HBITMAP MemBMP
= NULL
, OldBMP
= NULL
;
1053 HBRUSH OldBrush
= NULL
;
1054 HFONT OldFont
= NULL
;
1056 COLORREF ForeColor
, BackColor
;
1058 ForeColor
= SetTextColor(hDC
, RGB(0, 0, 0));
1059 BackColor
= SetBkColor(hDC
, RGB(255, 255, 255));
1063 // The documentation is a little vague on what exactly should happen
1064 // here. Something about using the same brush for window text???
1065 hBrush
= (HBRUSH
) GetCurrentObject(hDC
, OBJ_BRUSH
);
1068 if ((nCount
== -1) && (! lpOutputFunc
))
1073 // TODO: calculate the length (easy enough)
1076 nCount
= lstrlenW((WCHAR
*)lpData
);
1078 nCount
= lstrlenA((CHAR
*)lpData
);
1081 if (! nWidth
|| ! nHeight
)
1084 // TODO: calculate the rect
1087 success
= GetTextExtentPoint32W(hDC
, (WCHAR
*) lpData
, nCount
, &s
);
1089 success
= GetTextExtentPoint32A(hDC
, (CHAR
*) lpData
, nCount
, &s
);
1091 if (! success
) goto cleanup
;
1093 if (! nWidth
) nWidth
= s
.cx
;
1094 if (! nHeight
) nHeight
= s
.cy
;
1097 SetRect(&r
, X
, Y
, X
+ nWidth
, Y
+ nHeight
);
1099 MemDC
= CreateCompatibleDC(hDC
);
1100 if (! MemDC
) goto cleanup
;
1101 MemBMP
= CreateBitmap(nWidth
, nHeight
, 1, 1, NULL
);
1102 if (! MemBMP
) goto cleanup
;
1103 OldBMP
= SelectObject(MemDC
, MemBMP
);
1104 if (! OldBMP
) goto cleanup
;
1105 OldFont
= SelectObject(MemDC
, GetCurrentObject(hDC
, OBJ_FONT
));
1106 if (! OldFont
) goto cleanup
;
1107 OldBrush
= SelectObject(MemDC
, hBrush
);
1108 if (! OldBrush
) goto cleanup
;
1110 if (! BitBlt(MemDC
, 0, 0, nWidth
, nHeight
, hDC
, X
, Y
, SRCCOPY
)) goto cleanup
;
1112 SetTextColor(MemDC
, RGB(255, 255, 255));
1113 SetBkColor(MemDC
, RGB(0, 0, 0));
1117 success
= lpOutputFunc(MemDC
, lpData
, nCount
); // Set brush etc first?
1119 if ((nCount
== -1) && (! success
))
1121 // Don't gray (documented behaviour)
1122 success
= (BOOL
) BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
);
1129 success
= TextOutW(MemDC
, 0, 0, (WCHAR
*) lpData
, nCount
);
1131 success
= TextOutA(MemDC
, 0, 0, (CHAR
*) lpData
, nCount
);
1133 if (! success
) goto cleanup
;
1135 hbsave
= (HBRUSH
)SelectObject(MemDC
, gpsi
->hbrGray
);
1136 PatBlt(MemDC
, 0, 0, nWidth
, nHeight
, 0x000A0329);
1137 SelectObject(MemDC
, hbsave
);
1140 if (! BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
)) goto cleanup
;
1143 SetTextColor(hDC
, ForeColor
);
1144 SetBkColor(hDC
, BackColor
);
1148 if (OldFont
) SelectObject(MemDC
, OldFont
);
1149 if (OldBrush
) SelectObject(MemDC
, OldBrush
);
1150 if (OldBMP
) SelectObject(MemDC
, OldBMP
);
1151 if (MemBMP
) DeleteObject(MemBMP
);
1158 /**********************************************************************
1159 * PAINTING_DrawStateJam
1161 * Jams in the requested type in the dc
1163 static BOOL
PAINTING_DrawStateJam(HDC hdc
, UINT opcode
,
1164 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1165 LPRECT rc
, UINT dtflags
, BOOL unicode
)
1170 INT cx
= rc
->right
- rc
->left
;
1171 INT cy
= rc
->bottom
- rc
->top
;
1176 case DST_PREFIXTEXT
:
1178 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1180 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1183 return DrawIconEx(hdc
, rc
->left
, rc
->top
, (HICON
)lp
, cx
, cy
, 0, NULL
, DI_NORMAL
);
1186 memdc
= CreateCompatibleDC(hdc
);
1189 hbmsave
= (HBITMAP
)SelectObject(memdc
, (HBITMAP
)lp
);
1195 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
1196 SelectObject(memdc
, hbmsave
);
1204 /* DRAWSTATEPROC assumes that it draws at the center of coordinates */
1206 OffsetViewportOrgEx(hdc
, rc
->left
, rc
->top
, NULL
);
1207 bRet
= func(hdc
, lp
, wp
, cx
, cy
);
1208 /* Restore origin */
1209 OffsetViewportOrgEx(hdc
, -rc
->left
, -rc
->top
, NULL
);
1221 IntDrawState(HDC hdc
, HBRUSH hbr
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1222 INT x
, INT y
, INT cx
, INT cy
, UINT flags
, BOOL unicode
)
1224 HBITMAP hbm
, hbmsave
;
1226 HBRUSH hbsave
, hbrtmp
= 0;
1229 UINT dtflags
= DT_NOCLIP
;
1231 UINT opcode
= flags
& 0xf;
1235 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
1238 len
= lstrlenW((LPWSTR
)lp
);
1240 len
= lstrlenA((LPSTR
)lp
);
1243 /* Find out what size the image has if not given by caller */
1252 case DST_PREFIXTEXT
:
1254 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
1256 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
1262 if(!get_icon_size((HICON
)lp
, &s
))
1267 if(!GetObjectW((HBITMAP
)lp
, sizeof(bm
), &bm
))
1273 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1288 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1289 dtflags
|= DT_RIGHT
;
1290 if(opcode
== DST_TEXT
)
1291 dtflags
|= DT_NOPREFIX
;
1292 else if(opcode
== DST_PREFIXTEXT
)
1294 if (flags
& DSS_HIDEPREFIX
)
1295 dtflags
|= DT_HIDEPREFIX
;
1296 if (flags
& DSS_PREFIXONLY
)
1297 dtflags
|= DT_PREFIXONLY
;
1300 /* For DSS_NORMAL we just jam in the image and return */
1301 if((flags
& 0x79f0) == DSS_NORMAL
)
1303 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1306 /* For all other states we need to convert the image to B/W in a local bitmap */
1307 /* before it is displayed */
1308 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1309 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1310 hbm
= NULL
; hbmsave
= NULL
;
1311 memdc
= NULL
; hbsave
= NULL
;
1312 retval
= FALSE
; /* assume failure */
1314 /* From here on we must use "goto cleanup" when something goes wrong */
1315 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1318 memdc
= CreateCompatibleDC(hdc
);
1321 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
1324 rc
.left
= rc
.top
= 0;
1327 if(!FillRect(memdc
, &rc
, (HBRUSH
)GetStockObject(WHITE_BRUSH
)))
1329 SetBkColor(memdc
, RGB(255, 255, 255));
1330 SetTextColor(memdc
, RGB(0, 0, 0));
1331 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1333 /* DST_COMPLEX may draw text as well,
1334 * so we must be sure that correct font is selected
1336 if(!hfsave
&& (opcode
<= DST_PREFIXTEXT
))
1338 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1340 SelectObject(memdc
, hfsave
);
1344 /* This state cause the image to be dithered */
1345 if(flags
& DSS_UNION
)
1347 hbsave
= (HBRUSH
)SelectObject(memdc
, gpsi
->hbrGray
);
1348 if(!hbsave
) goto cleanup
;
1349 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1350 SelectObject(memdc
, hbsave
);
1351 if(!tmp
) goto cleanup
;
1354 if (flags
& DSS_DISABLED
)
1355 hbrtmp
= GetSysColorBrush(COLOR_3DHILIGHT
);
1356 else if (flags
& DSS_DEFAULT
)
1357 hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1359 /* Draw light or dark shadow */
1360 if (flags
& (DSS_DISABLED
|DSS_DEFAULT
))
1364 hbsave
= (HBRUSH
)SelectObject(hdc
, hbrtmp
);
1367 if(!BitBlt(hdc
, x
+1, y
+1, cx
, cy
, memdc
, 0, 0, 0x00B8074A))
1369 SelectObject(hdc
, hbsave
);
1372 if (flags
& DSS_DISABLED
)
1374 hbr
= hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1380 hbr
= (HBRUSH
)GetStockObject(BLACK_BRUSH
);
1383 hbsave
= (HBRUSH
)SelectObject(hdc
, hbr
);
1385 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A))
1388 retval
= TRUE
; /* We succeeded */
1391 SetTextColor(hdc
, fg
);
1392 SetBkColor(hdc
, bg
);
1395 SelectObject(hdc
, hbsave
);
1397 SelectObject(memdc
, hbmsave
);
1410 RealDrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1412 if (GetMapMode(hDC
) != MM_TEXT
)
1418 return UITOOLS95_DrawFrameButton(hDC
, rc
, uState
);
1420 return UITOOLS95_DrawFrameCaption(hDC
, rc
, uState
);
1422 return UITOOLS95_DrawFrameMenu(hDC
, rc
, uState
);
1429 return UITOOLS95_DrawFrameScroll(hDC
, rc
, uState
);
1435 DrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1437 BOOL Hook
, Ret
= FALSE
;
1441 Hook
= BeginIfHookedUserApiHook();
1443 /* Bypass SEH and go direct. */
1444 if (!Hook
) return RealDrawFrameControl(hDC
, rc
, uType
, uState
);
1448 Ret
= guah
.DrawFrameControl(hDC
, rc
, uType
, uState
);
1450 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1464 DrawEdge(HDC hDC
, LPRECT rc
, UINT edge
, UINT flags
)
1466 if (flags
& BF_DIAGONAL
)
1467 return IntDrawDiagEdge(hDC
, rc
, edge
, flags
);
1469 return IntDrawRectEdge(hDC
, rc
, edge
, flags
);
1476 GrayStringA(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1477 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1479 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, FALSE
);
1486 GrayStringW(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1487 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1489 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, TRUE
);
1496 InvertRect(HDC hDC
, CONST RECT
*lprc
)
1498 return PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1499 lprc
->bottom
- lprc
->top
, DSTINVERT
);
1506 FrameRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1511 if ((r
.right
<= r
.left
) || (r
.bottom
<= r
.top
)) return 0;
1512 if (!(oldbrush
= SelectObject(hDC
, hbr
))) return 0;
1514 PatBlt(hDC
, r
.left
, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1515 PatBlt(hDC
, r
.right
- 1, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1516 PatBlt(hDC
, r
.left
, r
.top
, r
.right
- r
.left
, 1, PATCOPY
);
1517 PatBlt(hDC
, r
.left
, r
.bottom
- 1, r
.right
- r
.left
, 1, PATCOPY
);
1519 SelectObject(hDC
, oldbrush
);
1527 FlashWindow(HWND hWnd
, BOOL bInvert
)
1529 FLASHWINFO FlashWndInfo
;
1531 FlashWndInfo
.cbSize
= sizeof(FLASHWINFO
);
1532 FlashWndInfo
.hwnd
= hWnd
;
1533 FlashWndInfo
.dwFlags
= !bInvert
? 0 : (FLASHW_TRAY
| FLASHW_CAPTION
);
1534 FlashWndInfo
.uCount
= 1;
1535 FlashWndInfo
.dwTimeout
= 0;
1537 return NtUserFlashWindowEx(&FlashWndInfo
);
1544 FillRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1547 HBRUSH prevhbr
= NULL
;
1549 /* Select brush if specified */
1552 /* Handle system colors */
1553 if (hbr
<= (HBRUSH
)(COLOR_MENUBAR
+ 1))
1554 hbr
= GetSysColorBrush(PtrToUlong(hbr
) - 1);
1556 prevhbr
= SelectObject(hDC
, hbr
);
1557 if (prevhbr
== NULL
)
1561 Ret
= PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1562 lprc
->bottom
- lprc
->top
, PATCOPY
);
1564 /* Select old brush */
1566 SelectObject(hDC
, prevhbr
);
1575 DrawFocusRect(HDC hdc
, CONST RECT
*rect
)
1580 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH
, 0, &cx
, 0);
1581 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT
, 0, &cy
, 0);
1583 OldObj
= SelectObject(hdc
, gpsi
->hbrGray
);
1586 PatBlt(hdc
, rect
->left
, rect
->top
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1588 PatBlt(hdc
, rect
->left
, rect
->bottom
- cy
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1590 PatBlt(hdc
, rect
->left
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1592 PatBlt(hdc
, rect
->right
- cx
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1594 SelectObject(hdc
, OldObj
);
1602 DrawStateA(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1603 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1605 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, FALSE
);
1612 DrawStateW(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1613 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1615 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, TRUE
);