source: trunk/src/user32/old/uitools.cpp@ 3830

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

Moved old user32 here

File size: 57.2 KB
Line 
1/* $Id: uitools.cpp,v 1.3 1999-09-15 23:20:39 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 /* Bertho Stultiens states above that this function exactly matches win95
466 * In win98 BF_FLAT rectangels have an inner border same color as the
467 * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
468 * I don't know I go with Bertho and just sets it for win98 until proven
469 * otherwise.
470 * Dennis Björklund, 10 June, 99
471 */
472 if(LTInnerI != -1 )
473 LTInnerI = RBInnerI = COLOR_BTNFACE;
474 }
475 else if(uFlags & BF_SOFT)
476 {
477 LTInnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
478 LTOuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
479 RBInnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
480 RBOuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
481 }
482 else
483 {
484 LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
485 LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
486 RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
487 RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
488 }
489
490 if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
491 if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
492 if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
493 if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
494
495 if(LTInnerI != -1) LTInnerPen = GetSysColorPen(LTInnerI);
496 if(LTOuterI != -1) LTOuterPen = GetSysColorPen(LTOuterI);
497 if(RBInnerI != -1) RBInnerPen = GetSysColorPen(RBInnerI);
498 if(RBOuterI != -1) RBOuterPen = GetSysColorPen(RBOuterI);
499
500 MoveToEx(hdc, 0, 0, &SavePoint);
501
502 /* Draw the outer edge */
503 SelectObject(hdc, LTOuterPen);
504 if(uFlags & BF_TOP)
505 {
506 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
507 LineTo(hdc, InnerRect.right-1, InnerRect.top);
508 }
509 if(uFlags & BF_LEFT)
510 {
511 MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
512 LineTo(hdc, InnerRect.left, InnerRect.bottom-1);
513 }
514
515 SelectObject(hdc, RBOuterPen);
516 if(uFlags & BF_BOTTOM)
517 {
518 MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
519 LineTo(hdc, InnerRect.left, InnerRect.bottom-1);
520 }
521 if(uFlags & BF_RIGHT)
522 {
523 MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
524 LineTo(hdc, InnerRect.right-1, InnerRect.top);
525 }
526
527 /* Draw the inner edge */
528 SelectObject(hdc, LTInnerPen);
529 if(uFlags & BF_TOP)
530 {
531 MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
532 LineTo(hdc, InnerRect.right-RTpenplus-1, InnerRect.top+1);
533 }
534 if(uFlags & BF_LEFT)
535 {
536 MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
537 LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus-1);
538 }
539 SelectObject(hdc, RBInnerPen);
540 if(uFlags & BF_BOTTOM)
541 {
542 MoveToEx(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
543 LineTo(hdc, InnerRect.left+LBpenplus, InnerRect.bottom-2);
544 }
545 if(uFlags & BF_RIGHT)
546 {
547 MoveToEx(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
548 LineTo(hdc, InnerRect.right-2, InnerRect.top+RTpenplus);
549 }
550
551 if( ((uFlags & BF_MIDDLE) && retval) || (uFlags & BF_ADJUST) )
552 {
553 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
554 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
555
556 if(uFlags & BF_LEFT) InnerRect.left += add;
557 if(uFlags & BF_RIGHT) InnerRect.right -= add;
558 if(uFlags & BF_TOP) InnerRect.top += add;
559 if(uFlags & BF_BOTTOM) InnerRect.bottom -= add;
560
561 if((uFlags & BF_MIDDLE) && retval)
562 {
563 FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?
564 COLOR_WINDOW : COLOR_BTNFACE));
565 }
566
567 if(uFlags & BF_ADJUST)
568 *rc = InnerRect;
569 }
570
571 /* Cleanup */
572 SelectObject(hdc, SavePen);
573 MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
574 return retval;
575}
576
577
578//**********************************************************************
579// DrawEdge (USER32.155)
580//
581BOOL WIN32API DrawEdge(HDC hdc, LPRECT rc, UINT edge, UINT flags)
582{
583
584 if (flags & BF_DIAGONAL)
585 return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
586 else
587 return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
588}
589
590/************************************************************************
591 * UITOOLS_MakeSquareRect
592 *
593 * Utility to create a square rectangle and returning the width
594 */
595static int UITOOLS_MakeSquareRect(LPRECT src, LPRECT dst)
596{
597 int Width = src->right - src->left;
598 int Height = src->bottom - src->top;
599 int SmallDiam = Width > Height ? Height : Width;
600
601 *dst = *src;
602
603 /* Make it a square box */
604 if(Width < Height) /* SmallDiam == Width */
605 {
606 dst->top += (Height-Width)/2;
607 dst->bottom = dst->top + SmallDiam;
608 }
609 else if(Width > Height) /* SmallDiam == Height */
610 {
611 dst->left += (Width-Height)/2;
612 dst->right = dst->left + SmallDiam;
613 }
614
615 return SmallDiam;
616}
617
618
619/************************************************************************
620 * UITOOLS_DFC_ButtonPush
621 *
622 * Draw a push button coming from DrawFrameControl()
623 *
624 * Does a pretty good job in emulating MS behavior. Some quirks are
625 * however there because MS uses a TrueType font (Marlett) to draw
626 * the buttons.
627 */
628static BOOL UITOOLS95_DFC_ButtonPush(HDC dc, LPRECT r, UINT uFlags)
629{
630 UINT edge;
631 RECT myr = *r;
632
633 if(uFlags & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
634 edge = EDGE_SUNKEN;
635 else
636 edge = EDGE_RAISED;
637
638 if(uFlags & DFCS_CHECKED)
639 {
640 if(uFlags & DFCS_MONO)
641 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
642 else
643 UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
644
645 if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
646 {
647 HBITMAP hbm = CreateBitmap(8, 8, 1, 1, wPattern_AA55);
648 HBRUSH hbsave;
649 HBRUSH hb = CreatePatternBrush(hbm);
650
651 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
652 hbsave = (HBRUSH)SelectObject(dc, hb);
653 PatBlt(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
654 SelectObject(dc, hbsave);
655 DeleteObject(hb);
656 DeleteObject(hbm);
657 }
658 else
659 {
660 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
661 }
662 }
663 else
664 {
665 if(uFlags & DFCS_MONO)
666 {
667 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
668 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
669 }
670 else
671 {
672 UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
673 }
674 }
675
676 /* Adjust rectangle if asked */
677 if(uFlags & DFCS_ADJUSTRECT)
678 {
679 r->left += 2;
680 r->right -= 2;
681 r->top += 2;
682 r->bottom -= 2;
683 }
684
685 return TRUE;
686}
687
688
689/************************************************************************
690 * UITOOLS_DFC_ButtonChcek
691 *
692 * Draw a check/3state button coming from DrawFrameControl()
693 *
694 * Does a pretty good job in emulating MS behavior. Some quirks are
695 * however there because MS uses a TrueType font (Marlett) to draw
696 * the buttons.
697 */
698#define DFC_CHECKPOINTSMAX 6
699
700static BOOL UITOOLS95_DFC_ButtonCheck(HDC dc, LPRECT r, UINT uFlags)
701{
702 RECT myr;
703 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
704 int BorderShrink = SmallDiam / 16;
705
706 if(BorderShrink < 1) BorderShrink = 1;
707
708 /* FIXME: The FillRect() sequence doesn't work for sizes less than */
709 /* 4 pixels in diameter. Not really a problem but it isn't M$'s */
710 /* 100% equivalent. */
711 if(uFlags & (DFCS_FLAT|DFCS_MONO))
712 {
713 FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOWFRAME));
714 myr.left += 2 * BorderShrink;
715 myr.right -= 2 * BorderShrink;
716 myr.top += 2 * BorderShrink;
717 myr.bottom -= 2 * BorderShrink;
718 }
719 else
720 {
721 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
722 myr.right -= BorderShrink;
723 myr.bottom -= BorderShrink;
724 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNSHADOW));
725 myr.left += BorderShrink;
726 myr.top += BorderShrink;
727 FillRect(dc, &myr, GetSysColorBrush(COLOR_3DLIGHT));
728 myr.right -= BorderShrink;
729 myr.bottom -= BorderShrink;
730 FillRect(dc, &myr, GetSysColorBrush(COLOR_3DDKSHADOW));
731 myr.left += BorderShrink;
732 myr.top += BorderShrink;
733 }
734
735 if(uFlags & (DFCS_INACTIVE|DFCS_PUSHED))
736 {
737 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
738 }
739 else if(uFlags & DFCS_CHECKED)
740 {
741 if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
742 {
743 HBITMAP hbm = CreateBitmap(8, 8, 1, 1, wPattern_AA55);
744 HBRUSH hbsave;
745 HBRUSH hb = CreatePatternBrush(hbm);
746
747 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
748 hbsave = (HBRUSH)SelectObject(dc, hb);
749 PatBlt(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
750 SelectObject(dc, hbsave);
751 DeleteObject(hb);
752 DeleteObject(hbm);
753 }
754 else
755 {
756 FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
757 }
758 }
759 else
760 {
761 FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOW));
762 }
763
764 if(uFlags & DFCS_CHECKED)
765 {
766 POINT CheckPoints[DFC_CHECKPOINTSMAX];
767 int i;
768 HBRUSH hbsave;
769 HPEN hpsave;
770
771 /* FIXME: This comes very close to M$'s checkmark, but not */
772 /* exactly... When small or large there is a few pixels */
773 /* shift. Not bad, but could be better :) */
774 UITOOLS_MakeSquareRect(r, &myr);
775 CheckPoints[0].x = myr.left + 253*SmallDiam/1000;
776 CheckPoints[0].y = myr.top + 345*SmallDiam/1000;
777 CheckPoints[1].x = myr.left + 409*SmallDiam/1000;
778 CheckPoints[1].y = CheckPoints[0].y + (CheckPoints[1].x-CheckPoints[0].x);
779 CheckPoints[2].x = myr.left + 690*SmallDiam/1000;
780 CheckPoints[2].y = CheckPoints[1].y - (CheckPoints[2].x-CheckPoints[1].x);
781 CheckPoints[3].x = CheckPoints[2].x;
782 CheckPoints[3].y = CheckPoints[2].y + 3*SmallDiam/16;
783 CheckPoints[4].x = CheckPoints[1].x;
784 CheckPoints[4].y = CheckPoints[1].y + 3*SmallDiam/16;
785 CheckPoints[5].x = CheckPoints[0].x;
786 CheckPoints[5].y = CheckPoints[0].y + 3*SmallDiam/16;
787
788 i = (uFlags & DFCS_INACTIVE) || (uFlags & 0xff) == DFCS_BUTTON3STATE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
789 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
790 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
791 Polygon(dc, CheckPoints, DFC_CHECKPOINTSMAX);
792 SelectObject(dc, hpsave);
793 SelectObject(dc, hbsave);
794 }
795 return TRUE;
796}
797
798
799/************************************************************************
800 * UITOOLS_DFC_ButtonRadio
801 *
802 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
803 *
804 * Does a pretty good job in emulating MS behavior. Some quirks are
805 * however there because MS uses a TrueType font (Marlett) to draw
806 * the buttons.
807 */
808static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
809{
810 RECT myr;
811 int i;
812 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
813 int BorderShrink = SmallDiam / 16;
814 HPEN hpsave;
815 HBRUSH hbsave;
816 int xe, ye;
817 int xc, yc;
818
819 if(BorderShrink < 1) BorderShrink = 1;
820
821 if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
822 {
823 FillRect(dc, r, (HBRUSH)GetStockObject(BLACK_BRUSH));
824 }
825
826 xe = myr.left;
827 ye = myr.top + SmallDiam - SmallDiam/2;
828
829 xc = myr.left + SmallDiam - SmallDiam/2;
830 yc = myr.top + SmallDiam - SmallDiam/2;
831
832 /* Define bounding box */
833 i = 14*SmallDiam/16;
834 myr.left = xc - i+i/2;
835 myr.right = xc + i/2;
836 myr.top = yc - i+i/2;
837 myr.bottom = yc + i/2;
838
839 if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
840 {
841 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
842 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
843 SelectObject(dc, hbsave);
844 }
845 else
846 {
847 if(uFlags & (DFCS_FLAT|DFCS_MONO))
848 {
849 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_WINDOWFRAME));
850 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
851 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
852 SelectObject(dc, hbsave);
853 SelectObject(dc, hpsave);
854 }
855 else
856 {
857 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
858 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
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_BTNSHADOW));
862 SelectObject(dc, GetSysColorBrush(COLOR_BTNSHADOW));
863 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
864
865 myr.left += BorderShrink;
866 myr.right -= BorderShrink;
867 myr.top += BorderShrink;
868 myr.bottom -= BorderShrink;
869
870 SelectObject(dc, GetSysColorPen(COLOR_3DLIGHT));
871 SelectObject(dc, GetSysColorBrush(COLOR_3DLIGHT));
872 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
873
874 SelectObject(dc, GetSysColorPen(COLOR_3DDKSHADOW));
875 SelectObject(dc, GetSysColorBrush(COLOR_3DDKSHADOW));
876 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
877 SelectObject(dc, hbsave);
878 SelectObject(dc, hpsave);
879 }
880
881 i = 10*SmallDiam/16;
882 myr.left = xc - i+i/2;
883 myr.right = xc + i/2;
884 myr.top = yc - i+i/2;
885 myr.bottom = yc + i/2;
886 i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
887 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
888 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
889 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
890 SelectObject(dc, hbsave);
891 SelectObject(dc, hpsave);
892 }
893
894 if(uFlags & DFCS_CHECKED)
895 {
896 i = 6*SmallDiam/16;
897 i = i < 1 ? 1 : i;
898 myr.left = xc - i+i/2;
899 myr.right = xc + i/2;
900 myr.top = yc - i+i/2;
901 myr.bottom = yc + i/2;
902
903 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
904 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
905 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
906 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
907 SelectObject(dc, hpsave);
908 SelectObject(dc, hbsave);
909 }
910
911 /* FIXME: M$ has a polygon in the center at relative points: */
912 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
913 /* 0.476, 0.525 */
914 /* 0.500, 0.500 */
915 /* 0.500, 0.499 */
916 /* when the button is unchecked. The reason for it is unknown. The */
917 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
918 /* least 3 times (it looks like a clip-region when you see it happen). */
919 /* I do not really see a reason why this should be implemented. If you */
920 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
921 /* font. */
922
923 return TRUE;
924}
925
926/***********************************************************************
927 * UITOOLS_DrawFrameButton
928 */
929static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT uState)
930{
931 switch(uState & 0xff)
932 {
933 case DFCS_BUTTONPUSH:
934 return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
935
936 case DFCS_BUTTONCHECK:
937 case DFCS_BUTTON3STATE:
938 return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
939
940 case DFCS_BUTTONRADIOIMAGE:
941 case DFCS_BUTTONRADIOMASK:
942 case DFCS_BUTTONRADIO:
943 return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
944
945// default:
946// WARN("Invalid button state=0x%04x\n", uState);
947 }
948
949 return FALSE;
950}
951
952/***********************************************************************
953 * UITOOLS_DrawFrameCaption
954 *
955 * Draw caption buttons (win95), coming from DrawFrameControl()
956 */
957
958static BOOL UITOOLS95_DrawFrameCaption(HDC dc, LPRECT r, UINT uFlags)
959{
960 POINT Line1[10];
961 POINT Line2[10];
962 int Line1N;
963 int Line2N;
964 RECT myr;
965 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr)-2;
966 int i;
967 HBRUSH hbsave;
968 HPEN hpsave;
969 HFONT hfsave, hf;
970 int xc = (myr.left+myr.right)/2;
971 int yc = (myr.top+myr.bottom)/2;
972 int edge, move;
973 char str[2] = "?";
974 UINT alignsave;
975 int bksave;
976 COLORREF clrsave;
977 SIZE size;
978
979 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
980
981 switch(uFlags & 0xff)
982 {
983 case DFCS_CAPTIONCLOSE:
984 edge = 328*SmallDiam/1000;
985 move = 95*SmallDiam/1000;
986 Line1[0].x = Line2[0].x = Line1[1].x = Line2[1].x = xc - edge;
987 Line1[2].y = Line2[5].y = Line1[1].y = Line2[4].y = yc - edge;
988 Line1[3].x = Line2[3].x = Line1[4].x = Line2[4].x = xc + edge;
989 Line1[5].y = Line2[2].y = Line1[4].y = Line2[1].y = yc + edge;
990 Line1[2].x = Line2[2].x = Line1[1].x + move;
991 Line1[0].y = Line2[3].y = Line1[1].y + move;
992 Line1[5].x = Line2[5].x = Line1[4].x - move;
993 Line1[3].y = Line2[0].y = Line1[4].y - move;
994 Line1N = 6;
995 Line2N = 6;
996 break;
997
998 case DFCS_CAPTIONHELP:
999 /* This one breaks the flow */
1000 /* FIXME: We need the Marlett font in order to get this right. */
1001
1002 hf = CreateFontA(-SmallDiam, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
1003 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
1004 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "System");
1005 alignsave = SetTextAlign(dc, TA_TOP|TA_LEFT);
1006 bksave = SetBkMode(dc, TRANSPARENT);
1007 clrsave = GetTextColor(dc);
1008 hfsave = (HFONT)SelectObject(dc, hf);
1009 GetTextExtentPoint32A(dc, str, 1, &size);
1010
1011 if(uFlags & DFCS_INACTIVE)
1012 {
1013 SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
1014 TextOutA(dc, xc-size.cx/2+1, yc-size.cy/2+1, str, 1);
1015 }
1016 SetTextColor(dc, GetSysColor(uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
1017 TextOutA(dc, xc-size.cx/2, yc-size.cy/2, str, 1);
1018
1019 SelectObject(dc, hfsave);
1020 SetTextColor(dc, clrsave);
1021 SetBkMode(dc, bksave);
1022 SetTextAlign(dc, alignsave);
1023 DeleteObject(hf);
1024 return TRUE;
1025
1026 case DFCS_CAPTIONMIN:
1027 Line1[0].x = Line1[3].x = myr.left + 96*SmallDiam/750+2;
1028 Line1[1].x = Line1[2].x = Line1[0].x + 372*SmallDiam/750;
1029 Line1[0].y = Line1[1].y = myr.top + 563*SmallDiam/750+1;
1030 Line1[2].y = Line1[3].y = Line1[0].y + 92*SmallDiam/750;
1031 Line1N = 4;
1032 Line2N = 0;
1033 break;
1034
1035 case DFCS_CAPTIONMAX:
1036 edge = 47*SmallDiam/750;
1037 Line1[0].x = Line1[5].x = myr.left + 57*SmallDiam/750+3;
1038 Line1[0].y = Line1[1].y = myr.top + 143*SmallDiam/750+1;
1039 Line1[1].x = Line1[2].x = Line1[0].x + 562*SmallDiam/750;
1040 Line1[5].y = Line1[4].y = Line1[0].y + 93*SmallDiam/750;
1041 Line1[2].y = Line1[3].y = Line1[0].y + 513*SmallDiam/750;
1042 Line1[3].x = Line1[4].x = Line1[1].x - edge;
1043
1044 Line2[0].x = Line2[5].x = Line1[0].x;
1045 Line2[3].x = Line2[4].x = Line1[1].x;
1046 Line2[1].x = Line2[2].x = Line1[0].x + edge;
1047 Line2[0].y = Line2[1].y = Line1[0].y;
1048 Line2[4].y = Line2[5].y = Line1[2].y;
1049 Line2[2].y = Line2[3].y = Line1[2].y - edge;
1050 Line1N = 6;
1051 Line2N = 6;
1052 break;
1053
1054 case DFCS_CAPTIONRESTORE:
1055 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1056 edge = 47*SmallDiam/750;
1057 move = 420*SmallDiam/750;
1058 Line1[0].x = Line1[9].x = myr.left + 198*SmallDiam/750+2;
1059 Line1[0].y = Line1[1].y = myr.top + 169*SmallDiam/750+1;
1060 Line1[6].y = Line1[7].y = Line1[0].y + 93*SmallDiam/750;
1061 Line1[7].x = Line1[8].x = Line1[0].x + edge;
1062 Line1[1].x = Line1[2].x = Line1[0].x + move;
1063 Line1[5].x = Line1[6].x = Line1[1].x - edge;
1064 Line1[9].y = Line1[8].y = Line1[0].y + 187*SmallDiam/750;
1065 Line1[2].y = Line1[3].y = Line1[0].y + 327*SmallDiam/750;
1066 Line1[4].y = Line1[5].y = Line1[2].y - edge;
1067 Line1[3].x = Line1[4].x = Line1[2].x - 140*SmallDiam/750;
1068
1069 Line2[1].x = Line2[2].x = Line1[3].x;
1070 Line2[7].x = Line2[8].x = Line2[1].x - edge;
1071 Line2[0].x = Line2[9].x = Line2[3].x = Line2[4].x = Line2[1].x - move;
1072 Line2[5].x = Line2[6].x = Line2[0].x + edge;
1073 Line2[0].y = Line2[1].y = Line1[9].y;
1074 Line2[4].y = Line2[5].y = Line2[8].y = Line2[9].y = Line2[0].y + 93*SmallDiam/750;
1075 Line2[2].y = Line2[3].y = Line2[0].y + 327*SmallDiam/750;
1076 Line2[6].y = Line2[7].y = Line2[2].y - edge;
1077 Line1N = 10;
1078 Line2N = 10;
1079 break;
1080
1081 default:
1082// WARN("Invalid caption; flags=0x%04x\n", uFlags);
1083 return FALSE;
1084 }
1085
1086 /* Here the drawing takes place */
1087 if(uFlags & DFCS_INACTIVE)
1088 {
1089 /* If we have an inactive button, then you see a shadow */
1090 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
1091 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
1092 Polygon(dc, Line1, Line1N);
1093 if(Line2N > 0)
1094 Polygon(dc, Line2, Line2N);
1095 SelectObject(dc, hpsave);
1096 SelectObject(dc, hbsave);
1097 }
1098
1099 /* Correct for the shadow shift */
1100 for(i = 0; i < Line1N; i++)
1101 {
1102 Line1[i].x--;
1103 Line1[i].y--;
1104 }
1105 for(i = 0; i < Line2N; i++)
1106 {
1107 Line2[i].x--;
1108 Line2[i].y--;
1109 }
1110
1111 /* Make the final picture */
1112 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1113 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
1114 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
1115
1116 Polygon(dc, Line1, Line1N);
1117 if(Line2N > 0)
1118 Polygon(dc, Line2, Line2N);
1119 SelectObject(dc, hpsave);
1120 SelectObject(dc, hbsave);
1121
1122 return TRUE;
1123}
1124
1125
1126/************************************************************************
1127 * UITOOLS_DrawFrameScroll
1128 *
1129 * Draw a scroll-bar control coming from DrawFrameControl()
1130 */
1131static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags)
1132{
1133 POINT Line[4];
1134 RECT myr;
1135 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2;
1136 int i;
1137 HBRUSH hbsave, hb, hb2;
1138 HPEN hpsave, hp, hp2;
1139 int tri = 290*SmallDiam/1000 -1;
1140 int d46, d93;
1141
1142 switch(uFlags & 0xff)
1143 {
1144 case DFCS_SCROLLCOMBOBOX:
1145 case DFCS_SCROLLDOWN:
1146 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1147 Line[2].y = myr.top + 687*SmallDiam/1000 + 1;
1148 Line[0].x = Line[2].x - tri;
1149 Line[1].x = Line[2].x + tri;
1150 Line[0].y = Line[1].y = Line[2].y - tri;
1151 break;
1152
1153 case DFCS_SCROLLUP:
1154 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1155 Line[2].y = myr.bottom - 687*SmallDiam/1000 + 1;
1156 Line[0].x = Line[2].x - tri;
1157 Line[1].x = Line[2].x + tri;
1158 Line[0].y = Line[1].y = Line[2].y + tri;
1159 break;
1160
1161 case DFCS_SCROLLLEFT:
1162 Line[2].x = myr.right - 687*SmallDiam/1000 + 1;
1163 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1164 Line[0].y = Line[2].y - tri;
1165 Line[1].y = Line[2].y + tri;
1166 Line[0].x = Line[1].x = Line[2].x + tri;
1167 break;
1168
1169 case DFCS_SCROLLRIGHT:
1170 Line[2].x = myr.left + 687*SmallDiam/1000 + 1;
1171 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1172 Line[0].y = Line[2].y - tri;
1173 Line[1].y = Line[2].y + tri;
1174 Line[0].x = Line[1].x = Line[2].x - tri;
1175 break;
1176
1177 case DFCS_SCROLLSIZEGRIP:
1178 /* This one breaks the flow... */
1179 UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
1180 hpsave = (HPEN)SelectObject(dc, GetStockObject(NULL_PEN));
1181 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH));
1182 if(uFlags & (DFCS_MONO|DFCS_FLAT))
1183 {
1184 hp = hp2 = GetSysColorPen(COLOR_WINDOWFRAME);
1185 hb = hb2 = GetSysColorBrush(COLOR_WINDOWFRAME);
1186 }
1187 else
1188 {
1189 hp = GetSysColorPen(COLOR_BTNHIGHLIGHT);
1190 hp2 = GetSysColorPen(COLOR_BTNSHADOW);
1191 hb = GetSysColorBrush(COLOR_BTNHIGHLIGHT);
1192 hb2 = GetSysColorBrush(COLOR_BTNSHADOW);
1193 }
1194 Line[0].x = Line[1].x = r->right-1;
1195 Line[2].y = Line[3].y = r->bottom-1;
1196 d46 = 46*SmallDiam/750;
1197 d93 = 93*SmallDiam/750;
1198
1199 i = 586*SmallDiam/750;
1200 Line[0].y = r->bottom - i - 1;
1201 Line[3].x = r->right - i - 1;
1202 Line[1].y = Line[0].y + d46;
1203 Line[2].x = Line[3].x + d46;
1204 SelectObject(dc, hb);
1205 SelectObject(dc, hp);
1206 Polygon(dc, Line, 4);
1207
1208 Line[1].y++; Line[2].x++;
1209 Line[0].y = Line[1].y + d93;
1210 Line[3].x = Line[2].x + d93;
1211 SelectObject(dc, hb2);
1212 SelectObject(dc, hp2);
1213 Polygon(dc, Line, 4);
1214
1215 i = 398*SmallDiam/750;
1216 Line[0].y = r->bottom - i - 1;
1217 Line[3].x = r->right - i - 1;
1218 Line[1].y = Line[0].y + d46;
1219 Line[2].x = Line[3].x + d46;
1220 SelectObject(dc, hb);
1221 SelectObject(dc, hp);
1222 Polygon(dc, Line, 4);
1223
1224 Line[1].y++; Line[2].x++;
1225 Line[0].y = Line[1].y + d93;
1226 Line[3].x = Line[2].x + d93;
1227 SelectObject(dc, hb2);
1228 SelectObject(dc, hp2);
1229 Polygon(dc, Line, 4);
1230
1231 i = 210*SmallDiam/750;
1232 Line[0].y = r->bottom - i - 1;
1233 Line[3].x = r->right - i - 1;
1234 Line[1].y = Line[0].y + d46;
1235 Line[2].x = Line[3].x + d46;
1236 SelectObject(dc, hb);
1237 SelectObject(dc, hp);
1238 Polygon(dc, Line, 4);
1239
1240 Line[1].y++; Line[2].x++;
1241 Line[0].y = Line[1].y + d93;
1242 Line[3].x = Line[2].x + d93;
1243 SelectObject(dc, hb2);
1244 SelectObject(dc, hp2);
1245 Polygon(dc, Line, 4);
1246
1247 SelectObject(dc, hpsave);
1248 SelectObject(dc, hbsave);
1249 return TRUE;
1250
1251 default:
1252// WARN("Invalid scroll; flags=0x%04x\n", uFlags);
1253 return FALSE;
1254 }
1255
1256 /* Here do the real scroll-bar controls end up */
1257 if( ! (uFlags & (0xff00 & ~DFCS_ADJUSTRECT)) )
1258 /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
1259 /* want for the normal scroll-arrow button. */
1260 UITOOLS95_DrawRectEdge( dc, r, EDGE_RAISED, (uFlags&DFCS_ADJUSTRECT) | BF_MIDDLE | BF_RECT);
1261 else
1262 UITOOLS95_DFC_ButtonPush(dc, r, (uFlags & 0xff00) );
1263
1264 if(uFlags & DFCS_INACTIVE)
1265 {
1266 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
1267 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
1268 Polygon(dc, Line, 3);
1269 SelectObject(dc, hpsave);
1270 SelectObject(dc, hbsave);
1271 }
1272
1273 if( (uFlags & DFCS_INACTIVE) || !(uFlags & DFCS_PUSHED) )
1274 for(i = 0; i < 3; i++)
1275 {
1276 Line[i].x--;
1277 Line[i].y--;
1278 }
1279
1280 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1281 hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
1282 hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
1283 Polygon(dc, Line, 3);
1284 SelectObject(dc, hpsave);
1285 SelectObject(dc, hbsave);
1286
1287 return TRUE;
1288}
1289
1290/************************************************************************
1291 * UITOOLS_DrawFrameMenu
1292 *
1293 * Draw a menu control coming from DrawFrameControl()
1294 */
1295static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
1296{
1297 POINT Points[6];
1298 RECT myr;
1299 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
1300 int i;
1301 HBRUSH hbsave;
1302 HPEN hpsave;
1303 int xe, ye;
1304 int xc, yc;
1305 BOOL retval = TRUE;
1306
1307 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1308 /* use anything else. I think I tried all sys-colors to change things */
1309 /* without luck. It seems as if this behavior is inherited from the */
1310 /* win31 DFC() implementation... (you remember, B/W menus). */
1311
1312 FillRect(dc, r, (HBRUSH)GetStockObject(WHITE_BRUSH));
1313
1314 hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
1315 hpsave = (HPEN)SelectObject(dc, GetStockObject(BLACK_PEN));
1316
1317 switch(uFlags & 0xff)
1318 {
1319 case DFCS_MENUARROW:
1320 i = 187*SmallDiam/750;
1321 Points[2].x = myr.left + 468*SmallDiam/750;
1322 Points[2].y = myr.top + 352*SmallDiam/750+1;
1323 Points[0].y = Points[2].y - i;
1324 Points[1].y = Points[2].y + i;
1325 Points[0].x = Points[1].x = Points[2].x - i;
1326 Polygon(dc, Points, 3);
1327 break;
1328
1329 case DFCS_MENUBULLET:
1330 xe = myr.left;
1331 ye = myr.top + SmallDiam - SmallDiam/2;
1332 xc = myr.left + SmallDiam - SmallDiam/2;
1333 yc = myr.top + SmallDiam - SmallDiam/2;
1334 i = 234*SmallDiam/750;
1335 i = i < 1 ? 1 : i;
1336 myr.left = xc - i+i/2;
1337 myr.right = xc + i/2;
1338 myr.top = yc - i+i/2;
1339 myr.bottom = yc + i/2;
1340 Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
1341 break;
1342
1343 case DFCS_MENUCHECK:
1344 Points[0].x = myr.left + 253*SmallDiam/1000;
1345 Points[0].y = myr.top + 445*SmallDiam/1000;
1346 Points[1].x = myr.left + 409*SmallDiam/1000;
1347 Points[1].y = Points[0].y + (Points[1].x-Points[0].x);
1348 Points[2].x = myr.left + 690*SmallDiam/1000;
1349 Points[2].y = Points[1].y - (Points[2].x-Points[1].x);
1350 Points[3].x = Points[2].x;
1351 Points[3].y = Points[2].y + 3*SmallDiam/16;
1352 Points[4].x = Points[1].x;
1353 Points[4].y = Points[1].y + 3*SmallDiam/16;
1354 Points[5].x = Points[0].x;
1355 Points[5].y = Points[0].y + 3*SmallDiam/16;
1356 Polygon(dc, Points, 6);
1357 break;
1358
1359 default:
1360// WARN("Invalid menu; flags=0x%04x\n", uFlags);
1361 retval = FALSE;
1362 break;
1363 }
1364
1365 SelectObject(dc, hpsave);
1366 SelectObject(dc, hbsave);
1367 return retval;
1368}
1369
1370/**********************************************************************
1371 * DrawFrameControl (USER32.158)
1372 */
1373BOOL WIN32API DrawFrameControl(HDC hdc, LPRECT rc, UINT uType,
1374 UINT uState )
1375{
1376 /* Win95 doesn't support drawing in other mapping modes */
1377 if(GetMapMode(hdc) != MM_TEXT)
1378 return FALSE;
1379
1380 switch(uType)
1381 {
1382 case DFC_BUTTON:
1383 return UITOOLS95_DrawFrameButton(hdc, rc, uState);
1384 case DFC_CAPTION:
1385 return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
1386 case DFC_MENU:
1387 return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
1388 case DFC_SCROLL:
1389 return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
1390// default:
1391// WARN("(%x,%p,%d,%x), bad type!\n",
1392// hdc,rc,uType,uState );
1393 }
1394 return FALSE;
1395}
1396
1397
1398/*****************************************************************************
1399 * Name : int WIN32API DrawTextExA
1400 * Purpose : The DrawTextEx function draw the text in the rectangle
1401 * Parameters:
1402 * Variables :
1403 * Result : If the function succeeds, the return value is the height of the
1404 * text, otherwise zero.
1405 * Remark : TODO: Returned number of characters is always the entire string
1406 * since there is no way to know the real answer this way.
1407 * Status : PARTIALLY IMPLEMENTED AND TESTED
1408 *
1409 * Author : Rene Pronk [Thu, 1999/07/29 15:03]
1410 *****************************************************************************/
1411
1412int WIN32API DrawTextExA (HDC hdc, LPTSTR lpchText, int cchText, LPRECT lprc,
1413 UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams) {
1414
1415 int result;
1416
1417 dprintf(("USER32:DrawTextExA (%08xh,%s,%08xh,%08xh,%08xh,%08xh).\n",
1418 hdc, lpchText, cchText, lprc, dwDTFormat, lpDTParams));
1419
1420 if (lpDTParams != NULL) {
1421 // 'create' margins
1422 lprc->left += lpDTParams->iLeftMargin;
1423 lprc->right -= lpDTParams->iRightMargin;
1424
1425 // just assume all the text has been drawn
1426 if (cchText != -1)
1427 lpDTParams->uiLengthDrawn = cchText;
1428 else {
1429 // determine string length
1430 int size = 0;
1431 while ((BYTE) *(lpchText + size) != 0)
1432 size ++;
1433 lpDTParams->uiLengthDrawn = size;
1434 }
1435 }
1436
1437 result = DrawTextA (hdc, lpchText, cchText, lprc, dwDTFormat);
1438
1439 if (lpDTParams != NULL) {
1440 // don't forget to restore the margins
1441 lprc->left -= lpDTParams->iLeftMargin;
1442 lprc->right += lpDTParams->iRightMargin;
1443 }
1444
1445 return result;
1446}
1447
1448
1449
1450/*****************************************************************************
1451 * Name : int WIN32API DrawTextExW
1452 * Purpose : The DrawTextEx function draw the text in the rectangle
1453 * Parameters:
1454 * Variables :
1455 * Result : If the function succeeds, the return value is the height of the
1456 * text, otherwise zero.
1457 * Remark : TODO: Returned number of characters is always the entire string
1458 * since there is no way to know the real answer this way.
1459 * Status : PARTIALLY IMPLEMENTED AND TESTED
1460 *
1461 * Author : Rene Pronk [Thu, 1999/07/29 15:03]
1462 *****************************************************************************/
1463
1464int WIN32API DrawTextExW (HDC hdc, LPTSTR lpchText, int cchText, LPRECT lprc,
1465 UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams) {
1466
1467 char *astring = UnicodeToAsciiString((LPWSTR)lpchText);
1468 int rc;
1469
1470 dprintf(("USER32:DrawTextExW (%08xh,%s,%08xh,%08xh,%08xh,%08xh).\n",
1471 hdc, astring, cchText, lprc, dwDTFormat, lpDTParams));
1472
1473 rc = DrawTextExA (hdc, astring, cchText, lprc, dwDTFormat, lpDTParams);
1474 FreeAsciiString(astring);
1475 return(rc);
1476}
1477
1478
1479/******************************************************************************
1480 *
1481 * This function is used by Paint_DrawState which is inturn used by both
1482 * DrawStateA and DrawStateW. The code is directly borrowed from Wine.
1483 *
1484 ******************************************************************************/
1485
1486static BOOL Paint_DrawStateJam(HDC hdc, UINT opcode,
1487 DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
1488 LPRECT rc, UINT dtflags, BOOL unicode)
1489{
1490 HDC memdc;
1491 HBITMAP hbmsave;
1492 BOOL retval;
1493 INT cx = rc->right - rc->left;
1494 INT cy = rc->bottom - rc->top;
1495
1496 switch(opcode)
1497 {
1498 case DST_TEXT:
1499 case DST_PREFIXTEXT:
1500 if(unicode)
1501 return DrawTextW(hdc, (LPWSTR)lp, (INT)wp, rc, dtflags);
1502 else
1503 return DrawTextA(hdc, (LPSTR)lp, (INT)wp, rc, dtflags);
1504
1505 case DST_ICON:
1506 return DrawIcon(hdc, rc->left, rc->top, (HICON)lp);
1507
1508 case DST_BITMAP:
1509 memdc = CreateCompatibleDC(hdc);
1510 if(!memdc) return FALSE;
1511 hbmsave = (HBITMAP)SelectObject(memdc, (HBITMAP)lp);
1512 if(!hbmsave)
1513 {
1514 DeleteDC(memdc);
1515 return FALSE;
1516 }
1517 retval = BitBlt(hdc, rc->left, rc->top, cx, cy, memdc, 0, 0, SRCCOPY);
1518 SelectObject(memdc, hbmsave);
1519 DeleteDC(memdc);
1520 return retval;
1521
1522 case DST_COMPLEX:
1523 if(func)
1524 return func(hdc, lp, wp, cx, cy);
1525 else
1526 return FALSE;
1527 }
1528 return FALSE;
1529}
1530
1531
1532/******************************************************************************
1533 *
1534 * This function is used by both DrawStateA and DrawStateW. The code is directly
1535 * borrowed from Wine
1536 *
1537 ******************************************************************************/
1538BOOL Paint_DrawState (HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
1539 INT x, INT y, INT cx, INT cy, UINT flags, BOOL unicode)
1540{
1541 HBITMAP hbm, hbmsave;
1542 HFONT hfsave;
1543 HBRUSH hbsave;
1544 HDC memdc;
1545 RECT rc;
1546 UINT dtflags = DT_NOCLIP;
1547 COLORREF fg, bg;
1548 UINT opcode = flags & 0xf;
1549 INT len = wp;
1550 BOOL retval, tmp;
1551
1552 if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len) /* The string is '\0' terminated */
1553 {
1554 if(unicode)
1555 len = lstrlenW((LPWSTR)lp);
1556 else
1557 len = lstrlenA((LPSTR)lp);
1558 }
1559
1560 /* Find out what size the image has if not given by caller */
1561 if(!cx || !cy)
1562 {
1563 SIZE s;
1564 BITMAP bmp;
1565
1566 switch(opcode)
1567 {
1568 case DST_TEXT:
1569 case DST_PREFIXTEXT:
1570 if(unicode)
1571 retval = GetTextExtentPoint32W(hdc, (LPWSTR)lp, len, &s);
1572 else
1573 retval = GetTextExtentPoint32A(hdc, (LPSTR)lp, len, &s);
1574 if(!retval) return FALSE;
1575 break;
1576
1577 case DST_ICON:
1578 /* Just assume the icon has the size given by GetSystemMetrics. This should be
1579 valid since both CreateIcon and LoadIcon can't create icons with different
1580 sizes. I wouldn't how else to get the size of the icon. RP
1581 */
1582 s.cx = GetSystemMetrics (SM_CXICON);
1583 s.cy = GetSystemMetrics (SM_CYICON);
1584 break;
1585
1586 case DST_BITMAP:
1587 retval = GetObjectA ((HBITMAP) lp, sizeof (BITMAP), &bmp);
1588 if(retval == 0) return FALSE;
1589 s.cx = bmp.bmWidth;
1590 s.cy = bmp.bmHeight;
1591 break;
1592
1593 case DST_COMPLEX: /* cx and cy must be set in this mode */
1594 return FALSE;
1595 }
1596
1597 if(!cx) cx = s.cx;
1598 if(!cy) cy = s.cy;
1599 }
1600
1601 rc.left = x;
1602 rc.top = y;
1603 rc.right = x + cx;
1604 rc.bottom = y + cy;
1605
1606 if(flags & DSS_RIGHT) /* This one is not documented in the win32.hlp file */
1607 dtflags |= DT_RIGHT;
1608 if(opcode == DST_TEXT)
1609 dtflags |= DT_NOPREFIX;
1610
1611 /* For DSS_NORMAL we just jam in the image and return */
1612 if((flags & 0x7ff0) == DSS_NORMAL)
1613 {
1614 return Paint_DrawStateJam(hdc, opcode, func, lp, len, &rc, dtflags, unicode);
1615 }
1616
1617 /* For all other states we need to convert the image to B/W in a local bitmap */
1618 /* before it is displayed */
1619 fg = SetTextColor(hdc, RGB(0, 0, 0));
1620 bg = SetBkColor(hdc, RGB(255, 255, 255));
1621 hbm = (HBITMAP)NULL; hbmsave = (HBITMAP)NULL;
1622 memdc = (HDC)NULL; hbsave = (HBRUSH)NULL;
1623 retval = FALSE; /* assume failure */
1624
1625 /* From here on we must use "goto cleanup" when something goes wrong */
1626 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
1627 if(!hbm) goto cleanup;
1628 memdc = CreateCompatibleDC(hdc);
1629 if(!memdc) goto cleanup;
1630 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
1631 if(!hbmsave) goto cleanup;
1632 rc.left = rc.top = 0;
1633 rc.right = cx;
1634 rc.bottom = cy;
1635 if(!FillRect(memdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH))) goto cleanup;
1636 SetBkColor(memdc, RGB(255, 255, 255));
1637 SetTextColor(memdc, RGB(0, 0, 0));
1638 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
1639 if(!hfsave && (opcode == DST_TEXT || opcode == DST_PREFIXTEXT)) goto cleanup;
1640 tmp = Paint_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode);
1641 if(hfsave) SelectObject(memdc, hfsave);
1642 if(!tmp) goto cleanup;
1643
1644 /* These states cause the image to be dithered */
1645 if(flags & (DSS_UNION|DSS_DISABLED))
1646 {
1647 WORD wPattern55AA[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
1648 HBITMAP hPattern55AABitmap = CreateBitmap( 8, 8, 1, 1, wPattern55AA );
1649 HBRUSH hPattern55AABrush = CreatePatternBrush(hPattern55AABitmap);
1650
1651 hbsave = (HBRUSH)SelectObject(memdc, hPattern55AABrush);
1652 if(!hbsave) goto cleanup;
1653 tmp = PatBlt(memdc, 0, 0, cx, cy, 0x00FA0089);
1654 if(hbsave) SelectObject(memdc, hbsave);
1655 if(!tmp) goto cleanup;
1656 }
1657
1658 hbsave = (HBRUSH)SelectObject(hdc, hbr ? hbr : GetStockObject(WHITE_BRUSH));
1659 if(!hbsave) goto cleanup;
1660
1661 if(!BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00B8074A)) goto cleanup;
1662
1663 /* DSS_DEFAULT makes the image boldface */
1664 if(flags & DSS_DEFAULT)
1665 {
1666 if(!BitBlt(hdc, x+1, y, cx, cy, memdc, 0, 0, 0x00B8074A)) goto cleanup;
1667 }
1668
1669 retval = TRUE; /* We succeeded */
1670
1671cleanup:
1672 SetTextColor(hdc, fg);
1673 SetBkColor(hdc, bg);
1674
1675 if(hbsave) SelectObject(hdc, hbsave);
1676 if(hbmsave) SelectObject(memdc, hbmsave);
1677 if(hbm) DeleteObject(hbm);
1678 if(memdc) DeleteDC(memdc);
1679
1680 return retval;
1681}
1682
1683
1684
1685/*****************************************************************************
1686 * Name : BOOL WIN32API DrawStateA
1687 * Purpose : Draws a bitmap, icon, text or complex object in one of the following
1688 * states: normal, disabled, union or mono
1689 * Parameters:
1690 * Variables :
1691 * Result : If the function succeeds, the return value is a handle of the
1692 * window station associated with the calling process.
1693 * If the function fails, the return value is NULL. This can occur
1694 * if the calling process is not an application written for Windows
1695 * NT. To get extended error information, call GetLastError.
1696 * Remark : Disabled doesn't look like the Windows implementation, but it does
1697 * look disabled.
1698 * Status : PARTIALLY IMPLEMENTED
1699 *
1700 * Author : Rene Pronk [Sun, 1999/07/25 21:27]
1701 *****************************************************************************/
1702
1703BOOL WIN32API DrawStateA(HDC hdc, HBRUSH hbc, DRAWSTATEPROC lpOutputFunc, LPARAM lData,
1704 WPARAM wData, int x, int y, int cx, int cy, UINT fuFlags)
1705{
1706 dprintf(("USER32:DrawStateA (%08xh,%08xh,%08xh,%08xh,%08xh,%d,%d,%d,%d,%08x).\n",
1707 hdc, hbc, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags));
1708
1709 return Paint_DrawState (hdc, hbc, lpOutputFunc, lData, wData, x, y ,cx, cy, fuFlags, FALSE);
1710}
1711
1712
1713
1714/*****************************************************************************
1715 * Name : BOOL WIN32API DrawStateW
1716 * Purpose : Draws a bitmap, icon, text or complex object in one of the following
1717 * states: normal, disabled, union or mono
1718 * Parameters:
1719 * Variables :
1720 * Result : If the function succeeds, the return value is a handle of the
1721 * window station associated with the calling process.
1722 * If the function fails, the return value is NULL. This can occur
1723 * if the calling process is not an application written for Windows
1724 * NT. To get extended error information, call GetLastError.
1725 * Remark : Disabled doesn't look like the Windows implementation, but it does
1726 * look disabled.
1727 * Status : PARTIALLY IMPLEMENTED
1728 *
1729 * Author : Rene Pronk [Sun, 1999/07/25 21:27]
1730 *****************************************************************************/
1731
1732BOOL WIN32API DrawStateW(HDC hdc, HBRUSH hbc, DRAWSTATEPROC lpOutputFunc, LPARAM lData,
1733 WPARAM wData, int x, int y, int cx, int cy, UINT fuFlags)
1734{
1735 dprintf(("USER32:DrawStateW (%08xh,%08xh,%08xh,%08xh,%08xh,%d,%d,%d,%d,%08x).\n",
1736 hdc, hbc, lpOutputFunc, lData, wData, x, y, cx, cy, fuFlags));
1737
1738 return Paint_DrawState (hdc, hbc, lpOutputFunc, lData, wData, x, y ,cx, cy, fuFlags, TRUE);
1739}
1740
Note: See TracBrowser for help on using the repository browser.