Mercurial > projects > dwt-linux
comparison dwt/widgets/Control.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | 5a30aa9820f3 |
children | f1bb3949939b |
comparison
equal
deleted
inserted
replaced
257:cc1d3de0e80b | 259:c0d810de7093 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
76 * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified. | 76 * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified. |
77 * </p><p> | 77 * </p><p> |
78 * IMPORTANT: This class is intended to be subclassed <em>only</em> | 78 * IMPORTANT: This class is intended to be subclassed <em>only</em> |
79 * within the DWT implementation. | 79 * within the DWT implementation. |
80 * </p> | 80 * </p> |
81 * | |
82 * @see <a href="http://www.eclipse.org/swt/snippets/#control">Control snippets</a> | |
83 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> | |
84 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
81 */ | 85 */ |
82 public abstract class Control : Widget, Drawable { | 86 public abstract class Control : Widget, Drawable { |
83 | 87 |
84 alias Widget.mnemonicHit mnemonicHit; | 88 alias Widget.mnemonicHit mnemonicHit; |
85 alias Widget.mnemonicMatch mnemonicMatch; | 89 alias Widget.mnemonicMatch mnemonicMatch; |
329 auto paintHandle = paintHandle (); | 333 auto paintHandle = paintHandle (); |
330 OS.gtk_widget_realize (paintHandle); | 334 OS.gtk_widget_realize (paintHandle); |
331 return OS.GTK_WIDGET_WINDOW (paintHandle); | 335 return OS.GTK_WIDGET_WINDOW (paintHandle); |
332 } | 336 } |
333 | 337 |
338 /** | |
339 * Prints the receiver and all children. | |
340 * | |
341 * @param gc the gc where the drawing occurs | |
342 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise | |
343 * | |
344 * @exception IllegalArgumentException <ul> | |
345 * <li>ERROR_NULL_ARGUMENT - if the gc is null</li> | |
346 * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li> | |
347 * </ul> | |
348 * @exception DWTException <ul> | |
349 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
350 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
351 * </ul> | |
352 * | |
353 * @since 3.4 | |
354 */ | |
334 public bool print (GC gc) { | 355 public bool print (GC gc) { |
335 checkWidget (); | 356 checkWidget (); |
336 if (gc is null) error (DWT.ERROR_NULL_ARGUMENT); | 357 if (gc is null) error (DWT.ERROR_NULL_ARGUMENT); |
337 if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); | 358 if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); |
338 auto topHandle_ = topHandle (); | 359 auto topHandle_ = topHandle (); |
968 checkWidget (); | 989 checkWidget (); |
969 if (size is null) error (DWT.ERROR_NULL_ARGUMENT); | 990 if (size is null) error (DWT.ERROR_NULL_ARGUMENT); |
970 setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); | 991 setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); |
971 } | 992 } |
972 | 993 |
994 /** | |
995 * Sets the shape of the control to the region specified | |
996 * by the argument. When the argument is null, the | |
997 * default shape of the control is restored. | |
998 * | |
999 * @param region the region that defines the shape of the control (or null) | |
1000 * | |
1001 * @exception IllegalArgumentException <ul> | |
1002 * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li> | |
1003 * </ul> | |
1004 * @exception DWTException <ul> | |
1005 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1006 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1007 * </ul> | |
1008 * | |
1009 * @since 3.4 | |
1010 */ | |
973 public void setRegion (Region region) { | 1011 public void setRegion (Region region) { |
974 checkWidget (); | 1012 checkWidget (); |
975 if ((style & DWT.NO_TRIM) is 0) return; | |
976 if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); | 1013 if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); |
977 auto window = OS.GTK_WIDGET_WINDOW (topHandle ()); | 1014 auto window = OS.GTK_WIDGET_WINDOW (topHandle ()); |
978 auto shape_region = (region is null) ? null : region.handle; | 1015 auto shape_region = (region is null) ? null : region.handle; |
979 OS.gdk_window_shape_combine_region (window, shape_region, 0, 0); | 1016 OS.gdk_window_shape_combine_region (window, shape_region, 0, 0); |
980 this.region = region; | 1017 this.region = region; |
2208 * Returns the receiver's cursor, or null if it has not been set. | 2245 * Returns the receiver's cursor, or null if it has not been set. |
2209 * <p> | 2246 * <p> |
2210 * When the mouse pointer passes over a control its appearance | 2247 * When the mouse pointer passes over a control its appearance |
2211 * is changed to match the control's cursor. | 2248 * is changed to match the control's cursor. |
2212 * </p> | 2249 * </p> |
2213 * </ul> | 2250 * |
2251 * @return the receiver's cursor or <code>null</code> | |
2252 * | |
2214 * @exception DWTException <ul> | 2253 * @exception DWTException <ul> |
2215 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 2254 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
2216 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 2255 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
2217 * </ul> | 2256 * </ul> |
2218 * | 2257 * |
2428 control = control.parent; | 2467 control = control.parent; |
2429 } | 2468 } |
2430 return result; | 2469 return result; |
2431 } | 2470 } |
2432 | 2471 |
2472 /** | |
2473 * Returns the region that defines the shape of the control, | |
2474 * or null if the control has the default shape. | |
2475 * | |
2476 * @return the region that defines the shape of the shell (or null) | |
2477 * | |
2478 * @exception DWTException <ul> | |
2479 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
2480 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2481 * </ul> | |
2482 * | |
2483 * @since 3.4 | |
2484 */ | |
2433 public Region getRegion () { | 2485 public Region getRegion () { |
2434 checkWidget (); | 2486 checkWidget (); |
2435 return region; | 2487 return region; |
2436 } | 2488 } |
2437 | 2489 |
3438 } | 3490 } |
3439 | 3491 |
3440 /** | 3492 /** |
3441 * If the argument is <code>true</code>, causes the receiver to have | 3493 * If the argument is <code>true</code>, causes the receiver to have |
3442 * all mouse events delivered to it until the method is called with | 3494 * all mouse events delivered to it until the method is called with |
3443 * <code>false</code> as the argument. | 3495 * <code>false</code> as the argument. Note that on some platforms, |
3496 * a mouse button must currently be down for capture to be assigned. | |
3444 * | 3497 * |
3445 * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it | 3498 * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it |
3446 * | 3499 * |
3447 * @exception DWTException <ul> | 3500 * @exception DWTException <ul> |
3448 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 3501 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
3561 } | 3614 } |
3562 } else { | 3615 } else { |
3563 OS.gtk_widget_realize (handle); | 3616 OS.gtk_widget_realize (handle); |
3564 auto parentHandle = parent.eventHandle (); | 3617 auto parentHandle = parent.eventHandle (); |
3565 auto window = parent.eventWindow(); | 3618 auto window = parent.eventWindow(); |
3566 Rectangle rect = getBounds (); | 3619 auto topHandle_ = topHandle (); |
3567 GdkWindowAttr attributes; | 3620 GdkWindowAttr attributes; |
3568 attributes.x = rect.x; | 3621 attributes.x = OS.GTK_WIDGET_X (topHandle_); |
3569 attributes.y = rect.y; | 3622 attributes.y = OS.GTK_WIDGET_Y (topHandle_); |
3570 attributes.width = rect.width; | 3623 attributes.width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle_); |
3571 attributes.height = rect.height; | 3624 attributes.height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle_); |
3572 attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); | 3625 attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); |
3573 attributes.wclass = OS.GDK_INPUT_ONLY; | 3626 attributes.wclass = OS.GDK_INPUT_ONLY; |
3574 attributes.window_type = OS.GDK_WINDOW_CHILD; | 3627 attributes.window_type = OS.GDK_WINDOW_CHILD; |
3575 enableWindow = OS.gdk_window_new (window, &attributes, OS.GDK_WA_X | OS.GDK_WA_Y); | 3628 enableWindow = OS.gdk_window_new (window, &attributes, OS.GDK_WA_X | OS.GDK_WA_Y); |
3576 if (enableWindow !is null) { | 3629 if (enableWindow !is null) { |
3577 auto topHandle_ = topHandle (); | |
3578 OS.gdk_window_set_user_data (enableWindow, parentHandle); | 3630 OS.gdk_window_set_user_data (enableWindow, parentHandle); |
3579 if (!OS.GDK_WINDOWING_X11 ()) { | 3631 if (!OS.GDK_WINDOWING_X11 ()) { |
3580 OS.gdk_window_raise (enableWindow); | 3632 OS.gdk_window_raise (enableWindow); |
3581 } else { | 3633 } else { |
3582 auto topWindow = OS.GTK_WIDGET_WINDOW (topHandle_); | 3634 auto topWindow = OS.GTK_WIDGET_WINDOW (topHandle_); |