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
)];
184 if(InnerI
!= -1) InnerPen
= GetStockObject(DC_PEN
);
185 if(OuterI
!= -1) OuterPen
= GetStockObject(DC_PEN
);
187 MoveToEx(hdc
, 0, 0, &SavePoint
);
189 /* Don't ask me why, but this is what is visible... */
190 /* This must be possible to do much simpler, but I fail to */
191 /* see the logic in the MS implementation (sigh...). */
192 /* So, this might look a bit brute force here (and it is), but */
193 /* it gets the job done;) */
195 switch(uFlags
& BF_RECT
)
201 /* Left bottom endpoint */
203 spx
= epx
+ SmallDiam
;
205 spy
= epy
- SmallDiam
;
210 /* Left top endpoint */
212 spx
= epx
+ SmallDiam
;
214 spy
= epy
+ SmallDiam
;
220 case BF_RIGHT
|BF_LEFT
:
221 case BF_RIGHT
|BF_LEFT
|BF_TOP
:
222 case BF_BOTTOM
|BF_TOP
:
223 case BF_BOTTOM
|BF_TOP
|BF_LEFT
:
224 case BF_BOTTOMRIGHT
|BF_LEFT
:
225 case BF_BOTTOMRIGHT
|BF_TOP
:
227 /* Right top endpoint */
229 epx
= spx
+ SmallDiam
;
231 epy
= spy
- SmallDiam
;
235 MoveToEx(hdc
, spx
, spy
, NULL
);
236 SelectObject(hdc
, OuterPen
);
237 SetDCPenColor(hdc
, GetSysColor(OuterI
));
238 LineTo(hdc
, epx
, epy
);
240 SelectObject(hdc
, InnerPen
);
241 SetDCPenColor(hdc
, GetSysColor(InnerI
));
243 switch(uFlags
& (BF_RECT
|BF_DIAGONAL
))
245 case BF_DIAGONAL_ENDBOTTOMLEFT
:
246 case (BF_DIAGONAL
|BF_BOTTOM
):
248 case (BF_DIAGONAL
|BF_LEFT
):
249 MoveToEx(hdc
, spx
-1, spy
, NULL
);
250 LineTo(hdc
, epx
, epy
-1);
251 Points
[0].x
= spx
-add
;
253 Points
[1].x
= rc
->left
;
254 Points
[1].y
= rc
->top
;
256 Points
[2].y
= epy
-1-add
;
257 Points
[3] = Points
[2];
260 case BF_DIAGONAL_ENDBOTTOMRIGHT
:
261 MoveToEx(hdc
, spx
-1, spy
, NULL
);
262 LineTo(hdc
, epx
, epy
+1);
263 Points
[0].x
= spx
-add
;
265 Points
[1].x
= rc
->left
;
266 Points
[1].y
= rc
->bottom
-1;
268 Points
[2].y
= epy
+1+add
;
269 Points
[3] = Points
[2];
272 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
):
273 case (BF_DIAGONAL
|BF_BOTTOM
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
274 case BF_DIAGONAL_ENDTOPRIGHT
:
275 case (BF_DIAGONAL
|BF_RIGHT
|BF_TOP
|BF_LEFT
):
276 MoveToEx(hdc
, spx
+1, spy
, NULL
);
277 LineTo(hdc
, epx
, epy
+1);
279 Points
[0].y
= epy
+1+add
;
280 Points
[1].x
= rc
->right
-1;
281 Points
[1].y
= rc
->top
+add
;
282 Points
[2].x
= rc
->right
-1;
283 Points
[2].y
= rc
->bottom
-1;
284 Points
[3].x
= spx
+add
;
288 case BF_DIAGONAL_ENDTOPLEFT
:
289 MoveToEx(hdc
, spx
, spy
-1, NULL
);
290 LineTo(hdc
, epx
+1, epy
);
291 Points
[0].x
= epx
+1+add
;
293 Points
[1].x
= rc
->right
-1;
294 Points
[1].y
= rc
->top
;
295 Points
[2].x
= rc
->right
-1;
296 Points
[2].y
= rc
->bottom
-1-add
;
298 Points
[3].y
= spy
-add
;
301 case (BF_DIAGONAL
|BF_TOP
):
302 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
):
303 case (BF_DIAGONAL
|BF_BOTTOM
|BF_TOP
|BF_LEFT
):
304 MoveToEx(hdc
, spx
+1, spy
-1, NULL
);
305 LineTo(hdc
, epx
, epy
);
308 Points
[1].x
= rc
->right
-1;
309 Points
[1].y
= rc
->top
;
310 Points
[2].x
= rc
->right
-1;
311 Points
[2].y
= rc
->bottom
-1-add
;
312 Points
[3].x
= spx
+add
;
313 Points
[3].y
= spy
-add
;
316 case (BF_DIAGONAL
|BF_RIGHT
):
317 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
):
318 case (BF_DIAGONAL
|BF_RIGHT
|BF_LEFT
|BF_BOTTOM
):
319 MoveToEx(hdc
, spx
, spy
, NULL
);
320 LineTo(hdc
, epx
-1, epy
+1);
323 Points
[1].x
= rc
->left
;
324 Points
[1].y
= rc
->top
+add
;
325 Points
[2].x
= epx
-1-add
;
326 Points
[2].y
= epy
+1+add
;
327 Points
[3] = Points
[2];
331 /* Fill the interior if asked */
332 if((uFlags
& BF_MIDDLE
) && retval
)
336 hbsave
= (HBRUSH
)SelectObject(hdc
, GetStockObject(DC_BRUSH
));
337 hpsave
= (HPEN
)SelectObject(hdc
, GetStockObject(DC_PEN
));
338 SetDCBrushColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
339 SetDCPenColor(hdc
, GetSysColor(uFlags
& BF_MONO
? COLOR_WINDOW
: COLOR_BTNFACE
));
340 Polygon(hdc
, Points
, 4);
341 SelectObject(hdc
, hbsave
);
342 SelectObject(hdc
, hpsave
);
345 /* Adjust rectangle if asked */
346 if(uFlags
& BF_ADJUST
)
348 if(uFlags
& BF_LEFT
) rc
->left
+= add
;
349 if(uFlags
& BF_RIGHT
) rc
->right
-= add
;
350 if(uFlags
& BF_TOP
) rc
->top
+= add
;
351 if(uFlags
& BF_BOTTOM
) rc
->bottom
-= add
;
355 SelectObject(hdc
, SavePen
);
356 MoveToEx(hdc
, SavePoint
.x
, SavePoint
.y
, NULL
);
361 /* Ported from WINE20020904 */
362 /* Same as DrawEdge invoked without BF_DIAGONAL
364 * 23-Nov-1997: Changed by Bertho Stultiens
365 * The width parameter sets the width of each outer and inner edge.
367 * Well, I started testing this and found out that there are a few things
368 * that weren't quite as win95. The following rewrite should reproduce
369 * win95 results completely.
370 * The colorselection is table-driven to avoid awfull if-statements.
371 * The table below show the color settings.
373 * Pen selection table for uFlags = 0
375 * uType | LTI | LTO | RBI | RBO
376 * ------+-------+-------+-------+-------
377 * 0000 | x | x | x | x
378 * 0001 | x | 22 | x | 21
379 * 0010 | x | 16 | x | 20
380 * 0011 | x | x | x | x
381 * ------+-------+-------+-------+-------
382 * 0100 | x | 20 | x | 16
383 * 0101 | 20 | 22 | 16 | 21
384 * 0110 | 20 | 16 | 16 | 20
385 * 0111 | x | x | x | x
386 * ------+-------+-------+-------+-------
387 * 1000 | x | 21 | x | 22
388 * 1001 | 21 | 22 | 22 | 21
389 * 1010 | 21 | 16 | 22 | 20
390 * 1011 | x | x | x | x
391 * ------+-------+-------+-------+-------
392 * 1100 | x | x | x | x
393 * 1101 | x | x (22)| x | x (21)
394 * 1110 | x | x (16)| x | x (20)
395 * 1111 | x | x | x | x
397 * Pen selection table for uFlags = BF_SOFT
399 * uType | LTI | LTO | RBI | RBO
400 * ------+-------+-------+-------+-------
401 * 0000 | x | x | x | x
402 * 0001 | x | 20 | x | 21
403 * 0010 | x | 21 | x | 20
404 * 0011 | x | x | x | x
405 * ------+-------+-------+-------+-------
406 * 0100 | x | 22 | x | 16
407 * 0101 | 22 | 20 | 16 | 21
408 * 0110 | 22 | 21 | 16 | 20
409 * 0111 | x | x | x | x
410 * ------+-------+-------+-------+-------
411 * 1000 | x | 16 | x | 22
412 * 1001 | 16 | 20 | 22 | 21
413 * 1010 | 16 | 21 | 22 | 20
414 * 1011 | x | x | x | x
415 * ------+-------+-------+-------+-------
416 * 1100 | x | x | x | x
417 * 1101 | x | x (20)| x | x (21)
418 * 1110 | x | x (21)| x | x (20)
419 * 1111 | x | x | x | x
421 * x = don't care; (n) = is what win95 actually uses
422 * LTI = left Top Inner line
423 * LTO = left Top Outer line
424 * RBI = Right Bottom Inner line
425 * RBO = Right Bottom Outer line
427 * 16 = COLOR_BTNSHADOW
428 * 20 = COLOR_BTNHIGHLIGHT
429 * 21 = COLOR_3DDKSHADOW
432 static BOOL
IntDrawRectEdge(HDC hdc
, LPRECT rc
, UINT uType
, UINT uFlags
, UINT width
)
434 signed char LTInnerI
, LTOuterI
;
435 signed char RBInnerI
, RBOuterI
;
436 HBRUSH lti_brush
, lto_brush
, rbi_brush
, rbo_brush
;
437 RECT InnerRect
= *rc
, fill_rect
;
438 int lbi_offset
= 0, lti_offset
= 0, rti_offset
= 0, rbi_offset
= 0;
439 BOOL retval
= !( ((uType
& BDR_INNER
) == BDR_INNER
440 || (uType
& BDR_OUTER
) == BDR_OUTER
)
441 && !(uFlags
& (BF_FLAT
|BF_MONO
)) );
443 lti_brush
= lto_brush
= rbi_brush
= rbo_brush
= GetStockObject(NULL_BRUSH
);
445 /* Determine the colors of the edges */
448 LTInnerI
= RBInnerI
= LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
449 LTOuterI
= RBOuterI
= LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)];
451 else if(uFlags
& BF_FLAT
)
453 LTInnerI
= RBInnerI
= LTRBInnerFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
454 LTOuterI
= RBOuterI
= LTRBOuterFlat
[uType
& (BDR_INNER
|BDR_OUTER
)];
456 /* Bertho Stultiens states above that this function exactly matches win95
457 * In win98 BF_FLAT rectangles have an inner border same color as the
458 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
459 * I don't know I go with Bertho and just sets it for win98 until proven
461 * Dennis Björklund, 10 June, 99
463 if( LTInnerI
!= -1 ) LTInnerI
= RBInnerI
= COLOR_BTNFACE
;
465 else if(uFlags
& BF_SOFT
)
467 LTInnerI
= LTInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
468 LTOuterI
= LTOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
469 RBInnerI
= RBInnerSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
470 RBOuterI
= RBOuterSoft
[uType
& (BDR_INNER
|BDR_OUTER
)];
474 LTInnerI
= LTInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
475 LTOuterI
= LTOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
476 RBInnerI
= RBInnerNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
477 RBOuterI
= RBOuterNormal
[uType
& (BDR_INNER
|BDR_OUTER
)];
480 if((uFlags
& BF_BOTTOMLEFT
) == BF_BOTTOMLEFT
) lbi_offset
= width
;
481 if((uFlags
& BF_TOPRIGHT
) == BF_TOPRIGHT
) rti_offset
= width
;
482 if((uFlags
& BF_BOTTOMRIGHT
) == BF_BOTTOMRIGHT
) rbi_offset
= width
;
483 if((uFlags
& BF_TOPLEFT
) == BF_TOPLEFT
) lti_offset
= width
;
485 if(LTInnerI
!= -1) lti_brush
= GetSysColorBrush(LTInnerI
);
486 if(LTOuterI
!= -1) lto_brush
= GetSysColorBrush(LTOuterI
);
487 if(RBInnerI
!= -1) rbi_brush
= GetSysColorBrush(RBInnerI
);
488 if(RBOuterI
!= -1) rbo_brush
= GetSysColorBrush(RBOuterI
);
490 /* Draw the outer edge */
493 fill_rect
= InnerRect
;
494 fill_rect
.bottom
= fill_rect
.top
+ width
;
495 FillRect( hdc
, &fill_rect
, lto_brush
);
499 fill_rect
= InnerRect
;
500 fill_rect
.right
= fill_rect
.left
+ width
;
501 FillRect( hdc
, &fill_rect
, lto_brush
);
503 if(uFlags
& BF_BOTTOM
)
505 fill_rect
= InnerRect
;
506 fill_rect
.top
= fill_rect
.bottom
- width
;
507 FillRect( hdc
, &fill_rect
, rbo_brush
);
509 if(uFlags
& BF_RIGHT
)
511 fill_rect
= InnerRect
;
512 fill_rect
.left
= fill_rect
.right
- width
;
513 FillRect( hdc
, &fill_rect
, rbo_brush
);
516 /* Draw the inner edge */
519 SetRect( &fill_rect
, InnerRect
.left
+ lti_offset
, InnerRect
.top
+ width
,
520 InnerRect
.right
- rti_offset
, InnerRect
.top
+ 2 * width
);
521 FillRect( hdc
, &fill_rect
, lti_brush
);
525 SetRect( &fill_rect
, InnerRect
.left
+ width
, InnerRect
.top
+ lti_offset
,
526 InnerRect
.left
+ 2 * width
, InnerRect
.bottom
- lbi_offset
);
527 FillRect( hdc
, &fill_rect
, lti_brush
);
529 if(uFlags
& BF_BOTTOM
)
531 SetRect( &fill_rect
, InnerRect
.left
+ lbi_offset
, InnerRect
.bottom
- 2 * width
,
532 InnerRect
.right
- rbi_offset
, InnerRect
.bottom
- width
);
533 FillRect( hdc
, &fill_rect
, rbi_brush
);
535 if(uFlags
& BF_RIGHT
)
537 SetRect( &fill_rect
, InnerRect
.right
- 2 * width
, InnerRect
.top
+ rti_offset
,
538 InnerRect
.right
- width
, InnerRect
.bottom
- rbi_offset
);
539 FillRect( hdc
, &fill_rect
, rbi_brush
);
542 if( ((uFlags
& BF_MIDDLE
) && retval
) || (uFlags
& BF_ADJUST
) )
544 int add
= (LTRBInnerMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? width
: 0)
545 + (LTRBOuterMono
[uType
& (BDR_INNER
|BDR_OUTER
)] != -1 ? width
: 0);
547 if(uFlags
& BF_LEFT
) InnerRect
.left
+= add
;
548 if(uFlags
& BF_RIGHT
) InnerRect
.right
-= add
;
549 if(uFlags
& BF_TOP
) InnerRect
.top
+= add
;
550 if(uFlags
& BF_BOTTOM
) InnerRect
.bottom
-= add
;
552 if((uFlags
& BF_MIDDLE
) && retval
)
554 FillRect(hdc
, &InnerRect
, GetSysColorBrush(uFlags
& BF_MONO
?
555 COLOR_WINDOW
: COLOR_BTNFACE
));
558 if(uFlags
& BF_ADJUST
)
565 /* Ported from WINE20020904 */
566 /* Utility to create a square rectangle and returning the width */
567 static int UITOOLS_MakeSquareRect(LPRECT src
, LPRECT dst
)
569 int Width
= src
->right
- src
->left
;
570 int Height
= src
->bottom
- src
->top
;
571 int SmallDiam
= Width
> Height
? Height
: Width
;
575 /* Make it a square box */
576 if(Width
< Height
) /* SmallDiam == Width */
578 dst
->top
+= (Height
-Width
)/2;
579 dst
->bottom
= dst
->top
+ SmallDiam
;
581 else if(Width
> Height
) /* SmallDiam == Height */
583 dst
->left
+= (Width
-Height
)/2;
584 dst
->right
= dst
->left
+ SmallDiam
;
590 /* Ported from WINE20020904 */
591 static void UITOOLS_DrawCheckedRect( HDC dc
, LPRECT rect
)
593 if(GetSysColor(COLOR_BTNHIGHLIGHT
) == RGB(255, 255, 255))
598 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNFACE
));
599 bg
= SetBkColor(dc
, RGB(255, 255, 255));
600 hbsave
= (HBRUSH
)SelectObject(dc
, gpsi
->hbrGray
);
601 PatBlt(dc
, rect
->left
, rect
->top
, rect
->right
-rect
->left
, rect
->bottom
-rect
->top
, 0x00FA0089);
602 SelectObject(dc
, hbsave
);
607 FillRect(dc
, rect
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
611 /* Ported from WINE20020904 */
612 /* Draw a push button coming from DrawFrameControl()
614 * Does a pretty good job in emulating MS behavior. Some quirks are
615 * however there because MS uses a TrueType font (Marlett) to draw
618 * FIXME: This looks a little bit strange, needs to be rewritten completely
619 * (several quirks with adjust, DFCS_CHECKED aso)
621 static BOOL
UITOOLS95_DFC_ButtonPush(HDC dc
, LPRECT r
, UINT uFlags
)
626 if(uFlags
& (DFCS_PUSHED
| DFCS_CHECKED
| DFCS_FLAT
))
631 if(uFlags
& DFCS_CHECKED
)
633 if(uFlags
& DFCS_MONO
)
634 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
, 1);
636 IntDrawRectEdge(dc
, &myr
, edge
, (uFlags
&DFCS_FLAT
)|BF_RECT
|BF_SOFT
|BF_ADJUST
, 1);
638 UITOOLS_DrawCheckedRect( dc
, &myr
);
642 if(uFlags
& DFCS_MONO
)
644 IntDrawRectEdge(dc
, &myr
, edge
, BF_MONO
|BF_RECT
|BF_ADJUST
, 1);
645 FillRect(dc
, &myr
, GetSysColorBrush(COLOR_BTNFACE
));
649 IntDrawRectEdge(dc
, r
, edge
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
| BF_SOFT
, 1);
653 /* Adjust rectangle if asked */
654 if(uFlags
& DFCS_ADJUSTRECT
)
655 InflateRect(r
, -2, -2);
660 static BOOL
UITOOLS95_DFC_ButtonCheckRadio(HDC dc
, LPRECT r
, UINT uFlags
, BOOL Radio
)
663 HFONT hFont
, hOldFont
;
665 TCHAR OutRight
, OutLeft
, InRight
, InLeft
, Center
;
666 INT X
, Y
, Width
, Height
, Shorter
;
667 INT BkMode
= GetBkMode(dc
);
668 COLORREF TextColor
= GetTextColor(dc
);
670 Width
= r
->right
- r
->left
;
671 Height
= r
->bottom
- r
->top
;
672 Shorter
= (Width
< Height
) ? Width
: Height
;
673 X
= r
->left
+ (Width
- Shorter
) / 2;
674 Y
= r
->top
+ (Height
- Shorter
) / 2;
678 OutRight
= 'j'; // Outer right
679 OutLeft
= 'k'; // Outer left
680 InRight
= 'l'; // inner left
681 InLeft
= 'm'; // inner right
682 Center
= 'n'; // center
686 OutRight
= 'c'; // Outer right
687 OutLeft
= 'd'; // Outer left
688 InRight
= 'e'; // inner left
689 InLeft
= 'f'; // inner right
690 Center
= 'g'; // center
693 ZeroMemory(&lf
, sizeof(LOGFONTW
));
694 lf
.lfHeight
= Shorter
;
695 lf
.lfCharSet
= DEFAULT_CHARSET
;
696 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
697 if (Radio
&& ((uFlags
& 0xFF) == DFCS_BUTTONRADIOMASK
))
699 lf
.lfQuality
= NONANTIALIASED_QUALITY
;
701 hFont
= CreateFontIndirect(&lf
);
702 hOldFont
= SelectObject(dc
, hFont
);
704 if (Radio
&& ((uFlags
& 0xFF) == DFCS_BUTTONRADIOMASK
))
707 // FIXME: improve font rendering
709 HGDIOBJ hbrOld
, hpenOld
;
710 FillRect(dc
, r
, (HBRUSH
)GetStockObject(WHITE_BRUSH
));
711 SetRect(&Rect
, X
, Y
, X
+ Shorter
, Y
+ Shorter
);
712 InflateRect(&Rect
, -(Shorter
* 8) / 54, -(Shorter
* 8) / 54);
713 hbrOld
= SelectObject(dc
, GetStockObject(BLACK_BRUSH
));
714 hpenOld
= SelectObject(dc
, GetStockObject(NULL_PEN
));
715 Ellipse(dc
, Rect
.left
, Rect
.top
, Rect
.right
, Rect
.bottom
);
716 SelectObject(dc
, hbrOld
);
717 SelectObject(dc
, hpenOld
);
719 SetBkMode(dc
, OPAQUE
);
720 SetBkColor(dc
, RGB(255, 255, 255));
721 SetTextColor(dc
, RGB(0, 0, 0));
722 TextOut(dc
, X
, Y
, &Center
, 1);
723 SetBkMode(dc
, TRANSPARENT
);
724 TextOut(dc
, X
, Y
, &OutRight
, 1);
725 TextOut(dc
, X
, Y
, &OutLeft
, 1);
726 TextOut(dc
, X
, Y
, &InRight
, 1);
727 TextOut(dc
, X
, Y
, &InLeft
, 1);
732 SetBkMode(dc
, TRANSPARENT
);
734 /* Center section, white for active, grey for inactive */
735 if ((uFlags
& (DFCS_INACTIVE
| DFCS_PUSHED
)))
739 SetTextColor(dc
, GetSysColor(i
));
740 TextOut(dc
, X
, Y
, &Center
, 1);
742 if (uFlags
& (DFCS_FLAT
| DFCS_MONO
))
744 SetTextColor(dc
, GetSysColor(COLOR_WINDOWFRAME
));
745 TextOut(dc
, X
, Y
, &OutRight
, 1);
746 TextOut(dc
, X
, Y
, &OutLeft
, 1);
747 TextOut(dc
, X
, Y
, &InRight
, 1);
748 TextOut(dc
, X
, Y
, &InLeft
, 1);
752 SetTextColor(dc
, GetSysColor(COLOR_BTNSHADOW
));
753 TextOut(dc
, X
, Y
, &OutRight
, 1);
754 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
755 TextOut(dc
, X
, Y
, &OutLeft
, 1);
756 SetTextColor(dc
, GetSysColor(COLOR_3DDKSHADOW
));
757 TextOut(dc
, X
, Y
, &InRight
, 1);
758 SetTextColor(dc
, GetSysColor(COLOR_3DLIGHT
));
759 TextOut(dc
, X
, Y
, &InLeft
, 1);
762 if (uFlags
& DFCS_CHECKED
)
764 TCHAR Check
= (Radio
) ? 'i' : 'b';
766 SetTextColor(dc
, GetSysColor(COLOR_WINDOWTEXT
));
767 TextOut(dc
, X
, Y
, &Check
, 1);
771 SelectObject(dc
, hOldFont
);
774 SetTextColor(dc
, TextColor
);
775 SetBkMode(dc
, BkMode
);
780 /* Ported from WINE20020904 */
781 static BOOL
UITOOLS95_DrawFrameButton(HDC hdc
, LPRECT rc
, UINT uState
)
783 switch(uState
& 0xff)
785 case DFCS_BUTTONPUSH
:
786 return UITOOLS95_DFC_ButtonPush(hdc
, rc
, uState
);
788 case DFCS_BUTTONCHECK
:
789 case DFCS_BUTTON3STATE
:
790 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, FALSE
);
792 case DFCS_BUTTONRADIOIMAGE
:
793 case DFCS_BUTTONRADIOMASK
:
794 case DFCS_BUTTONRADIO
:
795 return UITOOLS95_DFC_ButtonCheckRadio(hdc
, rc
, uState
, TRUE
);
799 DbgPrint("Invalid button state=0x%04x\n", uState);
806 static BOOL
UITOOLS95_DrawFrameCaption(HDC dc
, LPRECT r
, UINT uFlags
)
809 HFONT hFont
, hOldFont
;
814 switch(uFlags
& 0xff)
816 case DFCS_CAPTIONCLOSE
:
819 case DFCS_CAPTIONHELP
:
822 case DFCS_CAPTIONMIN
:
825 case DFCS_CAPTIONMAX
:
828 case DFCS_CAPTIONRESTORE
:
832 WARN("Invalid caption; flags=0x%04x\n", uFlags
);
835 IntDrawRectEdge(dc
,r
,(uFlags
&DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, BF_RECT
| BF_MIDDLE
| BF_SOFT
, 1);
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
);
935 WARN("Invalid scroll; flags=0x%04x\n", uFlags
);
938 IntDrawRectEdge(dc
, r
, (uFlags
& DFCS_PUSHED
) ? EDGE_SUNKEN
: EDGE_RAISED
, (uFlags
&DFCS_FLAT
) | BF_MIDDLE
| BF_RECT
, 1);
939 ZeroMemory(&lf
, sizeof(LOGFONTW
));
940 UITOOLS_MakeSquareRect(r
, &myr
);
945 if(uFlags
& DFCS_PUSHED
)
946 OffsetRect(&myr
,1,1);
947 lf
.lfHeight
= myr
.bottom
- myr
.top
;
949 lf
.lfWeight
= FW_NORMAL
;
950 lf
.lfCharSet
= DEFAULT_CHARSET
;
951 lstrcpy(lf
.lfFaceName
, TEXT("Marlett"));
952 hFont
= CreateFontIndirect(&lf
);
953 /* save font and text color */
954 hOldFont
= SelectObject(dc
, hFont
);
955 clrsave
= GetTextColor(dc
);
956 bkmode
= GetBkMode(dc
);
957 /* set color and drawing mode */
958 SetBkMode(dc
, TRANSPARENT
);
959 if(uFlags
& DFCS_INACTIVE
)
962 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
963 TextOut(dc
, myr
.left
+ 1, myr
.top
+ 1, &Symbol
, 1);
965 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
966 /* draw selected symbol */
967 TextOut(dc
, myr
.left
, myr
.top
, &Symbol
, 1);
968 /* restore previous settings */
969 SetTextColor(dc
, clrsave
);
970 SelectObject(dc
, hOldFont
);
971 SetBkMode(dc
, bkmode
);
976 static BOOL
UITOOLS95_DrawFrameMenu(HDC dc
, LPRECT r
, UINT uFlags
)
979 HFONT hFont
, hOldFont
;
981 switch(uFlags
& 0xff)
983 case DFCS_MENUARROWUP
:
987 case DFCS_MENUARROWDOWN
:
995 case DFCS_MENUARROWRIGHT
:
996 Symbol
= 'w'; // FIXME: needs to confirm
999 case DFCS_MENUBULLET
:
1003 case DFCS_MENUCHECK
:
1008 WARN("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
);
1022 if ((uFlags
& 0xff) == DFCS_MENUARROWUP
||
1023 (uFlags
& 0xff) == DFCS_MENUARROWDOWN
)
1026 if (uFlags
& DFCS_INACTIVE
)
1029 SetTextColor(dc
, GetSysColor(COLOR_BTNHIGHLIGHT
));
1030 TextOut(dc
, r
->left
+ 1, r
->top
+ 1, &Symbol
, 1);
1033 SetTextColor(dc
, GetSysColor((uFlags
& DFCS_INACTIVE
) ? COLOR_BTNSHADOW
: COLOR_BTNTEXT
));
1035 /* draw selected symbol */
1036 TextOut(dc
, r
->left
, r
->top
, &Symbol
, 1);
1037 /* restore previous settings */
1038 SelectObject(dc
, hOldFont
);
1039 DeleteObject(hFont
);
1048 GRAYSTRINGPROC lpOutputFunc
,
1057 // AG: Mostly implemented, but probably won't work properly or return
1058 // correct error codes. I doubt it grays strings either... Untested!
1060 BOOL success
= FALSE
;
1063 HBITMAP MemBMP
= NULL
, OldBMP
= NULL
;
1064 HBRUSH OldBrush
= NULL
;
1065 HFONT OldFont
= NULL
;
1067 COLORREF ForeColor
, BackColor
;
1069 ForeColor
= SetTextColor(hDC
, RGB(0, 0, 0));
1070 BackColor
= SetBkColor(hDC
, RGB(255, 255, 255));
1074 // The documentation is a little vague on what exactly should happen
1075 // here. Something about using the same brush for window text???
1076 hBrush
= (HBRUSH
) GetCurrentObject(hDC
, OBJ_BRUSH
);
1079 if ((nCount
== -1) && (! lpOutputFunc
))
1084 // TODO: calculate the length (easy enough)
1087 nCount
= lstrlenW((WCHAR
*)lpData
);
1089 nCount
= lstrlenA((CHAR
*)lpData
);
1092 if (! nWidth
|| ! nHeight
)
1095 // TODO: calculate the rect
1098 success
= GetTextExtentPoint32W(hDC
, (WCHAR
*) lpData
, nCount
, &s
);
1100 success
= GetTextExtentPoint32A(hDC
, (CHAR
*) lpData
, nCount
, &s
);
1102 if (! success
) goto cleanup
;
1104 if (! nWidth
) nWidth
= s
.cx
;
1105 if (! nHeight
) nHeight
= s
.cy
;
1108 SetRect(&r
, X
, Y
, X
+ nWidth
, Y
+ nHeight
);
1110 MemDC
= CreateCompatibleDC(hDC
);
1111 if (! MemDC
) goto cleanup
;
1112 MemBMP
= CreateBitmap(nWidth
, nHeight
, 1, 1, NULL
);
1113 if (! MemBMP
) goto cleanup
;
1114 OldBMP
= SelectObject(MemDC
, MemBMP
);
1115 if (! OldBMP
) goto cleanup
;
1116 OldFont
= SelectObject(MemDC
, GetCurrentObject(hDC
, OBJ_FONT
));
1117 if (! OldFont
) goto cleanup
;
1118 OldBrush
= SelectObject(MemDC
, hBrush
);
1119 if (! OldBrush
) goto cleanup
;
1121 if (! BitBlt(MemDC
, 0, 0, nWidth
, nHeight
, hDC
, X
, Y
, SRCCOPY
)) goto cleanup
;
1123 SetTextColor(MemDC
, RGB(255, 255, 255));
1124 SetBkColor(MemDC
, RGB(0, 0, 0));
1128 success
= lpOutputFunc(MemDC
, lpData
, nCount
); // Set brush etc first?
1130 if ((nCount
== -1) && (! success
))
1132 // Don't gray (documented behaviour)
1133 success
= (BOOL
) BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
);
1140 success
= TextOutW(MemDC
, 0, 0, (WCHAR
*) lpData
, nCount
);
1142 success
= TextOutA(MemDC
, 0, 0, (CHAR
*) lpData
, nCount
);
1144 if (! success
) goto cleanup
;
1146 hbsave
= (HBRUSH
)SelectObject(MemDC
, gpsi
->hbrGray
);
1147 PatBlt(MemDC
, 0, 0, nWidth
, nHeight
, 0x000A0329);
1148 SelectObject(MemDC
, hbsave
);
1151 if (! BitBlt(hDC
, X
, Y
, nWidth
, nHeight
, MemDC
, 0, 0, SRCCOPY
)) goto cleanup
;
1154 SetTextColor(hDC
, ForeColor
);
1155 SetBkColor(hDC
, BackColor
);
1159 if (OldFont
) SelectObject(MemDC
, OldFont
);
1160 if (OldBrush
) SelectObject(MemDC
, OldBrush
);
1161 if (OldBMP
) SelectObject(MemDC
, OldBMP
);
1162 if (MemBMP
) DeleteObject(MemBMP
);
1169 /**********************************************************************
1170 * PAINTING_DrawStateJam
1172 * Jams in the requested type in the dc
1174 static BOOL
PAINTING_DrawStateJam(HDC hdc
, UINT opcode
,
1175 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1176 LPRECT rc
, UINT dtflags
, BOOL unicode
)
1181 INT cx
= rc
->right
- rc
->left
;
1182 INT cy
= rc
->bottom
- rc
->top
;
1187 case DST_PREFIXTEXT
:
1189 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1191 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
1194 return DrawIconEx(hdc
, rc
->left
, rc
->top
, (HICON
)lp
, cx
, cy
, 0, NULL
, DI_NORMAL
);
1197 memdc
= CreateCompatibleDC(hdc
);
1200 hbmsave
= (HBITMAP
)SelectObject(memdc
, (HBITMAP
)lp
);
1206 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
1207 SelectObject(memdc
, hbmsave
);
1215 /* DRAWSTATEPROC assumes that it draws at the center of coordinates */
1217 OffsetViewportOrgEx(hdc
, rc
->left
, rc
->top
, NULL
);
1218 bRet
= func(hdc
, lp
, wp
, cx
, cy
);
1219 /* Restore origin */
1220 OffsetViewportOrgEx(hdc
, -rc
->left
, -rc
->top
, NULL
);
1232 IntDrawState(HDC hdc
, HBRUSH hbr
, DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
1233 INT x
, INT y
, INT cx
, INT cy
, UINT flags
, BOOL unicode
)
1235 HBITMAP hbm
, hbmsave
;
1237 HBRUSH hbsave
, hbrtmp
= 0;
1240 UINT dtflags
= DT_NOCLIP
;
1242 UINT opcode
= flags
& 0xf;
1246 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
1249 len
= lstrlenW((LPWSTR
)lp
);
1251 len
= lstrlenA((LPSTR
)lp
);
1254 /* 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(!get_icon_size((HICON
)lp
, &s
))
1278 if(!GetObjectW((HBITMAP
)lp
, sizeof(bm
), &bm
))
1284 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1288 ERR("Invalid opcode: %u\n", opcode
);
1296 SetRect(&rc
, x
, y
, x
+ cx
, y
+ cy
);
1298 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1299 dtflags
|= DT_RIGHT
;
1300 if(opcode
== DST_TEXT
)
1301 dtflags
|= DT_NOPREFIX
;
1302 else if(opcode
== DST_PREFIXTEXT
)
1304 if (flags
& DSS_HIDEPREFIX
)
1305 dtflags
|= DT_HIDEPREFIX
;
1306 if (flags
& DSS_PREFIXONLY
)
1307 dtflags
|= DT_PREFIXONLY
;
1310 /* For DSS_NORMAL we just jam in the image and return */
1311 if((flags
& 0x79f0) == DSS_NORMAL
)
1313 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1316 /* For all other states we need to convert the image to B/W in a local bitmap */
1317 /* before it is displayed */
1318 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1319 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1320 hbm
= NULL
; hbmsave
= NULL
;
1321 memdc
= NULL
; hbsave
= NULL
;
1322 retval
= FALSE
; /* assume failure */
1324 /* From here on we must use "goto cleanup" when something goes wrong */
1325 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1326 if(!hbm
) goto cleanup
;
1327 memdc
= CreateCompatibleDC(hdc
);
1328 if(!memdc
) goto cleanup
;
1329 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
1330 if(!hbmsave
) goto cleanup
;
1331 SetRect(&rc
, 0, 0, cx
, cy
);
1332 if(!FillRect(memdc
, &rc
, (HBRUSH
)GetStockObject(WHITE_BRUSH
))) goto cleanup
;
1333 SetBkColor(memdc
, RGB(255, 255, 255));
1334 SetTextColor(memdc
, RGB(0, 0, 0));
1335 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1336 SetLayout( memdc
, GetLayout( hdc
));
1338 /* DST_COMPLEX may draw text as well,
1339 * so we must be sure that correct font is selected
1341 if(!hfsave
&& (opcode
<= DST_PREFIXTEXT
)) goto cleanup
;
1342 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
);
1343 if(hfsave
) SelectObject(memdc
, hfsave
);
1344 if(!tmp
) goto cleanup
;
1346 /* This state cause the image to be dithered */
1347 if(flags
& DSS_UNION
)
1349 hbsave
= (HBRUSH
)SelectObject(memdc
, gpsi
->hbrGray
);
1350 if(!hbsave
) goto cleanup
;
1351 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1352 SelectObject(memdc
, hbsave
);
1353 if(!tmp
) goto cleanup
;
1356 if (flags
& DSS_DISABLED
)
1357 hbrtmp
= GetSysColorBrush(COLOR_3DHILIGHT
);
1358 else if (flags
& DSS_DEFAULT
)
1359 hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1361 /* Draw light or dark shadow */
1362 if (flags
& (DSS_DISABLED
|DSS_DEFAULT
))
1364 if(!hbrtmp
) goto cleanup
;
1365 hbsave
= (HBRUSH
)SelectObject(hdc
, hbrtmp
);
1366 if(!hbsave
) goto cleanup
;
1367 if(!BitBlt(hdc
, x
+1, y
+1, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1368 SelectObject(hdc
, hbsave
);
1371 if (flags
& DSS_DISABLED
)
1373 hbr
= hbrtmp
= GetSysColorBrush(COLOR_3DSHADOW
);
1374 if(!hbrtmp
) goto cleanup
;
1378 hbr
= (HBRUSH
)GetStockObject(BLACK_BRUSH
);
1381 hbsave
= (HBRUSH
)SelectObject(hdc
, hbr
);
1383 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1385 retval
= TRUE
; /* We succeeded */
1388 SetTextColor(hdc
, fg
);
1389 SetBkColor(hdc
, bg
);
1391 if(hbsave
) SelectObject(hdc
, hbsave
);
1392 if(hbmsave
) SelectObject(memdc
, hbmsave
);
1393 if(hbm
) DeleteObject(hbm
);
1394 if(memdc
) DeleteDC(memdc
);
1403 RealDrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1405 if (GetMapMode(hDC
) != MM_TEXT
)
1411 return UITOOLS95_DrawFrameButton(hDC
, rc
, uState
);
1413 return UITOOLS95_DrawFrameCaption(hDC
, rc
, uState
);
1415 return UITOOLS95_DrawFrameMenu(hDC
, rc
, uState
);
1422 return UITOOLS95_DrawFrameScroll(hDC
, rc
, uState
);
1428 DrawFrameControl(HDC hDC
, LPRECT rc
, UINT uType
, UINT uState
)
1430 BOOL Hook
, Ret
= FALSE
;
1434 Hook
= BeginIfHookedUserApiHook();
1436 /* Bypass SEH and go direct. */
1437 if (!Hook
) return RealDrawFrameControl(hDC
, rc
, uType
, uState
);
1441 Ret
= guah
.DrawFrameControl(hDC
, rc
, uType
, uState
);
1443 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1457 DrawEdge(HDC hDC
, LPRECT rc
, UINT edge
, UINT flags
)
1459 if (flags
& BF_DIAGONAL
)
1460 return IntDrawDiagEdge(hDC
, rc
, edge
, flags
);
1462 return IntDrawRectEdge(hDC
, rc
, edge
, flags
, 1);
1469 GrayStringA(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1470 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1472 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, FALSE
);
1479 GrayStringW(HDC hDC
, HBRUSH hBrush
, GRAYSTRINGPROC lpOutputFunc
, LPARAM lpData
,
1480 int nCount
, int X
, int Y
, int nWidth
, int nHeight
)
1482 return IntGrayString(hDC
, hBrush
, lpOutputFunc
, lpData
, nCount
, X
, Y
, nWidth
, nHeight
, TRUE
);
1489 InvertRect(HDC hDC
, CONST RECT
*lprc
)
1491 return PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1492 lprc
->bottom
- lprc
->top
, DSTINVERT
);
1499 FrameRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1504 if (IsRectEmpty(&r
)) return 0;
1505 if (!(oldbrush
= SelectObject(hDC
, hbr
))) return 0;
1507 PatBlt(hDC
, r
.left
, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1508 PatBlt(hDC
, r
.right
- 1, r
.top
, 1, r
.bottom
- r
.top
, PATCOPY
);
1509 PatBlt(hDC
, r
.left
, r
.top
, r
.right
- r
.left
, 1, PATCOPY
);
1510 PatBlt(hDC
, r
.left
, r
.bottom
- 1, r
.right
- r
.left
, 1, PATCOPY
);
1512 SelectObject(hDC
, oldbrush
);
1520 FlashWindow(HWND hWnd
, BOOL bInvert
)
1522 FLASHWINFO FlashWndInfo
;
1524 FlashWndInfo
.cbSize
= sizeof(FLASHWINFO
);
1525 FlashWndInfo
.hwnd
= hWnd
;
1526 FlashWndInfo
.dwFlags
= !bInvert
? 0 : (FLASHW_TRAY
| FLASHW_CAPTION
);
1527 FlashWndInfo
.uCount
= 1;
1528 FlashWndInfo
.dwTimeout
= 0;
1530 return NtUserFlashWindowEx(&FlashWndInfo
);
1537 FillRect(HDC hDC
, CONST RECT
*lprc
, HBRUSH hbr
)
1540 HBRUSH prevhbr
= NULL
;
1542 /* Select brush if specified */
1545 /* Handle system colors */
1546 if (hbr
<= (HBRUSH
)(COLOR_MENUBAR
+ 1))
1547 hbr
= GetSysColorBrush(PtrToUlong(hbr
) - 1);
1549 prevhbr
= SelectObject(hDC
, hbr
);
1550 if (prevhbr
== NULL
)
1554 Ret
= PatBlt(hDC
, lprc
->left
, lprc
->top
, lprc
->right
- lprc
->left
,
1555 lprc
->bottom
- lprc
->top
, PATCOPY
);
1557 /* Select old brush */
1559 SelectObject(hDC
, prevhbr
);
1568 DrawFocusRect(HDC hdc
, CONST RECT
*rect
)
1573 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH
, 0, &cx
, 0);
1574 NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT
, 0, &cy
, 0);
1576 OldObj
= SelectObject(hdc
, gpsi
->hbrGray
);
1579 PatBlt(hdc
, rect
->left
, rect
->top
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1581 PatBlt(hdc
, rect
->left
, rect
->bottom
- cy
, rect
->right
- rect
->left
, cy
, PATINVERT
);
1583 PatBlt(hdc
, rect
->left
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1585 PatBlt(hdc
, rect
->right
- cx
, rect
->top
+ cy
, cx
, rect
->bottom
- rect
->top
- (2 * cy
), PATINVERT
);
1587 SelectObject(hdc
, OldObj
);
1595 DrawStateA(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1596 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1598 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, FALSE
);
1605 DrawStateW(HDC hDC
, HBRUSH hBrush
, DRAWSTATEPROC lpOutputFunc
, LPARAM lData
,
1606 WPARAM wData
, int x
, int y
, int cx
, int cy
, UINT fuFlags
)
1608 return IntDrawState(hDC
, hBrush
, lpOutputFunc
, lData
, wData
, x
, y
, cx
, cy
, fuFlags
, TRUE
);