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

Last change on this file since 407 was 407, checked in by sandervl, 26 years ago

DrawState & DrawTextEx ported by Rene Pronk

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