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