2 * ReactOS User32 Library
3 * - Various drawing functions
5 * Copyright 2001 Casper S. Hournstroup
6 * Copyright 2003 Andrew Greenwood
7 * Copyright 2003 Filip Navara
11 * Copyright 1993, 1994 Alexandre Julliard
12 * Copyright 2002 Bill Medland
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /* INCLUDES *******************************************************************/
33 #include <wine/debug.h>
35 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
37 /* GLOBALS *******************************************************************/
39 #define DSS_DEFAULT 0x0040 /* Make it bold */
41 static const WORD wPattern_AA55
[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
42 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
44 /* These tables are used in:
45 * UITOOLS_DrawDiagEdge()
46 * UITOOLS_DrawRectEdge()
48 static const signed char LTInnerNormal
[] = {
50 -1, COLOR_BTNHIGHLIGHT
, COLOR_BTNHIGHLIGHT
, -1,
51 -1, COLOR_3DDKSHADOW
, COLOR_3DDKSHADOW
, -1,
55 static const signed char LTOuterNormal
[] = {
56 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
57 COLOR_BTNHIGHLIGHT
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
58 COLOR_3DDKSHADOW
, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1,
59 -1, COLOR_3DLIGHT
, COLOR_BTNSHADOW
, -1
62 static const signed char RBInnerNormal
[] = {
64 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
65 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
69 static const signed char RBOuterNormal
[] = {
70 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
71 COLOR_BTNSHADOW
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
72 COLOR_3DLIGHT
, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1,
73 -1, COLOR_3DDKSHADOW
, COLOR_BTNHIGHLIGHT
, -1
76 static const signed char LTInnerSoft
[] = {
78 -1, COLOR_3DLIGHT
, COLOR_3DLIGHT
, -1,
79 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, -1,
83 static const signed char LTOuterSoft
[] = {
84 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
85 COLOR_3DLIGHT
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
86 COLOR_BTNSHADOW
, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1,
87 -1, COLOR_BTNHIGHLIGHT
, COLOR_3DDKSHADOW
, -1
90 #define RBInnerSoft RBInnerNormal /* These are the same */
91 #define RBOuterSoft RBOuterNormal
93 static const signed char LTRBOuterMono
[] = {
94 -1, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
95 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
96 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
97 COLOR_WINDOW
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
, COLOR_WINDOWFRAME
,
100 static const signed char LTRBInnerMono
[] = {
102 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
103 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
104 -1, COLOR_WINDOW
, COLOR_WINDOW
, COLOR_WINDOW
,
107 static const signed char LTRBOuterFlat
[] = {
108 -1, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
109 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
110 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
111 COLOR_BTNFACE
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
, COLOR_BTNSHADOW
,
114 static const signed char LTRBInnerFlat
[] = {
116 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
117 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
118 -1, COLOR_BTNFACE
, COLOR_BTNFACE
, COLOR_BTNFACE
,
120 /* FUNCTIONS *****************************************************************/
123 HPEN WINAPI
GetSysColorPen(int nIndex
);
124 HBRUSH WINAPI
GetSysColorBrush(int nIndex
);
126 /* Ported from WINE20020904 */
127 /* Same as DrawEdge invoked with BF_DIAGONAL */
128 static BOOL
IntDrawDiagEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
)
131 signed char InnerI
, OuterI
;
132 HPEN InnerPen
, OuterPen
;
137 int Width
= rc
->right
- rc
->left
;
138 int Height
= rc
->bottom
- rc
->top
;
139 int SmallDiam
= Width
> Height
? Height
: Width
;
140 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
141 || (uType
& BDR_OUTER
) == BDR_OUTER
)
142 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
143 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
144 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
147 OuterPen
= InnerPen
= (HPEN
)GetStockObject(NULL_PEN
);
148 SavePen
= (HPEN
)SelectObject(hdc
, InnerPen
);
149 spx
= spy
= epx
= epy
= 0; /* Satisfy the compiler... */
151 /* Determine the colors of the edges */
154 InnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
155 OuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
157 else if(uFlags
& BF_FLAT
)
159 InnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
160 OuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
162 else if(uFlags
& BF_SOFT
)
164 if(uFlags
& BF_BOTTOM
)
166 InnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
167 OuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
171 InnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
172 OuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
177 if(uFlags
& BF_BOTTOM
)
179 InnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
180 OuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
184 InnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
185 OuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
190 InnerPen
= GetSysColorPen(InnerI
);
192 OuterPen
= GetSysColorPen(OuterI
);
194 MoveToEx(hdc
, 0, 0, &SavePoint
);
196 /* Don't ask me why, but this is what is visible... */
197 /* This must be possible to do much simpler, but I fail to */
198 /* see the logic in the MS implementation (sigh...). */
199 /* So, this might look a bit brute force here (and it is), but */
200 /* it gets the job done;) */
202 switch(uFlags
& BF_RECT
)
208 /* Left bottom endpoint */
210 spx
= epx
+ SmallDiam
;
212 spy
= epy
- SmallDiam
;
217 /* Left top endpoint */
219 spx
= epx
+ SmallDiam
;
221 spy
= epy
+ SmallDiam
;
227 case BF_RIGHT
|BF_LEFT
:
228 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
229 case BF_BOTTOM
|BF_TOP
:
230 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
231 case BF_BOTTOMRIGHT
|BF_LEFT
:
232 case BF_BOTTOMRIGHT
|BF_TOP
:
234 /* Right top endpoint */
236 epx
= spx
+ SmallDiam
;
238 epy
= spy
- SmallDiam
;
242 MoveToEx(hdc
, spx
, spy
, NULL
);
243 SelectObject(hdc
, OuterPen
);
244 LineTo(hdc
, epx
, epy
);
246 SelectObject(hdc
, InnerPen
);
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
)
340 HBRUSH hb
= GetSysColorBrush(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
);
342 HPEN hp
= GetSysColorPen(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
);
343 hbsave
= (HBRUSH
)SelectObject(hdc
, hb
);
344 hpsave
= (HPEN
)SelectObject(hdc
, hp
);
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
= GetSysColorPen(LTInnerI
);
508 LTOuterPen
= GetSysColorPen(LTOuterI
);
510 RBInnerPen
= GetSysColorPen(RBInnerI
);
512 RBOuterPen
= GetSysColorPen(RBOuterI
);
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
);
524 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
525 LineTo(hdc
, InnerRect
.right
, InnerRect
.top
);
529 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.top
, NULL
);
530 LineTo(hdc
, InnerRect
.left
, InnerRect
.bottom
);
532 SelectObject(hdc
, RBOuterPen
);
533 if(uFlags
& BF_BOTTOM
)
535 MoveToEx(hdc
, InnerRect
.left
, InnerRect
.bottom
-1, NULL
);
536 LineTo(hdc
, InnerRect
.right
, InnerRect
.bottom
-1);
538 if(uFlags
& BF_RIGHT
)
540 MoveToEx(hdc
, InnerRect
.right
-1, InnerRect
.top
, NULL
);
541 LineTo(hdc
, InnerRect
.right
-1, InnerRect
.bottom
);
544 /* Draw the inner edge */
545 SelectObject(hdc
, LTInnerPen
);
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 if(uFlags
& BF_BOTTOM
)
559 MoveToEx(hdc
, InnerRect
.left
+LBpenplus
, InnerRect
.bottom
-2, NULL
);
560 LineTo(hdc
, InnerRect
.right
-RBpenplus
, InnerRect
.bottom
-2);
562 if(uFlags
& BF_RIGHT
)
564 MoveToEx(hdc
, InnerRect
.right
-2, InnerRect
.top
+RTpenplus
, NULL
);
565 LineTo(hdc
, InnerRect
.right
-2, InnerRect
.bottom
-RBpenplus
);
568 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
570 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0)
571 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? 1 : 0);
574 InnerRect
.left
+= add
;
575 if(uFlags
& BF_RIGHT
)
576 InnerRect
.right
-= add
;
578 InnerRect
.top
+= add
;
579 if(uFlags
& BF_BOTTOM
)
580 InnerRect
.bottom
-= add
;
582 if(uFlags
& BF_ADJUST
)
587 SelectObject(hdc
, SavePen
);
588 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
592 /* Ported from WINE20020904 */
593 /* Utility to create a square rectangle and returning the width */
594 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
596 int Width
= src
->right
- src
->left
;
597 int Height
= src
->bottom
- src
->top
;
598 int SmallDiam
= Width
> Height
? Height
: Width
;
602 /* Make it a square box */
603 if(Width
< Height
) /* SmallDiam == Width */
605 dst
->top
+= (Height
-Width
)/2;
606 dst
->bottom
= dst
->top
+ SmallDiam
;
608 else if(Width
> Height
) /* SmallDiam == Height */
610 dst
->left
+= (Width
-Height
)/2;
611 dst
->right
= dst
->left
+ SmallDiam
;
617 /* Ported from WINE20020904 */
618 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
620 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
622 HBITMAP hbm
= CreateBitmap(8, 8, 1, 1, wPattern_AA55
);
624 HBRUSH hb
= CreatePatternBrush(hbm
);
627 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
628 bg
= SetBkColor(dc
, RGB(255, 255, 255));
629 hbsave
= (HBRUSH
)SelectObject(dc
, hb
);
630 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
631 SelectObject(dc
, hbsave
);
638 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
642 /* Ported from WINE20020904 */
643 /* Draw a push button coming from DrawFrameControl()
645 * Does a pretty good job in emulating MS behavior. Some quirks are
646 * however there because MS uses a TrueType font (Marlett) to draw
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
)
697 HFONT hFont
, hOldFont
;
699 TCHAR OutRight
, OutLeft
, InRight
, InLeft
, Center
;
703 OutRight
= 'j'; // Outer right
704 OutLeft
= 'k'; // Outer left
705 InRight
= 'l'; // inner left
706 InLeft
= 'm'; // inner right
707 Center
= 'n'; // center
710 OutRight
= 'c'; // Outer right
711 OutLeft
= 'd'; // Outer left
712 InRight
= 'e'; // inner left
713 InLeft
= 'f'; // inner right
714 Center
= 'g'; // center
717 SmallDiam
= UITOOLS_MakeSquareRect(r
, &rc
);
719 ZeroMemory(&lf
, sizeof(LOGFONT
));
720 lf
.lfHeight
= SmallDiam
;
722 lf
.lfWeight
= FW_NORMAL
;
723 lf
.lfCharSet
= DEFAULT_CHARSET
;
724 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
725 hFont
= CreateFontIndirect(&lf
);
726 hOldFont
= SelectObject(dc
, hFont
);
728 if(Radio
&& ((uFlags
& 0xff) == DFCS_BUTTONRADIOMASK
))
730 SetBkMode(dc
, OPAQUE
);
731 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
732 TextOut(dc
, rc
.left
, rc
.top
, &Center
, 1);
733 SetBkMode(dc
, TRANSPARENT
);
734 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
735 TextOut(dc
, rc
.left
, rc
.top
, &OutRight
, 1);
736 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
737 TextOut(dc
, rc
.left
, rc
.top
, &OutLeft
, 1);
741 SetBkMode(dc
, TRANSPARENT
);
743 /* Center section, white for active, grey for inactive */
744 i
= !(uFlags
& (DFCS_INACTIVE
|DFCS_PUSHED
)) ? COLOR_WINDOW
: COLOR_BTNFACE
;
745 SetTextColor(dc
, GetSysColor(i
));
746 TextOut(dc
, rc
.left
, rc
.top
, &Center
, 1);
748 if(uFlags
& (DFCS_FLAT
| DFCS_MONO
))
750 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
751 TextOut(dc
, rc
.left
, rc
.top
, &OutRight
, 1);
752 TextOut(dc
, rc
.left
, rc
.top
, &OutLeft
, 1);
753 TextOut(dc
, rc
.left
, rc
.top
, &InRight
, 1);
754 TextOut(dc
, rc
.left
, rc
.top
, &InLeft
, 1);
758 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
759 TextOut(dc
, rc
.left
, rc
.top
, &OutRight
, 1);
760 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
761 TextOut(dc
, rc
.left
, rc
.top
, &OutLeft
, 1);
762 SetTextColor(dc
, GetSysColor(COLOR_3DDKSHADOW
));
763 TextOut(dc
, rc
.left
, rc
.top
, &InRight
, 1);
764 SetTextColor(dc
, GetSysColor(COLOR_3DLIGHT
));
765 TextOut(dc
, rc
.left
, rc
.top
, &InLeft
, 1);
769 if(uFlags
& DFCS_CHECKED
)
771 TCHAR Check
= (Radio
) ? 'i' : 'b';
773 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
774 TextOut(dc
, rc
.left
, rc
.top
, &Check
, 1);
777 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
778 SelectObject(dc
, hOldFont
);
784 /* Ported from WINE20020904 */
785 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
787 switch(uState
& 0xff)
789 case DFCS_BUTTONPUSH
:
790 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
792 case DFCS_BUTTONCHECK
:
793 case DFCS_BUTTON3STATE
:
794 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, FALSE
);
796 case DFCS_BUTTONRADIOIMAGE
:
797 case DFCS_BUTTONRADIOMASK
:
798 case DFCS_BUTTONRADIO
:
799 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, TRUE
);
803 DbgPrint("Invalid button state=0x%04x\n", uState);
810 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
812 int colorIdx
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
814 HFONT hFont
, hOldFont
;
819 switch(uFlags
& 0xff)
821 case DFCS_CAPTIONCLOSE
:
824 case DFCS_CAPTIONHELP
:
827 case DFCS_CAPTIONMIN
:
830 case DFCS_CAPTIONMAX
:
833 case DFCS_CAPTIONRESTORE
:
839 if(uFlags
& DFCS_PUSHED
)
840 IntDrawRectEdge(dc
,r
,EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
| BF_SOFT
);
842 IntDrawRectEdge(dc
,r
,BDR_RAISEDINNER
| BDR_RAISEDOUTER
, BF_RECT
|
843 BF_SOFT
| BF_MIDDLE
);
844 ZeroMemory(&lf
, sizeof(LOGFONT
));
845 UITOOLS_MakeSquareRect(r
, &myr
);
850 if(uFlags
& DFCS_PUSHED
)
851 OffsetRect(&myr
,1,1);
852 lf
.lfHeight
= myr
.bottom
- myr
.top
;
854 lf
.lfWeight
= FW_NORMAL
;
855 lf
.lfCharSet
= DEFAULT_CHARSET
;
856 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
857 hFont
= CreateFontIndirect(&lf
);
858 /* save font and text color */
859 hOldFont
= SelectObject(dc
, hFont
);
860 clrsave
= GetTextColor(dc
);
861 bkmode
= GetBkMode(dc
);
862 /* set color and drawing mode */
863 SetBkMode(dc
, TRANSPARENT
);
864 if(uFlags
& DFCS_INACTIVE
)
867 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
868 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
870 SetTextColor(dc
, GetSysColor(colorIdx
));
871 /* draw selected symbol */
872 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
873 /* restore previous settings */
874 SetTextColor(dc
, clrsave
);
875 SelectObject(dc
, hOldFont
);
876 SetBkMode(dc
, bkmode
);
881 static BOOL
UITOOLS95_DrawFrameScroll(HDC dc
, LPRECT r
, UINT uFlags
)
885 int SmallDiam
= UITOOLS_MakeSquareRect(r
, &myr
) - 2;
887 HBRUSH hbsave
, hb
, hb2
;
888 HPEN hpsave
, hp
, hp2
;
889 int tri
= 290*SmallDiam
/1000 - 1;
893 * This fixes a problem with really tiny "scroll" buttons. In particular
894 * with the updown control.
895 * Making sure that the arrow is as least 3 pixels wide (or high).
900 switch(uFlags
& 0xff)
902 case DFCS_SCROLLCOMBOBOX
:
903 case DFCS_SCROLLDOWN
:
904 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
905 Line
[2].y
= myr
.top
+ 687*SmallDiam
/1000 + 1;
906 Line
[0].x
= Line
[2].x
- tri
;
907 Line
[1].x
= Line
[2].x
+ tri
;
908 Line
[0].y
= Line
[1].y
= Line
[2].y
- tri
;
912 Line
[2].x
= myr
.left
+ 470*SmallDiam
/1000 + 2;
913 Line
[2].y
= myr
.bottom
- (687*SmallDiam
/1000 + 1);
914 Line
[0].x
= Line
[2].x
- tri
;
915 Line
[1].x
= Line
[2].x
+ tri
;
916 Line
[0].y
= Line
[1].y
= Line
[2].y
+ tri
;
919 case DFCS_SCROLLLEFT
:
920 Line
[2].x
= myr
.right
- (687*SmallDiam
/1000 + 1);
921 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
922 Line
[0].y
= Line
[2].y
- tri
;
923 Line
[1].y
= Line
[2].y
+ tri
;
924 Line
[0].x
= Line
[1].x
= Line
[2].x
+ tri
;
927 case DFCS_SCROLLRIGHT
:
928 Line
[2].x
= myr
.left
+ 687*SmallDiam
/1000 + 1;
929 Line
[2].y
= myr
.top
+ 470*SmallDiam
/1000 + 2;
930 Line
[0].y
= Line
[2].y
- tri
;
931 Line
[1].y
= Line
[2].y
+ tri
;
932 Line
[0].x
= Line
[1].x
= Line
[2].x
- tri
;
935 case DFCS_SCROLLSIZEGRIP
:
936 /* This one breaks the flow... */
937 IntDrawRectEdge(dc
, r
, EDGE_BUMP
, BF_MIDDLE
| ((uFlags
&(DFCS_MONO
|DFCS_FLAT
)) ? BF_MONO
: 0));
938 hpsave
= (HPEN
)SelectObject(dc
, GetStockObject(NULL_PEN
));
939 hbsave
= (HBRUSH
)SelectObject(dc
, GetStockObject(NULL_BRUSH
));
940 if(uFlags
& (DFCS_MONO
|DFCS_FLAT
))
942 hp
= hp2
= GetSysColorPen(COLOR_WINDOWFRAME
);
943 hb
= hb2
= GetSysColorBrush(COLOR_WINDOWFRAME
);
947 hp
= GetSysColorPen(COLOR_BTNHIGHLIGHT
);
948 hp2
= GetSysColorPen(COLOR_BTNSHADOW
);
949 hb
= GetSysColorBrush(COLOR_BTNHIGHLIGHT
);
950 hb2
= GetSysColorBrush(COLOR_BTNSHADOW
);
952 Line
[0].x
= Line
[1].x
= r
->right
-1;
953 Line
[2].y
= Line
[3].y
= r
->bottom
-1;
954 d46
= 46*SmallDiam
/750;
955 d93
= 93*SmallDiam
/750;
957 i
= 586*SmallDiam
/750;
958 Line
[0].y
= r
->bottom
- i
- 1;
959 Line
[3].x
= r
->right
- i
- 1;
960 Line
[1].y
= Line
[0].y
+ d46
;
961 Line
[2].x
= Line
[3].x
+ d46
;
962 SelectObject(dc
, hb
);
963 SelectObject(dc
, hp
);
964 Polygon(dc
, Line
, 4);
966 Line
[1].y
++; Line
[2].x
++;
967 Line
[0].y
= Line
[1].y
+ d93
;
968 Line
[3].x
= Line
[2].x
+ d93
;
969 SelectObject(dc
, hb2
);
970 SelectObject(dc
, hp2
);
971 Polygon(dc
, Line
, 4);
973 i
= 398*SmallDiam
/750;
974 Line
[0].y
= r
->bottom
- i
- 1;
975 Line
[3].x
= r
->right
- i
- 1;
976 Line
[1].y
= Line
[0].y
+ d46
;
977 Line
[2].x
= Line
[3].x
+ d46
;
978 SelectObject(dc
, hb
);
979 SelectObject(dc
, hp
);
980 Polygon(dc
, Line
, 4);
982 Line
[1].y
++; Line
[2].x
++;
983 Line
[0].y
= Line
[1].y
+ d93
;
984 Line
[3].x
= Line
[2].x
+ d93
;
985 SelectObject(dc
, hb2
);
986 SelectObject(dc
, hp2
);
987 Polygon(dc
, Line
, 4);
989 i
= 210*SmallDiam
/750;
990 Line
[0].y
= r
->bottom
- i
- 1;
991 Line
[3].x
= r
->right
- i
- 1;
992 Line
[1].y
= Line
[0].y
+ d46
;
993 Line
[2].x
= Line
[3].x
+ d46
;
994 SelectObject(dc
, hb
);
995 SelectObject(dc
, hp
);
996 Polygon(dc
, Line
, 4);
998 Line
[1].y
++; Line
[2].x
++;
999 Line
[0].y
= Line
[1].y
+ d93
;
1000 Line
[3].x
= Line
[2].x
+ d93
;
1001 SelectObject(dc
, hb2
);
1002 SelectObject(dc
, hp2
);
1003 Polygon(dc
, Line
, 4);
1005 SelectObject(dc
, hpsave
);
1006 SelectObject(dc
, hbsave
);
1013 /* Here do the real scroll-bar controls end up */
1014 if( ! (uFlags
& (0xff00 & ~DFCS_ADJUSTRECT
)) )
1015 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1016 /* want for the normal scroll-arrow button. */
1017 IntDrawRectEdge( dc
, r
, EDGE_RAISED
, (uFlags
&DFCS_ADJUSTRECT
) | BF_MIDDLE
| BF_RECT
);
1019 UITOOLS95_DFC_ButtonPush(dc
, r
, (uFlags
& 0xff00) );
1021 if(uFlags
& DFCS_INACTIVE
)
1023 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
1024 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(COLOR_BTNHIGHLIGHT
));
1025 Polygon(dc
, Line
, 3);
1026 SelectObject(dc
, hpsave
);
1027 SelectObject(dc
, hbsave
);
1030 if( (uFlags
& DFCS_INACTIVE
) || !(uFlags
& DFCS_PUSHED
) )
1031 for(i
= 0; i
< 3; i
++)
1037 i
= uFlags
& DFCS_INACTIVE
? COLOR_BTNSHADOW
: COLOR_BTNTEXT
;
1038 hbsave
= (HBRUSH
)SelectObject(dc
, GetSysColorBrush(i
));
1039 hpsave
= (HPEN
)SelectObject(dc
, GetSysColorPen(i
));
1040 Polygon(dc
, Line
, 3);
1041 SelectObject(dc
, hpsave
);
1042 SelectObject(dc
, hbsave
);
1047 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
1050 HFONT hFont
, hOldFont
;
1052 switch(uFlags
& 0xff)
1054 case DFCS_MENUARROW
:
1058 case DFCS_MENUBULLET
:
1062 case DFCS_MENUCHECK
:
1068 DbgPrint("Invalid menu; flags=0x%04x\n", uFlags);
1072 /* acquire ressources only if valid menu */
1073 ZeroMemory(&lf
, sizeof(LOGFONT
));
1074 lf
.lfHeight
= r
->bottom
- r
->top
;
1076 lf
.lfWeight
= FW_NORMAL
;
1077 lf
.lfCharSet
= DEFAULT_CHARSET
;
1078 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
1079 hFont
= CreateFontIndirect(&lf
);
1081 hOldFont
= SelectObject(dc
, hFont
);
1082 /* draw selected symbol */
1083 TextOut(dc
, r
->left
, r
->top
, &Symbol
, 1);
1084 /* restore previous settings */
1085 SelectObject(dc
, hOldFont
);
1086 DeleteObject(hFont
);
1095 GRAYSTRINGPROC lpOutputFunc
,
1104 // AG: Mostly implemented, but probably won't work properly or return
1105 // correct error codes. I doubt it grays strings either... Untested!
1107 BOOL success
= FALSE
;
1109 HBITMAP MemBMP
= NULL
,
1111 HBRUSH OldBrush
= NULL
;
1112 HFONT OldFont
= NULL
;
1114 COLORREF ForeColor
, BackColor
;
1116 ForeColor
= SetTextColor(hDC
, RGB(0, 0, 0));
1117 BackColor
= SetBkColor(hDC
, RGB(255, 255, 255));
1122 // The documentation is a little vague on what exactly should happen
1123 // here. Something about using the same brush for window text???
1124 hBrush
= (HBRUSH
) GetCurrentObject(hDC
, OBJ_BRUSH
);
1127 if ((nCount
== -1) && (! lpOutputFunc
))
1132 // TODO: calculate the length (easy enough)
1135 nCount
= lstrlenW((WCHAR
*)lpData
);
1137 nCount
= lstrlenA((CHAR
*)lpData
);
1140 if (! nWidth
|| ! nHeight
)
1143 // TODO: calculate the rect
1146 success
= GetTextExtentPoint32W(hDC
, (WCHAR
*) lpData
, nCount
, &s
);
1148 success
= GetTextExtentPoint32A(hDC
, (CHAR
*) lpData
, nCount
, &s
);
1150 if (! success
) goto cleanup
;
1152 if (! nWidth
) nWidth
= s
.cx
;
1153 if (! nHeight
) nHeight
= s
.cy
;
1156 SetRect(&r
, X
, Y
, X
+ nWidth
, Y
+ nHeight
);
1158 MemDC
= CreateCompatibleDC(hDC
);
1159 if (! MemDC
) goto cleanup
;
1160 MemBMP
= CreateBitmap(nWidth
, nHeight
, 1, 1, NULL
);
1161 if (! MemBMP
) goto cleanup
;
1162 OldBMP
= SelectObject(MemDC
, MemBMP
);
1163 if (! OldBMP
) goto cleanup
;
1164 OldFont
= SelectObject(MemDC
, GetCurrentObject(hDC
, OBJ_FONT
));
1165 if (! OldFont
) goto cleanup
;
1166 OldBrush
= SelectObject(MemDC
, hBrush
);
1167 if (! OldBrush
) goto cleanup
;
1169 if (! BitBlt(MemDC
, 0, 0, nWidth
, nHeight
, hDC
, X
, Y
, SRCCOPY
)) goto cleanup
;
1171 SetTextColor(MemDC
, RGB(255, 255, 255));
1172 SetBkColor(MemDC
, RGB(0, 0, 0));
1176 success
= lpOutputFunc(MemDC
, lpData
, nCount
); // Set brush etc first?
1178 if ((nCount
== -1) && (! success
))
1180 // Don't gray (documented behaviour)
1181 success
= (BOOL
) BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
);
1188 success
= TextOutW(MemDC
, 0, 0, (WCHAR
*) lpData
, nCount
);
1190 success
= TextOutA(MemDC
, 0, 0, (CHAR
*) lpData
, nCount
);
1192 if (! success
) goto cleanup
;
1194 PatBlt(MemDC
, 0, 0, nWidth
, nHeight
, PATCOPY
);
1195 // This is how WINE does it: (but we should have our own graying brush already)
1196 // hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
1197 // PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
1198 // SelectObject(memdc, hbsave);
1201 if (! BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
)) goto cleanup
;
1204 SetTextColor(hDC
, ForeColor
);
1205 SetBkColor(hDC
, BackColor
);
1209 if (OldFont
) SelectObject(MemDC
, OldFont
);
1210 if (OldBrush
) SelectObject(MemDC
, OldBrush
);
1211 if (OldBMP
) SelectObject(MemDC
, OldBMP
);
1212 if (MemBMP
) DeleteObject(MemBMP
);
1219 /**********************************************************************
1220 * PAINTING_DrawStateJam
1222 * Jams in the requested type in the dc
1224 static BOOL
PAINTING_DrawStateJam(HDC hdc
, UINT opcode
,
1225 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1226 LPRECT rc
, UINT dtflags
, BOOL unicode
)
1231 INT cx
= rc
->right
- rc
->left
;
1232 INT cy
= rc
->bottom
- rc
->top
;
1237 case DST_PREFIXTEXT
:
1239 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1241 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1244 return DrawIconEx(hdc
, rc
->left
, rc
->top
, (HICON
)lp
, cx
, cy
, 0, NULL
, DI_NORMAL
);
1247 memdc
= CreateCompatibleDC(hdc
);
1250 hbmsave
= (HBITMAP
)SelectObject(memdc
, (HBITMAP
)lp
);
1256 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
1257 SelectObject(memdc
, hbmsave
);
1265 /* DRAWSTATEPROC assumes that it draws at the center of coordinates */
1267 OffsetViewportOrgEx(hdc
, rc
->left
, rc
->top
, NULL
);
1268 bRet
= func(hdc
, lp
, wp
, cx
, cy
);
1269 /* Restore origin */
1270 OffsetViewportOrgEx(hdc
, -rc
->left
, -rc
->top
, NULL
);
1282 IntDrawState(HDC hdc
, HBRUSH hbr
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1283 INT x
, INT y
, INT cx
, INT cy
, UINT flags
, BOOL unicode
)
1285 HBITMAP hbm
, hbmsave
;
1287 HBRUSH hbsave
, hbrtmp
= 0;
1290 UINT dtflags
= DT_NOCLIP
;
1292 UINT opcode
= flags
& 0xf;
1296 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
1299 len
= lstrlenW((LPWSTR
)lp
);
1301 len
= lstrlenA((LPSTR
)lp
);
1304 /* Find out what size the image has if not given by caller */
1314 case DST_PREFIXTEXT
:
1316 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
1318 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
1324 if(!GetIconInfo((HICON
)lp
, &ici
))
1326 if(!GetObjectW(ici
.hbmColor
, sizeof(bm
), &bm
))
1333 if(!GetObjectW((HBITMAP
)lp
, sizeof(bm
), &bm
))
1339 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1354 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1355 dtflags
|= DT_RIGHT
;
1356 if(opcode
== DST_TEXT
)
1357 dtflags
|= DT_NOPREFIX
;
1358 else if(opcode
== DST_PREFIXTEXT
)
1360 if (flags
& DSS_HIDEPREFIX
)
1361 dtflags
|= DT_HIDEPREFIX
;
1362 if (flags
& DSS_PREFIXONLY
)
1363 dtflags
|= DT_PREFIXONLY
;
1366 /* For DSS_NORMAL we just jam in the image and return */
1367 if((flags
& 0x79f0) == DSS_NORMAL
)
1369 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1372 /* For all other states we need to convert the image to B/W in a local bitmap */
1373 /* before it is displayed */
1374 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1375 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1376 hbm
= NULL
; hbmsave
= NULL
;
1377 memdc
= NULL
; hbsave
= NULL
;
1378 retval
= FALSE
; /* assume failure */
1380 /* From here on we must use "goto cleanup" when something goes wrong */
1381 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1384 memdc
= CreateCompatibleDC(hdc
);
1387 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
1390 rc
.left
= rc
.top
= 0;
1393 if(!FillRect(memdc
, &rc
, (HBRUSH
)GetStockObject(WHITE_BRUSH
)))
1395 SetBkColor(memdc
, RGB(255, 255, 255));
1396 SetTextColor(memdc
, RGB(0, 0, 0));
1397 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1399 /* DST_COMPLEX may draw text as well,
1400 * so we must be sure that correct font is selected
1402 if(!hfsave
&& (opcode
<= DST_PREFIXTEXT
))
1404 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1406 SelectObject(memdc
, hfsave
);
1410 /* This state cause the image to be dithered */
1411 if(flags
& DSS_UNION
)
1414 hbsave
= (HBRUSH
)SelectObject(memdc
, CACHE_GetPattern55AABrush());
1417 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1418 SelectObject(memdc
, hbsave
);
1426 if (flags
& DSS_DISABLED
)
1427 hbrtmp
= CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT
));
1428 else if (flags
& DSS_DEFAULT
)
1429 hbrtmp
= CreateSolidBrush(GetSysColor(COLOR_3DSHADOW
));
1431 /* Draw light or dark shadow */
1432 if (flags
& (DSS_DISABLED
|DSS_DEFAULT
))
1436 hbsave
= (HBRUSH
)SelectObject(hdc
, hbrtmp
);
1439 if(!BitBlt(hdc
, x
+1, y
+1, cx
, cy
, memdc
, 0, 0, 0x00B8074A))
1441 SelectObject(hdc
, hbsave
);
1442 DeleteObject(hbrtmp
);
1446 if (flags
& DSS_DISABLED
)
1448 hbr
= hbrtmp
= CreateSolidBrush(GetSysColor(COLOR_3DSHADOW
));
1454 hbr
= (HBRUSH
)GetStockObject(BLACK_BRUSH
);
1457 hbsave
= (HBRUSH
)SelectObject(hdc
, hbr
);
1459 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A))
1462 retval
= TRUE
; /* We succeeded */
1465 SetTextColor(hdc
, fg
);
1466 SetBkColor(hdc
, bg
);
1469 SelectObject(hdc
, hbsave
);
1471 SelectObject(memdc
, hbmsave
);
1473 DeleteObject(hbrtmp
);
1486 DrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1488 if (GetMapMode(hDC
) != MM_TEXT
)
1494 return UITOOLS95_DrawFrameButton(hDC
, rc
, uState
);
1496 return UITOOLS95_DrawFrameCaption(hDC
, rc
, uState
);
1498 return UITOOLS95_DrawFrameMenu(hDC
, rc
, uState
);
1505 return UITOOLS95_DrawFrameScroll(hDC
, rc
, uState
);
1514 DrawEdge(HDC hDC
, LPRECT rc
, UINT edge
, UINT flags
)
1516 if (flags
& BF_DIAGONAL
)
1517 return IntDrawDiagEdge(hDC
, rc
, edge
, flags
);
1519 return IntDrawRectEdge(hDC
, rc
, edge
, flags
);
1526 GrayStringA(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1527 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1529 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, FALSE
);
1536 GrayStringW(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1537 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1539 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, TRUE
);
1546 InvertRect(HDC hDC
, CONST RECT
*lprc
)
1548 return PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1549 lprc
->bottom
- lprc
->top
, DSTINVERT
);
1556 FrameRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1561 if ((r
.right
<= r
.left
) || (r
.bottom
<= r
.top
)) return 0;
1562 if (!(oldbrush
= SelectObject(hDC
, hbr
))) return 0;
1564 PatBlt(hDC
, r
.left
, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1565 PatBlt(hDC
, r
.right
- 1, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1566 PatBlt(hDC
, r
.left
, r
.top
, r
.right
- r
.left
, 1, PATCOPY
);
1567 PatBlt(hDC
, r
.left
, r
.bottom
- 1, r
.right
- r
.left
, 1, PATCOPY
);
1569 SelectObject(hDC
, oldbrush
);
1577 FlashWindow(HWND hWnd
, BOOL bInvert
)
1579 FLASHWINFO FlashWndInfo
;
1581 FlashWndInfo
.cbSize
= sizeof(FLASHWINFO
);
1582 FlashWndInfo
.hwnd
= hWnd
;
1583 FlashWndInfo
.dwFlags
= !bInvert
? 0 : (FLASHW_TRAY
| FLASHW_CAPTION
);
1584 FlashWndInfo
.uCount
= 1;
1585 FlashWndInfo
.dwTimeout
= 0;
1587 return NtUserFlashWindowEx(&FlashWndInfo
);
1594 FillRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1598 if (hbr
<= (HBRUSH
)(COLOR_MENUBAR
+ 1))
1600 hbr
= GetSysColorBrush((int)hbr
- 1);
1602 if ((prevhbr
= SelectObject(hDC
, hbr
)) == NULL
)
1606 PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1607 lprc
->bottom
- lprc
->top
, PATCOPY
);
1608 SelectObject(hDC
, prevhbr
);
1616 DrawFocusRect(HDC hdc
, CONST RECT
*rect
)
1618 static HBRUSH hFocusRectBrush
= NULL
;
1622 if(!hFocusRectBrush
)
1624 static HBITMAP hFocusPattern
= NULL
;
1625 const DWORD Pattern
[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
1627 hFocusPattern
= CreateBitmap(8, 8, 1, 1, Pattern
);
1628 hFocusRectBrush
= CreatePatternBrush(hFocusPattern
);
1631 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH
, 0, &cx
, 0);
1632 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT
, 0, &cy
, 0);
1634 OldObj
= SelectObject(hdc
, hFocusRectBrush
);
1637 PatBlt(hdc
, rect
->left
, rect
->top
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1639 PatBlt(hdc
, rect
->left
, rect
->bottom
- cy
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1641 PatBlt(hdc
, rect
->left
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1643 PatBlt(hdc
, rect
->right
- cx
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1645 SelectObject(hdc
, OldObj
);
1653 DrawStateA(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1654 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1656 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, FALSE
);
1663 DrawStateW(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1664 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1666 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, TRUE
);