Mercurial > projects > dwt-win
comparison dwt/widgets/Group.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | b4846fd3437a |
comparison
equal
deleted
inserted
replaced
212:ab60f3309436 | 213:36f5cb12e1a2 |
---|---|
205 RECT rect; | 205 RECT rect; |
206 int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE; | 206 int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE; |
207 OS.DrawText (hDC, buffer, -1, &rect, flags); | 207 OS.DrawText (hDC, buffer, -1, &rect, flags); |
208 if (newFont !is null) OS.SelectObject (hDC, oldFont); | 208 if (newFont !is null) OS.SelectObject (hDC, oldFont); |
209 OS.ReleaseDC (handle, hDC); | 209 OS.ReleaseDC (handle, hDC); |
210 size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6); | 210 int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1; |
211 size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6 + offsetY); | |
211 } | 212 } |
212 return size; | 213 return size; |
213 } | 214 } |
214 | 215 |
215 override public Rectangle computeTrim (int x, int y, int width, int height) { | 216 override public Rectangle computeTrim (int x, int y, int width, int height) { |
221 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); | 222 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); |
222 TEXTMETRIC tm; | 223 TEXTMETRIC tm; |
223 OS.GetTextMetrics (hDC, &tm); | 224 OS.GetTextMetrics (hDC, &tm); |
224 if (newFont !is null) OS.SelectObject (hDC, oldFont); | 225 if (newFont !is null) OS.SelectObject (hDC, oldFont); |
225 OS.ReleaseDC (handle, hDC); | 226 OS.ReleaseDC (handle, hDC); |
227 int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1; | |
226 trim.x -= CLIENT_INSET; | 228 trim.x -= CLIENT_INSET; |
227 trim.y -= tm.tmHeight; | 229 trim.y -= tm.tmHeight + offsetY; |
228 trim.width += CLIENT_INSET * 2; | 230 trim.width += CLIENT_INSET * 2; |
229 trim.height += tm.tmHeight + CLIENT_INSET; | 231 trim.height += tm.tmHeight + CLIENT_INSET; |
230 return trim; | 232 return trim; |
231 } | 233 } |
232 | 234 |
233 override void createHandle () { | 235 override void createHandle () { |
236 /* | |
237 * Feature in Windows. When a button is created, | |
238 * it clears the UI state for all controls in the | |
239 * shell by sending WM_CHANGEUISTATE with UIS_SET, | |
240 * UISF_HIDEACCEL and UISF_HIDEFOCUS to the parent. | |
241 * This is undocumented and unexpected. The fix | |
242 * is to ignore the WM_CHANGEUISTATE, when sent | |
243 * from CreateWindowEx(). | |
244 */ | |
245 parent.state |= IGNORE_WM_CHANGEUISTATE; | |
234 super.createHandle (); | 246 super.createHandle (); |
247 parent.state &= ~IGNORE_WM_CHANGEUISTATE; | |
235 state |= DRAW_BACKGROUND; | 248 state |= DRAW_BACKGROUND; |
236 state &= ~CANVAS; | 249 state &= ~CANVAS; |
237 } | 250 } |
238 | 251 |
239 override void enableWidget (bool enabled) { | 252 override void enableWidget (bool enabled) { |
263 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); | 276 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); |
264 TEXTMETRIC tm; | 277 TEXTMETRIC tm; |
265 OS.GetTextMetrics (hDC, &tm); | 278 OS.GetTextMetrics (hDC, &tm); |
266 if (newFont !is null) OS.SelectObject (hDC, oldFont); | 279 if (newFont !is null) OS.SelectObject (hDC, oldFont); |
267 OS.ReleaseDC (handle, hDC); | 280 OS.ReleaseDC (handle, hDC); |
268 int x = CLIENT_INSET, y = tm.tmHeight; | 281 int offsetY = OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed () ? 0 : 1; |
282 int x = CLIENT_INSET, y = tm.tmHeight + offsetY; | |
269 int width = Math.max (0, rect.right - CLIENT_INSET * 2); | 283 int width = Math.max (0, rect.right - CLIENT_INSET * 2); |
270 int height = Math.max (0, rect.bottom - y - CLIENT_INSET); | 284 int height = Math.max (0, rect.bottom - y - CLIENT_INSET); |
271 return new Rectangle (x, y, width, height); | 285 return new Rectangle (x, y, width, height); |
272 } | 286 } |
273 | 287 |
404 * Normally, group boxes in Windows do not have children and | 418 * Normally, group boxes in Windows do not have children and |
405 * this is the correct behavior for this case. Because we | 419 * this is the correct behavior for this case. Because we |
406 * allow children, answer HTCLIENT to allow mouse messages | 420 * allow children, answer HTCLIENT to allow mouse messages |
407 * to be delivered to the children. | 421 * to be delivered to the children. |
408 */ | 422 */ |
409 int code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); | 423 int /*long*/ code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); |
410 if (code is OS.HTTRANSPARENT) code = OS.HTCLIENT; | 424 if (code is OS.HTTRANSPARENT) code = OS.HTCLIENT; |
411 return new LRESULT (code); | 425 return new LRESULT (code); |
412 } | 426 } |
413 | 427 |
414 override LRESULT WM_MOUSEMOVE (int wParam, int lParam) { | 428 override LRESULT WM_MOUSEMOVE (int wParam, int lParam) { |
436 * BS_GROUP, there is no problem. The fix is to save | 450 * BS_GROUP, there is no problem. The fix is to save |
437 * and restore the current font. | 451 * and restore the current font. |
438 */ | 452 */ |
439 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { | 453 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { |
440 auto nSavedDC = OS.SaveDC (cast(HDC)wParam); | 454 auto nSavedDC = OS.SaveDC (cast(HDC)wParam); |
441 int code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam); | 455 int /*long*/ code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam); |
442 OS.RestoreDC (cast(HDC)wParam, nSavedDC); | 456 OS.RestoreDC (cast(HDC)wParam, nSavedDC); |
443 return new LRESULT (code); | 457 return new LRESULT (code); |
444 } | 458 } |
445 return result; | 459 return result; |
446 } | 460 } |
465 } | 479 } |
466 if (!redraw) redraw = findBackgroundControl () !is null; | 480 if (!redraw) redraw = findBackgroundControl () !is null; |
467 } | 481 } |
468 if (redraw) { | 482 if (redraw) { |
469 OS.InvalidateRect (handle, null, false); | 483 OS.InvalidateRect (handle, null, false); |
470 int code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam); | 484 int /*long*/ code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam); |
471 return new LRESULT (code); | 485 return new LRESULT (code); |
472 } | 486 } |
473 return result; | 487 return result; |
474 } | 488 } |
475 | 489 |