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