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