source: trunk/src/user32/uitools.cpp@ 9795

Last change on this file since 9795 was 9795, checked in by sandervl, 23 years ago

DrawFocusRect: conflict between SetROP2(R2_XORPEN) and SetBkMode(TRANSPARENT); commenting out the latter for now

File size: 60.4 KB
Line 
1/* $Id: uitools.cpp,v 1.35 2003-02-13 12:44:53 sandervl Exp $ */
2/*
3 * User Interface Functions
4 *
5 * Copyright 1997 Dimitrie O. Paun
6 * Copyright 1997 Bertho A. Stultiens
7 * Copyright 1999 Achim Hasenmueller
8 * Copyright 1999 Christoph Bratschi
9 * Copyright 1999 Rene Pronk
10 *
11 * WINE version: 990923
12 */
13
14#include "winuser.h"
15#include "user32.h"
16#include "win32wbase.h"
17#include "syscolor.h"
18
19#define DBG_LOCALLOG DBG_uitools
20#include "dbglocal.h"
21
22/* These tables are used in:
23 * UITOOLS_DrawDiagEdge()
24 * UITOOLS_DrawRectEdge()
25 */
26static const signed LTInnerNormal[] = {
27 -1, -1, -1, -1,
28 -1, COLOR_BTNHIGHLIGHT, COLOR_BTNHIGHLIGHT, -1,
29 -1, COLOR_3DDKSHADOW, COLOR_3DDKSHADOW, -1,
30 -1, -1, -1, -1
31};
32
33static const signed char LTOuterNormal[] = {
34 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
35 COLOR_BTNHIGHLIGHT, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
36 COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
37 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1
38};
39
40static const signed char RBInnerNormal[] = {
41 -1, -1, -1, -1,
42 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
43 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
44 -1, -1, -1, -1
45};
46
47static const signed char RBOuterNormal[] = {
48 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
49 COLOR_BTNSHADOW, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
50 COLOR_3DLIGHT, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
51 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1
52};
53
54static const signed char LTInnerSoft[] = {
55 -1, -1, -1, -1,
56 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
57 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
58 -1, -1, -1, -1
59};
60
61static const signed char LTOuterSoft[] = {
62 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
63 COLOR_3DLIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
64 COLOR_BTNSHADOW, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
65 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1
66};
67
68#define RBInnerSoft RBInnerNormal /* These are the same */
69#define RBOuterSoft RBOuterNormal
70
71static const signed char LTRBOuterMono[] = {
72 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
73 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
74 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
75 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
76};
77
78static const signed char LTRBInnerMono[] = {
79 -1, -1, -1, -1,
80 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
81 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
82 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
83};
84
85static const signed char LTRBOuterFlat[] = {
86 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
87 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
88 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
89 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
90};
91
92static const signed char LTRBInnerFlat[] = {
93 -1, -1, -1, -1,
94 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
95 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
96 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
97};
98
99/***********************************************************************
100 * UITOOLS_DrawDiagEdge
101 *
102 * Same as DrawEdge invoked with BF_DIAGONAL
103 *
104 * 03-Dec-1997: Changed by Bertho Stultiens
105 *
106 * See also comments with UITOOLS_DrawRectEdge()
107 */
108static BOOL UITOOLS95_DrawDiagEdge(HDC hdc, LPRECT rc,
109 UINT uType, UINT uFlags)
110{
111 POINT Points[4];
112 signed char InnerI, OuterI;
113 HPEN InnerPen, OuterPen;
114 POINT SavePoint;
115 HPEN SavePen;
116 int spx, spy;
117 int epx, epy;
118 int Width = rc->right - rc->left;
119 int Height= rc->bottom - rc->top;
120 int SmallDiam = Width > Height ? Height : Width;
121 BOOL retval = !( ((uType & BDR_INNER) == BDR_INNER
122 || (uType & BDR_OUTER) == BDR_OUTER)
123 && !(uFlags & (BF_FLAT|BF_MONO)) );
124 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
125 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
126
127 if (IsRectEmpty(rc)) return retval; //nothing to do
128
129 /* Init some vars */
130 OuterPen = InnerPen = (HPEN)GetStockObject(NULL_PEN);
131 SavePen = (HPEN)SelectObject(hdc, InnerPen);
132 spx = spy = epx = epy = 0; /* Satisfy the compiler... */
133
134 /* Determine the colors of the edges */
135 if(uFlags & BF_MONO)
136 {
137 InnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
138 OuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
139 }
140 else if(uFlags & BF_FLAT)
141 {
142 InnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
143 OuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
144 }
145 else if(uFlags & BF_SOFT)
146 {
147 if(uFlags & BF_BOTTOM)
148 {
149 InnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
150 OuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
151 }
152 else
153 {
154 InnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
155 OuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
156 }
157 }
158 else
159 {
160 if(uFlags & BF_BOTTOM)
161 {
162 InnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
163 OuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
164 }
165 else
166 {
167 InnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
168 OuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
169 }
170 }
171
172 if(InnerI != -1) InnerPen = GetSysColorPen(InnerI);
173 if(OuterI != -1) OuterPen = GetSysColorPen(OuterI);
174
175 MoveToEx(hdc, 0, 0, &SavePoint);
176
177 /* Don't ask me why, but this is what is visible... */
178 /* This must be possible to do much simpler, but I fail to */
179 /* see the logic in the MS implementation (sigh...). */
180 /* So, this might look a bit brute force here (and it is), but */
181 /* it gets the job done;) */
182
183 switch(uFlags & BF_RECT)
184 {
185 case 0:
186 case BF_LEFT:
187 case BF_BOTTOM:
188 case BF_BOTTOMLEFT:
189 /* Left bottom endpoint */
190 epx = rc->left-1;
191 spx = epx + SmallDiam;
192 epy = rc->bottom;
193 spy = epy - SmallDiam;
194 break;
195
196 case BF_TOPLEFT:
197 case BF_BOTTOMRIGHT:
198 /* Left top endpoint */
199 epx = rc->left-1;
200 spx = epx + SmallDiam;
201 epy = rc->top-1;
202 spy = epy + SmallDiam;
203 break;
204
205 case BF_TOP:
206 case BF_RIGHT:
207 case BF_TOPRIGHT:
208 case BF_RIGHT|BF_LEFT:
209 case BF_RIGHT|BF_LEFT|BF_TOP:
210 case BF_BOTTOM|BF_TOP:
211 case BF_BOTTOM|BF_TOP|BF_LEFT:
212 case BF_BOTTOMRIGHT|BF_LEFT:
213 case BF_BOTTOMRIGHT|BF_TOP:
214 case BF_RECT:
215 /* Right top endpoint */
216 spx = rc->left;
217 epx = spx + SmallDiam;
218 spy = rc->bottom-1;
219 epy = spy - SmallDiam;
220 break;
221 }
222
223 MoveToEx(hdc, spx, spy, NULL);
224 SelectObject(hdc, OuterPen);
225 LineTo(hdc, epx, epy);
226
227 SelectObject(hdc, InnerPen);
228
229 switch(uFlags & (BF_RECT|BF_DIAGONAL))
230 {
231 case BF_DIAGONAL_ENDBOTTOMLEFT:
232 case (BF_DIAGONAL|BF_BOTTOM):
233 case BF_DIAGONAL:
234 case (BF_DIAGONAL|BF_LEFT):
235 MoveToEx(hdc, spx-1, spy, NULL);
236 LineTo(hdc, epx, epy-1);
237 Points[0].x = spx-add;
238 Points[0].y = spy;
239 Points[1].x = rc->left;
240 Points[1].y = rc->top;
241 Points[2].x = epx+1;
242 Points[2].y = epy-1-add;
243 Points[3] = Points[2];
244 break;
245
246 case BF_DIAGONAL_ENDBOTTOMRIGHT:
247 MoveToEx(hdc, spx-1, spy, NULL);
248 LineTo(hdc, epx, epy+1);
249 Points[0].x = spx-add;
250 Points[0].y = spy;
251 Points[1].x = rc->left;
252 Points[1].y = rc->bottom-1;
253 Points[2].x = epx+1;
254 Points[2].y = epy+1+add;
255 Points[3] = Points[2];
256 break;
257
258 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP):
259 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP|BF_LEFT):
260 case BF_DIAGONAL_ENDTOPRIGHT:
261 case (BF_DIAGONAL|BF_RIGHT|BF_TOP|BF_LEFT):
262 MoveToEx(hdc, spx+1, spy, NULL);
263 LineTo(hdc, epx, epy+1);
264 Points[0].x = epx-1;
265 Points[0].y = epy+1+add;
266 Points[1].x = rc->right-1;
267 Points[1].y = rc->top+add;
268 Points[2].x = rc->right-1;
269 Points[2].y = rc->bottom-1;
270 Points[3].x = spx+add;
271 Points[3].y = spy;
272 break;
273
274 case BF_DIAGONAL_ENDTOPLEFT:
275 MoveToEx(hdc, spx, spy-1, NULL);
276 LineTo(hdc, epx+1, epy);
277 Points[0].x = epx+1+add;
278 Points[0].y = epy+1;
279 Points[1].x = rc->right-1;
280 Points[1].y = rc->top;
281 Points[2].x = rc->right-1;
282 Points[2].y = rc->bottom-1-add;
283 Points[3].x = spx;
284 Points[3].y = spy-add;
285 break;
286
287 case (BF_DIAGONAL|BF_TOP):
288 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP):
289 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP|BF_LEFT):
290 MoveToEx(hdc, spx+1, spy-1, NULL);
291 LineTo(hdc, epx, epy);
292 Points[0].x = epx-1;
293 Points[0].y = epy+1;
294 Points[1].x = rc->right-1;
295 Points[1].y = rc->top;
296 Points[2].x = rc->right-1;
297 Points[2].y = rc->bottom-1-add;
298 Points[3].x = spx+add;
299 Points[3].y = spy-add;
300 break;
301
302 case (BF_DIAGONAL|BF_RIGHT):
303 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT):
304 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT|BF_BOTTOM):
305 MoveToEx(hdc, spx, spy, NULL);
306 LineTo(hdc, epx-1, epy+1);
307 Points[0].x = spx;
308 Points[0].y = spy;
309 Points[1].x = rc->left;
310 Points[1].y = rc->top+add;
311 Points[2].x = epx-1-add;
312 Points[2].y = epy+1+add;
313 Points[3] = Points[2];
314 break;
315 }
316
317 /* Fill the interior if asked */
318 if((uFlags & BF_MIDDLE) && retval)
319 {
320 HBRUSH hbsave;
321 HBRUSH hb = GetSysColorBrush(uFlags & BF_MONO ? COLOR_WINDOW
322 :COLOR_BTNFACE);
323 HPEN hpsave;
324 HPEN hp = GetSysColorPen(uFlags & BF_MONO ? COLOR_WINDOW
325 : COLOR_BTNFACE);
326 hbsave = (HBRUSH)SelectObject(hdc, hb);
327 hpsave = (HPEN)SelectObject(hdc, hp);
328 Polygon(hdc, Points, 4);
329 SelectObject(hdc, hbsave);
330 SelectObject(hdc, hpsave);
331 }
332
333 /* Adjust rectangle if asked */
334 if(uFlags & BF_ADJUST)
335 {
336 if(uFlags & BF_LEFT) rc->left += add;
337 if(uFlags & BF_RIGHT) rc->right -= add;
338 if(uFlags & BF_TOP) rc->top += add;
339 if(uFlags & BF_BOTTOM) rc->bottom -= add;
340 }
341
342 /* Cleanup */
343 SelectObject(hdc, SavePen);
344 MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
345
346 return retval;
347}
348
349/***********************************************************************
350 * UITOOLS_DrawRectEdge
351 *
352 * Same as DrawEdge invoked without BF_DIAGONAL
353 *
354 * 23-Nov-1997: Changed by Bertho Stultiens
355 *
356 * Well, I started testing this and found out that there are a few things
357 * that weren't quite as win95. The following rewrite should reproduce
358 * win95 results completely.
359 * The colorselection is table-driven to avoid awfull if-statements.
360 * The table below show the color settings.
361 *
362 * Pen selection table for uFlags = 0
363 *
364 * uType | LTI | LTO | RBI | RBO
365 * ------+-------+-------+-------+-------
366 * 0000 | x | x | x | x
367 * 0001 | x | 22 | x | 21
368 * 0010 | x | 16 | x | 20
369 * 0011 | x | x | x | x
370 * ------+-------+-------+-------+-------
371 * 0100 | x | 20 | x | 16
372 * 0101 | 20 | 22 | 16 | 21
373 * 0110 | 20 | 16 | 16 | 20
374 * 0111 | x | x | x | x
375 * ------+-------+-------+-------+-------
376 * 1000 | x | 21 | x | 22
377 * 1001 | 21 | 22 | 22 | 21
378 * 1010 | 21 | 16 | 22 | 20
379 * 1011 | x | x | x | x
380 * ------+-------+-------+-------+-------
381 * 1100 | x | x | x | x
382 * 1101 | x | x (22)| x | x (21)
383 * 1110 | x | x (16)| x | x (20)
384 * 1111 | x | x | x | x
385 *
386 * Pen selection table for uFlags = BF_SOFT
387 *
388 * uType | LTI | LTO | RBI | RBO
389 * ------+-------+-------+-------+-------
390 * 0000 | x | x | x | x
391 * 0001 | x | 20 | x | 21
392 * 0010 | x | 21 | x | 20
393 * 0011 | x | x | x | x
394 * ------+-------+-------+-------+-------
395 * 0100 | x | 22 | x | 16
396 * 0101 | 22 | 20 | 16 | 21
397 * 0110 | 22 | 21 | 16 | 20
398 * 0111 | x | x | x | x
399 * ------+-------+-------+-------+-------
400 * 1000 | x | 16 | x | 22
401 * 1001 | 16 | 20 | 22 | 21
402 * 1010 | 16 | 21 | 22 | 20
403 * 1011 | x | x | x | x
404 * ------+-------+-------+-------+-------
405 * 1100 | x | x | x | x
406 * 1101 | x | x (20)| x | x (21)
407 * 1110 | x | x (21)| x | x (20)
408 * 1111 | x | x | x | x
409 *
410 * x = don't care; (n) = is what win95 actually uses
411 * LTI = left Top Inner line
412 * LTO = left Top Outer line
413 * RBI = Right Bottom Inner line
414 * RBO = Right Bottom Outer line
415 * 15 = COLOR_BTNFACE
416 * 16 = COLOR_BTNSHADOW
417 * 20 = COLOR_BTNHIGHLIGHT
418 * 21 = COLOR_3DDKSHADOW
419 * 22 = COLOR_3DLIGHT
420 */
421
422
423static BOOL UITOOLS95_DrawRectEdge(HDC hdc, LPRECT rc,
424 UINT uType, UINT uFlags)
425{
426 signed char LTInnerI, LTOuterI;
427 signed char RBInnerI, RBOuterI;
428 HPEN LTInnerPen, LTOuterPen;
429 HPEN RBInnerPen, RBOuterPen;
430 RECT InnerRect = *rc;
431 POINT SavePoint;
432 HPEN SavePen;
433 int LBpenplus = 0;
434 int LTpenplus = 0;
435 int RTpenplus = 0;
436 int RBpenplus = 0;
437 BOOL retval = !( ((uType & BDR_INNER) == BDR_INNER
438 || (uType & BDR_OUTER) == BDR_OUTER)
439 && !(uFlags & (BF_FLAT|BF_MONO)) );
440
441 if (IsRectEmpty(rc)) return retval; //nothing to do
442
443 /* Init some vars */
444 LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN)GetStockObject(NULL_PEN);
445 SavePen = (HPEN)SelectObject(hdc, LTInnerPen);
446
447 /* Determine the colors of the edges */
448 if(uFlags & BF_MONO)
449 {
450 LTInnerI = RBInnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
451 LTOuterI = RBOuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
452 }
453 else if(uFlags & BF_FLAT)
454 {
455 LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
456 LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
457
458 /* Bertho Stultiens states above that this function exactly matches win95
459 * In win98 BF_FLAT rectangels have an inner border same color as the
460 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
461 * I don't know I go with Bertho and just sets it for win98 until proven
462 * otherwise.
463 * Dennis Björklund, 10 June, 99
464 */
465 if(LTInnerI != -1 )
466 LTInnerI = RBInnerI = COLOR_BTNFACE;
467 }
468 else if(uFlags & BF_SOFT)
469 {
470 LTInnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
471 LTOuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
472 RBInnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
473 RBOuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
474 }
475 else
476 {
477 LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
478 LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
479 RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
480 RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
481 }
482
483 if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
484 if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
485 if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
486 if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
487
488 if(LTInnerI != -1) LTInnerPen = GetSysColorPen(LTInnerI);
489 if(LTOuterI != -1) LTOuterPen = GetSysColorPen(LTOuterI);
490 if(RBInnerI != -1) RBInnerPen = GetSysColorPen(RBInnerI);
491 if(RBOuterI != -1) RBOuterPen = GetSysColorPen(RBOuterI);
492
493 MoveToEx(hdc, 0, 0, &SavePoint);
494
495 /* Draw the outer edge */
496 SelectObject(hdc, LTOuterPen);
497 if(uFlags & BF_TOP)
498 {
499 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
500 LineTo(hdc, InnerRect.right, InnerRect.top);
501 }
502 if(uFlags & BF_LEFT)
503 {
504 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
505 LineTo(hdc, InnerRect.left, InnerRect.bottom);
506 }
507
508 SelectObject(hdc, RBOuterPen);
509 if(uFlags & BF_BOTTOM)
510 {
511 MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
512 LineTo(hdc, InnerRect.left-1, InnerRect.bottom-1);
513 }
514 if(uFlags & BF_RIGHT)
515 {
516 MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
517 LineTo(hdc, InnerRect.right-1, InnerRect.top-1);
518 }
519
520 /* Draw the inner edge */
521 SelectObject(hdc, LTInnerPen);
522 if(uFlags & BF_TOP)
523 {
524 MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
525 LineTo(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
526 }
527 if(uFlags & BF_LEFT)
528 {
529 MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
530 LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
531 }
532 SelectObject(hdc, RBInnerPen);
533 if(uFlags & BF_BOTTOM)
534 {
535 MoveToEx(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
536 LineTo(hdc, InnerRect.left-1+LBpenplus, InnerRect.bottom-2);
537 }
538 if(uFlags & BF_RIGHT)
539 {
540 MoveToEx(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
541 LineTo(hdc, InnerRect.right-2, InnerRect.top-1+RTpenplus);
542 }
543
544 if( ((uFlags & BF_MIDDLE) && retval) || (uFlags & BF_ADJUST) )
545 {
546 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
547 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
548
549 if(uFlags & BF_LEFT) InnerRect.left += add;
550 if(uFlags & BF_RIGHT) InnerRect.right -= add;
551 if(uFlags & BF_TOP) InnerRect.top += add;
552 if(uFlags & BF_BOTTOM) InnerRect.bottom -= add;
553
554 if((uFlags & BF_MIDDLE) && retval)
555 {
556 FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?
557 COLOR_WINDOW : COLOR_BTNFACE));
558 }
559
560 if(uFlags & BF_ADJUST)
561 *rc = InnerRect;
562 }
563
564 /* Cleanup */
565 SelectObject(hdc, SavePen);
566 MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
567 return retval;
568}
569
570
571//**********************************************************************
572// DrawEdge (USER32.155)
573//
574BOOL WIN32API DrawEdge(HDC hdc, LPRECT rc, UINT edge, UINT flags)
575{
576
577 if (flags & BF_DIAGONAL)
578 return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
579 else
580 return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
581}
582
583/************************************************************************
584 * UITOOLS_MakeSquareRect
585 *
586 * Utility to create a square rectangle and returning the width
587 */
588static int UITOOLS_MakeSquareRect(LPRECT src, LPRECT dst)
589{
590 int Width = src->right - src->left;
591 int Height = src->bottom - src->top;
592 int SmallDiam = Width > Height ? Height : Width;
593
594 *dst = *src;
595
596 /* Make it a square box */
597 if(Width < Height) /* SmallDiam == Width */
598 {
599 dst->top += (Height-Width)/2;
600 dst->bottom = dst->top + SmallDiam;
601 }
602 else if(Width > Height) /* SmallDiam == Height */
603 {
604 dst->left += (Width-Height)/2;
605 dst->right = dst->left + SmallDiam;
606 }
607
608 return SmallDiam;
609}
610
611
612static void UITOOLS_DrawCheckedRect( HDC dc, LPRECT rect )
613{
614 if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
615 {
616 COLORREF bg;
617 HBRUSH hbsave;
618
619 FillRect(dc, rect, GetSysColorBrush(COLOR_BTNFACE));
620 bg = SetBkColor(dc, RGB(255, 255, 255));
621 hbsave = (HBRUSH)SelectObject(dc,GetPattern55AABrush());
622 PatBlt(dc, rect->left, rect->top, rect->right-rect->left, rect->bottom-rect->top, 0x00FA0089);
623 SelectObject(dc, hbsave);
624 SetBkColor(dc, bg);
625 }
626 else
627 {
628 FillRect(dc, rect, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
629 }
630}
631
632/************************************************************************
633 * UITOOLS_DFC_ButtonPush
634 *
635 * Draw a push button coming from DrawFrameControl()
636 *
637 * Does a pretty good job in emulating MS behavior. Some quirks are
638 * however there because MS uses a TrueType font (Marlett) to draw
639 * the buttons.
640 */
641static BOOL UITOOLS95_DFC_ButtonPush(HDC dc, LPRECT r, UINT uFlags)
642{
643 UINT edge;
644 RECT myr = *r;
645
646 if(uFlags & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
647 edge = EDGE_SUNKEN;
648 else
649 edge = EDGE_RAISED;
650
651 if(uFlags & DFCS_CHECKED)
652 {
653 if(uFlags & DFCS_MONO)
654 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
655 else
656 UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
657
658 UITOOLS_DrawCheckedRect( dc, &myr );
659 }
660 else
661 {
662 if(uFlags & DFCS_MONO)
663 {
664 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
665 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
666 }
667 else
668 {
669 UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
670 }
671 }
672
673 /* Adjust rectangle if asked */
674 if(uFlags & DFCS_ADJUSTRECT)
675 {
676 r->left += 2;
677 r->right -= 2;
678 r->top += 2;
679 r->bottom -= 2;
680 }
681
682 return TRUE;
683}
684
685
686/************************************************************************
687 * UITOOLS_DFC_ButtonCheck
688 *
689 * Draw a check/3state button coming from DrawFrameControl()
690 *
691 * Does a pretty good job in emulating MS behavior. Some quirks are
692 * however there because MS uses a TrueType font (Marlett) to draw
693 * the buttons.
694 */
695#define DFC_CHECKPOINTSMAX 6
696
697static BOOL UITOOLS95_DFC_ButtonCheck(HDC dc, LPRECT r, UINT uFlags)
698{
699 RECT myr;
700 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
701 UINT flags = BF_RECT | BF_ADJUST;
702
703 if(uFlags & DFCS_FLAT) flags |= BF_FLAT;
704 else if(uFlags & DFCS_MONO) flags |= BF_MONO;
705
706 UITOOLS95_DrawRectEdge( dc, &myr, EDGE_SUNKEN, flags );
707
708 if(uFlags & (DFCS_INACTIVE|DFCS_PUSHED))
709 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
710 else if( (uFlags & DFCS_BUTTON3STATE) && (uFlags & DFCS_CHECKED) )
711 UITOOLS_DrawCheckedRect( dc, &myr );
712 else
713 {
714 FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOW));
715 }
716
717 if(uFlags & DFCS_CHECKED)
718 {
719 POINT CheckPoints[DFC_CHECKPOINTSMAX];
720 int i;
721 HBRUSH hbsave;
722 HPEN hpsave;
723
724 /* FIXME: This comes very close to M$'s checkmark, but not */
725 /* exactly... When small or large there is a few pixels */
726 /* shift. Not bad, but could be better :) */
727 UITOOLS_MakeSquareRect(r, &myr);
728 CheckPoints[0].x = myr.left + 253*SmallDiam/1000;
729 CheckPoints[0].y = myr.top + 345*SmallDiam/1000;
730 CheckPoints[1].x = myr.left + 409*SmallDiam/1000;
731 CheckPoints[1].y = CheckPoints[0].y + (CheckPoints[1].x-CheckPoints[0].x);
732 CheckPoints[2].x = myr.left + 690*SmallDiam/1000;
733 CheckPoints[2].y = CheckPoints[1].y - (CheckPoints[2].x-CheckPoints[1].x);
734 CheckPoints[3].x = CheckPoints[2].x;
735 CheckPoints[3].y = CheckPoints[2].y + 3*SmallDiam/16;
736 CheckPoints[4].x = CheckPoints[1].x;
737 CheckPoints[4].y = CheckPoints[1].y + 3*SmallDiam/16;
738 CheckPoints[5].x = CheckPoints[0].x;
739 CheckPoints[5].y = CheckPoints[0].y + 3*SmallDiam/16;
740
741 i = (uFlags & DFCS_INACTIVE) || (uFlags & 0xff) == DFCS_BUTTON3STATE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
742 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
743 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
744 Polygon(dc, CheckPoints, DFC_CHECKPOINTSMAX);
745 SelectObject(dc, hpsave);
746 SelectObject(dc, hbsave);
747 }
748 return TRUE;
749}
750
751
752/************************************************************************
753 * UITOOLS_DFC_ButtonRadio
754 *
755 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
756 *
757 * Does a pretty good job in emulating MS behavior. Some quirks are
758 * however there because MS uses a TrueType font (Marlett) to draw
759 * the buttons.
760 */
761static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
762{
763 RECT myr;
764 int i;
765 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
766 int BorderShrink = SmallDiam / 16;
767 HPEN hpsave;
768 HBRUSH hbsave;
769 int xe, ye;
770 int xc, yc;
771
772 if(BorderShrink < 1) BorderShrink = 1;
773
774 if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
775 {
776 FillRect(dc, r, (HBRUSH)GetStockObject(BLACK_BRUSH));
777 }
778
779 xe = myr.left;
780 ye = myr.top + SmallDiam - SmallDiam/2;
781
782 xc = myr.left + SmallDiam - SmallDiam/2;
783 yc = myr.top + SmallDiam - SmallDiam/2;
784
785 /* Define bounding box */
786 i = (14*SmallDiam)/16;
787 myr.left = xc - i+i/2;
788 myr.right = xc + i/2;
789 myr.top = yc - i+i/2;
790 myr.bottom = yc + i/2;
791
792 if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
793 {
794 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
795 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
796 SelectObject(dc, hbsave);
797 }
798 else
799 {
800 if(uFlags & (DFCS_FLAT|DFCS_MONO))
801 {
802 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_WINDOWFRAME));
803 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
804 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
805 SelectObject(dc, hbsave);
806 SelectObject(dc, hpsave);
807 }
808 else
809 {
810 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
811 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
812 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
813
814 SelectObject(dc, GetSysColorPen(COLOR_BTNSHADOW));
815 SelectObject(dc, GetSysColorBrush(COLOR_BTNSHADOW));
816 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
817
818 myr.left += BorderShrink;
819 myr.right -= BorderShrink;
820 myr.top += BorderShrink;
821 myr.bottom -= BorderShrink;
822
823 SelectObject(dc, GetSysColorPen(COLOR_3DLIGHT));
824 SelectObject(dc, GetSysColorBrush(COLOR_3DLIGHT));
825 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
826
827 SelectObject(dc, GetSysColorPen(COLOR_3DDKSHADOW));
828 SelectObject(dc, GetSysColorBrush(COLOR_3DDKSHADOW));
829 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
830 SelectObject(dc, hbsave);
831 SelectObject(dc, hpsave);
832 }
833
834 i = (10*SmallDiam)/16,1;
835 myr.left = xc - i+i/2;
836 myr.right = xc + i/2;
837 myr.top = yc - i+i/2;
838 myr.bottom = yc + i/2;
839 i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
840 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
841 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
842 Ellipse(dc,myr.left,myr.top,myr.right,myr.bottom);
843 SelectObject(dc, hbsave);
844 SelectObject(dc, hpsave);
845 }
846
847 if(uFlags & DFCS_CHECKED)
848 {
849 i = (6*SmallDiam)/16;
850 i = i < 1 ? 1 : i;
851 myr.left = xc - i+i/2;
852 myr.right = xc + i/2;
853 myr.top = yc - i+i/2;
854 myr.bottom = yc + i/2;
855
856 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
857 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
858 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
859 Ellipse(dc,myr.left,myr.top,myr.right,myr.bottom);
860 SelectObject(dc, hpsave);
861 SelectObject(dc, hbsave);
862 }
863
864 /* FIXME: M$ has a polygon in the center at relative points: */
865 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
866 /* 0.476, 0.525 */
867 /* 0.500, 0.500 */
868 /* 0.500, 0.499 */
869 /* when the button is unchecked. The reason for it is unknown. The */
870 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
871 /* least 3 times (it looks like a clip-region when you see it happen). */
872 /* I do not really see a reason why this should be implemented. If you */
873 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
874 /* font. */
875
876 return TRUE;
877}
878
879/***********************************************************************
880 * UITOOLS_DrawFrameButton
881 */
882static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT uState)
883{
884 switch(uState & 0xff)
885 {
886 case DFCS_BUTTONPUSH:
887 return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
888
889 case DFCS_BUTTONCHECK:
890 case DFCS_BUTTON3STATE:
891 return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
892
893 case DFCS_BUTTONRADIOIMAGE:
894 case DFCS_BUTTONRADIOMASK:
895 case DFCS_BUTTONRADIO:
896 return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
897
898// default:
899// WARN("Invalid button state=0x%04x\n", uState);
900 }
901
902 return FALSE;
903}
904
905/***********************************************************************
906 * UITOOLS_DrawFrameCaption
907 *
908 * Draw caption buttons (win95), coming from DrawFrameControl()
909 */
910
911static BOOL UITOOLS95_DrawFrameCaption(HDC dc, LPRECT r, UINT uFlags)
912{
913 POINT Line1[10];
914 POINT Line2[10];
915 int Line1N;
916 int Line2N;
917 RECT myr;
918 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr)-2;
919 int i;
920 HBRUSH hbsave;
921 HPEN hpsave;
922 HFONT hfsave, hf;
923 int xc = (myr.left+myr.right)/2;
924 int yc = (myr.top+myr.bottom)/2;
925 int edge, move;
926 char str[2] = "?";
927 UINT alignsave;
928 int bksave;
929 COLORREF clrsave;
930 SIZE size;
931
932 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
933
934 switch(uFlags & 0xff)
935 {
936 case DFCS_CAPTIONCLOSE:
937 edge = 328*SmallDiam/1000;
938 move = 95*SmallDiam/1000;
939 Line1[0].x = Line2[0].x = Line1[1].x = Line2[1].x = xc - edge;
940 Line1[2].y = Line2[5].y = Line1[1].y = Line2[4].y = yc - edge;
941 Line1[3].x = Line2[3].x = Line1[4].x = Line2[4].x = xc + edge;
942 Line1[5].y = Line2[2].y = Line1[4].y = Line2[1].y = yc + edge;
943 Line1[2].x = Line2[2].x = Line1[1].x + move;
944 Line1[0].y = Line2[3].y = Line1[1].y + move;
945 Line1[5].x = Line2[5].x = Line1[4].x - move;
946 Line1[3].y = Line2[0].y = Line1[4].y - move;
947 Line1N = 6;
948 Line2N = 6;
949 break;
950
951 case DFCS_CAPTIONHELP:
952 /* This one breaks the flow */
953 /* FIXME: We need the Marlett font in order to get this right. */
954
955 hf = CreateFontA(-SmallDiam, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
956 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
957 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "System");
958 alignsave = SetTextAlign(dc, TA_TOP|TA_LEFT);
959 bksave = SetBkMode(dc, TRANSPARENT);
960 clrsave = GetTextColor(dc);
961 hfsave = (HFONT)SelectObject(dc, hf);
962 GetTextExtentPoint32A(dc, str, 1, &size);
963
964 if(uFlags & DFCS_INACTIVE)
965 {
966 SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
967 TextOutA(dc, xc-size.cx/2+1, yc-size.cy/2+1, str, 1);
968 }
969 SetTextColor(dc, GetSysColor(uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
970 TextOutA(dc, xc-size.cx/2, yc-size.cy/2, str, 1);
971
972 SelectObject(dc, hfsave);
973 SetTextColor(dc, clrsave);
974 SetBkMode(dc, bksave);
975 SetTextAlign(dc, alignsave);
976 DeleteObject(hf);
977 return TRUE;
978
979 case DFCS_CAPTIONMIN:
980 Line1[0].x = Line1[3].x = myr.left + 96*SmallDiam/750+2;
981 Line1[1].x = Line1[2].x = Line1[0].x + 372*SmallDiam/750;
982 Line1[0].y = Line1[1].y = myr.top + 563*SmallDiam/750+1;
983 Line1[2].y = Line1[3].y = Line1[0].y + 92*SmallDiam/750;
984 Line1N = 4;
985 Line2N = 0;
986 break;
987
988 case DFCS_CAPTIONMAX:
989 edge = 47*SmallDiam/750;
990 Line1[0].x = Line1[5].x = myr.left + 57*SmallDiam/750+3;
991 Line1[0].y = Line1[1].y = myr.top + 143*SmallDiam/750+1;
992 Line1[1].x = Line1[2].x = Line1[0].x + 562*SmallDiam/750;
993 Line1[5].y = Line1[4].y = Line1[0].y + 93*SmallDiam/750;
994 Line1[2].y = Line1[3].y = Line1[0].y + 513*SmallDiam/750;
995 Line1[3].x = Line1[4].x = Line1[1].x - edge;
996
997 Line2[0].x = Line2[5].x = Line1[0].x;
998 Line2[3].x = Line2[4].x = Line1[1].x;
999 Line2[1].x = Line2[2].x = Line1[0].x + edge;
1000 Line2[0].y = Line2[1].y = Line1[0].y;
1001 Line2[4].y = Line2[5].y = Line1[2].y;
1002 Line2[2].y = Line2[3].y = Line1[2].y - edge;
1003 Line1N = 6;
1004 Line2N = 6;
1005 break;
1006
1007 case DFCS_CAPTIONRESTORE:
1008 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1009 edge = 47*SmallDiam/750;
1010 move = 420*SmallDiam/750;
1011 Line1[0].x = Line1[9].x = myr.left + 198*SmallDiam/750+2;
1012 Line1[0].y = Line1[1].y = myr.top + 169*SmallDiam/750+1;
1013 Line1[6].y = Line1[7].y = Line1[0].y + 93*SmallDiam/750;
1014 Line1[7].x = Line1[8].x = Line1[0].x + edge;
1015 Line1[1].x = Line1[2].x = Line1[0].x + move;
1016 Line1[5].x = Line1[6].x = Line1[1].x - edge;
1017 Line1[9].y = Line1[8].y = Line1[0].y + 187*SmallDiam/750;
1018 Line1[2].y = Line1[3].y = Line1[0].y + 327*SmallDiam/750;
1019 Line1[4].y = Line1[5].y = Line1[2].y - edge;
1020 Line1[3].x = Line1[4].x = Line1[2].x - 140*SmallDiam/750;
1021
1022 Line2[1].x = Line2[2].x = Line1[3].x;
1023 Line2[7].x = Line2[8].x = Line2[1].x - edge;
1024 Line2[0].x = Line2[9].x = Line2[3].x = Line2[4].x = Line2[1].x - move;
1025 Line2[5].x = Line2[6].x = Line2[0].x + edge;
1026 Line2[0].y = Line2[1].y = Line1[9].y;
1027 Line2[4].y = Line2[5].y = Line2[8].y = Line2[9].y = Line2[0].y + 93*SmallDiam/750;
1028 Line2[2].y = Line2[3].y = Line2[0].y + 327*SmallDiam/750;
1029 Line2[6].y = Line2[7].y = Line2[2].y - edge;
1030 Line1N = 10;
1031 Line2N = 10;
1032 break;
1033
1034 default:
1035// WARN("Invalid caption; flags=0x%04x\n", uFlags);
1036 return FALSE;
1037 }
1038
1039 /* Here the drawing takes place */
1040 if(uFlags & DFCS_INACTIVE)
1041 {
1042 /* If we have an inactive button, then you see a shadow */
1043 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
1044 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
1045 Polygon(dc, Line1, Line1N);
1046 if(Line2N > 0)
1047 Polygon(dc, Line2, Line2N);
1048 SelectObject(dc, hpsave);
1049 SelectObject(dc, hbsave);
1050 }
1051
1052 /* Correct for the shadow shift */
1053 for(i = 0; i < Line1N; i++)
1054 {
1055 Line1[i].x--;
1056 Line1[i].y--;
1057 }
1058 for(i = 0; i < Line2N; i++)
1059 {
1060 Line2[i].x--;
1061 Line2[i].y--;
1062 }
1063
1064 /* Make the final picture */
1065 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1066 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
1067 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
1068
1069 Polygon(dc, Line1, Line1N);
1070 if(Line2N > 0)
1071 Polygon(dc, Line2, Line2N);
1072 SelectObject(dc, hpsave);
1073 SelectObject(dc, hbsave);
1074
1075 return TRUE;
1076}
1077
1078
1079/************************************************************************
1080 * UITOOLS_DrawFrameScroll
1081 *
1082 * Draw a scroll-bar control coming from DrawFrameControl()
1083 */
1084static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags)
1085{
1086 POINT Line[4];
1087 RECT myr;
1088 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2;
1089 int i;
1090 HBRUSH hbsave, hb, hb2;
1091 HPEN hpsave, hp, hp2;
1092 int tri = 290*SmallDiam/1000 -1;
1093 int d46, d93;
1094
1095 /*
1096 * This fixes a problem with really tiny "scroll" buttons. In particular
1097 * with the updown control.
1098 * Making sure that the arrow is as least 3 pixels wide (or high).
1099 */
1100 if (tri == 0)
1101 tri = 1;
1102
1103 switch(uFlags & 0xff)
1104 {
1105 case DFCS_SCROLLCOMBOBOX:
1106 case DFCS_SCROLLDOWN:
1107 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1108 Line[2].y = myr.top + 687*SmallDiam/1000 + 1;
1109 Line[0].x = Line[2].x - tri;
1110 Line[1].x = Line[2].x + tri;
1111 Line[0].y = Line[1].y = Line[2].y - tri;
1112 break;
1113
1114 case DFCS_SCROLLUP:
1115 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1116 Line[2].y = myr.bottom - 687*SmallDiam/1000 + 1;
1117 Line[0].x = Line[2].x - tri;
1118 Line[1].x = Line[2].x + tri;
1119 Line[0].y = Line[1].y = Line[2].y + tri;
1120 break;
1121
1122 case DFCS_SCROLLLEFT:
1123 Line[2].x = myr.right - 687*SmallDiam/1000 + 1;
1124 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1125 Line[0].y = Line[2].y - tri;
1126 Line[1].y = Line[2].y + tri;
1127 Line[0].x = Line[1].x = Line[2].x + tri;
1128 break;
1129
1130 case DFCS_SCROLLRIGHT:
1131 Line[2].x = myr.left + 687*SmallDiam/1000 + 1;
1132 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1133 Line[0].y = Line[2].y - tri;
1134 Line[1].y = Line[2].y + tri;
1135 Line[0].x = Line[1].x = Line[2].x - tri;
1136 break;
1137
1138 case DFCS_SCROLLSIZEGRIP:
1139 /* This one breaks the flow... */
1140 UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
1141 hpsave = (HPEN)SelectObject(dc, GetStockObject(NULL_PEN));
1142 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH));
1143 if(uFlags & (DFCS_MONO|DFCS_FLAT))
1144 {
1145 hp = hp2 = GetSysColorPen(COLOR_WINDOWFRAME);
1146 hb = hb2 = GetSysColorBrush(COLOR_WINDOWFRAME);
1147 }
1148 else
1149 {
1150 hp = GetSysColorPen(COLOR_BTNHIGHLIGHT);
1151 hp2 = GetSysColorPen(COLOR_BTNSHADOW);
1152 hb = GetSysColorBrush(COLOR_BTNHIGHLIGHT);
1153 hb2 = GetSysColorBrush(COLOR_BTNSHADOW);
1154 }
1155 Line[0].x = Line[1].x = r->right-1;
1156 Line[2].y = Line[3].y = r->bottom-1;
1157 d46 = 46*SmallDiam/750;
1158 d93 = 93*SmallDiam/750;
1159
1160 i = 586*SmallDiam/750;
1161 Line[0].y = r->bottom - i - 1;
1162 Line[3].x = r->right - i - 1;
1163 Line[1].y = Line[0].y + d46;
1164 Line[2].x = Line[3].x + d46;
1165 SelectObject(dc, hb);
1166 SelectObject(dc, hp);
1167 Polygon(dc, Line, 4);
1168
1169 Line[1].y++; Line[2].x++;
1170 Line[0].y = Line[1].y + d93;
1171 Line[3].x = Line[2].x + d93;
1172 SelectObject(dc, hb2);
1173 SelectObject(dc, hp2);
1174 Polygon(dc, Line, 4);
1175
1176 i = 398*SmallDiam/750;
1177 Line[0].y = r->bottom - i - 1;
1178 Line[3].x = r->right - i - 1;
1179 Line[1].y = Line[0].y + d46;
1180 Line[2].x = Line[3].x + d46;
1181 SelectObject(dc, hb);
1182 SelectObject(dc, hp);
1183 Polygon(dc, Line, 4);
1184
1185 Line[1].y++; Line[2].x++;
1186 Line[0].y = Line[1].y + d93;
1187 Line[3].x = Line[2].x + d93;
1188 SelectObject(dc, hb2);
1189 SelectObject(dc, hp2);
1190 Polygon(dc, Line, 4);
1191
1192 i = 210*SmallDiam/750;
1193 Line[0].y = r->bottom - i - 1;
1194 Line[3].x = r->right - i - 1;
1195 Line[1].y = Line[0].y + d46;
1196 Line[2].x = Line[3].x + d46;
1197 SelectObject(dc, hb);
1198 SelectObject(dc, hp);
1199 Polygon(dc, Line, 4);
1200
1201 Line[1].y++; Line[2].x++;
1202 Line[0].y = Line[1].y + d93;
1203 Line[3].x = Line[2].x + d93;
1204 SelectObject(dc, hb2);
1205 SelectObject(dc, hp2);
1206 Polygon(dc, Line, 4);
1207
1208 SelectObject(dc, hpsave);
1209 SelectObject(dc, hbsave);
1210 return TRUE;
1211
1212 default:
1213// WARN("Invalid scroll; flags=0x%04x\n", uFlags);
1214 return FALSE;
1215 }
1216
1217 /* Here do the real scroll-bar controls end up */
1218 if( ! (uFlags & (0xff00 & ~DFCS_ADJUSTRECT)) )
1219 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1220 /* want for the normal scroll-arrow button. */
1221 UITOOLS95_DrawRectEdge( dc, r, EDGE_RAISED, (uFlags&DFCS_ADJUSTRECT) | BF_MIDDLE | BF_RECT);
1222 else
1223 UITOOLS95_DFC_ButtonPush(dc, r, (uFlags & 0xff00) );
1224
1225 if(uFlags & DFCS_INACTIVE)
1226 {
1227 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
1228 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
1229 Polygon(dc, Line, 3);
1230 SelectObject(dc, hpsave);
1231 SelectObject(dc, hbsave);
1232 }
1233
1234 if( (uFlags & DFCS_INACTIVE) || !(uFlags & DFCS_PUSHED) )
1235 for(i = 0; i < 3; i++)
1236 {
1237 Line[i].x--;
1238 Line[i].y--;
1239 }
1240
1241 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1242 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
1243 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
1244 Polygon(dc, Line, 3);
1245 SelectObject(dc, hpsave);
1246 SelectObject(dc, hbsave);
1247
1248 return TRUE;
1249}
1250
1251/************************************************************************
1252 * UITOOLS_DrawFrameMenu
1253 *
1254 * Draw a menu control coming from DrawFrameControl()
1255 */
1256static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
1257{
1258 POINT Points[6];
1259 RECT myr;
1260 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
1261 int i;
1262 HBRUSH hbsave;
1263 HPEN hpsave;
1264 int xe, ye;
1265 int xc, yc;
1266 BOOL retval = TRUE;
1267
1268 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1269 /* use anything else. I think I tried all sys-colors to change things */
1270 /* without luck. It seems as if this behavior is inherited from the */
1271 /* win31 DFC() implementation... (you remember, B/W menus). */
1272
1273 FillRect(dc, r, (HBRUSH)GetStockObject(WHITE_BRUSH));
1274
1275 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
1276 hpsave = (HPEN)SelectObject(dc, GetStockObject(BLACK_PEN));
1277
1278 switch(uFlags & 0xff)
1279 {
1280 case DFCS_MENUARROW:
1281 i = 187*SmallDiam/750;
1282 Points[2].x = myr.left + 468*SmallDiam/750;
1283 Points[2].y = myr.top + 352*SmallDiam/750+1;
1284 Points[0].y = Points[2].y - i;
1285 Points[1].y = Points[2].y + i;
1286 Points[0].x = Points[1].x = Points[2].x - i;
1287 Polygon(dc, Points, 3);
1288 break;
1289
1290 case DFCS_MENUBULLET:
1291 xe = myr.left;
1292 ye = myr.top + SmallDiam - SmallDiam/2;
1293 xc = myr.left + SmallDiam - SmallDiam/2;
1294 yc = myr.top + SmallDiam - SmallDiam/2;
1295 i = 234*SmallDiam/750;
1296 i = i < 1 ? 1 : i;
1297 myr.left = xc - i+i/2;
1298 myr.right = xc + i/2;
1299 myr.top = yc - i+i/2;
1300 myr.bottom = yc + i/2;
1301 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
1302 break;
1303
1304 case DFCS_MENUCHECK:
1305 Points[0].x = myr.left + 253*SmallDiam/1000;
1306 Points[0].y = myr.top + 445*SmallDiam/1000;
1307 Points[1].x = myr.left + 409*SmallDiam/1000;
1308 Points[1].y = Points[0].y + (Points[1].x-Points[0].x);
1309 Points[2].x = myr.left + 690*SmallDiam/1000;
1310 Points[2].y = Points[1].y - (Points[2].x-Points[1].x);
1311 Points[3].x = Points[2].x;
1312 Points[3].y = Points[2].y + 3*SmallDiam/16;
1313 Points[4].x = Points[1].x;
1314 Points[4].y = Points[1].y + 3*SmallDiam/16;
1315 Points[5].x = Points[0].x;
1316 Points[5].y = Points[0].y + 3*SmallDiam/16;
1317 Polygon(dc, Points, 6);
1318 break;
1319
1320 default:
1321// WARN("Invalid menu; flags=0x%04x\n", uFlags);
1322 retval = FALSE;
1323 break;
1324 }
1325
1326 SelectObject(dc, hpsave);
1327 SelectObject(dc, hbsave);
1328 return retval;
1329}
1330
1331/**********************************************************************
1332 * DrawFrameControl (USER32.158)
1333 */
1334BOOL WIN32API DrawFrameControl(HDC hdc, LPRECT rc, UINT uType,
1335 UINT uState )
1336{
1337 /* Win95 doesn't support drawing in other mapping modes */
1338 if(GetMapMode(hdc) != MM_TEXT)
1339 return FALSE;
1340
1341 switch(uType)
1342 {
1343 case DFC_BUTTON:
1344 return UITOOLS95_DrawFrameButton(hdc, rc, uState);
1345 case DFC_CAPTION:
1346 return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
1347 case DFC_MENU:
1348 return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
1349 case DFC_SCROLL:
1350 return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
1351// default:
1352// WARN("(%x,%p,%d,%x), bad type!\n",
1353// hdc,rc,uType,uState );
1354 }
1355 return FALSE;
1356}
1357/******************************************************************************
1358 *
1359 * This function is used by Paint_DrawState which is inturn used by both
1360 * DrawStateA and DrawStateW. The code is directly borrowed from Wine.
1361 *
1362 ******************************************************************************/
1363
1364static BOOL Paint_DrawStateJam(HDC hdc, UINT opcode,
1365 DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
1366 LPRECT rc, UINT dtflags, BOOL unicode)
1367{
1368 HDC memdc;
1369 HBITMAP hbmsave;
1370 BOOL retval;
1371 INT cx = rc->right - rc->left;
1372 INT cy = rc->bottom - rc->top;
1373
1374 switch(opcode)
1375 {
1376 case DST_TEXT:
1377 case DST_PREFIXTEXT:
1378 if(unicode)
1379 return DrawTextW(hdc, (LPWSTR)lp, (INT)wp, rc, dtflags);
1380 else
1381 return DrawTextA(hdc, (LPSTR)lp, (INT)wp, rc, dtflags);
1382
1383 case DST_ICON:
1384 return DrawIcon(hdc, rc->left, rc->top, (HICON)lp);
1385
1386 case DST_BITMAP:
1387 memdc = CreateCompatibleDC(hdc);
1388 if(!memdc) return FALSE;
1389 hbmsave = (HBITMAP)SelectObject(memdc, (HBITMAP)lp);
1390 if(!hbmsave)
1391 {
1392 DeleteDC(memdc);
1393 return FALSE;
1394 }
1395 retval = BitBlt(hdc, rc->left, rc->top, cx, cy, memdc, 0, 0, SRCCOPY);
1396 SelectObject(memdc, hbmsave);
1397 DeleteDC(memdc);
1398 return retval;
1399
1400 case DST_COMPLEX:
1401 if(func)
1402 return func(hdc, lp, wp, cx, cy);
1403 else
1404 return FALSE;
1405 }
1406 return FALSE;
1407}
1408
1409
1410/******************************************************************************
1411 *
1412 * This function is used by both DrawStateA and DrawStateW. The code is directly
1413 * borrowed from Wine
1414 *
1415 ******************************************************************************/
1416BOOL Paint_DrawState (HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
1417 INT x, INT y, INT cx, INT cy, UINT flags, BOOL unicode)
1418{
1419 HBITMAP hbm, hbmsave;
1420 HFONT hfsave;
1421 HBRUSH hbsave;
1422 HDC memdc;
1423 RECT rc;
1424 UINT dtflags = DT_NOCLIP;
1425 COLORREF fg, bg;
1426 UINT opcode = flags & 0xf;
1427 INT len = wp;
1428 BOOL retval, tmp;
1429
1430 if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len) /* The string is '\0' terminated */
1431 {
1432 if(unicode)
1433 len = lstrlenW((LPWSTR)lp);
1434 else
1435 len = lstrlenA((LPSTR)lp);
1436 }
1437
1438 /* Find out what size the image has if not given by caller */
1439 if(!cx || !cy)
1440 {
1441 SIZE s;
1442 BITMAP bmp;
1443
1444 switch(opcode)
1445 {
1446 case DST_TEXT:
1447 case DST_PREFIXTEXT:
1448 if(unicode)
1449 retval = GetTextExtentPoint32W(hdc, (LPWSTR)lp, len, &s);
1450 else
1451 retval = GetTextExtentPoint32A(hdc, (LPSTR)lp, len, &s);
1452 if(!retval) return FALSE;
1453 break;
1454
1455 case DST_ICON:
1456 /* Just assume the icon has the size given by GetSystemMetrics. This should be
1457 valid since both CreateIcon and LoadIcon can't create icons with different
1458 sizes. I wouldn't how else to get the size of the icon. RP
1459 */
1460 s.cx = GetSystemMetrics (SM_CXICON);
1461 s.cy = GetSystemMetrics (SM_CYICON);
1462 break;
1463
1464 case DST_BITMAP:
1465 retval = GetObjectA ((HBITMAP) lp, sizeof (BITMAP), &bmp);
1466 if(retval == 0) return FALSE;
1467 s.cx = bmp.bmWidth;
1468 s.cy = bmp.bmHeight;
1469 break;
1470
1471 case DST_COMPLEX: /* cx and cy must be set in this mode */
1472 return FALSE;
1473 }
1474
1475 if(!cx) cx = s.cx;
1476 if(!cy) cy = s.cy;
1477 }
1478
1479 rc.left = x;
1480 rc.top = y;
1481 rc.right = x + cx;
1482 rc.bottom = y + cy;
1483
1484 if(flags & DSS_RIGHT) /* This one is not documented in the win32.hlp file */
1485 dtflags |= DT_RIGHT;
1486 if(opcode == DST_TEXT)
1487 dtflags |= DT_NOPREFIX;
1488
1489 /* For DSS_NORMAL we just jam in the image and return */
1490 if((flags & 0x7ff0) == DSS_NORMAL)
1491 {
1492 return Paint_DrawStateJam(hdc, opcode, func, lp, len, &rc, dtflags, unicode);
1493 }
1494
1495 /* For all other states we need to convert the image to B/W in a local bitmap */
1496 /* before it is displayed */
1497 fg = SetTextColor(hdc, RGB(0, 0, 0));
1498 bg = SetBkColor(hdc, RGB(255, 255, 255));
1499 hbm = (HBITMAP)NULL; hbmsave = (HBITMAP)NULL;
1500 memdc = (HDC)NULL; hbsave = (HBRUSH)NULL;
1501 retval = FALSE; /* assume failure */
1502
1503 /* From here on we must use "goto cleanup" when something goes wrong */
1504 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
1505 if(!hbm) goto cleanup;
1506 memdc = CreateCompatibleDC(hdc);
1507 if(!memdc) goto cleanup;
1508 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
1509 if(!hbmsave) goto cleanup;
1510 rc.left = rc.top = 0;
1511 rc.right = cx;
1512 rc.bottom = cy;
1513 if(!FillRect(memdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH))) goto cleanup;
1514 SetBkColor(memdc, RGB(255, 255, 255));
1515 SetTextColor(memdc, RGB(0, 0, 0));
1516 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
1517 if(!hfsave && (opcode == DST_TEXT || opcode == DST_PREFIXTEXT)) goto cleanup;
1518 tmp = Paint_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode);
1519 if(hfsave) SelectObject(memdc, hfsave);
1520 if(!tmp) goto cleanup;
1521
1522 /* These states cause the image to be dithered */
1523 if(flags & (DSS_UNION|DSS_DISABLED))
1524 {
1525 hbsave = (HBRUSH)SelectObject(memdc,GetPattern55AABrush());
1526 if(!hbsave) goto cleanup;
1527 tmp = PatBlt(memdc, 0, 0, cx, cy, 0x00FA0089);
1528 if(hbsave) SelectObject(memdc, hbsave);
1529 if(!tmp) goto cleanup;
1530 }
1531
1532 hbsave = (HBRUSH)SelectObject(hdc, hbr ? hbr : GetStockObject(WHITE_BRUSH));
1533 if(!hbsave) goto cleanup;
1534
1535 if(!BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00B8074A)) goto cleanup;
1536
1537 /* DSS_DEFAULT makes the image boldface */
1538 if(flags & DSS_DEFAULT)
1539 {
1540 if(!BitBlt(hdc, x+1, y, cx, cy, memdc, 0, 0, 0x00B8074A)) goto cleanup;
1541 }
1542
1543 retval = TRUE; /* We succeeded */
1544
1545cleanup:
1546 SetTextColor(hdc, fg);
1547 SetBkColor(hdc, bg);
1548
1549 if(hbsave) SelectObject(hdc, hbsave);
1550 if(hbmsave) SelectObject(memdc, hbmsave);
1551 if(hbm) DeleteObject(hbm);
1552 if(memdc) DeleteDC(memdc);
1553
1554 return retval;
1555}
1556
1557
1558
1559/*****************************************************************************
1560 * Name : BOOL WIN32API DrawStateA
1561 * Purpose : Draws a bitmap, icon, text or complex object in one of the following
1562 * states: normal, disabled, union or mono
1563 * Parameters:
1564 * Variables :
1565 * Result : If the function succeeds, the return value is a handle of the
1566 * window station associated with the calling process.
1567 * If the function fails, the return value is NULL. This can occur
1568 * if the calling process is not an application written for Windows
1569 * NT. To get extended error information, call GetLastError.
1570 * Remark : Disabled doesn't look like the Windows implementation, but it does
1571 * look disabled.
1572 * Status : PARTIALLY IMPLEMENTED
1573 *
1574 * Author : Rene Pronk [Sun, 1999/07/25 21:27]
1575 *****************************************************************************/
1576
1577BOOL WIN32API DrawStateA(HDC hdc, HBRUSH hbc, DRAWSTATEPROC lpOutputFunc, LPARAM lData,
1578 WPARAM wData, int x, int y, int cx, int cy, UINT fuFlags)
1579{
1580 dprintf(("USER32:DrawStateA (%08xh,%08xh,%08xh,%08xh,%08xh,%d,%d,%d,%d,%08x).\n",
1581 hdc, hbc, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags));
1582
1583 return Paint_DrawState (hdc, hbc, lpOutputFunc, lData, wData, x, y ,cx, cy, fuFlags, FALSE);
1584}
1585
1586
1587
1588/*****************************************************************************
1589 * Name : BOOL WIN32API DrawStateW
1590 * Purpose : Draws a bitmap, icon, text or complex object in one of the following
1591 * states: normal, disabled, union or mono
1592 * Parameters:
1593 * Variables :
1594 * Result : If the function succeeds, the return value is a handle of the
1595 * window station associated with the calling process.
1596 * If the function fails, the return value is NULL. This can occur
1597 * if the calling process is not an application written for Windows
1598 * NT. To get extended error information, call GetLastError.
1599 * Remark : Disabled doesn't look like the Windows implementation, but it does
1600 * look disabled.
1601 * Status : PARTIALLY IMPLEMENTED
1602 *
1603 * Author : Rene Pronk [Sun, 1999/07/25 21:27]
1604 *****************************************************************************/
1605
1606BOOL WIN32API DrawStateW(HDC hdc, HBRUSH hbc, DRAWSTATEPROC lpOutputFunc, LPARAM lData,
1607 WPARAM wData, int x, int y, int cx, int cy, UINT fuFlags)
1608{
1609 dprintf(("USER32:DrawStateW (%08xh,%08xh,%08xh,%08xh,%08xh,%d,%d,%d,%d,%08x).\n",
1610 hdc, hbc, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags));
1611
1612 return Paint_DrawState (hdc, hbc, lpOutputFunc, lData, wData, x, y ,cx, cy, fuFlags, TRUE);
1613}
1614//******************************************************************************
1615//******************************************************************************
1616BOOL WIN32API DrawFocusRect( HDC hdc, const RECT *lpRect)
1617{
1618 //TODO: This doesn't work. Find out why (SetROP2!)
1619 //NOTE: Executing this code in NT4 shows the same problem. No visible
1620 // rectangle. Commenting out SetROP2 creates a solid rectangle in
1621 // in NT4. (instead of dotted)
1622
1623 HBRUSH hOldBrush;
1624 HPEN hOldPen, hNewPen;
1625 INT oldDrawMode, oldBkMode;
1626
1627 dprintf(("USER32: DrawFocusRect %x (%d,%d)(%d,%d)", hdc, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom));
1628
1629 hOldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
1630 hNewPen = CreatePen(PS_ALTERNATE, 1, GetSysColor(COLOR_WINDOWTEXT));
1631 hOldPen = SelectObject(hdc, hNewPen);
1632 oldDrawMode = SetROP2(hdc, R2_XORPEN);
1633////NOTE: This causes the problem. (WGSS bug)
1634//// oldBkMode = SetBkMode(hdc, TRANSPARENT);
1635
1636 Rectangle(hdc, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1637
1638//// SetBkMode(hdc, oldBkMode);
1639 SetROP2(hdc, oldDrawMode);
1640 SelectObject(hdc, hOldPen);
1641 DeleteObject(hNewPen);
1642 SelectObject(hdc, hOldBrush);
1643
1644 return TRUE;
1645}
1646//******************************************************************************
1647//******************************************************************************
1648BOOL WIN32API DrawIcon( HDC hDC, int X, int Y, HICON hIcon)
1649{
1650 ICONINFO ii;
1651 HDC hMemDC;
1652 BITMAP bmp;
1653 HBITMAP oldBmp;
1654 COLORREF oldFg,oldBg;
1655
1656 dprintf(("USER32: DrawIcon\n"));
1657
1658 if (!hDC || !hIcon)
1659 {
1660 SetLastError(ERROR_INVALID_PARAMETER);
1661
1662 return FALSE;
1663 }
1664
1665 if (!GetIconInfo(hIcon,&ii)) return FALSE;
1666 oldFg = SetTextColor(hDC,RGB(0,0,0));
1667 oldBg = SetBkColor(hDC,RGB(255,255,255));
1668 hMemDC = CreateCompatibleDC(hDC);
1669 oldBmp = SelectObject(hMemDC,ii.hbmMask);
1670 if (ii.hbmColor)
1671 {
1672 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
1673 BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCAND);
1674 SelectObject(hMemDC,ii.hbmColor);
1675 BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight,hMemDC,0,0,SRCINVERT);
1676 } else
1677 {
1678 GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp);
1679 BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight/2,hMemDC,0,0,SRCAND);
1680 BitBlt(hDC,X,Y,bmp.bmWidth,bmp.bmHeight/2,hMemDC,0,bmp.bmHeight/2,SRCINVERT);
1681 }
1682 SelectObject(hMemDC,oldBmp);
1683 DeleteDC(hMemDC);
1684 if (ii.hbmColor) DeleteObject(ii.hbmColor);
1685 if (ii.hbmMask) DeleteObject(ii.hbmMask);
1686 SetTextColor(hDC,oldFg);
1687 SetBkColor(hDC,oldBg);
1688
1689 return TRUE;
1690}
1691//******************************************************************************
1692//******************************************************************************
1693BOOL WIN32API DrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon,
1694 int cxWidth, int cyWidth, UINT istepIfAniCur,
1695 HBRUSH hbrFlickerFreeDraw, UINT diFlags)
1696{
1697 ICONINFO ii;
1698 HDC hMemDC;
1699 BITMAP bmp;
1700 HBITMAP oldBmp;
1701 COLORREF oldFg,oldBg;
1702 INT oldStretchMode;
1703
1704 dprintf(("USER32: DrawIconEx"));
1705
1706 //CB: istepIfAniCur, DI_COMPAT ignored
1707
1708 if (!hdc || !hIcon)
1709 {
1710 SetLastError(ERROR_INVALID_PARAMETER);
1711
1712 return FALSE;
1713 }
1714
1715 if (!GetIconInfo(hIcon,&ii)) return FALSE;
1716 if (ii.hbmColor)
1717 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
1718 else
1719 GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp);
1720
1721 /* Calculate the size of the destination image. */
1722 if (diFlags & DI_DEFAULTSIZE)
1723 {
1724 cxWidth = GetSystemMetrics(SM_CXICON);
1725 cyWidth = GetSystemMetrics(SM_CYICON);
1726 } else if (cxWidth == 0)
1727 {
1728 cxWidth = bmp.bmWidth;
1729 } else if (cyWidth == 0)
1730 {
1731 cyWidth = ii.hbmColor ? bmp.bmHeight:bmp.bmHeight/2;
1732 }
1733
1734 if (hbrFlickerFreeDraw)
1735 {
1736 HDC hBmpDC = CreateCompatibleDC(hdc);
1737 HBITMAP oldMemBmp, memBmp = CreateCompatibleBitmap(hdc,cxWidth,cyWidth);
1738 RECT rect;
1739
1740 oldMemBmp = SelectObject(hBmpDC,memBmp);
1741 rect.left = 0;
1742 rect.top = 0;
1743 rect.right = cxWidth;
1744 rect.bottom = cyWidth;
1745 FillRect(hBmpDC,&rect,hbrFlickerFreeDraw);
1746 oldFg = SetTextColor(hBmpDC,RGB(0,0,0));
1747 oldBg = SetBkColor(hBmpDC,RGB(255,255,255));
1748 hMemDC = CreateCompatibleDC(hdc);
1749 oldBmp = SelectObject(hMemDC,ii.hbmMask);
1750 oldStretchMode = SetStretchBltMode(hBmpDC,STRETCH_DELETESCANS);
1751 if (ii.hbmColor)
1752 {
1753 if (diFlags & DI_MASK)
1754 StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
1755 if (diFlags & DI_IMAGE)
1756 {
1757 SelectObject(hMemDC,ii.hbmColor);
1758 StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
1759 }
1760 } else if (diFlags & DI_MASK)
1761 {
1762 StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight/2,SRCAND);
1763 StretchBlt(hBmpDC,0,0,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight/2,bmp.bmWidth,bmp.bmHeight/2,SRCINVERT);
1764 }
1765 BitBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hBmpDC,0,0,SRCCOPY);
1766 SelectObject(hMemDC,oldBmp);
1767 DeleteDC(hMemDC);
1768 SetTextColor(hdc,oldFg);
1769 SetBkColor(hdc,oldBg);
1770 SetStretchBltMode(hBmpDC,oldStretchMode);
1771 SelectObject(hBmpDC,oldMemBmp);
1772 DeleteDC(hBmpDC);
1773 DeleteObject(memBmp);
1774 } else
1775 {
1776 oldFg = SetTextColor(hdc,RGB(0,0,0));
1777 oldBg = SetBkColor(hdc,RGB(255,255,255));
1778 hMemDC = CreateCompatibleDC(hdc);
1779 oldBmp = SelectObject(hMemDC,ii.hbmMask);
1780 oldStretchMode = SetStretchBltMode(hdc,STRETCH_DELETESCANS);
1781 if (ii.hbmColor)
1782 {
1783 if (diFlags & DI_MASK)
1784 StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
1785 if (diFlags & DI_IMAGE)
1786 {
1787 SelectObject(hMemDC,ii.hbmColor);
1788 StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCINVERT);
1789 }
1790 } else if (diFlags & DI_MASK)
1791 {
1792 StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCAND);
1793 StretchBlt(hdc,xLeft,yTop,cxWidth,cyWidth,hMemDC,0,bmp.bmHeight/2,bmp.bmWidth,bmp.bmHeight/2,SRCINVERT);
1794 }
1795 SelectObject(hMemDC,oldBmp);
1796 DeleteDC(hMemDC);
1797 SetTextColor(hdc,oldFg);
1798 SetBkColor(hdc,oldBg);
1799 SetStretchBltMode(hdc,oldStretchMode);
1800 }
1801 if (ii.hbmColor) DeleteObject(ii.hbmColor);
1802 if (ii.hbmMask) DeleteObject(ii.hbmMask);
1803
1804 return TRUE;
1805}
1806/*****************************************************************************
1807 * Name : BOOL WIN32API DrawAnimatedRects
1808 * Purpose : The DrawAnimatedRects function draws a wire-frame rectangle
1809 * and animates it to indicate the opening of an icon or the
1810 * minimizing or maximizing of a window.
1811 * Parameters: HWND hwnd handle of clipping window
1812 * int idAni type of animation
1813 * CONST RECT * lprcFrom address of rectangle coordinates (minimized)
1814 * CONST RECT * lprcTo address of rectangle coordinates (restored)
1815 * Variables :
1816 * Result : If the function succeeds, the return value is TRUE.
1817 * If the function fails, the return value is FALSE.
1818 * Remark :
1819 * Status : UNTESTED STUB
1820 *
1821 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
1822 *****************************************************************************/
1823
1824BOOL WIN32API DrawAnimatedRects(HWND hwnd,
1825 int idAni,
1826 CONST RECT *lprcFrom,
1827 CONST RECT *lprcTo)
1828{
1829 dprintf(("USER32:DrawAnimatedRects (%08xh,%u,%08xh,%08x) not implemented.\n",
1830 hwnd,
1831 idAni,
1832 lprcFrom,
1833 lprcTo));
1834
1835 return (TRUE);
1836}
1837//******************************************************************************
1838//******************************************************************************
Note: See TracBrowser for help on using the repository browser.