1 | /* $Id: uitools.cpp,v 1.3 1999-06-26 15:29:11 achimha 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 | */
|
---|
10 |
|
---|
11 | #include "winuser.h"
|
---|
12 | #include "user32.h"
|
---|
13 |
|
---|
14 | static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
|
---|
15 | 0xaaaa, 0x5555, 0xaaaa, 0x5555 };
|
---|
16 |
|
---|
17 | /* These tables are used in:
|
---|
18 | * UITOOLS_DrawDiagEdge()
|
---|
19 | * UITOOLS_DrawRectEdge()
|
---|
20 | */
|
---|
21 | static const char LTInnerNormal[] = {
|
---|
22 | -1, -1, -1, -1,
|
---|
23 | -1, COLOR_BTNHIGHLIGHT, COLOR_BTNHIGHLIGHT, -1,
|
---|
24 | -1, COLOR_3DDKSHADOW, COLOR_3DDKSHADOW, -1,
|
---|
25 | -1, -1, -1, -1
|
---|
26 | };
|
---|
27 |
|
---|
28 | static const char LTOuterNormal[] = {
|
---|
29 | -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
|
---|
30 | COLOR_BTNHIGHLIGHT, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
|
---|
31 | COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1,
|
---|
32 | -1, COLOR_3DLIGHT, COLOR_BTNSHADOW, -1
|
---|
33 | };
|
---|
34 |
|
---|
35 | static const char RBInnerNormal[] = {
|
---|
36 | -1, -1, -1, -1,
|
---|
37 | -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
|
---|
38 | -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
|
---|
39 | -1, -1, -1, -1
|
---|
40 | };
|
---|
41 |
|
---|
42 | static const char RBOuterNormal[] = {
|
---|
43 | -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
|
---|
44 | COLOR_BTNSHADOW, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
|
---|
45 | COLOR_3DLIGHT, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1,
|
---|
46 | -1, COLOR_3DDKSHADOW, COLOR_BTNHIGHLIGHT, -1
|
---|
47 | };
|
---|
48 |
|
---|
49 | static const char LTInnerSoft[] = {
|
---|
50 | -1, -1, -1, -1,
|
---|
51 | -1, COLOR_3DLIGHT, COLOR_3DLIGHT, -1,
|
---|
52 | -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, -1,
|
---|
53 | -1, -1, -1, -1
|
---|
54 | };
|
---|
55 |
|
---|
56 | static const char LTOuterSoft[] = {
|
---|
57 | -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
|
---|
58 | COLOR_3DLIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
|
---|
59 | COLOR_BTNSHADOW, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1,
|
---|
60 | -1, COLOR_BTNHIGHLIGHT, COLOR_3DDKSHADOW, -1
|
---|
61 | };
|
---|
62 |
|
---|
63 | #define RBInnerSoft RBInnerNormal /* These are the same */
|
---|
64 | #define RBOuterSoft RBOuterNormal
|
---|
65 |
|
---|
66 | static const char LTRBOuterMono[] = {
|
---|
67 | -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
|
---|
68 | COLOR_WINDOW, 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 | };
|
---|
72 |
|
---|
73 | static const char LTRBInnerMono[] = {
|
---|
74 | -1, -1, -1, -1,
|
---|
75 | -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
|
---|
76 | -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
|
---|
77 | -1, COLOR_WINDOW, COLOR_WINDOW, COLOR_WINDOW,
|
---|
78 | };
|
---|
79 |
|
---|
80 | static const char LTRBOuterFlat[] = {
|
---|
81 | -1, COLOR_BTNSHADOW, COLOR_BTNSHADOW, COLOR_BTNSHADOW,
|
---|
82 | COLOR_WINDOWFRAME, 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 | };
|
---|
86 |
|
---|
87 | static const char LTRBInnerFlat[] = {
|
---|
88 | -1, -1, -1, -1,
|
---|
89 | -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
|
---|
90 | -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
|
---|
91 | -1, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME, COLOR_WINDOWFRAME,
|
---|
92 | };
|
---|
93 |
|
---|
94 | /***********************************************************************
|
---|
95 | * UITOOLS_DrawDiagEdge
|
---|
96 | *
|
---|
97 | * Same as DrawEdge invoked with BF_DIAGONAL
|
---|
98 | *
|
---|
99 | * 03-Dec-1997: Changed by Bertho Stultiens
|
---|
100 | *
|
---|
101 | * See also comments with UITOOLS_DrawRectEdge()
|
---|
102 | */
|
---|
103 | static BOOL UITOOLS95_DrawDiagEdge(HDC hdc, LPRECT rc,
|
---|
104 | UINT uType, UINT uFlags)
|
---|
105 | {
|
---|
106 | POINT Points[4];
|
---|
107 | char InnerI, OuterI;
|
---|
108 | HPEN InnerPen, OuterPen;
|
---|
109 | POINT SavePoint;
|
---|
110 | HPEN SavePen;
|
---|
111 | int spx, spy;
|
---|
112 | int epx, epy;
|
---|
113 | int Width = rc->right - rc->left;
|
---|
114 | int Height= rc->bottom - rc->top;
|
---|
115 | int SmallDiam = Width > Height ? Height : Width;
|
---|
116 | BOOL retval = !( ((uType & BDR_INNER) == BDR_INNER
|
---|
117 | || (uType & BDR_OUTER) == BDR_OUTER)
|
---|
118 | && !(uFlags & (BF_FLAT|BF_MONO)) );
|
---|
119 | int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
|
---|
120 | + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
|
---|
121 |
|
---|
122 | if (IsRectEmpty(rc)) return retval; //nothing to do
|
---|
123 |
|
---|
124 | /* Init some vars */
|
---|
125 | OuterPen = InnerPen = (HPEN)GetStockObject(NULL_PEN);
|
---|
126 | SavePen = (HPEN)SelectObject(hdc, InnerPen);
|
---|
127 | spx = spy = epx = epy = 0; /* Satisfy the compiler... */
|
---|
128 |
|
---|
129 | /* Determine the colors of the edges */
|
---|
130 | if(uFlags & BF_MONO)
|
---|
131 | {
|
---|
132 | InnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
|
---|
133 | OuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
|
---|
134 | }
|
---|
135 | else if(uFlags & BF_FLAT)
|
---|
136 | {
|
---|
137 | InnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
|
---|
138 | OuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
|
---|
139 | }
|
---|
140 | else if(uFlags & BF_SOFT)
|
---|
141 | {
|
---|
142 | if(uFlags & BF_BOTTOM)
|
---|
143 | {
|
---|
144 | InnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
145 | OuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
146 | }
|
---|
147 | else
|
---|
148 | {
|
---|
149 | InnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
150 | OuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
151 | }
|
---|
152 | }
|
---|
153 | else
|
---|
154 | {
|
---|
155 | if(uFlags & BF_BOTTOM)
|
---|
156 | {
|
---|
157 | InnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
158 | OuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
159 | }
|
---|
160 | else
|
---|
161 | {
|
---|
162 | InnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
163 | OuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | if(InnerI != -1) InnerPen = GetSysColorPen(InnerI);
|
---|
168 | if(OuterI != -1) OuterPen = GetSysColorPen(OuterI);
|
---|
169 |
|
---|
170 | MoveToEx(hdc, 0, 0, &SavePoint);
|
---|
171 |
|
---|
172 | /* Don't ask me why, but this is what is visible... */
|
---|
173 | /* This must be possible to do much simpler, but I fail to */
|
---|
174 | /* see the logic in the MS implementation (sigh...). */
|
---|
175 | /* So, this might look a bit brute force here (and it is), but */
|
---|
176 | /* it gets the job done;) */
|
---|
177 |
|
---|
178 | switch(uFlags & BF_RECT)
|
---|
179 | {
|
---|
180 | case 0:
|
---|
181 | case BF_LEFT:
|
---|
182 | case BF_BOTTOM:
|
---|
183 | case BF_BOTTOMLEFT:
|
---|
184 | /* Left bottom endpoint */
|
---|
185 | epx = rc->left-1;
|
---|
186 | spx = epx + SmallDiam;
|
---|
187 | epy = rc->bottom;
|
---|
188 | spy = epy - SmallDiam;
|
---|
189 | epx++;
|
---|
190 | epy--;
|
---|
191 | break;
|
---|
192 |
|
---|
193 | case BF_TOPLEFT:
|
---|
194 | case BF_BOTTOMRIGHT:
|
---|
195 | /* Left top endpoint */
|
---|
196 | epx = rc->left-1;
|
---|
197 | spx = epx + SmallDiam;
|
---|
198 | epy = rc->top-1;
|
---|
199 | spy = epy + SmallDiam;
|
---|
200 | epx++;
|
---|
201 | epy++;
|
---|
202 | break;
|
---|
203 |
|
---|
204 | case BF_TOP:
|
---|
205 | case BF_RIGHT:
|
---|
206 | case BF_TOPRIGHT:
|
---|
207 | case BF_RIGHT|BF_LEFT:
|
---|
208 | case BF_RIGHT|BF_LEFT|BF_TOP:
|
---|
209 | case BF_BOTTOM|BF_TOP:
|
---|
210 | case BF_BOTTOM|BF_TOP|BF_LEFT:
|
---|
211 | case BF_BOTTOMRIGHT|BF_LEFT:
|
---|
212 | case BF_BOTTOMRIGHT|BF_TOP:
|
---|
213 | case BF_RECT:
|
---|
214 | /* Right top endpoint */
|
---|
215 | spx = rc->left;
|
---|
216 | epx = spx + SmallDiam;
|
---|
217 | spy = rc->bottom-1;
|
---|
218 | epy = spy - SmallDiam;
|
---|
219 | epx--;
|
---|
220 | epy++;
|
---|
221 | break;
|
---|
222 | }
|
---|
223 |
|
---|
224 | MoveToEx(hdc, spx, spy, NULL);
|
---|
225 | SelectObject(hdc, OuterPen);
|
---|
226 | LineTo(hdc, epx, epy);
|
---|
227 |
|
---|
228 | SelectObject(hdc, InnerPen);
|
---|
229 |
|
---|
230 | switch(uFlags & (BF_RECT|BF_DIAGONAL))
|
---|
231 | {
|
---|
232 | case BF_DIAGONAL_ENDBOTTOMLEFT:
|
---|
233 | case (BF_DIAGONAL|BF_BOTTOM):
|
---|
234 | case BF_DIAGONAL:
|
---|
235 | case (BF_DIAGONAL|BF_LEFT):
|
---|
236 | MoveToEx(hdc, spx-1, spy, NULL);
|
---|
237 | LineTo(hdc, epx, epy-1);
|
---|
238 | Points[0].x = spx-add;
|
---|
239 | Points[0].y = spy;
|
---|
240 | Points[1].x = rc->left;
|
---|
241 | Points[1].y = rc->top;
|
---|
242 | Points[2].x = epx+1;
|
---|
243 | Points[2].y = epy-1-add;
|
---|
244 | Points[3] = Points[2];
|
---|
245 | break;
|
---|
246 |
|
---|
247 | case BF_DIAGONAL_ENDBOTTOMRIGHT:
|
---|
248 | MoveToEx(hdc, spx-1, spy, NULL);
|
---|
249 | LineTo(hdc, epx, epy+1);
|
---|
250 | Points[0].x = spx-add;
|
---|
251 | Points[0].y = spy;
|
---|
252 | Points[1].x = rc->left;
|
---|
253 | Points[1].y = rc->bottom-1;
|
---|
254 | Points[2].x = epx+1;
|
---|
255 | Points[2].y = epy+1+add;
|
---|
256 | Points[3] = Points[2];
|
---|
257 | break;
|
---|
258 |
|
---|
259 | case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP):
|
---|
260 | case (BF_DIAGONAL|BF_BOTTOM|BF_RIGHT|BF_TOP|BF_LEFT):
|
---|
261 | case BF_DIAGONAL_ENDTOPRIGHT:
|
---|
262 | case (BF_DIAGONAL|BF_RIGHT|BF_TOP|BF_LEFT):
|
---|
263 | MoveToEx(hdc, spx+1, spy, NULL);
|
---|
264 | LineTo(hdc, epx, epy+1);
|
---|
265 | Points[0].x = epx-1;
|
---|
266 | Points[0].y = epy+1+add;
|
---|
267 | Points[1].x = rc->right-1;
|
---|
268 | Points[1].y = rc->top+add;
|
---|
269 | Points[2].x = rc->right-1;
|
---|
270 | Points[2].y = rc->bottom-1;
|
---|
271 | Points[3].x = spx+add;
|
---|
272 | Points[3].y = spy;
|
---|
273 | break;
|
---|
274 |
|
---|
275 | case BF_DIAGONAL_ENDTOPLEFT:
|
---|
276 | MoveToEx(hdc, spx, spy-1, NULL);
|
---|
277 | LineTo(hdc, epx+1, epy);
|
---|
278 | Points[0].x = epx+1+add;
|
---|
279 | Points[0].y = epy+1;
|
---|
280 | Points[1].x = rc->right-1;
|
---|
281 | Points[1].y = rc->top;
|
---|
282 | Points[2].x = rc->right-1;
|
---|
283 | Points[2].y = rc->bottom-1-add;
|
---|
284 | Points[3].x = spx;
|
---|
285 | Points[3].y = spy-add;
|
---|
286 | break;
|
---|
287 |
|
---|
288 | case (BF_DIAGONAL|BF_TOP):
|
---|
289 | case (BF_DIAGONAL|BF_BOTTOM|BF_TOP):
|
---|
290 | case (BF_DIAGONAL|BF_BOTTOM|BF_TOP|BF_LEFT):
|
---|
291 | MoveToEx(hdc, spx+1, spy-1, NULL);
|
---|
292 | LineTo(hdc, epx, epy);
|
---|
293 | Points[0].x = epx-1;
|
---|
294 | Points[0].y = epy+1;
|
---|
295 | Points[1].x = rc->right-1;
|
---|
296 | Points[1].y = rc->top;
|
---|
297 | Points[2].x = rc->right-1;
|
---|
298 | Points[2].y = rc->bottom-1-add;
|
---|
299 | Points[3].x = spx+add;
|
---|
300 | Points[3].y = spy-add;
|
---|
301 | break;
|
---|
302 |
|
---|
303 | case (BF_DIAGONAL|BF_RIGHT):
|
---|
304 | case (BF_DIAGONAL|BF_RIGHT|BF_LEFT):
|
---|
305 | case (BF_DIAGONAL|BF_RIGHT|BF_LEFT|BF_BOTTOM):
|
---|
306 | MoveToEx(hdc, spx, spy, NULL);
|
---|
307 | LineTo(hdc, epx-1, epy+1);
|
---|
308 | Points[0].x = spx;
|
---|
309 | Points[0].y = spy;
|
---|
310 | Points[1].x = rc->left;
|
---|
311 | Points[1].y = rc->top+add;
|
---|
312 | Points[2].x = epx-1-add;
|
---|
313 | Points[2].y = epy+1+add;
|
---|
314 | Points[3] = Points[2];
|
---|
315 | break;
|
---|
316 | }
|
---|
317 |
|
---|
318 | /* Fill the interior if asked */
|
---|
319 | if((uFlags & BF_MIDDLE) && retval)
|
---|
320 | {
|
---|
321 | HBRUSH hbsave;
|
---|
322 | HBRUSH hb = GetSysColorBrush(uFlags & BF_MONO ? COLOR_WINDOW
|
---|
323 | :COLOR_BTNFACE);
|
---|
324 | HPEN hpsave;
|
---|
325 | HPEN hp = GetSysColorPen(uFlags & BF_MONO ? COLOR_WINDOW
|
---|
326 | : COLOR_BTNFACE);
|
---|
327 | hbsave = (HBRUSH)SelectObject(hdc, hb);
|
---|
328 | hpsave = (HPEN)SelectObject(hdc, hp);
|
---|
329 | Polygon(hdc, Points, 4);
|
---|
330 | SelectObject(hdc, hbsave);
|
---|
331 | SelectObject(hdc, hpsave);
|
---|
332 | }
|
---|
333 |
|
---|
334 | /* Adjust rectangle if asked */
|
---|
335 | if(uFlags & BF_ADJUST)
|
---|
336 | {
|
---|
337 | if(uFlags & BF_LEFT) rc->left += add;
|
---|
338 | if(uFlags & BF_RIGHT) rc->right -= add;
|
---|
339 | if(uFlags & BF_TOP) rc->top += add;
|
---|
340 | if(uFlags & BF_BOTTOM) rc->bottom -= add;
|
---|
341 | }
|
---|
342 |
|
---|
343 | /* Cleanup */
|
---|
344 | SelectObject(hdc, SavePen);
|
---|
345 | MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
|
---|
346 |
|
---|
347 | return retval;
|
---|
348 | }
|
---|
349 |
|
---|
350 | /***********************************************************************
|
---|
351 | * UITOOLS_DrawRectEdge
|
---|
352 | *
|
---|
353 | * Same as DrawEdge invoked without BF_DIAGONAL
|
---|
354 | *
|
---|
355 | * 23-Nov-1997: Changed by Bertho Stultiens
|
---|
356 | * 25-June-1999: Changed by Christoph Bratschi
|
---|
357 | *
|
---|
358 | * Attention: only draw in the rect's range!
|
---|
359 | * left to right-1
|
---|
360 | * top to bottom-1
|
---|
361 | *
|
---|
362 | * Well, I started testing this and found out that there are a few things
|
---|
363 | * that weren't quite as win95. The following rewrite should reproduce
|
---|
364 | * win95 results completely.
|
---|
365 | * The colorselection is table-driven to avoid awfull if-statements.
|
---|
366 | * The table below show the color settings.
|
---|
367 | *
|
---|
368 | * Pen selection table for uFlags = 0
|
---|
369 | *
|
---|
370 | * uType | LTI | LTO | RBI | RBO
|
---|
371 | * ------+-------+-------+-------+-------
|
---|
372 | * 0000 | x | x | x | x
|
---|
373 | * 0001 | x | 22 | x | 21
|
---|
374 | * 0010 | x | 16 | x | 20
|
---|
375 | * 0011 | x | x | x | x
|
---|
376 | * ------+-------+-------+-------+-------
|
---|
377 | * 0100 | x | 20 | x | 16
|
---|
378 | * 0101 | 20 | 22 | 16 | 21
|
---|
379 | * 0110 | 20 | 16 | 16 | 20
|
---|
380 | * 0111 | x | x | x | x
|
---|
381 | * ------+-------+-------+-------+-------
|
---|
382 | * 1000 | x | 21 | x | 22
|
---|
383 | * 1001 | 21 | 22 | 22 | 21
|
---|
384 | * 1010 | 21 | 16 | 22 | 20
|
---|
385 | * 1011 | x | x | x | x
|
---|
386 | * ------+-------+-------+-------+-------
|
---|
387 | * 1100 | x | x | x | x
|
---|
388 | * 1101 | x | x (22)| x | x (21)
|
---|
389 | * 1110 | x | x (16)| x | x (20)
|
---|
390 | * 1111 | x | x | x | x
|
---|
391 | *
|
---|
392 | * Pen selection table for uFlags = BF_SOFT
|
---|
393 | *
|
---|
394 | * uType | LTI | LTO | RBI | RBO
|
---|
395 | * ------+-------+-------+-------+-------
|
---|
396 | * 0000 | x | x | x | x
|
---|
397 | * 0001 | x | 20 | x | 21
|
---|
398 | * 0010 | x | 21 | x | 20
|
---|
399 | * 0011 | x | x | x | x
|
---|
400 | * ------+-------+-------+-------+-------
|
---|
401 | * 0100 | x | 22 | x | 16
|
---|
402 | * 0101 | 22 | 20 | 16 | 21
|
---|
403 | * 0110 | 22 | 21 | 16 | 20
|
---|
404 | * 0111 | x | x | x | x
|
---|
405 | * ------+-------+-------+-------+-------
|
---|
406 | * 1000 | x | 16 | x | 22
|
---|
407 | * 1001 | 16 | 20 | 22 | 21
|
---|
408 | * 1010 | 16 | 21 | 22 | 20
|
---|
409 | * 1011 | x | x | x | x
|
---|
410 | * ------+-------+-------+-------+-------
|
---|
411 | * 1100 | x | x | x | x
|
---|
412 | * 1101 | x | x (20)| x | x (21)
|
---|
413 | * 1110 | x | x (21)| x | x (20)
|
---|
414 | * 1111 | x | x | x | x
|
---|
415 | *
|
---|
416 | * x = don't care; (n) = is what win95 actually uses
|
---|
417 | * LTI = left Top Inner line
|
---|
418 | * LTO = left Top Outer line
|
---|
419 | * RBI = Right Bottom Inner line
|
---|
420 | * RBO = Right Bottom Outer line
|
---|
421 | * 15 = COLOR_BTNFACE
|
---|
422 | * 16 = COLOR_BTNSHADOW
|
---|
423 | * 20 = COLOR_BTNHIGHLIGHT
|
---|
424 | * 21 = COLOR_3DDKSHADOW
|
---|
425 | * 22 = COLOR_3DLIGHT
|
---|
426 | */
|
---|
427 |
|
---|
428 |
|
---|
429 | static BOOL UITOOLS95_DrawRectEdge(HDC hdc, LPRECT rc,
|
---|
430 | UINT uType, UINT uFlags)
|
---|
431 | {
|
---|
432 | char LTInnerI, LTOuterI;
|
---|
433 | char RBInnerI, RBOuterI;
|
---|
434 | HPEN LTInnerPen, LTOuterPen;
|
---|
435 | HPEN RBInnerPen, RBOuterPen;
|
---|
436 | RECT InnerRect = *rc;
|
---|
437 | POINT SavePoint;
|
---|
438 | HPEN SavePen;
|
---|
439 | int LBpenplus = 0;
|
---|
440 | int LTpenplus = 0;
|
---|
441 | int RTpenplus = 0;
|
---|
442 | int RBpenplus = 0;
|
---|
443 | BOOL retval = !( ((uType & BDR_INNER) == BDR_INNER
|
---|
444 | || (uType & BDR_OUTER) == BDR_OUTER)
|
---|
445 | && !(uFlags & (BF_FLAT|BF_MONO)) );
|
---|
446 |
|
---|
447 | if (IsRectEmpty(rc)) return retval; //nothing to do
|
---|
448 |
|
---|
449 | /* Init some vars */
|
---|
450 | LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN)GetStockObject(NULL_PEN);
|
---|
451 | SavePen = (HPEN)SelectObject(hdc, LTInnerPen);
|
---|
452 |
|
---|
453 | /* Determine the colors of the edges */
|
---|
454 | if(uFlags & BF_MONO)
|
---|
455 | {
|
---|
456 | LTInnerI = RBInnerI = LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)];
|
---|
457 | LTOuterI = RBOuterI = LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)];
|
---|
458 | }
|
---|
459 | else if(uFlags & BF_FLAT)
|
---|
460 | {
|
---|
461 | LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
|
---|
462 | LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
|
---|
463 | }
|
---|
464 | else if(uFlags & BF_SOFT)
|
---|
465 | {
|
---|
466 | LTInnerI = LTInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
467 | LTOuterI = LTOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
468 | RBInnerI = RBInnerSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
469 | RBOuterI = RBOuterSoft[uType & (BDR_INNER|BDR_OUTER)];
|
---|
470 | }
|
---|
471 | else
|
---|
472 | {
|
---|
473 | LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
474 | LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
475 | RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
476 | RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
|
---|
477 | }
|
---|
478 |
|
---|
479 | if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
|
---|
480 | if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
|
---|
481 | if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
|
---|
482 | if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
|
---|
483 |
|
---|
484 | if(LTInnerI != -1) LTInnerPen = GetSysColorPen(LTInnerI);
|
---|
485 | if(LTOuterI != -1) LTOuterPen = GetSysColorPen(LTOuterI);
|
---|
486 | if(RBInnerI != -1) RBInnerPen = GetSysColorPen(RBInnerI);
|
---|
487 | if(RBOuterI != -1) RBOuterPen = GetSysColorPen(RBOuterI);
|
---|
488 |
|
---|
489 | if((uFlags & BF_MIDDLE) && retval)
|
---|
490 | {
|
---|
491 | FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?
|
---|
492 | COLOR_WINDOW : COLOR_BTNFACE));
|
---|
493 | }
|
---|
494 |
|
---|
495 | MoveToEx(hdc, 0, 0, &SavePoint);
|
---|
496 |
|
---|
497 | /* Draw the outer edge */
|
---|
498 | SelectObject(hdc, LTOuterPen);
|
---|
499 | if(uFlags & BF_TOP)
|
---|
500 | {
|
---|
501 | MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
|
---|
502 | LineTo(hdc, InnerRect.right-1, InnerRect.top);
|
---|
503 | }
|
---|
504 | if(uFlags & BF_LEFT)
|
---|
505 | {
|
---|
506 | MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
|
---|
507 | LineTo(hdc, InnerRect.left, InnerRect.bottom-1);
|
---|
508 | }
|
---|
509 |
|
---|
510 | SelectObject(hdc, RBOuterPen);
|
---|
511 | if(uFlags & BF_BOTTOM)
|
---|
512 | {
|
---|
513 | MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
|
---|
514 | LineTo(hdc, InnerRect.left, InnerRect.bottom-1);
|
---|
515 | }
|
---|
516 | if(uFlags & BF_RIGHT)
|
---|
517 | {
|
---|
518 | MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
|
---|
519 | LineTo(hdc, InnerRect.right-1, InnerRect.top);
|
---|
520 | }
|
---|
521 |
|
---|
522 | /* Draw the inner edge */
|
---|
523 | SelectObject(hdc, LTInnerPen);
|
---|
524 | if(uFlags & BF_TOP)
|
---|
525 | {
|
---|
526 | MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
|
---|
527 | LineTo(hdc, InnerRect.right-RTpenplus-1, InnerRect.top+1);
|
---|
528 | }
|
---|
529 | if(uFlags & BF_LEFT)
|
---|
530 | {
|
---|
531 | MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
|
---|
532 | LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus-1);
|
---|
533 | }
|
---|
534 | SelectObject(hdc, RBInnerPen);
|
---|
535 | if(uFlags & BF_BOTTOM)
|
---|
536 | {
|
---|
537 | MoveToEx(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
|
---|
538 | LineTo(hdc, InnerRect.left+LBpenplus, InnerRect.bottom-2);
|
---|
539 | }
|
---|
540 | if(uFlags & BF_RIGHT)
|
---|
541 | {
|
---|
542 | MoveToEx(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
|
---|
543 | LineTo(hdc, InnerRect.right-2, InnerRect.top+RTpenplus);
|
---|
544 | }
|
---|
545 |
|
---|
546 | /* Adjust rectangle if asked */
|
---|
547 | if(uFlags & BF_ADJUST)
|
---|
548 | {
|
---|
549 | int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
|
---|
550 | + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
|
---|
551 | if(uFlags & BF_LEFT) rc->left += add;
|
---|
552 | if(uFlags & BF_RIGHT) rc->right -= add;
|
---|
553 | if(uFlags & BF_TOP) rc->top += add;
|
---|
554 | if(uFlags & BF_BOTTOM) rc->bottom -= add;
|
---|
555 | }
|
---|
556 |
|
---|
557 | /* Cleanup */
|
---|
558 | SelectObject(hdc, SavePen);
|
---|
559 | MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
|
---|
560 | return retval;
|
---|
561 | }
|
---|
562 |
|
---|
563 |
|
---|
564 | //**********************************************************************
|
---|
565 | // DrawEdge (USER32.155)
|
---|
566 | //
|
---|
567 | BOOL WIN32API DrawEdge(HDC hdc, LPRECT rc, UINT edge, UINT flags)
|
---|
568 | {
|
---|
569 |
|
---|
570 | if (flags & BF_DIAGONAL)
|
---|
571 | return UITOOLS95_DrawDiagEdge(hdc, rc, edge, flags);
|
---|
572 | else
|
---|
573 | return UITOOLS95_DrawRectEdge(hdc, rc, edge, flags);
|
---|
574 | }
|
---|
575 |
|
---|
576 | /************************************************************************
|
---|
577 | * UITOOLS_MakeSquareRect
|
---|
578 | *
|
---|
579 | * Utility to create a square rectangle and returning the width
|
---|
580 | */
|
---|
581 | static int UITOOLS_MakeSquareRect(LPRECT src, LPRECT dst)
|
---|
582 | {
|
---|
583 | int Width = src->right - src->left;
|
---|
584 | int Height = src->bottom - src->top;
|
---|
585 | int SmallDiam = Width > Height ? Height : Width;
|
---|
586 |
|
---|
587 | *dst = *src;
|
---|
588 |
|
---|
589 | /* Make it a square box */
|
---|
590 | if(Width < Height) /* SmallDiam == Width */
|
---|
591 | {
|
---|
592 | dst->top += (Height-Width)/2;
|
---|
593 | dst->bottom = dst->top + SmallDiam;
|
---|
594 | }
|
---|
595 | else if(Width > Height) /* SmallDiam == Height */
|
---|
596 | {
|
---|
597 | dst->left += (Width-Height)/2;
|
---|
598 | dst->right = dst->left + SmallDiam;
|
---|
599 | }
|
---|
600 |
|
---|
601 | return SmallDiam;
|
---|
602 | }
|
---|
603 |
|
---|
604 |
|
---|
605 | /************************************************************************
|
---|
606 | * UITOOLS_DFC_ButtonPush
|
---|
607 | *
|
---|
608 | * Draw a push button coming from DrawFrameControl()
|
---|
609 | *
|
---|
610 | * Does a pretty good job in emulating MS behavior. Some quirks are
|
---|
611 | * however there because MS uses a TrueType font (Marlett) to draw
|
---|
612 | * the buttons.
|
---|
613 | */
|
---|
614 | static BOOL UITOOLS95_DFC_ButtonPush(HDC dc, LPRECT r, UINT uFlags)
|
---|
615 | {
|
---|
616 | UINT edge;
|
---|
617 | RECT myr = *r;
|
---|
618 |
|
---|
619 | if(uFlags & (DFCS_PUSHED | DFCS_CHECKED | DFCS_FLAT))
|
---|
620 | edge = EDGE_SUNKEN;
|
---|
621 | else
|
---|
622 | edge = EDGE_RAISED;
|
---|
623 |
|
---|
624 | if(uFlags & DFCS_CHECKED)
|
---|
625 | {
|
---|
626 | if(uFlags & DFCS_MONO)
|
---|
627 | UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
|
---|
628 | else
|
---|
629 | UITOOLS95_DrawRectEdge(dc, &myr, edge, (uFlags&DFCS_FLAT)|BF_RECT|BF_SOFT|BF_ADJUST);
|
---|
630 |
|
---|
631 | if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
|
---|
632 | {
|
---|
633 | HBITMAP hbm = CreateBitmap(8, 8, 1, 1, wPattern_AA55);
|
---|
634 | HBRUSH hbsave;
|
---|
635 | HBRUSH hb = CreatePatternBrush(hbm);
|
---|
636 |
|
---|
637 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
|
---|
638 | hbsave = (HBRUSH)SelectObject(dc, hb);
|
---|
639 | PatBlt(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
|
---|
640 | SelectObject(dc, hbsave);
|
---|
641 | DeleteObject(hb);
|
---|
642 | DeleteObject(hbm);
|
---|
643 | }
|
---|
644 | else
|
---|
645 | {
|
---|
646 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
|
---|
647 | }
|
---|
648 | }
|
---|
649 | else
|
---|
650 | {
|
---|
651 | if(uFlags & DFCS_MONO)
|
---|
652 | {
|
---|
653 | UITOOLS95_DrawRectEdge(dc, &myr, edge, BF_MONO|BF_RECT|BF_ADJUST);
|
---|
654 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
|
---|
655 | }
|
---|
656 | else
|
---|
657 | {
|
---|
658 | UITOOLS95_DrawRectEdge(dc, r, edge, (uFlags&DFCS_FLAT) | BF_MIDDLE |BF_SOFT| BF_RECT);
|
---|
659 | }
|
---|
660 | }
|
---|
661 |
|
---|
662 | /* Adjust rectangle if asked */
|
---|
663 | if(uFlags & DFCS_ADJUSTRECT)
|
---|
664 | {
|
---|
665 | r->left += 2;
|
---|
666 | r->right -= 2;
|
---|
667 | r->top += 2;
|
---|
668 | r->bottom -= 2;
|
---|
669 | }
|
---|
670 |
|
---|
671 | return TRUE;
|
---|
672 | }
|
---|
673 |
|
---|
674 |
|
---|
675 | /************************************************************************
|
---|
676 | * UITOOLS_DFC_ButtonChcek
|
---|
677 | *
|
---|
678 | * Draw a check/3state button coming from DrawFrameControl()
|
---|
679 | *
|
---|
680 | * Does a pretty good job in emulating MS behavior. Some quirks are
|
---|
681 | * however there because MS uses a TrueType font (Marlett) to draw
|
---|
682 | * the buttons.
|
---|
683 | */
|
---|
684 | #define DFC_CHECKPOINTSMAX 6
|
---|
685 |
|
---|
686 | static BOOL UITOOLS95_DFC_ButtonCheck(HDC dc, LPRECT r, UINT uFlags)
|
---|
687 | {
|
---|
688 | RECT myr;
|
---|
689 | int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
|
---|
690 | int BorderShrink = SmallDiam / 16;
|
---|
691 |
|
---|
692 | if(BorderShrink < 1) BorderShrink = 1;
|
---|
693 |
|
---|
694 | /* FIXME: The FillRect() sequence doesn't work for sizes less than */
|
---|
695 | /* 4 pixels in diameter. Not really a problem but it isn't M$'s */
|
---|
696 | /* 100% equivalent. */
|
---|
697 | if(uFlags & (DFCS_FLAT|DFCS_MONO))
|
---|
698 | {
|
---|
699 | FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOWFRAME));
|
---|
700 | myr.left += 2 * BorderShrink;
|
---|
701 | myr.right -= 2 * BorderShrink;
|
---|
702 | myr.top += 2 * BorderShrink;
|
---|
703 | myr.bottom -= 2 * BorderShrink;
|
---|
704 | }
|
---|
705 | else
|
---|
706 | {
|
---|
707 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
|
---|
708 | myr.right -= BorderShrink;
|
---|
709 | myr.bottom -= BorderShrink;
|
---|
710 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNSHADOW));
|
---|
711 | myr.left += BorderShrink;
|
---|
712 | myr.top += BorderShrink;
|
---|
713 | FillRect(dc, &myr, GetSysColorBrush(COLOR_3DLIGHT));
|
---|
714 | myr.right -= BorderShrink;
|
---|
715 | myr.bottom -= BorderShrink;
|
---|
716 | FillRect(dc, &myr, GetSysColorBrush(COLOR_3DDKSHADOW));
|
---|
717 | myr.left += BorderShrink;
|
---|
718 | myr.top += BorderShrink;
|
---|
719 | }
|
---|
720 |
|
---|
721 | if(uFlags & (DFCS_INACTIVE|DFCS_PUSHED))
|
---|
722 | {
|
---|
723 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
|
---|
724 | }
|
---|
725 | else if(uFlags & DFCS_CHECKED)
|
---|
726 | {
|
---|
727 | if(GetSysColor(COLOR_BTNHIGHLIGHT) == RGB(255, 255, 255))
|
---|
728 | {
|
---|
729 | HBITMAP hbm = CreateBitmap(8, 8, 1, 1, wPattern_AA55);
|
---|
730 | HBRUSH hbsave;
|
---|
731 | HBRUSH hb = CreatePatternBrush(hbm);
|
---|
732 |
|
---|
733 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNFACE));
|
---|
734 | hbsave = (HBRUSH)SelectObject(dc, hb);
|
---|
735 | PatBlt(dc, myr.left, myr.top, myr.right-myr.left, myr.bottom-myr.top, 0x00FA0089);
|
---|
736 | SelectObject(dc, hbsave);
|
---|
737 | DeleteObject(hb);
|
---|
738 | DeleteObject(hbm);
|
---|
739 | }
|
---|
740 | else
|
---|
741 | {
|
---|
742 | FillRect(dc, &myr, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
|
---|
743 | }
|
---|
744 | }
|
---|
745 | else
|
---|
746 | {
|
---|
747 | FillRect(dc, &myr, GetSysColorBrush(COLOR_WINDOW));
|
---|
748 | }
|
---|
749 |
|
---|
750 | if(uFlags & DFCS_CHECKED)
|
---|
751 | {
|
---|
752 | POINT CheckPoints[DFC_CHECKPOINTSMAX];
|
---|
753 | int i;
|
---|
754 | HBRUSH hbsave;
|
---|
755 | HPEN hpsave;
|
---|
756 |
|
---|
757 | /* FIXME: This comes very close to M$'s checkmark, but not */
|
---|
758 | /* exactly... When small or large there is a few pixels */
|
---|
759 | /* shift. Not bad, but could be better :) */
|
---|
760 | UITOOLS_MakeSquareRect(r, &myr);
|
---|
761 | CheckPoints[0].x = myr.left + 253*SmallDiam/1000;
|
---|
762 | CheckPoints[0].y = myr.top + 345*SmallDiam/1000;
|
---|
763 | CheckPoints[1].x = myr.left + 409*SmallDiam/1000;
|
---|
764 | CheckPoints[1].y = CheckPoints[0].y + (CheckPoints[1].x-CheckPoints[0].x);
|
---|
765 | CheckPoints[2].x = myr.left + 690*SmallDiam/1000;
|
---|
766 | CheckPoints[2].y = CheckPoints[1].y - (CheckPoints[2].x-CheckPoints[1].x);
|
---|
767 | CheckPoints[3].x = CheckPoints[2].x;
|
---|
768 | CheckPoints[3].y = CheckPoints[2].y + 3*SmallDiam/16;
|
---|
769 | CheckPoints[4].x = CheckPoints[1].x;
|
---|
770 | CheckPoints[4].y = CheckPoints[1].y + 3*SmallDiam/16;
|
---|
771 | CheckPoints[5].x = CheckPoints[0].x;
|
---|
772 | CheckPoints[5].y = CheckPoints[0].y + 3*SmallDiam/16;
|
---|
773 |
|
---|
774 | i = (uFlags & DFCS_INACTIVE) || (uFlags & 0xff) == DFCS_BUTTON3STATE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
|
---|
775 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
|
---|
776 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
|
---|
777 | Polygon(dc, CheckPoints, DFC_CHECKPOINTSMAX);
|
---|
778 | SelectObject(dc, hpsave);
|
---|
779 | SelectObject(dc, hbsave);
|
---|
780 | }
|
---|
781 | return TRUE;
|
---|
782 | }
|
---|
783 |
|
---|
784 |
|
---|
785 | /************************************************************************
|
---|
786 | * UITOOLS_DFC_ButtonRadio
|
---|
787 | *
|
---|
788 | * Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
|
---|
789 | *
|
---|
790 | * Does a pretty good job in emulating MS behavior. Some quirks are
|
---|
791 | * however there because MS uses a TrueType font (Marlett) to draw
|
---|
792 | * the buttons.
|
---|
793 | */
|
---|
794 | static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
|
---|
795 | {
|
---|
796 | RECT myr;
|
---|
797 | int i;
|
---|
798 | int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
|
---|
799 | int BorderShrink = SmallDiam / 16;
|
---|
800 | HPEN hpsave;
|
---|
801 | HBRUSH hbsave;
|
---|
802 | int xe, ye;
|
---|
803 | int xc, yc;
|
---|
804 |
|
---|
805 | if(BorderShrink < 1) BorderShrink = 1;
|
---|
806 |
|
---|
807 | if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
|
---|
808 | {
|
---|
809 | FillRect(dc, r, (HBRUSH)GetStockObject(BLACK_BRUSH));
|
---|
810 | }
|
---|
811 |
|
---|
812 | xe = myr.left;
|
---|
813 | ye = myr.top + SmallDiam - SmallDiam/2;
|
---|
814 |
|
---|
815 | xc = myr.left + SmallDiam - SmallDiam/2;
|
---|
816 | yc = myr.top + SmallDiam - SmallDiam/2;
|
---|
817 |
|
---|
818 | /* Define bounding box */
|
---|
819 | i = 14*SmallDiam/16;
|
---|
820 | myr.left = xc - i+i/2;
|
---|
821 | myr.right = xc + i/2;
|
---|
822 | myr.top = yc - i+i/2;
|
---|
823 | myr.bottom = yc + i/2;
|
---|
824 |
|
---|
825 | if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
|
---|
826 | {
|
---|
827 | hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
|
---|
828 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
|
---|
829 | SelectObject(dc, hbsave);
|
---|
830 | }
|
---|
831 | else
|
---|
832 | {
|
---|
833 | if(uFlags & (DFCS_FLAT|DFCS_MONO))
|
---|
834 | {
|
---|
835 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_WINDOWFRAME));
|
---|
836 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
|
---|
837 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
|
---|
838 | SelectObject(dc, hbsave);
|
---|
839 | SelectObject(dc, hpsave);
|
---|
840 | }
|
---|
841 | else
|
---|
842 | {
|
---|
843 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
|
---|
844 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
|
---|
845 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
|
---|
846 |
|
---|
847 | SelectObject(dc, GetSysColorPen(COLOR_BTNSHADOW));
|
---|
848 | SelectObject(dc, GetSysColorBrush(COLOR_BTNSHADOW));
|
---|
849 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
|
---|
850 |
|
---|
851 | myr.left += BorderShrink;
|
---|
852 | myr.right -= BorderShrink;
|
---|
853 | myr.top += BorderShrink;
|
---|
854 | myr.bottom -= BorderShrink;
|
---|
855 |
|
---|
856 | SelectObject(dc, GetSysColorPen(COLOR_3DLIGHT));
|
---|
857 | SelectObject(dc, GetSysColorBrush(COLOR_3DLIGHT));
|
---|
858 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.left-1, myr.bottom, myr.right-1, myr.top);
|
---|
859 |
|
---|
860 | SelectObject(dc, GetSysColorPen(COLOR_3DDKSHADOW));
|
---|
861 | SelectObject(dc, GetSysColorBrush(COLOR_3DDKSHADOW));
|
---|
862 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, myr.right+1, myr.top, myr.left+1, myr.bottom);
|
---|
863 | SelectObject(dc, hbsave);
|
---|
864 | SelectObject(dc, hpsave);
|
---|
865 | }
|
---|
866 |
|
---|
867 | i = 10*SmallDiam/16;
|
---|
868 | myr.left = xc - i+i/2;
|
---|
869 | myr.right = xc + i/2;
|
---|
870 | myr.top = yc - i+i/2;
|
---|
871 | myr.bottom = yc + i/2;
|
---|
872 | i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
|
---|
873 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
|
---|
874 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
|
---|
875 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
|
---|
876 | SelectObject(dc, hbsave);
|
---|
877 | SelectObject(dc, hpsave);
|
---|
878 | }
|
---|
879 |
|
---|
880 | if(uFlags & DFCS_CHECKED)
|
---|
881 | {
|
---|
882 | i = 6*SmallDiam/16;
|
---|
883 | i = i < 1 ? 1 : i;
|
---|
884 | myr.left = xc - i+i/2;
|
---|
885 | myr.right = xc + i/2;
|
---|
886 | myr.top = yc - i+i/2;
|
---|
887 | myr.bottom = yc + i/2;
|
---|
888 |
|
---|
889 | i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
|
---|
890 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
|
---|
891 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
|
---|
892 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
|
---|
893 | SelectObject(dc, hpsave);
|
---|
894 | SelectObject(dc, hbsave);
|
---|
895 | }
|
---|
896 |
|
---|
897 | /* FIXME: M$ has a polygon in the center at relative points: */
|
---|
898 | /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
|
---|
899 | /* 0.476, 0.525 */
|
---|
900 | /* 0.500, 0.500 */
|
---|
901 | /* 0.500, 0.499 */
|
---|
902 | /* when the button is unchecked. The reason for it is unknown. The */
|
---|
903 | /* color is COLOR_BTNHIGHLIGHT, although the polygon gets painted at */
|
---|
904 | /* least 3 times (it looks like a clip-region when you see it happen). */
|
---|
905 | /* I do not really see a reason why this should be implemented. If you */
|
---|
906 | /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
|
---|
907 | /* font. */
|
---|
908 |
|
---|
909 | return TRUE;
|
---|
910 | }
|
---|
911 |
|
---|
912 | /***********************************************************************
|
---|
913 | * UITOOLS_DrawFrameButton
|
---|
914 | */
|
---|
915 | static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT uState)
|
---|
916 | {
|
---|
917 | switch(uState & 0xff)
|
---|
918 | {
|
---|
919 | case DFCS_BUTTONPUSH:
|
---|
920 | return UITOOLS95_DFC_ButtonPush(hdc, rc, uState);
|
---|
921 |
|
---|
922 | case DFCS_BUTTONCHECK:
|
---|
923 | case DFCS_BUTTON3STATE:
|
---|
924 | return UITOOLS95_DFC_ButtonCheck(hdc, rc, uState);
|
---|
925 |
|
---|
926 | case DFCS_BUTTONRADIOIMAGE:
|
---|
927 | case DFCS_BUTTONRADIOMASK:
|
---|
928 | case DFCS_BUTTONRADIO:
|
---|
929 | return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
|
---|
930 |
|
---|
931 | // default:
|
---|
932 | // WARN("Invalid button state=0x%04x\n", uState);
|
---|
933 | }
|
---|
934 |
|
---|
935 | return FALSE;
|
---|
936 | }
|
---|
937 |
|
---|
938 | /***********************************************************************
|
---|
939 | * UITOOLS_DrawFrameCaption
|
---|
940 | *
|
---|
941 | * Draw caption buttons (win95), coming from DrawFrameControl()
|
---|
942 | */
|
---|
943 |
|
---|
944 | static BOOL UITOOLS95_DrawFrameCaption(HDC dc, LPRECT r, UINT uFlags)
|
---|
945 | {
|
---|
946 | POINT Line1[10];
|
---|
947 | POINT Line2[10];
|
---|
948 | int Line1N;
|
---|
949 | int Line2N;
|
---|
950 | RECT myr;
|
---|
951 | int SmallDiam = UITOOLS_MakeSquareRect(r, &myr)-2;
|
---|
952 | int i;
|
---|
953 | HBRUSH hbsave;
|
---|
954 | HPEN hpsave;
|
---|
955 | HFONT hfsave, hf;
|
---|
956 | int xc = (myr.left+myr.right)/2;
|
---|
957 | int yc = (myr.top+myr.bottom)/2;
|
---|
958 | int edge, move;
|
---|
959 | char str[2] = "?";
|
---|
960 | UINT alignsave;
|
---|
961 | int bksave;
|
---|
962 | COLORREF clrsave;
|
---|
963 | SIZE size;
|
---|
964 |
|
---|
965 | UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
|
---|
966 |
|
---|
967 | switch(uFlags & 0xff)
|
---|
968 | {
|
---|
969 | case DFCS_CAPTIONCLOSE:
|
---|
970 | edge = 328*SmallDiam/1000;
|
---|
971 | move = 95*SmallDiam/1000;
|
---|
972 | Line1[0].x = Line2[0].x = Line1[1].x = Line2[1].x = xc - edge;
|
---|
973 | Line1[2].y = Line2[5].y = Line1[1].y = Line2[4].y = yc - edge;
|
---|
974 | Line1[3].x = Line2[3].x = Line1[4].x = Line2[4].x = xc + edge;
|
---|
975 | Line1[5].y = Line2[2].y = Line1[4].y = Line2[1].y = yc + edge;
|
---|
976 | Line1[2].x = Line2[2].x = Line1[1].x + move;
|
---|
977 | Line1[0].y = Line2[3].y = Line1[1].y + move;
|
---|
978 | Line1[5].x = Line2[5].x = Line1[4].x - move;
|
---|
979 | Line1[3].y = Line2[0].y = Line1[4].y - move;
|
---|
980 | Line1N = 6;
|
---|
981 | Line2N = 6;
|
---|
982 | break;
|
---|
983 |
|
---|
984 | case DFCS_CAPTIONHELP:
|
---|
985 | /* This one breaks the flow */
|
---|
986 | /* FIXME: We need the Marlett font in order to get this right. */
|
---|
987 |
|
---|
988 | hf = CreateFontA(-SmallDiam, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
---|
989 | ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
---|
990 | DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "System");
|
---|
991 | alignsave = SetTextAlign(dc, TA_TOP|TA_LEFT);
|
---|
992 | bksave = SetBkMode(dc, TRANSPARENT);
|
---|
993 | clrsave = GetTextColor(dc);
|
---|
994 | hfsave = (HFONT)SelectObject(dc, hf);
|
---|
995 | GetTextExtentPoint32A(dc, str, 1, &size);
|
---|
996 |
|
---|
997 | if(uFlags & DFCS_INACTIVE)
|
---|
998 | {
|
---|
999 | SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
|
---|
1000 | TextOutA(dc, xc-size.cx/2+1, yc-size.cy/2+1, str, 1);
|
---|
1001 | }
|
---|
1002 | SetTextColor(dc, GetSysColor(uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
|
---|
1003 | TextOutA(dc, xc-size.cx/2, yc-size.cy/2, str, 1);
|
---|
1004 |
|
---|
1005 | SelectObject(dc, hfsave);
|
---|
1006 | SetTextColor(dc, clrsave);
|
---|
1007 | SetBkMode(dc, bksave);
|
---|
1008 | SetTextAlign(dc, alignsave);
|
---|
1009 | DeleteObject(hf);
|
---|
1010 | return TRUE;
|
---|
1011 |
|
---|
1012 | case DFCS_CAPTIONMIN:
|
---|
1013 | Line1[0].x = Line1[3].x = myr.left + 96*SmallDiam/750+2;
|
---|
1014 | Line1[1].x = Line1[2].x = Line1[0].x + 372*SmallDiam/750;
|
---|
1015 | Line1[0].y = Line1[1].y = myr.top + 563*SmallDiam/750+1;
|
---|
1016 | Line1[2].y = Line1[3].y = Line1[0].y + 92*SmallDiam/750;
|
---|
1017 | Line1N = 4;
|
---|
1018 | Line2N = 0;
|
---|
1019 | break;
|
---|
1020 |
|
---|
1021 | case DFCS_CAPTIONMAX:
|
---|
1022 | edge = 47*SmallDiam/750;
|
---|
1023 | Line1[0].x = Line1[5].x = myr.left + 57*SmallDiam/750+3;
|
---|
1024 | Line1[0].y = Line1[1].y = myr.top + 143*SmallDiam/750+1;
|
---|
1025 | Line1[1].x = Line1[2].x = Line1[0].x + 562*SmallDiam/750;
|
---|
1026 | Line1[5].y = Line1[4].y = Line1[0].y + 93*SmallDiam/750;
|
---|
1027 | Line1[2].y = Line1[3].y = Line1[0].y + 513*SmallDiam/750;
|
---|
1028 | Line1[3].x = Line1[4].x = Line1[1].x - edge;
|
---|
1029 |
|
---|
1030 | Line2[0].x = Line2[5].x = Line1[0].x;
|
---|
1031 | Line2[3].x = Line2[4].x = Line1[1].x;
|
---|
1032 | Line2[1].x = Line2[2].x = Line1[0].x + edge;
|
---|
1033 | Line2[0].y = Line2[1].y = Line1[0].y;
|
---|
1034 | Line2[4].y = Line2[5].y = Line1[2].y;
|
---|
1035 | Line2[2].y = Line2[3].y = Line1[2].y - edge;
|
---|
1036 | Line1N = 6;
|
---|
1037 | Line2N = 6;
|
---|
1038 | break;
|
---|
1039 |
|
---|
1040 | case DFCS_CAPTIONRESTORE:
|
---|
1041 | /* FIXME: this one looks bad at small sizes < 15x15 :( */
|
---|
1042 | edge = 47*SmallDiam/750;
|
---|
1043 | move = 420*SmallDiam/750;
|
---|
1044 | Line1[0].x = Line1[9].x = myr.left + 198*SmallDiam/750+2;
|
---|
1045 | Line1[0].y = Line1[1].y = myr.top + 169*SmallDiam/750+1;
|
---|
1046 | Line1[6].y = Line1[7].y = Line1[0].y + 93*SmallDiam/750;
|
---|
1047 | Line1[7].x = Line1[8].x = Line1[0].x + edge;
|
---|
1048 | Line1[1].x = Line1[2].x = Line1[0].x + move;
|
---|
1049 | Line1[5].x = Line1[6].x = Line1[1].x - edge;
|
---|
1050 | Line1[9].y = Line1[8].y = Line1[0].y + 187*SmallDiam/750;
|
---|
1051 | Line1[2].y = Line1[3].y = Line1[0].y + 327*SmallDiam/750;
|
---|
1052 | Line1[4].y = Line1[5].y = Line1[2].y - edge;
|
---|
1053 | Line1[3].x = Line1[4].x = Line1[2].x - 140*SmallDiam/750;
|
---|
1054 |
|
---|
1055 | Line2[1].x = Line2[2].x = Line1[3].x;
|
---|
1056 | Line2[7].x = Line2[8].x = Line2[1].x - edge;
|
---|
1057 | Line2[0].x = Line2[9].x = Line2[3].x = Line2[4].x = Line2[1].x - move;
|
---|
1058 | Line2[5].x = Line2[6].x = Line2[0].x + edge;
|
---|
1059 | Line2[0].y = Line2[1].y = Line1[9].y;
|
---|
1060 | Line2[4].y = Line2[5].y = Line2[8].y = Line2[9].y = Line2[0].y + 93*SmallDiam/750;
|
---|
1061 | Line2[2].y = Line2[3].y = Line2[0].y + 327*SmallDiam/750;
|
---|
1062 | Line2[6].y = Line2[7].y = Line2[2].y - edge;
|
---|
1063 | Line1N = 10;
|
---|
1064 | Line2N = 10;
|
---|
1065 | break;
|
---|
1066 |
|
---|
1067 | default:
|
---|
1068 | // WARN("Invalid caption; flags=0x%04x\n", uFlags);
|
---|
1069 | return FALSE;
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | /* Here the drawing takes place */
|
---|
1073 | if(uFlags & DFCS_INACTIVE)
|
---|
1074 | {
|
---|
1075 | /* If we have an inactive button, then you see a shadow */
|
---|
1076 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
|
---|
1077 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
|
---|
1078 | Polygon(dc, Line1, Line1N);
|
---|
1079 | if(Line2N > 0)
|
---|
1080 | Polygon(dc, Line2, Line2N);
|
---|
1081 | SelectObject(dc, hpsave);
|
---|
1082 | SelectObject(dc, hbsave);
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | /* Correct for the shadow shift */
|
---|
1086 | for(i = 0; i < Line1N; i++)
|
---|
1087 | {
|
---|
1088 | Line1[i].x--;
|
---|
1089 | Line1[i].y--;
|
---|
1090 | }
|
---|
1091 | for(i = 0; i < Line2N; i++)
|
---|
1092 | {
|
---|
1093 | Line2[i].x--;
|
---|
1094 | Line2[i].y--;
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 | /* Make the final picture */
|
---|
1098 | i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
|
---|
1099 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
|
---|
1100 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
|
---|
1101 |
|
---|
1102 | Polygon(dc, Line1, Line1N);
|
---|
1103 | if(Line2N > 0)
|
---|
1104 | Polygon(dc, Line2, Line2N);
|
---|
1105 | SelectObject(dc, hpsave);
|
---|
1106 | SelectObject(dc, hbsave);
|
---|
1107 |
|
---|
1108 | return TRUE;
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 |
|
---|
1112 | /************************************************************************
|
---|
1113 | * UITOOLS_DrawFrameScroll
|
---|
1114 | *
|
---|
1115 | * Draw a scroll-bar control coming from DrawFrameControl()
|
---|
1116 | */
|
---|
1117 | static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags)
|
---|
1118 | {
|
---|
1119 | POINT Line[4];
|
---|
1120 | RECT myr;
|
---|
1121 | int SmallDiam = UITOOLS_MakeSquareRect(r, &myr) - 2;
|
---|
1122 | int i;
|
---|
1123 | HBRUSH hbsave, hb, hb2;
|
---|
1124 | HPEN hpsave, hp, hp2;
|
---|
1125 | int tri = 310*SmallDiam/1000;
|
---|
1126 | int d46, d93;
|
---|
1127 |
|
---|
1128 | switch(uFlags & 0xff)
|
---|
1129 | {
|
---|
1130 | case DFCS_SCROLLCOMBOBOX:
|
---|
1131 | case DFCS_SCROLLDOWN:
|
---|
1132 | Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
|
---|
1133 | Line[2].y = myr.top + 687*SmallDiam/1000 + 1;
|
---|
1134 | Line[0].x = Line[2].x - tri;
|
---|
1135 | Line[1].x = Line[2].x + tri;
|
---|
1136 | Line[0].y = Line[1].y = Line[2].y - tri;
|
---|
1137 | break;
|
---|
1138 |
|
---|
1139 | case DFCS_SCROLLUP:
|
---|
1140 | Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
|
---|
1141 | Line[2].y = myr.top + 313*SmallDiam/1000 + 1;
|
---|
1142 | Line[0].x = Line[2].x - tri;
|
---|
1143 | Line[1].x = Line[2].x + tri;
|
---|
1144 | Line[0].y = Line[1].y = Line[2].y + tri;
|
---|
1145 | break;
|
---|
1146 |
|
---|
1147 | case DFCS_SCROLLLEFT:
|
---|
1148 | Line[2].x = myr.left + 313*SmallDiam/1000 + 1;
|
---|
1149 | Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
|
---|
1150 | Line[0].y = Line[2].y - tri;
|
---|
1151 | Line[1].y = Line[2].y + tri;
|
---|
1152 | Line[0].x = Line[1].x = Line[2].x + tri;
|
---|
1153 | break;
|
---|
1154 |
|
---|
1155 | case DFCS_SCROLLRIGHT:
|
---|
1156 | Line[2].x = myr.left + 687*SmallDiam/1000 + 1;
|
---|
1157 | Line[2].y = myr.top + 470*SmallDiam/1000 + 2;
|
---|
1158 | Line[0].y = Line[2].y - tri;
|
---|
1159 | Line[1].y = Line[2].y + tri;
|
---|
1160 | Line[0].x = Line[1].x = Line[2].x - tri;
|
---|
1161 | break;
|
---|
1162 |
|
---|
1163 | case DFCS_SCROLLSIZEGRIP:
|
---|
1164 | /* This one breaks the flow... */
|
---|
1165 | UITOOLS95_DrawRectEdge(dc, r, EDGE_BUMP, BF_MIDDLE | ((uFlags&(DFCS_MONO|DFCS_FLAT)) ? BF_MONO : 0));
|
---|
1166 | hpsave = (HPEN)SelectObject(dc, GetStockObject(NULL_PEN));
|
---|
1167 | hbsave = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH));
|
---|
1168 | if(uFlags & (DFCS_MONO|DFCS_FLAT))
|
---|
1169 | {
|
---|
1170 | hp = hp2 = GetSysColorPen(COLOR_WINDOWFRAME);
|
---|
1171 | hb = hb2 = GetSysColorBrush(COLOR_WINDOWFRAME);
|
---|
1172 | }
|
---|
1173 | else
|
---|
1174 | {
|
---|
1175 | hp = GetSysColorPen(COLOR_BTNHIGHLIGHT);
|
---|
1176 | hp2 = GetSysColorPen(COLOR_BTNSHADOW);
|
---|
1177 | hb = GetSysColorBrush(COLOR_BTNHIGHLIGHT);
|
---|
1178 | hb2 = GetSysColorBrush(COLOR_BTNSHADOW);
|
---|
1179 | }
|
---|
1180 | Line[0].x = Line[1].x = r->right-1;
|
---|
1181 | Line[2].y = Line[3].y = r->bottom-1;
|
---|
1182 | d46 = 46*SmallDiam/750;
|
---|
1183 | d93 = 93*SmallDiam/750;
|
---|
1184 |
|
---|
1185 | i = 586*SmallDiam/750;
|
---|
1186 | Line[0].y = r->bottom - i - 1;
|
---|
1187 | Line[3].x = r->right - i - 1;
|
---|
1188 | Line[1].y = Line[0].y + d46;
|
---|
1189 | Line[2].x = Line[3].x + d46;
|
---|
1190 | SelectObject(dc, hb);
|
---|
1191 | SelectObject(dc, hp);
|
---|
1192 | Polygon(dc, Line, 4);
|
---|
1193 |
|
---|
1194 | Line[1].y++; Line[2].x++;
|
---|
1195 | Line[0].y = Line[1].y + d93;
|
---|
1196 | Line[3].x = Line[2].x + d93;
|
---|
1197 | SelectObject(dc, hb2);
|
---|
1198 | SelectObject(dc, hp2);
|
---|
1199 | Polygon(dc, Line, 4);
|
---|
1200 |
|
---|
1201 | i = 398*SmallDiam/750;
|
---|
1202 | Line[0].y = r->bottom - i - 1;
|
---|
1203 | Line[3].x = r->right - i - 1;
|
---|
1204 | Line[1].y = Line[0].y + d46;
|
---|
1205 | Line[2].x = Line[3].x + d46;
|
---|
1206 | SelectObject(dc, hb);
|
---|
1207 | SelectObject(dc, hp);
|
---|
1208 | Polygon(dc, Line, 4);
|
---|
1209 |
|
---|
1210 | Line[1].y++; Line[2].x++;
|
---|
1211 | Line[0].y = Line[1].y + d93;
|
---|
1212 | Line[3].x = Line[2].x + d93;
|
---|
1213 | SelectObject(dc, hb2);
|
---|
1214 | SelectObject(dc, hp2);
|
---|
1215 | Polygon(dc, Line, 4);
|
---|
1216 |
|
---|
1217 | i = 210*SmallDiam/750;
|
---|
1218 | Line[0].y = r->bottom - i - 1;
|
---|
1219 | Line[3].x = r->right - i - 1;
|
---|
1220 | Line[1].y = Line[0].y + d46;
|
---|
1221 | Line[2].x = Line[3].x + d46;
|
---|
1222 | SelectObject(dc, hb);
|
---|
1223 | SelectObject(dc, hp);
|
---|
1224 | Polygon(dc, Line, 4);
|
---|
1225 |
|
---|
1226 | Line[1].y++; Line[2].x++;
|
---|
1227 | Line[0].y = Line[1].y + d93;
|
---|
1228 | Line[3].x = Line[2].x + d93;
|
---|
1229 | SelectObject(dc, hb2);
|
---|
1230 | SelectObject(dc, hp2);
|
---|
1231 | Polygon(dc, Line, 4);
|
---|
1232 |
|
---|
1233 | SelectObject(dc, hpsave);
|
---|
1234 | SelectObject(dc, hbsave);
|
---|
1235 | return TRUE;
|
---|
1236 |
|
---|
1237 | default:
|
---|
1238 | // WARN("Invalid scroll; flags=0x%04x\n", uFlags);
|
---|
1239 | return FALSE;
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | /* Here do the real scroll-bar controls end up */
|
---|
1243 | UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
|
---|
1244 |
|
---|
1245 | if(uFlags & DFCS_INACTIVE)
|
---|
1246 | {
|
---|
1247 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
|
---|
1248 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
|
---|
1249 | Polygon(dc, Line, 3);
|
---|
1250 | SelectObject(dc, hpsave);
|
---|
1251 | SelectObject(dc, hbsave);
|
---|
1252 | }
|
---|
1253 |
|
---|
1254 | for(i = 0; i < 3; i++)
|
---|
1255 | {
|
---|
1256 | Line[i].x--;
|
---|
1257 | Line[i].y--;
|
---|
1258 | }
|
---|
1259 |
|
---|
1260 | i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
|
---|
1261 | hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
|
---|
1262 | hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
|
---|
1263 | Polygon(dc, Line, 3);
|
---|
1264 | SelectObject(dc, hpsave);
|
---|
1265 | SelectObject(dc, hbsave);
|
---|
1266 |
|
---|
1267 | return TRUE;
|
---|
1268 | }
|
---|
1269 |
|
---|
1270 | /************************************************************************
|
---|
1271 | * UITOOLS_DrawFrameMenu
|
---|
1272 | *
|
---|
1273 | * Draw a menu control coming from DrawFrameControl()
|
---|
1274 | */
|
---|
1275 | static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
|
---|
1276 | {
|
---|
1277 | POINT Points[6];
|
---|
1278 | RECT myr;
|
---|
1279 | int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
|
---|
1280 | int i;
|
---|
1281 | HBRUSH hbsave;
|
---|
1282 | HPEN hpsave;
|
---|
1283 | int xe, ye;
|
---|
1284 | int xc, yc;
|
---|
1285 | BOOL retval = TRUE;
|
---|
1286 |
|
---|
1287 | /* Using black and white seems to be utterly wrong, but win95 doesn't */
|
---|
1288 | /* use anything else. I think I tried all sys-colors to change things */
|
---|
1289 | /* without luck. It seems as if this behavior is inherited from the */
|
---|
1290 | /* win31 DFC() implementation... (you remember, B/W menus). */
|
---|
1291 |
|
---|
1292 | FillRect(dc, r, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
---|
1293 |
|
---|
1294 | hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
|
---|
1295 | hpsave = (HPEN)SelectObject(dc, GetStockObject(BLACK_PEN));
|
---|
1296 |
|
---|
1297 | switch(uFlags & 0xff)
|
---|
1298 | {
|
---|
1299 | case DFCS_MENUARROW:
|
---|
1300 | i = 187*SmallDiam/750;
|
---|
1301 | Points[2].x = myr.left + 468*SmallDiam/750;
|
---|
1302 | Points[2].y = myr.top + 352*SmallDiam/750+1;
|
---|
1303 | Points[0].y = Points[2].y - i;
|
---|
1304 | Points[1].y = Points[2].y + i;
|
---|
1305 | Points[0].x = Points[1].x = Points[2].x - i;
|
---|
1306 | Polygon(dc, Points, 3);
|
---|
1307 | break;
|
---|
1308 |
|
---|
1309 | case DFCS_MENUBULLET:
|
---|
1310 | xe = myr.left;
|
---|
1311 | ye = myr.top + SmallDiam - SmallDiam/2;
|
---|
1312 | xc = myr.left + SmallDiam - SmallDiam/2;
|
---|
1313 | yc = myr.top + SmallDiam - SmallDiam/2;
|
---|
1314 | i = 234*SmallDiam/750;
|
---|
1315 | i = i < 1 ? 1 : i;
|
---|
1316 | myr.left = xc - i+i/2;
|
---|
1317 | myr.right = xc + i/2;
|
---|
1318 | myr.top = yc - i+i/2;
|
---|
1319 | myr.bottom = yc + i/2;
|
---|
1320 | Pie(dc, myr.left, myr.top, myr.right, myr.bottom, xe, ye, xe, ye);
|
---|
1321 | break;
|
---|
1322 |
|
---|
1323 | case DFCS_MENUCHECK:
|
---|
1324 | Points[0].x = myr.left + 253*SmallDiam/1000;
|
---|
1325 | Points[0].y = myr.top + 445*SmallDiam/1000;
|
---|
1326 | Points[1].x = myr.left + 409*SmallDiam/1000;
|
---|
1327 | Points[1].y = Points[0].y + (Points[1].x-Points[0].x);
|
---|
1328 | Points[2].x = myr.left + 690*SmallDiam/1000;
|
---|
1329 | Points[2].y = Points[1].y - (Points[2].x-Points[1].x);
|
---|
1330 | Points[3].x = Points[2].x;
|
---|
1331 | Points[3].y = Points[2].y + 3*SmallDiam/16;
|
---|
1332 | Points[4].x = Points[1].x;
|
---|
1333 | Points[4].y = Points[1].y + 3*SmallDiam/16;
|
---|
1334 | Points[5].x = Points[0].x;
|
---|
1335 | Points[5].y = Points[0].y + 3*SmallDiam/16;
|
---|
1336 | Polygon(dc, Points, 6);
|
---|
1337 | break;
|
---|
1338 |
|
---|
1339 | default:
|
---|
1340 | // WARN("Invalid menu; flags=0x%04x\n", uFlags);
|
---|
1341 | retval = FALSE;
|
---|
1342 | break;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | SelectObject(dc, hpsave);
|
---|
1346 | SelectObject(dc, hbsave);
|
---|
1347 | return retval;
|
---|
1348 | }
|
---|
1349 |
|
---|
1350 | /**********************************************************************
|
---|
1351 | * DrawFrameControl (USER32.158)
|
---|
1352 | */
|
---|
1353 | BOOL WIN32API DrawFrameControl(HDC hdc, LPRECT rc, UINT uType,
|
---|
1354 | UINT uState )
|
---|
1355 | {
|
---|
1356 | /* Win95 doesn't support drawing in other mapping modes */
|
---|
1357 | if(GetMapMode(hdc) != MM_TEXT)
|
---|
1358 | return FALSE;
|
---|
1359 |
|
---|
1360 | switch(uType)
|
---|
1361 | {
|
---|
1362 | case DFC_BUTTON:
|
---|
1363 | return UITOOLS95_DrawFrameButton(hdc, rc, uState);
|
---|
1364 | case DFC_CAPTION:
|
---|
1365 | return UITOOLS95_DrawFrameCaption(hdc, rc, uState);
|
---|
1366 | case DFC_MENU:
|
---|
1367 | return UITOOLS95_DrawFrameMenu(hdc, rc, uState);
|
---|
1368 | case DFC_SCROLL:
|
---|
1369 | return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
|
---|
1370 | // default:
|
---|
1371 | // WARN("(%x,%p,%d,%x), bad type!\n",
|
---|
1372 | // hdc,rc,uType,uState );
|
---|
1373 | }
|
---|
1374 | return FALSE;
|
---|
1375 | }
|
---|