CB_GETTEXT: Use lpBuffer instead of lpText for LB_GETTEXT32, handle 0
[wine/multimedia.git] / controls / uitools.c
blob0169b000c07509934cca877f243b0a4dd3bffe56
1 /*
2 * User Interface Functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1997 Bertho A. Stultiens
6 */
8 #include "windows.h"
9 #include "debug.h"
11 static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
12 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
14 /* These tables are used in:
15 * UITOOLS_DrawDiagEdge()
16 * UITOOLS_DrawRectEdge()
18 static const char LTInnerNormal[] = {
19 -1, -1, -1, -1,
20 -1, COLOR_BTNHIGHLIGHT, COLOR_BTNHIGHLIGHT, -1,
21 -1, COLOR_3DDKSHADOW, COLOR_3DDKSHADOW, -1,
22 -1, -1, -1, -1
25 static const char LTOuterNormal[] = {
26 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
27 COLOR_BTNHIGHLIGHT, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
28 COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
29 -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1
32 static const char RBInnerNormal[] = {
33 -1, -1, -1, -1,
34 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
35 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
36 -1, -1, -1, -1
39 static const char RBOuterNormal[] = {
40 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
41 COLOR_BTNSHADOW, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
42 COLOR_3DLIGHT, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
43 -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1
46 static const char LTInnerSoft[] = {
47 -1, -1, -1, -1,
48 -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
49 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
50 -1, -1, -1, -1
53 static const char LTOuterSoft[] = {
54 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
55 COLOR_3DLIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
56 COLOR_BTNSHADOW, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
57 -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1
60 #define RBInnerSoft RBInnerNormal /* These are the same */
61 #define RBOuterSoft RBOuterNormal
63 static const char LTRBOuterMono[] = {
64 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
65 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
66 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
67 COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
70 static const char LTRBInnerMono[] = {
71 -1, -1, -1, -1,
72 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
73 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
74 -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
77 static const char LTRBOuterFlat[] = {
78 -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
79 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
80 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
81 COLOR_WINDOWFRAME, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
84 static const char LTRBInnerFlat[] = {
85 -1, -1, -1, -1,
86 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
87 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
88 -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
91 /***********************************************************************
92 * UITOOLS_DrawDiagEdge
94 * Same as DrawEdge invoked with BF_DIAGONAL
96 * 03-Dec-1997: Changed by Bertho Stultiens
98 * See also comments with UITOOLS_DrawRectEdge()
100 static BOOL32 UITOOLS95_DrawDiagEdge(HDC32 hdc, LPRECT32 rc,
101 UINT32 uType, UINT32 uFlags)
103 POINT32 Points[4];
104 char InnerI, OuterI;
105 HPEN32 InnerPen, OuterPen;
106 POINT32 SavePoint;
107 HPEN32 SavePen;
108 int spx, spy;
109 int epx, epy;
110 int Width = rc->right - rc->left;
111 int Height= rc->bottom - rc->top;
112 int SmallDiam = Width > Height ? Height : Width;
113 BOOL32 retval = !( ((uType & BDR_INNER) == BDR_INNER
114 || (uType & BDR_OUTER) == BDR_OUTER)
115 && !(uFlags & (BF_FLAT|BF_MONO)) );
116 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
117 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
119 /* Init some vars */
120 OuterPen = InnerPen = (HPEN32)GetStockObject32(NULL_PEN);
121 SavePen = (HPEN32)SelectObject32(hdc, InnerPen);
122 spx = spy = epx = epy = 0; /* Satisfy the compiler... */
124 /* Determine the colors of the edges */
125 if(uFlags & BF_MONO)
127 InnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
128 OuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
130 else if(uFlags & BF_FLAT)
132 InnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
133 OuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
135 else if(uFlags & BF_SOFT)
137 if(uFlags & BF_BOTTOM)
139 InnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
140 OuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
142 else
144 InnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
145 OuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
148 else
150 if(uFlags & BF_BOTTOM)
152 InnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
153 OuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
155 else
157 InnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
158 OuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
162 if(InnerI != -1) InnerPen = GetSysColorPen32(InnerI);
163 if(OuterI != -1) OuterPen = GetSysColorPen32(OuterI);
165 MoveToEx32(hdc, 0, 0, &SavePoint);
167 /* Don't ask me why, but this is what is visible... */
168 /* This must be possible to do much simpler, but I fail to */
169 /* see the logic in the MS implementation (sigh...). */
170 /* So, this might look a bit brute force here (and it is), but */
171 /* it gets the job done;) */
173 switch(uFlags & BF_RECT)
175 case 0:
176 case BF_LEFT:
177 case BF_BOTTOM:
178 case BF_BOTTOMLEFT:
179 /* Left bottom endpoint */
180 epx = rc->left-1;
181 spx = epx + SmallDiam;
182 epy = rc->bottom;
183 spy = epy - SmallDiam;
184 break;
186 case BF_TOPLEFT:
187 case BF_BOTTOMRIGHT:
188 /* Left top endpoint */
189 epx = rc->left-1;
190 spx = epx + SmallDiam;
191 epy = rc->top-1;
192 spy = epy + SmallDiam;
193 break;
195 case BF_TOP:
196 case BF_RIGHT:
197 case BF_TOPRIGHT:
198 case BF_RIGHT|BF_LEFT:
199 case BF_RIGHT|BF_LEFT|BF_TOP:
200 case BF_BOTTOM|BF_TOP:
201 case BF_BOTTOM|BF_TOP|BF_LEFT:
202 case BF_BOTTOMRIGHT|BF_LEFT:
203 case BF_BOTTOMRIGHT|BF_TOP:
204 case BF_RECT:
205 /* Right top endpoint */
206 spx = rc->left;
207 epx = spx + SmallDiam;
208 spy = rc->bottom-1;
209 epy = spy - SmallDiam;
210 break;
213 MoveToEx32(hdc, spx, spy, NULL);
214 SelectObject32(hdc, OuterPen);
215 LineTo32(hdc, epx, epy);
217 SelectObject32(hdc, InnerPen);
219 switch(uFlags & (BF_RECT|BF_DIAGONAL))
221 case BF_DIAGONAL_ENDBOTTOMLEFT:
222 case (BF_DIAGONAL|BF_BOTTOM):
223 case BF_DIAGONAL:
224 case (BF_DIAGONAL|BF_LEFT):
225 MoveToEx32(hdc, spx-1, spy, NULL);
226 LineTo32(hdc, epx, epy-1);
227 Points[0].x = spx-add;
228 Points[0].y = spy;
229 Points[1].x = rc->left;
230 Points[1].y = rc->top;
231 Points[2].x = epx+1;
232 Points[2].y = epy-1-add;
233 Points[3] = Points[2];
234 break;
236 case BF_DIAGONAL_ENDBOTTOMRIGHT:
237 MoveToEx32(hdc, spx-1, spy, NULL);
238 LineTo32(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->bottom-1;
243 Points[2].x = epx+1;
244 Points[2].y = epy+1+add;
245 Points[3] = Points[2];
246 break;
248 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP):
249 case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP|BF_LEFT):
250 case BF_DIAGONAL_ENDTOPRIGHT:
251 case (BF_DIAGONAL|BF_RIGHT|BF_TOP|BF_LEFT):
252 MoveToEx32(hdc, spx+1, spy, NULL);
253 LineTo32(hdc, epx, epy+1);
254 Points[0].x = epx-1;
255 Points[0].y = epy+1+add;
256 Points[1].x = rc->right-1;
257 Points[1].y = rc->top+add;
258 Points[2].x = rc->right-1;
259 Points[2].y = rc->bottom-1;
260 Points[3].x = spx+add;
261 Points[3].y = spy;
262 break;
264 case BF_DIAGONAL_ENDTOPLEFT:
265 MoveToEx32(hdc, spx, spy-1, NULL);
266 LineTo32(hdc, epx+1, epy);
267 Points[0].x = epx+1+add;
268 Points[0].y = epy+1;
269 Points[1].x = rc->right-1;
270 Points[1].y = rc->top;
271 Points[2].x = rc->right-1;
272 Points[2].y = rc->bottom-1-add;
273 Points[3].x = spx;
274 Points[3].y = spy-add;
275 break;
277 case (BF_DIAGONAL|BF_TOP):
278 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP):
279 case (BF_DIAGONAL|BF_BOTTOM|BF_TOP|BF_LEFT):
280 MoveToEx32(hdc, spx+1, spy-1, NULL);
281 LineTo32(hdc, epx, epy);
282 Points[0].x = epx-1;
283 Points[0].y = epy+1;
284 Points[1].x = rc->right-1;
285 Points[1].y = rc->top;
286 Points[2].x = rc->right-1;
287 Points[2].y = rc->bottom-1-add;
288 Points[3].x = spx+add;
289 Points[3].y = spy-add;
290 break;
292 case (BF_DIAGONAL|BF_RIGHT):
293 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT):
294 case (BF_DIAGONAL|BF_RIGHT|BF_LEFT|BF_BOTTOM):
295 MoveToEx32(hdc, spx, spy, NULL);
296 LineTo32(hdc, epx-1, epy+1);
297 Points[0].x = spx;
298 Points[0].y = spy;
299 Points[1].x = rc->left;
300 Points[1].y = rc->top+add;
301 Points[2].x = epx-1-add;
302 Points[2].y = epy+1+add;
303 Points[3] = Points[2];
304 break;
307 /* Fill the interior if asked */
308 if((uFlags & BF_MIDDLE) && retval)
310 HBRUSH32 hbsave;
311 HBRUSH32 hb = GetSysColorBrush32(uFlags & BF_MONO ? COLOR_WINDOW
312 :COLOR_BTNFACE);
313 HPEN32 hpsave;
314 HPEN32 hp = GetSysColorPen32(uFlags & BF_MONO ? COLOR_WINDOW
315 : COLOR_BTNFACE);
316 hbsave = (HBRUSH32)SelectObject32(hdc, hb);
317 hpsave = (HPEN32)SelectObject32(hdc, hp);
318 Polygon32(hdc, Points, 4);
319 SelectObject32(hdc, hbsave);
320 SelectObject32(hdc, hpsave);
323 /* Adjust rectangle if asked */
324 if(uFlags & BF_ADJUST)
326 if(uFlags & BF_LEFT) rc->left += add;
327 if(uFlags & BF_RIGHT) rc->right -= add;
328 if(uFlags & BF_TOP) rc->top += add;
329 if(uFlags & BF_BOTTOM) rc->bottom -= add;
332 /* Cleanup */
333 SelectObject32(hdc, SavePen);
334 MoveToEx32(hdc, SavePoint.x, SavePoint.y, NULL);
336 return retval;
339 /***********************************************************************
340 * UITOOLS_DrawRectEdge
342 * Same as DrawEdge invoked without BF_DIAGONAL
344 * 23-Nov-1997: Changed by Bertho Stultiens
346 * Well, I started testing this and found out that there are a few things
347 * that weren't quite as win95. The following rewrite should reproduce
348 * win95 results completely.
349 * The colorselection is table-driven to avoid awfull if-statements.
350 * The table below show the color settings.
352 * Pen selection table for uFlags = 0
354 * uType | LTI | LTO | RBI | RBO
355 * ------+-------+-------+-------+-------
356 * 0000 | x | x | x | x
357 * 0001 | x | 22 | x | 21
358 * 0010 | x | 16 | x | 20
359 * 0011 | x | x | x | x
360 * ------+-------+-------+-------+-------
361 * 0100 | x | 20 | x | 16
362 * 0101 | 20 | 22 | 16 | 21
363 * 0110 | 20 | 16 | 16 | 20
364 * 0111 | x | x | x | x
365 * ------+-------+-------+-------+-------
366 * 1000 | x | 21 | x | 22
367 * 1001 | 21 | 22 | 22 | 21
368 * 1010 | 21 | 16 | 22 | 20
369 * 1011 | x | x | x | x
370 * ------+-------+-------+-------+-------
371 * 1100 | x | x | x | x
372 * 1101 | x | x (22)| x | x (21)
373 * 1110 | x | x (16)| x | x (20)
374 * 1111 | x | x | x | x
376 * Pen selection table for uFlags = BF_SOFT
378 * uType | LTI | LTO | RBI | RBO
379 * ------+-------+-------+-------+-------
380 * 0000 | x | x | x | x
381 * 0001 | x | 20 | x | 21
382 * 0010 | x | 21 | x | 20
383 * 0011 | x | x | x | x
384 * ------+-------+-------+-------+-------
385 * 0100 | x | 22 | x | 16
386 * 0101 | 22 | 20 | 16 | 21
387 * 0110 | 22 | 21 | 16 | 20
388 * 0111 | x | x | x | x
389 * ------+-------+-------+-------+-------
390 * 1000 | x | 16 | x | 22
391 * 1001 | 16 | 20 | 22 | 21
392 * 1010 | 16 | 21 | 22 | 20
393 * 1011 | x | x | x | x
394 * ------+-------+-------+-------+-------
395 * 1100 | x | x | x | x
396 * 1101 | x | x (20)| x | x (21)
397 * 1110 | x | x (21)| x | x (20)
398 * 1111 | x | x | x | x
400 * x = don't care; (n) = is what win95 actually uses
401 * LTI = left Top Inner line
402 * LTO = left Top Outer line
403 * RBI = Right Bottom Inner line
404 * RBO = Right Bottom Outer line
405 * 15 = COLOR_BTNFACE
406 * 16 = COLOR_BTNSHADOW
407 * 20 = COLOR_BTNHIGHLIGHT
408 * 21 = COLOR_3DDKSHADOW
409 * 22 = COLOR_3DLIGHT
413 static BOOL32 UITOOLS95_DrawRectEdge(HDC32 hdc, LPRECT32 rc,
414 UINT32 uType, UINT32 uFlags)
416 char LTInnerI, LTOuterI;
417 char RBInnerI, RBOuterI;
418 HPEN32 LTInnerPen, LTOuterPen;
419 HPEN32 RBInnerPen, RBOuterPen;
420 RECT32 InnerRect = *rc;
421 POINT32 SavePoint;
422 HPEN32 SavePen;
423 int LBpenplus = 0;
424 int LTpenplus = 0;
425 int RTpenplus = 0;
426 int RBpenplus = 0;
427 BOOL32 retval = !( ((uType & BDR_INNER) == BDR_INNER
428 || (uType & BDR_OUTER) == BDR_OUTER)
429 && !(uFlags & (BF_FLAT|BF_MONO)) );
431 /* Init some vars */
432 LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN32)GetStockObject32(NULL_PEN);
433 SavePen = (HPEN32)SelectObject32(hdc, LTInnerPen);
435 /* Determine the colors of the edges */
436 if(uFlags & BF_MONO)
438 LTInnerI = RBInnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
439 LTOuterI = RBOuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
441 else if(uFlags & BF_FLAT)
443 LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
444 LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
446 else if(uFlags & BF_SOFT)
448 LTInnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
449 LTOuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
450 RBInnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
451 RBOuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
453 else
455 LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
456 LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
457 RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
458 RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
461 if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
462 if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
463 if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
464 if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
466 if(LTInnerI != -1) LTInnerPen = GetSysColorPen32(LTInnerI);
467 if(LTOuterI != -1) LTOuterPen = GetSysColorPen32(LTOuterI);
468 if(RBInnerI != -1) RBInnerPen = GetSysColorPen32(RBInnerI);
469 if(RBOuterI != -1) RBOuterPen = GetSysColorPen32(RBOuterI);
471 if((uFlags & BF_MIDDLE) && retval)
473 FillRect32(hdc, &InnerRect, GetSysColorBrush32(uFlags & BF_MONO ?
474 COLOR_WINDOW : COLOR_BTNFACE));
477 MoveToEx32(hdc, 0, 0, &SavePoint);
479 /* Draw the outer edge */
480 SelectObject32(hdc, LTOuterPen);
481 if(uFlags & BF_TOP)
483 MoveToEx32(hdc, InnerRect.left, InnerRect.top, NULL);
484 LineTo32(hdc, InnerRect.right, InnerRect.top);
486 if(uFlags & BF_LEFT)
488 MoveToEx32(hdc, InnerRect.left, InnerRect.top, NULL);
489 LineTo32(hdc, InnerRect.left, InnerRect.bottom);
491 SelectObject32(hdc, RBOuterPen);
492 if(uFlags & BF_BOTTOM)
494 MoveToEx32(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
495 LineTo32(hdc, InnerRect.left-1, InnerRect.bottom-1);
497 if(uFlags & BF_RIGHT)
499 MoveToEx32(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
500 LineTo32(hdc, InnerRect.right-1, InnerRect.top-1);
503 /* Draw the inner edge */
504 SelectObject32(hdc, LTInnerPen);
505 if(uFlags & BF_TOP)
507 MoveToEx32(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
508 LineTo32(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
510 if(uFlags & BF_LEFT)
512 MoveToEx32(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
513 LineTo32(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
515 SelectObject32(hdc, RBInnerPen);
516 if(uFlags & BF_BOTTOM)
518 MoveToEx32(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
519 LineTo32(hdc, InnerRect.left-1+LBpenplus, InnerRect.bottom-2);
521 if(uFlags & BF_RIGHT)
523 MoveToEx32(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
524 LineTo32(hdc, InnerRect.right-2, InnerRect.top-1+RTpenplus);
527 /* Adjust rectangle if asked */
528 if(uFlags & BF_ADJUST)
530 int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
531 + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
532 if(uFlags & BF_LEFT) rc->left += add;
533 if(uFlags & BF_RIGHT) rc->right -= add;
534 if(uFlags & BF_TOP) rc->top += add;
535 if(uFlags & BF_BOTTOM) rc->bottom -= add;
538 /* Cleanup */
539 SelectObject32(hdc, SavePen);
540 MoveToEx32(hdc, SavePoint.x, SavePoint.y, NULL);
541 return retval;
545 /**********************************************************************
546 * DrawEdge16 (USER.659)
548 BOOL16 WINAPI DrawEdge16( HDC16 hdc, LPRECT16 rc, UINT16 edge, UINT16 flags )
550 RECT32 rect32;
551 BOOL32 ret;
553 CONV_RECT16TO32( rc, &rect32 );
554 ret = DrawEdge32( hdc, &rect32, edge, flags );
555 CONV_RECT32TO16( &rect32, rc );
556 return ret;
559 /**********************************************************************
560 * DrawEdge32 (USER32.155)
562 BOOL32 WINAPI DrawEdge32( HDC32 hdc, LPRECT32 rc, UINT32 edge, UINT32 flags )
564 TRACE(graphics, "%04x %d,%d-%d,%d %04x %04x\n",
565 hdc, rc->left, rc->top, rc->right, rc->bottom, edge, flags );
567 if(flags & BF_DIAGONAL)
568 return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
569 else
570 return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
574 /************************************************************************
575 * UITOOLS_MakeSquareRect
577 * Utility to create a square rectangle and returning the width
579 static int UITOOLS_MakeSquareRect(LPRECT32 src, LPRECT32 dst)
581 int Width = src->right - src->left;
582 int Height = src->bottom - src->top;
583 int SmallDiam = Width > Height ? Height : Width;
585 *dst = *src;
587 /* Make it a square box */
588 if(Width < Height) /* SmallDiam == Width */
590 dst->top += (Height-Width)/2;
591 dst->bottom = dst->top + SmallDiam;
593 else if(Width > Height) /* SmallDiam == Height */
595 dst->left += (Width-Height)/2;
596 dst->right = dst->left + SmallDiam;
599 return SmallDiam;
603 /************************************************************************
604 * UITOOLS_DFC_ButtonPush
606 * Draw a push button coming from DrawFrameControl()
608 * Does a pretty good job in emulating MS behavior. Some quirks are
609 * however there because MS uses a TrueType font (Marlett) to draw
610 * the buttons.
612 static BOOL32 UITOOLS95_DFC_ButtonPush(HDC32 dc, LPRECT32 r, UINT32 uFlags)
614 UINT32 edge;
615 RECT32 myr = *r;
617 if(uFlags & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
618 edge = EDGE_SUNKEN;
619 else
620 edge = EDGE_RAISED;
622 if(uFlags & DFCS_CHECKED)
624 if(uFlags & DFCS_MONO)
625 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
626 else
627 UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
629 if(GetSysColor32(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
631 HBITMAP32 hbm = CreateBitmap32(8, 8, 1, 1, wPattern_AA55);
632 HBRUSH32 hbsave;
633 HBRUSH32 hb = CreatePatternBrush32(hbm);
635 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
636 hbsave = (HBRUSH32)SelectObject32(dc, hb);
637 PatBlt32(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
638 SelectObject32(dc, hbsave);
639 DeleteObject32(hb);
640 DeleteObject32(hbm);
642 else
644 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
647 else
649 if(uFlags & DFCS_MONO)
651 UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
652 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
654 else
656 UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
660 /* Adjust rectangle if asked */
661 if(uFlags & DFCS_ADJUSTRECT)
663 r->left += 2;
664 r->right -= 2;
665 r->top += 2;
666 r->bottom -= 2;
669 return TRUE;
673 /************************************************************************
674 * UITOOLS_DFC_ButtonChcek
676 * Draw a check/3state button coming from DrawFrameControl()
678 * Does a pretty good job in emulating MS behavior. Some quirks are
679 * however there because MS uses a TrueType font (Marlett) to draw
680 * the buttons.
682 #define DFC_CHECKPOINTSMAX 6
684 static BOOL32 UITOOLS95_DFC_ButtonCheck(HDC32 dc, LPRECT32 r, UINT32 uFlags)
686 RECT32 myr;
687 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
688 int BorderShrink = SmallDiam / 16;
690 if(BorderShrink < 1) BorderShrink = 1;
692 /* FIXME: The FillRect() sequence doesn't work for sizes less than */
693 /* 4 pixels in diameter. Not really a problem but it isn't M$'s */
694 /* 100% equivalent. */
695 if(uFlags & (DFCS_FLAT|DFCS_MONO))
697 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_WINDOWFRAME));
698 myr.left += 2 * BorderShrink;
699 myr.right -= 2 * BorderShrink;
700 myr.top += 2 * BorderShrink;
701 myr.bottom -= 2 * BorderShrink;
703 else
705 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
706 myr.right -= BorderShrink;
707 myr.bottom -= BorderShrink;
708 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNSHADOW));
709 myr.left += BorderShrink;
710 myr.top += BorderShrink;
711 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_3DLIGHT));
712 myr.right -= BorderShrink;
713 myr.bottom -= BorderShrink;
714 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_3DDKSHADOW));
715 myr.left += BorderShrink;
716 myr.top += BorderShrink;
719 if(uFlags & (DFCS_INACTIVE|DFCS_PUSHED))
721 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
723 else if(uFlags & DFCS_CHECKED)
725 if(GetSysColor32(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
727 HBITMAP32 hbm = CreateBitmap32(8, 8, 1, 1, wPattern_AA55);
728 HBRUSH32 hbsave;
729 HBRUSH32 hb = CreatePatternBrush32(hbm);
731 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNFACE));
732 hbsave = (HBRUSH32)SelectObject32(dc, hb);
733 PatBlt32(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
734 SelectObject32(dc, hbsave);
735 DeleteObject32(hb);
736 DeleteObject32(hbm);
738 else
740 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
743 else
745 FillRect32(dc, &myr, GetSysColorBrush32(COLOR_WINDOW));
748 if(uFlags & DFCS_CHECKED)
750 POINT32 CheckPoints[DFC_CHECKPOINTSMAX];
751 int i;
752 HBRUSH32 hbsave;
753 HPEN32 hpsave;
755 /* FIXME: This comes very close to M$'s checkmark, but not */
756 /* exactly... When small or large there is a few pixels */
757 /* shift. Not bad, but could be better :) */
758 UITOOLS_MakeSquareRect(r, &myr);
759 CheckPoints[0].x = myr.left + 253*SmallDiam/1000;
760 CheckPoints[0].y = myr.top + 345*SmallDiam/1000;
761 CheckPoints[1].x = myr.left + 409*SmallDiam/1000;
762 CheckPoints[1].y = CheckPoints[0].y + (CheckPoints[1].x-CheckPoints[0].x);
763 CheckPoints[2].x = myr.left + 690*SmallDiam/1000;
764 CheckPoints[2].y = CheckPoints[1].y - (CheckPoints[2].x-CheckPoints[1].x);
765 CheckPoints[3].x = CheckPoints[2].x;
766 CheckPoints[3].y = CheckPoints[2].y + 3*SmallDiam/16;
767 CheckPoints[4].x = CheckPoints[1].x;
768 CheckPoints[4].y = CheckPoints[1].y + 3*SmallDiam/16;
769 CheckPoints[5].x = CheckPoints[0].x;
770 CheckPoints[5].y = CheckPoints[0].y + 3*SmallDiam/16;
772 i = (uFlags & DFCS_INACTIVE) || (uFlags & 0xff) == DFCS_BUTTON3STATE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
773 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
774 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
775 Polygon32(dc, CheckPoints, DFC_CHECKPOINTSMAX);
776 SelectObject32(dc, hpsave);
777 SelectObject32(dc, hbsave);
779 return TRUE;
783 /************************************************************************
784 * UITOOLS_DFC_ButtonRadio
786 * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
788 * Does a pretty good job in emulating MS behavior. Some quirks are
789 * however there because MS uses a TrueType font (Marlett) to draw
790 * the buttons.
792 static BOOL32 UITOOLS95_DFC_ButtonRadio(HDC32 dc, LPRECT32 r, UINT32 uFlags)
794 RECT32 myr;
795 int i;
796 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
797 int BorderShrink = SmallDiam / 16;
798 HPEN32 hpsave;
799 HBRUSH32 hbsave;
800 int xe, ye;
801 int xc, yc;
803 if(BorderShrink < 1) BorderShrink = 1;
805 if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
807 FillRect32(dc, r, (HBRUSH32)GetStockObject32(BLACK_BRUSH));
810 xe = myr.left;
811 ye = myr.top + SmallDiam - SmallDiam/2;
813 xc = myr.left + SmallDiam - SmallDiam/2;
814 yc = myr.top + SmallDiam - SmallDiam/2;
816 /* Define bounding box */
817 i = 14*SmallDiam/16;
818 myr.left = xc - i+i/2;
819 myr.right = xc + i/2;
820 myr.top = yc - i+i/2;
821 myr.bottom = yc + i/2;
823 if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
825 hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(BLACK_BRUSH));
826 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
827 SelectObject32(dc, hbsave);
829 else
831 if(uFlags & (DFCS_FLAT|DFCS_MONO))
833 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_WINDOWFRAME));
834 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_WINDOWFRAME));
835 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
836 SelectObject32(dc, hbsave);
837 SelectObject32(dc, hpsave);
839 else
841 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_BTNHIGHLIGHT));
842 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
843 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
845 SelectObject32(dc, GetSysColorPen32(COLOR_BTNSHADOW));
846 SelectObject32(dc, GetSysColorBrush32(COLOR_BTNSHADOW));
847 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
849 myr.left += BorderShrink;
850 myr.right -= BorderShrink;
851 myr.top += BorderShrink;
852 myr.bottom -= BorderShrink;
854 SelectObject32(dc, GetSysColorPen32(COLOR_3DLIGHT));
855 SelectObject32(dc, GetSysColorBrush32(COLOR_3DLIGHT));
856 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
858 SelectObject32(dc, GetSysColorPen32(COLOR_3DDKSHADOW));
859 SelectObject32(dc, GetSysColorBrush32(COLOR_3DDKSHADOW));
860 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
861 SelectObject32(dc, hbsave);
862 SelectObject32(dc, hpsave);
865 i = 10*SmallDiam/16;
866 myr.left = xc - i+i/2;
867 myr.right = xc + i/2;
868 myr.top = yc - i+i/2;
869 myr.bottom = yc + i/2;
870 i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
871 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
872 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
873 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
874 SelectObject32(dc, hbsave);
875 SelectObject32(dc, hpsave);
878 if(uFlags & DFCS_CHECKED)
880 i = 6*SmallDiam/16;
881 i = i < 1 ? 1 : i;
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;
887 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
888 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
889 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
890 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
891 SelectObject32(dc, hpsave);
892 SelectObject32(dc, hbsave);
895 /* FIXME: M$ has a polygon in the center at relative points: */
896 /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
897 /* 0.476, 0.525 */
898 /* 0.500, 0.500 */
899 /* 0.500, 0.499 */
900 /* when the button is unchecked. The reason for it is unknown. The */
901 /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
902 /* least 3 times (it looks like a clip-region when you see it happen). */
903 /* I do not really see a reason why this should be implemented. If you */
904 /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
905 /* font. */
907 return TRUE;
910 /***********************************************************************
911 * UITOOLS_DrawFrameButton
913 static BOOL32 UITOOLS95_DrawFrameButton(HDC32 hdc, LPRECT32 rc, UINT32 uState)
915 switch(uState & 0xff)
917 case DFCS_BUTTONPUSH:
918 return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
920 case DFCS_BUTTONCHECK:
921 case DFCS_BUTTON3STATE:
922 return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
924 case DFCS_BUTTONRADIOIMAGE:
925 case DFCS_BUTTONRADIOMASK:
926 case DFCS_BUTTONRADIO:
927 return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
929 default:
930 WARN(uitools, "Invalid button state=0x%04x\n", uState);
933 return FALSE;
936 /***********************************************************************
937 * UITOOLS_DrawFrameCaption
939 * Draw caption buttons (win95), coming from DrawFrameControl()
942 static BOOL32 UITOOLS95_DrawFrameCaption(HDC32 dc, LPRECT32 r, UINT32 uFlags)
944 POINT32 Line1[10];
945 POINT32 Line2[10];
946 int Line1N;
947 int Line2N;
948 RECT32 myr;
949 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr)-2;
950 int i;
951 HBRUSH32 hbsave;
952 HPEN32 hpsave;
953 HFONT32 hfsave, hf;
954 int xc = (myr.left+myr.right)/2;
955 int yc = (myr.top+myr.bottom)/2;
956 int edge, move;
957 char str[2] = "?";
958 UINT32 alignsave;
959 int bksave;
960 COLORREF clrsave;
961 SIZE32 size;
963 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
965 switch(uFlags & 0xff)
967 case DFCS_CAPTIONCLOSE:
968 edge = 328*SmallDiam/1000;
969 move = 95*SmallDiam/1000;
970 Line1[0].x = Line2[0].x = Line1[1].x = Line2[1].x = xc - edge;
971 Line1[2].y = Line2[5].y = Line1[1].y = Line2[4].y = yc - edge;
972 Line1[3].x = Line2[3].x = Line1[4].x = Line2[4].x = xc + edge;
973 Line1[5].y = Line2[2].y = Line1[4].y = Line2[1].y = yc + edge;
974 Line1[2].x = Line2[2].x = Line1[1].x + move;
975 Line1[0].y = Line2[3].y = Line1[1].y + move;
976 Line1[5].x = Line2[5].x = Line1[4].x - move;
977 Line1[3].y = Line2[0].y = Line1[4].y - move;
978 Line1N = 6;
979 Line2N = 6;
980 break;
982 case DFCS_CAPTIONHELP:
983 /* This one breaks the flow */
984 /* FIXME: We need the Marlett font in order to get this right. */
986 hf = CreateFont32A(-SmallDiam, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
987 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
988 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "System");
989 alignsave = SetTextAlign32(dc, TA_TOP|TA_LEFT);
990 bksave = SetBkMode32(dc, TRANSPARENT);
991 clrsave = GetTextColor32(dc);
992 hfsave = (HFONT32)SelectObject32(dc, hf);
993 GetTextExtentPoint32A(dc, str, 1, &size);
995 if(uFlags & DFCS_INACTIVE)
997 SetTextColor32(dc, GetSysColor32(COLOR_BTNHIGHLIGHT));
998 TextOut32A(dc, xc-size.cx/2+1, yc-size.cy/2+1, str, 1);
1000 SetTextColor32(dc, GetSysColor32(uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
1001 TextOut32A(dc, xc-size.cx/2, yc-size.cy/2, str, 1);
1003 SelectObject32(dc, hfsave);
1004 SetTextColor32(dc, clrsave);
1005 SetBkMode32(dc, bksave);
1006 SetTextAlign32(dc, alignsave);
1007 DeleteObject32(hf);
1008 return TRUE;
1010 case DFCS_CAPTIONMIN:
1011 Line1[0].x = Line1[3].x = myr.left + 96*SmallDiam/750+2;
1012 Line1[1].x = Line1[2].x = Line1[0].x + 372*SmallDiam/750;
1013 Line1[0].y = Line1[1].y = myr.top + 563*SmallDiam/750+1;
1014 Line1[2].y = Line1[3].y = Line1[0].y + 92*SmallDiam/750;
1015 Line1N = 4;
1016 Line2N = 0;
1017 break;
1019 case DFCS_CAPTIONMAX:
1020 edge = 47*SmallDiam/750;
1021 Line1[0].x = Line1[5].x = myr.left + 57*SmallDiam/750+3;
1022 Line1[0].y = Line1[1].y = myr.top + 143*SmallDiam/750+1;
1023 Line1[1].x = Line1[2].x = Line1[0].x + 562*SmallDiam/750;
1024 Line1[5].y = Line1[4].y = Line1[0].y + 93*SmallDiam/750;
1025 Line1[2].y = Line1[3].y = Line1[0].y + 513*SmallDiam/750;
1026 Line1[3].x = Line1[4].x = Line1[1].x - edge;
1028 Line2[0].x = Line2[5].x = Line1[0].x;
1029 Line2[3].x = Line2[4].x = Line1[1].x;
1030 Line2[1].x = Line2[2].x = Line1[0].x + edge;
1031 Line2[0].y = Line2[1].y = Line1[0].y;
1032 Line2[4].y = Line2[5].y = Line1[2].y;
1033 Line2[2].y = Line2[3].y = Line1[2].y - edge;
1034 Line1N = 6;
1035 Line2N = 6;
1036 break;
1038 case DFCS_CAPTIONRESTORE:
1039 /* FIXME: this one looks bad at small sizes < 15x15 :( */
1040 edge = 47*SmallDiam/750;
1041 move = 420*SmallDiam/750;
1042 Line1[0].x = Line1[9].x = myr.left + 198*SmallDiam/750+2;
1043 Line1[0].y = Line1[1].y = myr.top + 169*SmallDiam/750+1;
1044 Line1[6].y = Line1[7].y = Line1[0].y + 93*SmallDiam/750;
1045 Line1[7].x = Line1[8].x = Line1[0].x + edge;
1046 Line1[1].x = Line1[2].x = Line1[0].x + move;
1047 Line1[5].x = Line1[6].x = Line1[1].x - edge;
1048 Line1[9].y = Line1[8].y = Line1[0].y + 187*SmallDiam/750;
1049 Line1[2].y = Line1[3].y = Line1[0].y + 327*SmallDiam/750;
1050 Line1[4].y = Line1[5].y = Line1[2].y - edge;
1051 Line1[3].x = Line1[4].x = Line1[2].x - 140*SmallDiam/750;
1053 Line2[1].x = Line2[2].x = Line1[3].x;
1054 Line2[7].x = Line2[8].x = Line2[1].x - edge;
1055 Line2[0].x = Line2[9].x = Line2[3].x = Line2[4].x = Line2[1].x - move;
1056 Line2[5].x = Line2[6].x = Line2[0].x + edge;
1057 Line2[0].y = Line2[1].y = Line1[9].y;
1058 Line2[4].y = Line2[5].y = Line2[8].y = Line2[9].y = Line2[0].y + 93*SmallDiam/750;
1059 Line2[2].y = Line2[3].y = Line2[0].y + 327*SmallDiam/750;
1060 Line2[6].y = Line2[7].y = Line2[2].y - edge;
1061 Line1N = 10;
1062 Line2N = 10;
1063 break;
1065 default:
1066 WARN(uitools, "Invalid caption; flags=0x%04x\n", uFlags);
1067 return FALSE;
1070 /* Here the drawing takes place */
1071 if(uFlags & DFCS_INACTIVE)
1073 /* If we have an inactive button, then you see a shadow */
1074 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
1075 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_BTNHIGHLIGHT));
1076 Polygon32(dc, Line1, Line1N);
1077 if(Line2N > 0)
1078 Polygon32(dc, Line2, Line2N);
1079 SelectObject32(dc, hpsave);
1080 SelectObject32(dc, hbsave);
1083 /* Correct for the shadow shift */
1084 for(i = 0; i < Line1N; i++)
1086 Line1[i].x--;
1087 Line1[i].y--;
1089 for(i = 0; i < Line2N; i++)
1091 Line2[i].x--;
1092 Line2[i].y--;
1095 /* Make the final picture */
1096 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1097 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
1098 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
1100 Polygon32(dc, Line1, Line1N);
1101 if(Line2N > 0)
1102 Polygon32(dc, Line2, Line2N);
1103 SelectObject32(dc, hpsave);
1104 SelectObject32(dc, hbsave);
1106 return TRUE;
1110 /************************************************************************
1111 * UITOOLS_DrawFrameScroll
1113 * Draw a scroll-bar control coming from DrawFrameControl()
1115 static BOOL32 UITOOLS95_DrawFrameScroll(HDC32 dc, LPRECT32 r, UINT32 uFlags)
1117 POINT32 Line[4];
1118 RECT32 myr;
1119 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2;
1120 int i;
1121 HBRUSH32 hbsave, hb, hb2;
1122 HPEN32 hpsave, hp, hp2;
1123 int tri = 310*SmallDiam/1000;
1124 int d46, d93;
1126 switch(uFlags & 0xff)
1128 case DFCS_SCROLLCOMBOBOX:
1129 case DFCS_SCROLLDOWN:
1130 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1131 Line[2].y = myr.top + 687*SmallDiam/1000 + 1;
1132 Line[0].x = Line[2].x - tri;
1133 Line[1].x = Line[2].x + tri;
1134 Line[0].y = Line[1].y = Line[2].y - tri;
1135 break;
1137 case DFCS_SCROLLUP:
1138 Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
1139 Line[2].y = myr.top + 313*SmallDiam/1000 + 1;
1140 Line[0].x = Line[2].x - tri;
1141 Line[1].x = Line[2].x + tri;
1142 Line[0].y = Line[1].y = Line[2].y + tri;
1143 break;
1145 case DFCS_SCROLLLEFT:
1146 Line[2].x = myr.left + 313*SmallDiam/1000 + 1;
1147 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1148 Line[0].y = Line[2].y - tri;
1149 Line[1].y = Line[2].y + tri;
1150 Line[0].x = Line[1].x = Line[2].x + tri;
1151 break;
1153 case DFCS_SCROLLRIGHT:
1154 Line[2].x = myr.left + 687*SmallDiam/1000 + 1;
1155 Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
1156 Line[0].y = Line[2].y - tri;
1157 Line[1].y = Line[2].y + tri;
1158 Line[0].x = Line[1].x = Line[2].x - tri;
1159 break;
1161 case DFCS_SCROLLSIZEGRIP:
1162 /* This one breaks the flow... */
1163 UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
1164 hpsave = (HPEN32)SelectObject32(dc, GetStockObject32(NULL_PEN));
1165 hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(NULL_BRUSH));
1166 if(uFlags & (DFCS_MONO|DFCS_FLAT))
1168 hp = hp2 = GetSysColorPen32(COLOR_WINDOWFRAME);
1169 hb = hb2 = GetSysColorBrush32(COLOR_WINDOWFRAME);
1171 else
1173 hp = GetSysColorPen32(COLOR_BTNHIGHLIGHT);
1174 hp2 = GetSysColorPen32(COLOR_BTNSHADOW);
1175 hb = GetSysColorBrush32(COLOR_BTNHIGHLIGHT);
1176 hb2 = GetSysColorBrush32(COLOR_BTNSHADOW);
1178 Line[0].x = Line[1].x = r->right-1;
1179 Line[2].y = Line[3].y = r->bottom-1;
1180 d46 = 46*SmallDiam/750;
1181 d93 = 93*SmallDiam/750;
1183 i = 586*SmallDiam/750;
1184 Line[0].y = r->bottom - i - 1;
1185 Line[3].x = r->right - i - 1;
1186 Line[1].y = Line[0].y + d46;
1187 Line[2].x = Line[3].x + d46;
1188 SelectObject32(dc, hb);
1189 SelectObject32(dc, hp);
1190 Polygon32(dc, Line, 4);
1192 Line[1].y++; Line[2].x++;
1193 Line[0].y = Line[1].y + d93;
1194 Line[3].x = Line[2].x + d93;
1195 SelectObject32(dc, hb2);
1196 SelectObject32(dc, hp2);
1197 Polygon32(dc, Line, 4);
1199 i = 398*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 SelectObject32(dc, hb);
1205 SelectObject32(dc, hp);
1206 Polygon32(dc, Line, 4);
1208 Line[1].y++; Line[2].x++;
1209 Line[0].y = Line[1].y + d93;
1210 Line[3].x = Line[2].x + d93;
1211 SelectObject32(dc, hb2);
1212 SelectObject32(dc, hp2);
1213 Polygon32(dc, Line, 4);
1215 i = 210*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 SelectObject32(dc, hb);
1221 SelectObject32(dc, hp);
1222 Polygon32(dc, Line, 4);
1224 Line[1].y++; Line[2].x++;
1225 Line[0].y = Line[1].y + d93;
1226 Line[3].x = Line[2].x + d93;
1227 SelectObject32(dc, hb2);
1228 SelectObject32(dc, hp2);
1229 Polygon32(dc, Line, 4);
1231 SelectObject32(dc, hpsave);
1232 SelectObject32(dc, hbsave);
1233 return TRUE;
1235 default:
1236 WARN(uitools, "Invalid scroll; flags=0x%04x\n", uFlags);
1237 return FALSE;
1240 /* Here do the real scroll-bar controls end up */
1241 UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
1243 if(uFlags & DFCS_INACTIVE)
1245 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(COLOR_BTNHIGHLIGHT));
1246 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(COLOR_BTNHIGHLIGHT));
1247 Polygon32(dc, Line, 3);
1248 SelectObject32(dc, hpsave);
1249 SelectObject32(dc, hbsave);
1252 for(i = 0; i < 3; i++)
1254 Line[i].x--;
1255 Line[i].y--;
1258 i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
1259 hbsave = (HBRUSH32)SelectObject32(dc, GetSysColorBrush32(i));
1260 hpsave = (HPEN32)SelectObject32(dc, GetSysColorPen32(i));
1261 Polygon32(dc, Line, 3);
1262 SelectObject32(dc, hpsave);
1263 SelectObject32(dc, hbsave);
1265 return TRUE;
1268 /************************************************************************
1269 * UITOOLS_DrawFrameMenu
1271 * Draw a menu control coming from DrawFrameControl()
1273 static BOOL32 UITOOLS95_DrawFrameMenu(HDC32 dc, LPRECT32 r, UINT32 uFlags)
1275 POINT32 Points[6];
1276 RECT32 myr;
1277 int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
1278 int i;
1279 HBRUSH32 hbsave;
1280 HPEN32 hpsave;
1281 int xe, ye;
1282 int xc, yc;
1283 BOOL32 retval = TRUE;
1285 /* Using black and white seems to be utterly wrong, but win95 doesn't */
1286 /* use anything else. I think I tried all sys-colors to change things */
1287 /* without luck. It seems as if this behavior is inherited from the */
1288 /* win31 DFC() implementation... (you remember, B/W menus). */
1290 FillRect32(dc, r, (HBRUSH32)GetStockObject32(WHITE_BRUSH));
1292 hbsave = (HBRUSH32)SelectObject32(dc, GetStockObject32(BLACK_BRUSH));
1293 hpsave = (HPEN32)SelectObject32(dc, GetStockObject32(BLACK_PEN));
1295 switch(uFlags & 0xff)
1297 case DFCS_MENUARROW:
1298 i = 187*SmallDiam/750;
1299 Points[2].x = myr.left + 468*SmallDiam/750;
1300 Points[2].y = myr.top + 352*SmallDiam/750+1;
1301 Points[0].y = Points[2].y - i;
1302 Points[1].y = Points[2].y + i;
1303 Points[0].x = Points[1].x = Points[2].x - i;
1304 Polygon32(dc, Points, 3);
1305 break;
1307 case DFCS_MENUBULLET:
1308 xe = myr.left;
1309 ye = myr.top + SmallDiam - SmallDiam/2;
1310 xc = myr.left + SmallDiam - SmallDiam/2;
1311 yc = myr.top + SmallDiam - SmallDiam/2;
1312 i = 234*SmallDiam/750;
1313 i = i < 1 ? 1 : i;
1314 myr.left = xc - i+i/2;
1315 myr.right = xc + i/2;
1316 myr.top = yc - i+i/2;
1317 myr.bottom = yc + i/2;
1318 Pie32(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
1319 break;
1321 case DFCS_MENUCHECK:
1322 Points[0].x = myr.left + 253*SmallDiam/1000;
1323 Points[0].y = myr.top + 445*SmallDiam/1000;
1324 Points[1].x = myr.left + 409*SmallDiam/1000;
1325 Points[1].y = Points[0].y + (Points[1].x-Points[0].x);
1326 Points[2].x = myr.left + 690*SmallDiam/1000;
1327 Points[2].y = Points[1].y - (Points[2].x-Points[1].x);
1328 Points[3].x = Points[2].x;
1329 Points[3].y = Points[2].y + 3*SmallDiam/16;
1330 Points[4].x = Points[1].x;
1331 Points[4].y = Points[1].y + 3*SmallDiam/16;
1332 Points[5].x = Points[0].x;
1333 Points[5].y = Points[0].y + 3*SmallDiam/16;
1334 Polygon32(dc, Points, 6);
1335 break;
1337 default:
1338 WARN(uitools, "Invalid menu; flags=0x%04x\n", uFlags);
1339 retval = FALSE;
1340 break;
1343 SelectObject32(dc, hpsave);
1344 SelectObject32(dc, hbsave);
1345 return retval;
1349 /**********************************************************************
1350 * DrawFrameControl16 (USER.656)
1352 BOOL16 WINAPI DrawFrameControl16( HDC16 hdc, LPRECT16 rc, UINT16 uType,
1353 UINT16 uState )
1355 RECT32 rect32;
1356 BOOL32 ret;
1358 CONV_RECT16TO32( rc, &rect32 );
1359 ret = DrawFrameControl32( hdc, &rect32, uType, uState );
1360 CONV_RECT32TO16( &rect32, rc );
1361 return ret;
1365 /**********************************************************************
1366 * DrawFrameControl32 (USER32.158)
1368 BOOL32 WINAPI DrawFrameControl32( HDC32 hdc, LPRECT32 rc, UINT32 uType,
1369 UINT32 uState )
1371 /* Win95 doesn't support drawing in other mapping modes */
1372 if(GetMapMode32(hdc) != MM_TEXT)
1373 return FALSE;
1375 switch(uType)
1377 case DFC_BUTTON:
1378 return UITOOLS95_DrawFrameButton(hdc, rc, uState);
1379 case DFC_CAPTION:
1380 return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
1381 case DFC_MENU:
1382 return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
1383 case DFC_SCROLL:
1384 return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
1385 default:
1386 WARN(uitools, "(%x,%p,%d,%x), bad type!\n",
1387 hdc,rc,uType,uState );
1389 return FALSE;