Mercurial > projects > dwt-linux
diff dwt/widgets/Control.d @ 59:8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 12 Jan 2008 08:44:23 +0100 |
parents | a5c274fa5af9 |
children | 6537a52fde85 |
line wrap: on
line diff
--- a/dwt/widgets/Control.d Sat Jan 12 07:02:08 2008 +0100 +++ b/dwt/widgets/Control.d Sat Jan 12 08:44:23 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -76,18 +76,18 @@ * </p> */ public abstract class Control : Widget, Drawable { - GtkWidget* fixedHandle; - GdkWindow* redrawWindow; + GtkWidget* fixedHandle; + GdkWindow* redrawWindow; GdkWindow* enableWindow; - int drawCount; - Composite parent; - Cursor cursor; - Menu menu; - Image backgroundImage; - Font font; - char[] toolTipText; - Object layoutData; - Accessible accessible; + int drawCount; + Composite parent; + Cursor cursor; + Menu menu; + Image backgroundImage; + Font font; + char[] toolTipText; + Object layoutData; + Accessible accessible; this () { } @@ -121,202 +121,202 @@ * @see Widget#getStyle */ public this (Composite parent, int style) { - super (parent, style); - this.parent = parent; - createWidget (0); + super (parent, style); + this.parent = parent; + createWidget (0); } PangoFontDescription* defaultFont () { - return display.getSystemFont ().handle; + return display.getSystemFont ().handle; } override void deregister () { - super.deregister (); - if (fixedHandle !is null) display.removeWidget (fixedHandle); - auto imHandle = imHandle (); - if (imHandle !is null) display.removeWidget (cast(GtkWidget*)imHandle); + super.deregister (); + if (fixedHandle !is null) display.removeWidget (fixedHandle); + auto imHandle = imHandle (); + if (imHandle !is null) display.removeWidget (cast(GtkWidget*)imHandle); } bool drawGripper (int x, int y, int width, int height, bool vertical) { - auto paintHandle = paintHandle (); - auto window = OS.GTK_WIDGET_WINDOW (paintHandle); - if (window is null) return false; - int orientation = vertical ? OS.GTK_ORIENTATION_HORIZONTAL : OS.GTK_ORIENTATION_VERTICAL; + auto paintHandle = paintHandle (); + auto window = OS.GTK_WIDGET_WINDOW (paintHandle); + if (window is null) return false; + int orientation = vertical ? OS.GTK_ORIENTATION_HORIZONTAL : OS.GTK_ORIENTATION_VERTICAL; char dummy; - OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_OUT, null, paintHandle, &dummy, x, y, width, height, orientation); - return true; + OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_OUT, null, paintHandle, &dummy, x, y, width, height, orientation); + return true; } void enableWidget (bool enabled) { - OS.gtk_widget_set_sensitive (handle, enabled); + OS.gtk_widget_set_sensitive (handle, enabled); } GtkWidget* enterExitHandle () { - return eventHandle (); + return eventHandle (); } GtkWidget* eventHandle () { - return handle; + return handle; } GdkWindow* eventWindow () { - auto eventHandle = eventHandle (); - OS.gtk_widget_realize (eventHandle); - return OS.GTK_WIDGET_WINDOW (eventHandle); + auto eventHandle = eventHandle (); + OS.gtk_widget_realize (eventHandle); + return OS.GTK_WIDGET_WINDOW (eventHandle); } void fixFocus (Control focusControl) { - Shell shell = getShell (); - Control control = this; - while (control !is shell && (control = control.parent) !is null) { - if (control.setFocus ()) return; - } - shell.setSavedFocus (focusControl); - auto focusHandle = shell.vboxHandle; - OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); - OS.gtk_widget_grab_focus (focusHandle); - OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); + Shell shell = getShell (); + Control control = this; + while (control !is shell && (control = control.parent) !is null) { + if (control.setFocus ()) return; + } + shell.setSavedFocus (focusControl); + auto focusHandle = shell.vboxHandle; + OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); + OS.gtk_widget_grab_focus (focusHandle); + OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); } public void fixStyle () { - if (fixedHandle !is null) fixStyle (fixedHandle); + if (fixedHandle !is null) fixStyle (fixedHandle); } void fixStyle (GtkWidget* handle) { - /* - * Feature in GTK. Some GTK themes apply a different background to - * the contents of a GtkNotebook. However, in an SWT TabFolder, the - * children are not parented below the GtkNotebook widget, and usually - * have their own GtkFixed. The fix is to look up the correct style - * for a child of a GtkNotebook and apply its background to any GtkFixed - * widgets that are direct children of an SWT TabFolder. - * - * Note that this has to be when the theme settings changes and that it - * should not override the application background. - */ - if ((state & BACKGROUND) !is 0) return; - auto childStyle = parent.childStyle (); - if (childStyle !is null) { - GdkColor color; - OS.gtk_style_get_bg (childStyle, 0, &color); - OS.gtk_widget_modify_bg (handle, 0, &color); - } + /* + * Feature in GTK. Some GTK themes apply a different background to + * the contents of a GtkNotebook. However, in an SWT TabFolder, the + * children are not parented below the GtkNotebook widget, and usually + * have their own GtkFixed. The fix is to look up the correct style + * for a child of a GtkNotebook and apply its background to any GtkFixed + * widgets that are direct children of an SWT TabFolder. + * + * Note that this has to be when the theme settings changes and that it + * should not override the application background. + */ + if ((state & BACKGROUND) !is 0) return; + auto childStyle = parent.childStyle (); + if (childStyle !is null) { + GdkColor color; + OS.gtk_style_get_bg (childStyle, 0, &color); + OS.gtk_widget_modify_bg (handle, 0, &color); + } } GtkWidget* focusHandle () { - return handle; + return handle; } GtkWidget* fontHandle () { - return handle; + return handle; } bool hasFocus () { - return this is display.getFocusControl(); + return this is display.getFocusControl(); } override void hookEvents () { - /* Connect the keyboard signals */ - auto focusHandle = focusHandle (); - int focusMask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK; - OS.gtk_widget_add_events (focusHandle, focusMask); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [POPUP_MENU], 0, display.closures [POPUP_MENU], false); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [SHOW_HELP], 0, display.closures [SHOW_HELP], false); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_PRESS_EVENT], 0, display.closures [KEY_PRESS_EVENT], false); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_RELEASE_EVENT], 0, display.closures [KEY_RELEASE_EVENT], false); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS], 0, display.closures [FOCUS], false); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_IN_EVENT], 0, display.closures [FOCUS_IN_EVENT], false); - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false); - - /* Connect the mouse signals */ - auto eventHandle = eventHandle (); - int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | - OS.GDK_BUTTON_RELEASE_MASK; - OS.gtk_widget_add_events (eventHandle, eventMask); - OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false); - OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false); - OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT], false); - OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [SCROLL_EVENT], 0, display.closures [SCROLL_EVENT], false); - - /* Connect enter/exit signals */ - auto enterExitHandle = enterExitHandle (); - int enterExitMask = OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK; - OS.gtk_widget_add_events (enterExitHandle, enterExitMask); - OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false); - OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.closures [LEAVE_NOTIFY_EVENT], false); - - /* - * Feature in GTK. Events such as mouse move are propagate up - * the widget hierarchy and are seen by the parent. This is the - * correct GTK behavior but not correct for SWT. The fix is to - * hook a signal after and stop the propagation using a negative - * event number to distinguish this case. - * - * The signal is hooked to the fixedHandle to catch events sent to - * lightweight widgets. - */ - auto blockHandle = fixedHandle !is null ? fixedHandle : eventHandle; - OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT_INVERSE], true); - OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true); - OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT_INVERSE], true); - - /* Connect the event_after signal for both key and mouse */ - OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); - if (focusHandle !is eventHandle) { - OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); - } - - /* Connect the paint signal */ - auto paintHandle = paintHandle (); - int paintMask = OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK; - OS.gtk_widget_add_events (paintHandle, paintMask); - OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT_INVERSE], false); - OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [VISIBILITY_NOTIFY_EVENT], 0, display.closures [VISIBILITY_NOTIFY_EVENT], false); - OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true); - - /* Connect the Input Method signals */ - OS.g_signal_connect_closure_by_id (handle, display.signalIds [REALIZE], 0, display.closures [REALIZE], true); - OS.g_signal_connect_closure_by_id (handle, display.signalIds [UNREALIZE], 0, display.closures [UNREALIZE], false); - auto imHandle = imHandle (); - if (imHandle !is null) { - OS.g_signal_connect_closure (imHandle, OS.commit.ptr, display.closures [COMMIT], false); - OS.g_signal_connect_closure (imHandle, OS.preedit_changed.ptr, display.closures [PREEDIT_CHANGED], false); - } - - OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [STYLE_SET], 0, display.closures [STYLE_SET], false); - - auto topHandle = topHandle (); - OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true); + /* Connect the keyboard signals */ + auto focusHandle = focusHandle (); + int focusMask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK; + OS.gtk_widget_add_events (focusHandle, focusMask); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [POPUP_MENU], 0, display.closures [POPUP_MENU], false); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [SHOW_HELP], 0, display.closures [SHOW_HELP], false); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_PRESS_EVENT], 0, display.closures [KEY_PRESS_EVENT], false); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_RELEASE_EVENT], 0, display.closures [KEY_RELEASE_EVENT], false); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS], 0, display.closures [FOCUS], false); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_IN_EVENT], 0, display.closures [FOCUS_IN_EVENT], false); + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false); + + /* Connect the mouse signals */ + auto eventHandle = eventHandle (); + int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | + OS.GDK_BUTTON_RELEASE_MASK; + OS.gtk_widget_add_events (eventHandle, eventMask); + OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false); + OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false); + OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT], false); + OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [SCROLL_EVENT], 0, display.closures [SCROLL_EVENT], false); + + /* Connect enter/exit signals */ + auto enterExitHandle = enterExitHandle (); + int enterExitMask = OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK; + OS.gtk_widget_add_events (enterExitHandle, enterExitMask); + OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false); + OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.closures [LEAVE_NOTIFY_EVENT], false); + + /* + * Feature in GTK. Events such as mouse move are propagate up + * the widget hierarchy and are seen by the parent. This is the + * correct GTK behavior but not correct for SWT. The fix is to + * hook a signal after and stop the propagation using a negative + * event number to distinguish this case. + * + * The signal is hooked to the fixedHandle to catch events sent to + * lightweight widgets. + */ + auto blockHandle = fixedHandle !is null ? fixedHandle : eventHandle; + OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT_INVERSE], true); + OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true); + OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT_INVERSE], true); + + /* Connect the event_after signal for both key and mouse */ + OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); + if (focusHandle !is eventHandle) { + OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); + } + + /* Connect the paint signal */ + auto paintHandle = paintHandle (); + int paintMask = OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK; + OS.gtk_widget_add_events (paintHandle, paintMask); + OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT_INVERSE], false); + OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [VISIBILITY_NOTIFY_EVENT], 0, display.closures [VISIBILITY_NOTIFY_EVENT], false); + OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true); + + /* Connect the Input Method signals */ + OS.g_signal_connect_closure_by_id (handle, display.signalIds [REALIZE], 0, display.closures [REALIZE], true); + OS.g_signal_connect_closure_by_id (handle, display.signalIds [UNREALIZE], 0, display.closures [UNREALIZE], false); + auto imHandle = imHandle (); + if (imHandle !is null) { + OS.g_signal_connect_closure (imHandle, OS.commit.ptr, display.closures [COMMIT], false); + OS.g_signal_connect_closure (imHandle, OS.preedit_changed.ptr, display.closures [PREEDIT_CHANGED], false); + } + + OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [STYLE_SET], 0, display.closures [STYLE_SET], false); + + auto topHandle = topHandle (); + OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true); } override int /*long*/ hoverProc (GtkWidget* widget) { - int x, y; + int x, y; int mask; - OS.gdk_window_get_pointer (null, &x, &y, &mask); - sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x , y , false, mask ); - /* Always return zero in order to cancel the hover timer */ - return 0; + OS.gdk_window_get_pointer (null, &x, &y, &mask); + sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x , y , false, mask ); + /* Always return zero in order to cancel the hover timer */ + return 0; } override GtkWidget* topHandle() { - if (fixedHandle !is null) return fixedHandle; - return super.topHandle (); + if (fixedHandle !is null) return fixedHandle; + return super.topHandle (); } GtkWidget* paintHandle () { - auto topHandle = topHandle (); - auto paintHandle = handle; - while (paintHandle !is topHandle) { - if ((OS.GTK_WIDGET_FLAGS (paintHandle) & OS.GTK_NO_WINDOW) is 0) break; - paintHandle = OS.gtk_widget_get_parent (paintHandle); - } - return paintHandle; + auto topHandle = topHandle (); + auto paintHandle = handle; + while (paintHandle !is topHandle) { + if ((OS.GTK_WIDGET_FLAGS (paintHandle) & OS.GTK_NO_WINDOW) is 0) break; + paintHandle = OS.gtk_widget_get_parent (paintHandle); + } + return paintHandle; } override GdkWindow* paintWindow () { - auto paintHandle = paintHandle (); - OS.gtk_widget_realize (paintHandle); - return OS.GTK_WIDGET_WINDOW (paintHandle); + auto paintHandle = paintHandle (); + OS.gtk_widget_realize (paintHandle); + return OS.GTK_WIDGET_WINDOW (paintHandle); } /** @@ -347,87 +347,87 @@ * @see "computeTrim, getClientArea for controls that implement them" */ public Point computeSize (int wHint, int hHint) { - return computeSize (wHint, hHint, true); + return computeSize (wHint, hHint, true); } Control computeTabGroup () { - if (isTabGroup()) return this; - return parent.computeTabGroup (); + if (isTabGroup()) return this; + return parent.computeTabGroup (); } Control[] computeTabList() { - if (isTabGroup()) { - if (getVisible() && getEnabled()) { - return [this]; - } - } - return new Control[0]; + if (isTabGroup()) { + if (getVisible() && getEnabled()) { + return [this]; + } + } + return new Control[0]; } Control computeTabRoot () { - Control[] tabList = parent._getTabList(); - if (tabList !is null) { - int index = 0; - while (index < tabList.length) { - if (tabList [index] is this) break; - index++; - } - if (index is tabList.length) { - if (isTabGroup ()) return this; - } - } - return parent.computeTabRoot (); + Control[] tabList = parent._getTabList(); + if (tabList !is null) { + int index = 0; + while (index < tabList.length) { + if (tabList [index] is this) break; + index++; + } + if (index is tabList.length) { + if (isTabGroup ()) return this; + } + } + return parent.computeTabRoot (); } void checkBuffered () { - style |= SWT.DOUBLE_BUFFERED; + style |= SWT.DOUBLE_BUFFERED; } void checkBackground () { - Shell shell = getShell (); - if (this is shell) return; - state &= ~PARENT_BACKGROUND; - Composite composite = parent; - do { - int mode = composite.backgroundMode; - if (mode !is SWT.INHERIT_NONE) { - if (mode is SWT.INHERIT_DEFAULT) { - Control control = this; - do { - if ((control.state & THEME_BACKGROUND) is 0) { - return; - } - control = control.parent; - } while (control !is composite); - } - state |= PARENT_BACKGROUND; - return; - } - if (composite is shell) break; - composite = composite.parent; - } while (true); + Shell shell = getShell (); + if (this is shell) return; + state &= ~PARENT_BACKGROUND; + Composite composite = parent; + do { + int mode = composite.backgroundMode; + if (mode !is SWT.INHERIT_NONE) { + if (mode is SWT.INHERIT_DEFAULT) { + Control control = this; + do { + if ((control.state & THEME_BACKGROUND) is 0) { + return; + } + control = control.parent; + } while (control !is composite); + } + state |= PARENT_BACKGROUND; + return; + } + if (composite is shell) break; + composite = composite.parent; + } while (true); } void checkBorder () { - if (getBorderWidth () is 0) style &= ~SWT.BORDER; + if (getBorderWidth () is 0) style &= ~SWT.BORDER; } GtkStyle* childStyle () { - return parent.childStyle (); + return parent.childStyle (); } override void createWidget (int index) { - state |= DRAG_DETECT; - checkOrientation (parent); - super.createWidget (index); - checkBackground (); - if ((state & PARENT_BACKGROUND) !is 0) setBackground (); - checkBuffered (); - showWidget (); - setInitialBounds (); - setZOrder (null, false, false); - setRelations (); - checkBorder (); + state |= DRAG_DETECT; + checkOrientation (parent); + super.createWidget (index); + checkBackground (); + if ((state & PARENT_BACKGROUND) !is 0) setBackground (); + checkBuffered (); + showWidget (); + setInitialBounds (); + setZOrder (null, false, false); + setRelations (); + checkBorder (); } /** @@ -465,47 +465,47 @@ * @see "computeTrim, getClientArea for controls that implement them" */ public Point computeSize (int wHint, int hHint, bool changed) { - checkWidget(); - if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0; - if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0; - return computeNativeSize (handle, wHint, hHint, changed); + checkWidget(); + if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0; + if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0; + return computeNativeSize (handle, wHint, hHint, changed); } Point computeNativeSize (GtkWidget* h, int wHint, int hHint, bool changed) { - int width = wHint, height = hHint; - if (wHint is SWT.DEFAULT && hHint is SWT.DEFAULT) { - GtkRequisition requisition; - gtk_widget_size_request (h, &requisition); - width = OS.GTK_WIDGET_REQUISITION_WIDTH (h); - height = OS.GTK_WIDGET_REQUISITION_HEIGHT (h); - } else if (wHint is SWT.DEFAULT || hHint is SWT.DEFAULT) { - int reqWidth, reqHeight; - OS.gtk_widget_get_size_request (h, &reqWidth, &reqHeight); - OS.gtk_widget_set_size_request (h, wHint, hHint); - GtkRequisition requisition; - gtk_widget_size_request (h, &requisition); - OS.gtk_widget_set_size_request (h, reqWidth, reqHeight); - width = wHint is SWT.DEFAULT ? requisition.width : wHint; - height = hHint is SWT.DEFAULT ? requisition.height : hHint; - } - return new Point (width, height); + int width = wHint, height = hHint; + if (wHint is SWT.DEFAULT && hHint is SWT.DEFAULT) { + GtkRequisition requisition; + gtk_widget_size_request (h, &requisition); + width = OS.GTK_WIDGET_REQUISITION_WIDTH (h); + height = OS.GTK_WIDGET_REQUISITION_HEIGHT (h); + } else if (wHint is SWT.DEFAULT || hHint is SWT.DEFAULT) { + int reqWidth, reqHeight; + OS.gtk_widget_get_size_request (h, &reqWidth, &reqHeight); + OS.gtk_widget_set_size_request (h, wHint, hHint); + GtkRequisition requisition; + gtk_widget_size_request (h, &requisition); + OS.gtk_widget_set_size_request (h, reqWidth, reqHeight); + width = wHint is SWT.DEFAULT ? requisition.width : wHint; + height = hHint is SWT.DEFAULT ? requisition.height : hHint; + } + return new Point (width, height); } void forceResize () { - /* - * Force size allocation on all children of this widget's - * topHandle. Note that all calls to gtk_widget_size_allocate() - * must be preceded by a call to gtk_widget_size_request(). - */ - auto topHandle = topHandle (); - GtkRequisition requisition; - gtk_widget_size_request (topHandle, &requisition); - GtkAllocation allocation; - allocation.x = OS.GTK_WIDGET_X (topHandle); - allocation.y = OS.GTK_WIDGET_Y (topHandle); - allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); - allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); - OS.gtk_widget_size_allocate (topHandle, &allocation); + /* + * Force size allocation on all children of this widget's + * topHandle. Note that all calls to gtk_widget_size_allocate() + * must be preceded by a call to gtk_widget_size_request(). + */ + auto topHandle = topHandle (); + GtkRequisition requisition; + gtk_widget_size_request (topHandle, &requisition); + GtkAllocation allocation; + allocation.x = OS.GTK_WIDGET_X (topHandle); + allocation.y = OS.GTK_WIDGET_Y (topHandle); + allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); + allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); + OS.gtk_widget_size_allocate (topHandle, &allocation); } /** @@ -526,11 +526,11 @@ * @since 2.0 */ public Accessible getAccessible () { - checkWidget (); - if (accessible is null) { - accessible = Accessible.internal_new_Accessible (this); - } - return accessible; + checkWidget (); + if (accessible is null) { + accessible = Accessible.internal_new_Accessible (this); + } + return accessible; } /** @@ -547,13 +547,13 @@ * </ul> */ public Rectangle getBounds () { - checkWidget(); - auto topHandle = topHandle (); - int x = OS.GTK_WIDGET_X (topHandle); - int y = OS.GTK_WIDGET_Y (topHandle); - int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); - int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle); - return new Rectangle (x, y, width, height); + checkWidget(); + auto topHandle = topHandle (); + int x = OS.GTK_WIDGET_X (topHandle); + int y = OS.GTK_WIDGET_Y (topHandle); + int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); + int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle); + return new Rectangle (x, y, width, height); } /** @@ -575,9 +575,9 @@ * </ul> */ public void setBounds (Rectangle rect) { - checkWidget (); - if (rect is null) error (SWT.ERROR_NULL_ARGUMENT); - setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true); + checkWidget (); + if (rect is null) error (SWT.ERROR_NULL_ARGUMENT); + setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true); } /** @@ -604,130 +604,130 @@ * </ul> */ public void setBounds (int x, int y, int width, int height) { - checkWidget(); - setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true); + checkWidget(); + setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true); } void markLayout (bool changed, bool all) { - /* Do nothing */ + /* Do nothing */ } void moveHandle (int x, int y) { - auto topHandle = topHandle (); - auto parentHandle = parent.parentingHandle (); - /* - * Feature in GTK. Calling gtk_fixed_move() to move a child causes - * the whole parent to redraw. This is a performance problem. The - * fix is temporarily make the parent not visible during the move. - * - * NOTE: Because every widget in SWT has an X window, the new and - * old bounds of the child are correctly redrawn. - */ - int flags = OS.GTK_WIDGET_FLAGS (parentHandle); - OS.GTK_WIDGET_UNSET_FLAGS (parentHandle, OS.GTK_VISIBLE); - OS.gtk_fixed_move (cast(GtkFixed*)parentHandle, topHandle, x, y); - if ((flags & OS.GTK_VISIBLE) !is 0) { - OS.GTK_WIDGET_SET_FLAGS (parentHandle, OS.GTK_VISIBLE); - } + auto topHandle = topHandle (); + auto parentHandle = parent.parentingHandle (); + /* + * Feature in GTK. Calling gtk_fixed_move() to move a child causes + * the whole parent to redraw. This is a performance problem. The + * fix is temporarily make the parent not visible during the move. + * + * NOTE: Because every widget in SWT has an X window, the new and + * old bounds of the child are correctly redrawn. + */ + int flags = OS.GTK_WIDGET_FLAGS (parentHandle); + OS.GTK_WIDGET_UNSET_FLAGS (parentHandle, OS.GTK_VISIBLE); + OS.gtk_fixed_move (cast(GtkFixed*)parentHandle, topHandle, x, y); + if ((flags & OS.GTK_VISIBLE) !is 0) { + OS.GTK_WIDGET_SET_FLAGS (parentHandle, OS.GTK_VISIBLE); + } } void resizeHandle (int width, int height) { - auto topHandle = topHandle (); - OS.gtk_widget_set_size_request (topHandle, width, height); - if (topHandle !is handle) OS.gtk_widget_set_size_request (handle, width, height); + auto topHandle = topHandle (); + OS.gtk_widget_set_size_request (topHandle, width, height); + if (topHandle !is handle) OS.gtk_widget_set_size_request (handle, width, height); } int setBounds (int x, int y, int width, int height, bool move, bool resize) { - auto topHandle = topHandle (); - bool sameOrigin = true, sameExtent = true; - if (move) { - int oldX = OS.GTK_WIDGET_X (topHandle); - int oldY = OS.GTK_WIDGET_Y (topHandle); - sameOrigin = x is oldX && y is oldY; - if (!sameOrigin) { - if (enableWindow !is null) { - OS.gdk_window_move (enableWindow, x, y); - } - moveHandle (x, y); - } - } - if (resize) { - int oldWidth = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); - int oldHeight = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle); - sameExtent = width is oldWidth && height is oldHeight; - if (!sameExtent && !(width is 0 && height is 0)) { - int newWidth = Math.max (1, width); - int newHeight = Math.max (1, height); - if (redrawWindow !is null) { - OS.gdk_window_resize (redrawWindow, newWidth, newHeight); - } - if (enableWindow !is null) { - OS.gdk_window_resize (enableWindow, newWidth, newHeight); - } - resizeHandle (newWidth, newHeight); - } - } - if (!sameOrigin || !sameExtent) { - /* - * Cause a size allocation this widget's topHandle. Note that - * all calls to gtk_widget_size_allocate() must be preceded by - * a call to gtk_widget_size_request(). - */ - GtkRequisition requisition; - gtk_widget_size_request (topHandle, &requisition); - GtkAllocation allocation; - if (move) { - allocation.x = x; - allocation.y = y; - } else { - allocation.x = OS.GTK_WIDGET_X (topHandle); - allocation.y = OS.GTK_WIDGET_Y (topHandle); - } - if (resize) { - allocation.width = width; - allocation.height = height; - } else { - allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); - allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); - } - OS.gtk_widget_size_allocate (topHandle, &allocation); - } - /* - * Bug in GTK. Widgets cannot be sized smaller than 1x1. - * The fix is to hide zero-sized widgets and show them again - * when they are resized larger. - */ - if (!sameExtent) { - state = (width is 0) ? state | ZERO_WIDTH : state & ~ZERO_WIDTH; - state = (height is 0) ? state | ZERO_HEIGHT : state & ~ZERO_HEIGHT; - if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) !is 0) { - if (enableWindow !is null) { - OS.gdk_window_hide (enableWindow); - } - OS.gtk_widget_hide (topHandle); - } else { - if ((state & HIDDEN) is 0) { - if (enableWindow !is null) { - OS.gdk_window_show_unraised (enableWindow); - } - OS.gtk_widget_show (topHandle); - } - } - } - int result = 0; - if (move && !sameOrigin) { - Control control = findBackgroundControl (); - if (control !is null && control.backgroundImage !is null) { - if (isVisible ()) redrawWidget (0, 0, 0, 0, true, true, true); - } - sendEvent (SWT.Move); - result |= MOVED; - } - if (resize && !sameExtent) { - sendEvent (SWT.Resize); - result |= RESIZED; - } - return result; + auto topHandle = topHandle (); + bool sameOrigin = true, sameExtent = true; + if (move) { + int oldX = OS.GTK_WIDGET_X (topHandle); + int oldY = OS.GTK_WIDGET_Y (topHandle); + sameOrigin = x is oldX && y is oldY; + if (!sameOrigin) { + if (enableWindow !is null) { + OS.gdk_window_move (enableWindow, x, y); + } + moveHandle (x, y); + } + } + if (resize) { + int oldWidth = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); + int oldHeight = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle); + sameExtent = width is oldWidth && height is oldHeight; + if (!sameExtent && !(width is 0 && height is 0)) { + int newWidth = Math.max (1, width); + int newHeight = Math.max (1, height); + if (redrawWindow !is null) { + OS.gdk_window_resize (redrawWindow, newWidth, newHeight); + } + if (enableWindow !is null) { + OS.gdk_window_resize (enableWindow, newWidth, newHeight); + } + resizeHandle (newWidth, newHeight); + } + } + if (!sameOrigin || !sameExtent) { + /* + * Cause a size allocation this widget's topHandle. Note that + * all calls to gtk_widget_size_allocate() must be preceded by + * a call to gtk_widget_size_request(). + */ + GtkRequisition requisition; + gtk_widget_size_request (topHandle, &requisition); + GtkAllocation allocation; + if (move) { + allocation.x = x; + allocation.y = y; + } else { + allocation.x = OS.GTK_WIDGET_X (topHandle); + allocation.y = OS.GTK_WIDGET_Y (topHandle); + } + if (resize) { + allocation.width = width; + allocation.height = height; + } else { + allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); + allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); + } + OS.gtk_widget_size_allocate (topHandle, &allocation); + } + /* + * Bug in GTK. Widgets cannot be sized smaller than 1x1. + * The fix is to hide zero-sized widgets and show them again + * when they are resized larger. + */ + if (!sameExtent) { + state = (width is 0) ? state | ZERO_WIDTH : state & ~ZERO_WIDTH; + state = (height is 0) ? state | ZERO_HEIGHT : state & ~ZERO_HEIGHT; + if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) !is 0) { + if (enableWindow !is null) { + OS.gdk_window_hide (enableWindow); + } + OS.gtk_widget_hide (topHandle); + } else { + if ((state & HIDDEN) is 0) { + if (enableWindow !is null) { + OS.gdk_window_show_unraised (enableWindow); + } + OS.gtk_widget_show (topHandle); + } + } + } + int result = 0; + if (move && !sameOrigin) { + Control control = findBackgroundControl (); + if (control !is null && control.backgroundImage !is null) { + if (isVisible ()) redrawWidget (0, 0, 0, 0, true, true, true); + } + sendEvent (SWT.Move); + result |= MOVED; + } + if (resize && !sameExtent) { + sendEvent (SWT.Resize); + result |= RESIZED; + } + return result; } /** @@ -744,11 +744,11 @@ * </ul> */ public Point getLocation () { - checkWidget(); - auto topHandle = topHandle (); - int x = OS.GTK_WIDGET_X (topHandle); - int y = OS.GTK_WIDGET_Y (topHandle); - return new Point (x, y); + checkWidget(); + auto topHandle = topHandle (); + int x = OS.GTK_WIDGET_X (topHandle); + int y = OS.GTK_WIDGET_Y (topHandle); + return new Point (x, y); } /** @@ -766,9 +766,9 @@ * </ul> */ public void setLocation (Point location) { - checkWidget (); - if (location is null) error (SWT.ERROR_NULL_ARGUMENT); - setBounds (location.x, location.y, 0, 0, true, false); + checkWidget (); + if (location is null) error (SWT.ERROR_NULL_ARGUMENT); + setBounds (location.x, location.y, 0, 0, true, false); } /** @@ -787,8 +787,8 @@ * </ul> */ public void setLocation(int x, int y) { - checkWidget(); - setBounds (x, y, 0, 0, true, false); + checkWidget(); + setBounds (x, y, 0, 0, true, false); } /** @@ -805,11 +805,11 @@ * </ul> */ public Point getSize () { - checkWidget(); - auto topHandle = topHandle (); - int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); - int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle); - return new Point (width, height); + checkWidget(); + auto topHandle = topHandle (); + int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); + int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle); + return new Point (width, height); } /** @@ -831,36 +831,36 @@ * </ul> */ public void setSize (Point size) { - checkWidget (); - if (size is null) error (SWT.ERROR_NULL_ARGUMENT); - setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); + checkWidget (); + if (size is null) error (SWT.ERROR_NULL_ARGUMENT); + setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); } void setRelations () { - auto parentHandle = parent.parentingHandle (); + auto parentHandle = parent.parentingHandle (); Stdout.formatln( "setRelations {:x}", cast(uint)parentHandle ); Stdout.formatln( "showWidget gtk_container_get_children {:x}", parentHandle ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentHandle) ); - auto list = OS.gtk_container_get_children (cast(GtkContainer*)parentHandle); - if (list is null) return; - int count = OS.g_list_length (list); - if (count > 1) { - /* - * the receiver is the last item in the list, so its predecessor will - * be the second-last item in the list - */ - auto handle = cast(GtkWidget*) OS.g_list_nth_data (list, count - 2); - if (handle !is null) { - Widget widget = display.getWidget (handle); - if (widget !is null && widget !is this) { - if (auto sibling = cast(Control)widget ) { - sibling.addRelation (this); - } - } - } - } - OS.g_list_free (list); + auto list = OS.gtk_container_get_children (cast(GtkContainer*)parentHandle); + if (list is null) return; + int count = OS.g_list_length (list); + if (count > 1) { + /* + * the receiver is the last item in the list, so its predecessor will + * be the second-last item in the list + */ + auto handle = cast(GtkWidget*) OS.g_list_nth_data (list, count - 2); + if (handle !is null) { + Widget widget = display.getWidget (handle); + if (widget !is null && widget !is this) { + if (auto sibling = cast(Control)widget ) { + sibling.addRelation (this); + } + } + } + } + OS.g_list_free (list); } /** @@ -880,8 +880,8 @@ * </ul> */ public void setSize (int width, int height) { - checkWidget(); - setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true); + checkWidget(); + setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true); } /* @@ -889,7 +889,7 @@ * a layout should be read by screen readers as the recevier's label. */ bool isDescribedByLabel () { - return true; + return true; } /** @@ -913,12 +913,12 @@ * @see Composite#getChildren */ public void moveAbove (Control control) { - checkWidget(); - if (control !is null) { - if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - if (parent !is control.parent) return; - } - setZOrder (control, true, true); + checkWidget(); + if (control !is null) { + if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + if (parent !is control.parent) return; + } + setZOrder (control, true, true); } /** @@ -942,12 +942,12 @@ * @see Composite#getChildren */ public void moveBelow (Control control) { - checkWidget(); - if (control !is null) { - if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); - if (parent !is control.parent) return; - } - setZOrder (control, false, true); + checkWidget(); + if (control !is null) { + if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); + if (parent !is control.parent) return; + } + setZOrder (control, false, true); } /** @@ -963,7 +963,7 @@ * @see #computeSize(int, int, bool) */ public void pack () { - pack (true); + pack (true); } /** @@ -988,7 +988,7 @@ * @see #computeSize(int, int, bool) */ public void pack (bool changed) { - setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed)); + setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed)); } /** @@ -1002,8 +1002,8 @@ * </ul> */ public void setLayoutData (Object layoutData) { - checkWidget(); - this.layoutData = layoutData; + checkWidget(); + this.layoutData = layoutData; } /** @@ -1023,11 +1023,11 @@ * @since 2.1 */ public Point toControl (int x, int y) { - checkWidget (); - auto window = eventWindow (); - int origin_x, origin_y; - OS.gdk_window_get_origin (window, &origin_x, &origin_y); - return new Point (x - origin_x , y - origin_y ); + checkWidget (); + auto window = eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + return new Point (x - origin_x , y - origin_y ); } /** @@ -1047,9 +1047,9 @@ * </ul> */ public Point toControl (Point point) { - checkWidget (); - if (point is null) error (SWT.ERROR_NULL_ARGUMENT); - return toControl (point.x, point.y); + checkWidget (); + if (point is null) error (SWT.ERROR_NULL_ARGUMENT); + return toControl (point.x, point.y); } /** @@ -1069,11 +1069,11 @@ * @since 2.1 */ public Point toDisplay (int x, int y) { - checkWidget(); - auto window = eventWindow (); - int origin_x, origin_y; - OS.gdk_window_get_origin (window, &origin_x, &origin_y); - return new Point (origin_x + x, origin_y + y); + checkWidget(); + auto window = eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + return new Point (origin_x + x, origin_y + y); } /** @@ -1093,9 +1093,9 @@ * </ul> */ public Point toDisplay (Point point) { - checkWidget(); - if (point is null) error (SWT.ERROR_NULL_ARGUMENT); - return toDisplay (point.x, point.y); + checkWidget(); + if (point is null) error (SWT.ERROR_NULL_ARGUMENT); + return toDisplay (point.x, point.y); } /** @@ -1118,11 +1118,11 @@ * @see #removeControlListener */ public void addControlListener(ControlListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Resize,typedListener); - addListener (SWT.Move,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Resize,typedListener); + addListener (SWT.Move,typedListener); } /** @@ -1147,10 +1147,10 @@ * @since 3.3 */ public void addDragDetectListener (DragDetectListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.DragDetect,typedListener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.DragDetect,typedListener); } /** @@ -1173,11 +1173,11 @@ * @see #removeFocusListener */ public void addFocusListener(FocusListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener(SWT.FocusIn,typedListener); - addListener(SWT.FocusOut,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener(SWT.FocusIn,typedListener); + addListener(SWT.FocusOut,typedListener); } /** @@ -1200,10 +1200,10 @@ * @see #removeHelpListener */ public void addHelpListener (HelpListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Help, typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Help, typedListener); } /** @@ -1237,11 +1237,11 @@ * @see #removeKeyListener */ public void addKeyListener(KeyListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener(SWT.KeyUp,typedListener); - addListener(SWT.KeyDown,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener(SWT.KeyUp,typedListener); + addListener(SWT.KeyDown,typedListener); } /** @@ -1266,10 +1266,10 @@ * @since 3.3 */ public void addMenuDetectListener (MenuDetectListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.MenuDetect, typedListener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.MenuDetect, typedListener); } /** @@ -1292,12 +1292,12 @@ * @see #removeMouseListener */ public void addMouseListener(MouseListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener(SWT.MouseDown,typedListener); - addListener(SWT.MouseUp,typedListener); - addListener(SWT.MouseDoubleClick,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener(SWT.MouseDown,typedListener); + addListener(SWT.MouseUp,typedListener); + addListener(SWT.MouseDoubleClick,typedListener); } /** @@ -1320,10 +1320,10 @@ * @see #removeMouseMoveListener */ public void addMouseMoveListener(MouseMoveListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener(SWT.MouseMove,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener(SWT.MouseMove,typedListener); } /** @@ -1346,12 +1346,12 @@ * @see #removeMouseTrackListener */ public void addMouseTrackListener (MouseTrackListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.MouseEnter,typedListener); - addListener (SWT.MouseExit,typedListener); - addListener (SWT.MouseHover,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.MouseEnter,typedListener); + addListener (SWT.MouseExit,typedListener); + addListener (SWT.MouseHover,typedListener); } /** @@ -1376,10 +1376,10 @@ * @since 3.3 */ public void addMouseWheelListener (MouseWheelListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.MouseWheel, typedListener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.MouseWheel, typedListener); } /** @@ -1402,10 +1402,10 @@ * @see #removePaintListener */ public void addPaintListener(PaintListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener(SWT.Paint,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener(SWT.Paint,typedListener); } void addRelation (Control control) { @@ -1431,10 +1431,10 @@ * @see #removeTraverseListener */ public void addTraverseListener (TraverseListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Traverse,typedListener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Traverse,typedListener); } /** @@ -1455,11 +1455,11 @@ * @see #addControlListener */ public void removeControlListener (ControlListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.Move, listener); - eventTable.unhook (SWT.Resize, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.Move, listener); + eventTable.unhook (SWT.Resize, listener); } /** @@ -1482,10 +1482,10 @@ * @since 3.3 */ public void removeDragDetectListener(DragDetectListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.DragDetect, listener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.DragDetect, listener); } /** @@ -1506,11 +1506,11 @@ * @see #addFocusListener */ public void removeFocusListener(FocusListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.FocusIn, listener); - eventTable.unhook (SWT.FocusOut, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.FocusIn, listener); + eventTable.unhook (SWT.FocusOut, listener); } /** * Removes the listener from the collection of listeners who will @@ -1530,10 +1530,10 @@ * @see #addHelpListener */ public void removeHelpListener (HelpListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.Help, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.Help, listener); } /** * Removes the listener from the collection of listeners who will @@ -1553,11 +1553,11 @@ * @see #addKeyListener */ public void removeKeyListener(KeyListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.KeyUp, listener); - eventTable.unhook (SWT.KeyDown, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.KeyUp, listener); + eventTable.unhook (SWT.KeyDown, listener); } /** * Removes the listener from the collection of listeners who will @@ -1580,10 +1580,10 @@ * @since 3.3 */ public void removeMenuDetectListener (MenuDetectListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.MenuDetect, listener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.MenuDetect, listener); } /** * Removes the listener from the collection of listeners who will @@ -1603,12 +1603,12 @@ * @see #addMouseListener */ public void removeMouseListener (MouseListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.MouseDown, listener); - eventTable.unhook (SWT.MouseUp, listener); - eventTable.unhook (SWT.MouseDoubleClick, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.MouseDown, listener); + eventTable.unhook (SWT.MouseUp, listener); + eventTable.unhook (SWT.MouseDoubleClick, listener); } /** * Removes the listener from the collection of listeners who will @@ -1628,10 +1628,10 @@ * @see #addMouseMoveListener */ public void removeMouseMoveListener(MouseMoveListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.MouseMove, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.MouseMove, listener); } /** @@ -1652,12 +1652,12 @@ * @see #addMouseTrackListener */ public void removeMouseTrackListener(MouseTrackListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.MouseEnter, listener); - eventTable.unhook (SWT.MouseExit, listener); - eventTable.unhook (SWT.MouseHover, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.MouseEnter, listener); + eventTable.unhook (SWT.MouseExit, listener); + eventTable.unhook (SWT.MouseHover, listener); } /** @@ -1680,10 +1680,10 @@ * @since 3.3 */ public void removeMouseWheelListener (MouseWheelListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.MouseWheel, listener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.MouseWheel, listener); } /** @@ -1704,26 +1704,26 @@ * @see #addPaintListener */ public void removePaintListener(PaintListener listener) { - checkWidget(); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook(SWT.Paint, listener); + checkWidget(); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook(SWT.Paint, listener); } /* * Remove "Labelled by" relations from the receiver. */ void removeRelation () { - if (!isDescribedByLabel ()) return; /* there will not be any */ - auto accessible = OS.gtk_widget_get_accessible (handle); - if (accessible is null) return; - auto set = ATK.atk_object_ref_relation_set (accessible); - int count = ATK.atk_relation_set_get_n_relations (set); - for (int i = 0; i < count; i++) { - auto relation = ATK.atk_relation_set_get_relation (set, 0); - ATK.atk_relation_set_remove (set, relation); - } - OS.g_object_unref (set); + if (!isDescribedByLabel ()) return; /* there will not be any */ + auto accessible = OS.gtk_widget_get_accessible (handle); + if (accessible is null) return; + auto set = ATK.atk_object_ref_relation_set (accessible); + int count = ATK.atk_relation_set_get_n_relations (set); + for (int i = 0; i < count; i++) { + auto relation = ATK.atk_relation_set_get_relation (set, 0); + ATK.atk_relation_set_remove (set, relation); + } + OS.g_object_unref (set); } /** @@ -1744,10 +1744,10 @@ * @see #addTraverseListener */ public void removeTraverseListener(TraverseListener listener) { - checkWidget (); - if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable is null) return; - eventTable.unhook (SWT.Traverse, listener); + checkWidget (); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; + eventTable.unhook (SWT.Traverse, listener); } /** @@ -1787,9 +1787,9 @@ * @since 3.3 */ public bool dragDetect (Event event) { - checkWidget (); - if (event is null) error (SWT.ERROR_NULL_ARGUMENT); - return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); + checkWidget (); + if (event is null) error (SWT.ERROR_NULL_ARGUMENT); + return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); } /** @@ -1829,107 +1829,107 @@ * @since 3.3 */ public bool dragDetect (MouseEvent event) { - checkWidget (); - if (event is null) error (SWT.ERROR_NULL_ARGUMENT); - return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); + checkWidget (); + if (event is null) error (SWT.ERROR_NULL_ARGUMENT); + return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); } bool dragDetect (int button, int count, int stateMask, int x, int y) { - if (button !is 1 || count !is 1) return false; - if (!dragDetect (x, y, false, null)) return false; - return sendDragEvent (button, stateMask, x, y, true); + if (button !is 1 || count !is 1) return false; + if (!dragDetect (x, y, false, null)) return false; + return sendDragEvent (button, stateMask, x, y, true); } bool dragDetect (int x, int y, bool filter, bool* consume) { - bool quit = false, dragging = false; - while (!quit) { - GdkEvent* eventPtr; - while (true) { - eventPtr = OS.gdk_event_get (); - if (eventPtr !is null) { - break; - } else { - try {Thread.sleep(0.050);} catch (Exception ex) {} - } - } - switch (cast(int)OS.GDK_EVENT_TYPE (eventPtr)) { - case OS.GDK_MOTION_NOTIFY: { - GdkEventMotion* gdkMotionEvent = cast(GdkEventMotion*)eventPtr; - if ((gdkMotionEvent.state & OS.GDK_BUTTON1_MASK) !is 0) { - if (OS.gtk_drag_check_threshold (handle, x, y, cast(int) gdkMotionEvent.x, cast(int) gdkMotionEvent.y)) { - dragging = true; - quit = true; - } - } else { - quit = true; - } - int newX, newY; - OS.gdk_window_get_pointer (gdkMotionEvent.window, &newX, &newY, null); - break; - } - case OS.GDK_KEY_PRESS: - case OS.GDK_KEY_RELEASE: { - GdkEventKey* gdkEvent = cast(GdkEventKey*)eventPtr; - if (gdkEvent.keyval is OS.GDK_Escape) quit = true; - break; - } - case OS.GDK_BUTTON_RELEASE: - case OS.GDK_BUTTON_PRESS: - case OS.GDK_2BUTTON_PRESS: - case OS.GDK_3BUTTON_PRESS: { - OS.gdk_event_put (eventPtr); - quit = true; - break; - } - default: - OS.gtk_main_do_event (eventPtr); - } - OS.gdk_event_free (eventPtr); - } - return dragging; + bool quit = false, dragging = false; + while (!quit) { + GdkEvent* eventPtr; + while (true) { + eventPtr = OS.gdk_event_get (); + if (eventPtr !is null) { + break; + } else { + try {Thread.sleep(0.050);} catch (Exception ex) {} + } + } + switch (cast(int)OS.GDK_EVENT_TYPE (eventPtr)) { + case OS.GDK_MOTION_NOTIFY: { + GdkEventMotion* gdkMotionEvent = cast(GdkEventMotion*)eventPtr; + if ((gdkMotionEvent.state & OS.GDK_BUTTON1_MASK) !is 0) { + if (OS.gtk_drag_check_threshold (handle, x, y, cast(int) gdkMotionEvent.x, cast(int) gdkMotionEvent.y)) { + dragging = true; + quit = true; + } + } else { + quit = true; + } + int newX, newY; + OS.gdk_window_get_pointer (gdkMotionEvent.window, &newX, &newY, null); + break; + } + case OS.GDK_KEY_PRESS: + case OS.GDK_KEY_RELEASE: { + GdkEventKey* gdkEvent = cast(GdkEventKey*)eventPtr; + if (gdkEvent.keyval is OS.GDK_Escape) quit = true; + break; + } + case OS.GDK_BUTTON_RELEASE: + case OS.GDK_BUTTON_PRESS: + case OS.GDK_2BUTTON_PRESS: + case OS.GDK_3BUTTON_PRESS: { + OS.gdk_event_put (eventPtr); + quit = true; + break; + } + default: + OS.gtk_main_do_event (eventPtr); + } + OS.gdk_event_free (eventPtr); + } + return dragging; } bool filterKey (int keyval, GdkEventKey* event) { - auto imHandle = imHandle (); - if (imHandle !is null) { - return cast(bool)OS.gtk_im_context_filter_keypress (imHandle, event); - } - return false; + auto imHandle = imHandle (); + if (imHandle !is null) { + return cast(bool)OS.gtk_im_context_filter_keypress (imHandle, event); + } + return false; } Control findBackgroundControl () { - if ((state & BACKGROUND) !is 0 || backgroundImage !is null) return this; - return (state & PARENT_BACKGROUND) !is 0 ? parent.findBackgroundControl () : null; + if ((state & BACKGROUND) !is 0 || backgroundImage !is null) return this; + return (state & PARENT_BACKGROUND) !is 0 ? parent.findBackgroundControl () : null; } Menu [] findMenus (Control control) { - if (menu !is null && this !is control) return [menu]; - return new Menu [0]; + if (menu !is null && this !is control) return [menu]; + return new Menu [0]; } void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) { - oldShell.fixShell (newShell, this); - oldDecorations.fixDecorations (newDecorations, this, menus); + oldShell.fixShell (newShell, this); + oldDecorations.fixDecorations (newDecorations, this, menus); } override int /*long*/ fixedMapProc (GtkWidget* widget) { - OS.GTK_WIDGET_SET_FLAGS (widget, OS.GTK_MAPPED); - auto widgetList = OS.gtk_container_get_children (cast(GtkContainer*)widget); - if (widgetList !is null) { - auto widgets = widgetList; - while (widgets !is null) { - auto child = cast(GtkWidget*)OS.g_list_data (widgets); - if (OS.GTK_WIDGET_VISIBLE (child) && OS.gtk_widget_get_child_visible (child) && !OS.GTK_WIDGET_MAPPED (child)) { - OS.gtk_widget_map (child); - } - widgets = cast(GList*)OS.g_list_next (widgets); - } - OS.g_list_free (widgetList); - } - if ((OS.GTK_WIDGET_FLAGS (widget) & OS.GTK_NO_WINDOW) is 0) { - OS.gdk_window_show_unraised (OS.GTK_WIDGET_WINDOW (widget)); - } - return 0; + OS.GTK_WIDGET_SET_FLAGS (widget, OS.GTK_MAPPED); + auto widgetList = OS.gtk_container_get_children (cast(GtkContainer*)widget); + if (widgetList !is null) { + auto widgets = widgetList; + while (widgets !is null) { + auto child = cast(GtkWidget*)OS.g_list_data (widgets); + if (OS.GTK_WIDGET_VISIBLE (child) && OS.gtk_widget_get_child_visible (child) && !OS.GTK_WIDGET_MAPPED (child)) { + OS.gtk_widget_map (child); + } + widgets = cast(GList*)OS.g_list_next (widgets); + } + OS.g_list_free (widgetList); + } + if ((OS.GTK_WIDGET_FLAGS (widget) & OS.GTK_NO_WINDOW) is 0) { + OS.gdk_window_show_unraised (OS.GTK_WIDGET_WINDOW (widget)); + } + return 0; } /** @@ -1946,31 +1946,31 @@ * @see #setFocus */ public bool forceFocus () { - checkWidget(); - if (display.focusEvent is SWT.FocusOut) return false; - Shell shell = getShell (); - shell.setSavedFocus (this); - if (!isEnabled () || !isVisible ()) return false; - shell.bringToTop (false); - return forceFocus (focusHandle ()); + checkWidget(); + if (display.focusEvent is SWT.FocusOut) return false; + Shell shell = getShell (); + shell.setSavedFocus (this); + if (!isEnabled () || !isVisible ()) return false; + shell.bringToTop (false); + return forceFocus (focusHandle ()); } bool forceFocus (GtkWidget* focusHandle) { - /* When the control is zero sized it must be realized */ - OS.gtk_widget_realize (focusHandle); - OS.gtk_widget_grab_focus (focusHandle); - Shell shell = getShell (); - auto shellHandle = shell.shellHandle; - auto handle = OS.gtk_window_get_focus (cast(GtkWindow*)shellHandle); - while (handle !is null) { - if (handle is focusHandle) return true; - Widget widget = display.getWidget (handle); - if (widget !is null && (null !is cast(Control)widget)) { - return widget is this; - } - handle = OS.gtk_widget_get_parent (handle); - } - return false; + /* When the control is zero sized it must be realized */ + OS.gtk_widget_realize (focusHandle); + OS.gtk_widget_grab_focus (focusHandle); + Shell shell = getShell (); + auto shellHandle = shell.shellHandle; + auto handle = OS.gtk_window_get_focus (cast(GtkWindow*)shellHandle); + while (handle !is null) { + if (handle is focusHandle) return true; + Widget widget = display.getWidget (handle); + if (widget !is null && (null !is cast(Control)widget)) { + return widget is this; + } + handle = OS.gtk_widget_get_parent (handle); + } + return false; } /** @@ -1984,14 +1984,14 @@ * </ul> */ public Color getBackground () { - checkWidget(); - Control control = findBackgroundControl (); - if (control is null) control = this; - return Color.gtk_new (display, control.getBackgroundColor ()); + checkWidget(); + Control control = findBackgroundControl (); + if (control is null) control = this; + return Color.gtk_new (display, control.getBackgroundColor ()); } GdkColor* getBackgroundColor () { - return getBgColor (); + return getBgColor (); } /** @@ -2007,26 +2007,26 @@ * @since 3.2 */ public Image getBackgroundImage () { - checkWidget (); - Control control = findBackgroundControl (); - if (control is null) control = this; - return control.backgroundImage; + checkWidget (); + Control control = findBackgroundControl (); + if (control is null) control = this; + return control.backgroundImage; } GdkColor* getBgColor () { - auto fontHandle = fontHandle (); - OS.gtk_widget_realize (fontHandle); - GdkColor* color = new GdkColor (); - OS.gtk_style_get_bg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); - return color; + auto fontHandle = fontHandle (); + OS.gtk_widget_realize (fontHandle); + GdkColor* color = new GdkColor (); + OS.gtk_style_get_bg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); + return color; } GdkColor* getBaseColor () { - auto fontHandle = fontHandle (); - OS.gtk_widget_realize (fontHandle); - GdkColor* color = new GdkColor (); - OS.gtk_style_get_base (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); - return color; + auto fontHandle = fontHandle (); + OS.gtk_widget_realize (fontHandle); + GdkColor* color = new GdkColor (); + OS.gtk_style_get_base (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); + return color; } /** @@ -2040,8 +2040,8 @@ * </ul> */ public int getBorderWidth () { - checkWidget(); - return 0; + checkWidget(); + return 0; } /** @@ -2059,8 +2059,8 @@ * @since 3.3 */ public Cursor getCursor () { - checkWidget (); - return cursor; + checkWidget (); + return cursor; } /** @@ -2077,8 +2077,8 @@ * @since 3.3 */ public bool getDragDetect () { - checkWidget (); - return (state & DRAG_DETECT) !is 0; + checkWidget (); + return (state & DRAG_DETECT) !is 0; } /** @@ -2097,8 +2097,8 @@ * @see #isEnabled */ public bool getEnabled () { - checkWidget (); - return (state & DISABLED) is 0; + checkWidget (); + return (state & DISABLED) is 0; } /** @@ -2112,15 +2112,15 @@ * </ul> */ public Font getFont () { - checkWidget(); - if (font !is null) return font; - return Font.gtk_new (display, defaultFont ()); + checkWidget(); + if (font !is null) return font; + return Font.gtk_new (display, defaultFont ()); } PangoFontDescription* getFontDescription () { - auto fontHandle = fontHandle (); - OS.gtk_widget_realize (fontHandle); - return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle)); + auto fontHandle = fontHandle (); + OS.gtk_widget_realize (fontHandle); + return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle)); } /** @@ -2134,32 +2134,32 @@ * </ul> */ public Color getForeground () { - checkWidget(); - return Color.gtk_new (display, getForegroundColor ()); + checkWidget(); + return Color.gtk_new (display, getForegroundColor ()); } GdkColor* getForegroundColor () { - return getFgColor (); + return getFgColor (); } GdkColor* getFgColor () { - auto fontHandle = fontHandle (); - OS.gtk_widget_realize (fontHandle); - GdkColor* color = new GdkColor (); - OS.gtk_style_get_fg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); - return color; + auto fontHandle = fontHandle (); + OS.gtk_widget_realize (fontHandle); + GdkColor* color = new GdkColor (); + OS.gtk_style_get_fg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); + return color; } Point getIMCaretPos () { - return new Point (0, 0); + return new Point (0, 0); } GdkColor* getTextColor () { - auto fontHandle = fontHandle (); - OS.gtk_widget_realize (fontHandle); - GdkColor* color = new GdkColor (); - OS.gtk_style_get_text (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); - return color; + auto fontHandle = fontHandle (); + OS.gtk_widget_realize (fontHandle); + GdkColor* color = new GdkColor (); + OS.gtk_style_get_text (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); + return color; } /** @@ -2173,8 +2173,8 @@ * </ul> */ public Object getLayoutData () { - checkWidget(); - return layoutData; + checkWidget(); + return layoutData; } /** @@ -2193,8 +2193,8 @@ * </ul> */ public Menu getMenu () { - checkWidget(); - return menu; + checkWidget(); + return menu; } /** @@ -2205,36 +2205,36 @@ * @since 3.0 */ public dwt.widgets.Monitor.Monitor getMonitor () { - checkWidget(); - dwt.widgets.Monitor.Monitor monitor = null; - auto screen = OS.gdk_screen_get_default (); - if (screen !is null) { - int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, paintWindow ()); - GdkRectangle dest; - OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, &dest); - monitor = new dwt.widgets.Monitor.Monitor (); - monitor.handle = monitorNumber; - monitor.x = dest.x; - monitor.y = dest.y; - monitor.width = dest.width; - monitor.height = dest.height; - Rectangle workArea = null; - if (monitorNumber is 0) workArea = display.getWorkArea (); - if (workArea !is null) { - monitor.clientX = workArea.x; - monitor.clientY = workArea.y; - monitor.clientWidth = workArea.width; - monitor.clientHeight = workArea.height; - } else { - monitor.clientX = monitor.x; - monitor.clientY = monitor.y; - monitor.clientWidth = monitor.width; - monitor.clientHeight = monitor.height; - } - } else { - monitor = display.getPrimaryMonitor (); - } - return monitor; + checkWidget(); + dwt.widgets.Monitor.Monitor monitor = null; + auto screen = OS.gdk_screen_get_default (); + if (screen !is null) { + int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, paintWindow ()); + GdkRectangle dest; + OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, &dest); + monitor = new dwt.widgets.Monitor.Monitor (); + monitor.handle = monitorNumber; + monitor.x = dest.x; + monitor.y = dest.y; + monitor.width = dest.width; + monitor.height = dest.height; + Rectangle workArea = null; + if (monitorNumber is 0) workArea = display.getWorkArea (); + if (workArea !is null) { + monitor.clientX = workArea.x; + monitor.clientY = workArea.y; + monitor.clientWidth = workArea.width; + monitor.clientHeight = workArea.height; + } else { + monitor.clientX = monitor.x; + monitor.clientY = monitor.y; + monitor.clientWidth = monitor.width; + monitor.clientHeight = monitor.height; + } + } else { + monitor = display.getPrimaryMonitor (); + } + return monitor; } /** @@ -2250,25 +2250,25 @@ * </ul> */ public Composite getParent () { - checkWidget(); - return parent; + checkWidget(); + return parent; } Control [] getPath () { - int count = 0; - Shell shell = getShell (); - Control control = this; - while (control !is shell) { - count++; - control = control.parent; - } - control = this; - Control [] result = new Control [count]; - while (control !is shell) { - result [--count] = control; - control = control.parent; - } - return result; + int count = 0; + Shell shell = getShell (); + Control control = this; + while (control !is shell) { + count++; + control = control.parent; + } + control = this; + Control [] result = new Control [count]; + while (control !is shell) { + result [--count] = control; + control = control.parent; + } + return result; } /** @@ -2287,12 +2287,12 @@ * @see #getParent */ public Shell getShell() { - checkWidget(); - return _getShell(); + checkWidget(); + return _getShell(); } Shell _getShell() { - return parent._getShell(); + return parent._getShell(); } /** @@ -2307,8 +2307,8 @@ * </ul> */ public char[] getToolTipText () { - checkWidget(); - return toolTipText; + checkWidget(); + return toolTipText; } /** * Returns <code>true</code> if the receiver is visible, and @@ -2328,379 +2328,379 @@ * </ul> */ public bool getVisible () { - checkWidget(); - return (state & HIDDEN) is 0; + checkWidget(); + return (state & HIDDEN) is 0; } override int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* gdkEvent) { - if (gdkEvent.type is OS.GDK_3BUTTON_PRESS) return 0; - /* - * When a shell is created with SWT.ON_TOP and SWT.NO_FOCUS, - * do not activate the shell when the user clicks on the - * the client area or on the border or a control within the - * shell that does not take focus. - */ - Shell shell = _getShell (); - if (((shell.style & SWT.ON_TOP) !is 0) && (((shell.style & SWT.NO_FOCUS) is 0) || ((style & SWT.NO_FOCUS) is 0))) { - shell.forceActive(); - } - int /*long*/ result = 0; - if (gdkEvent.type is OS.GDK_BUTTON_PRESS) { - display.clickCount = 1; - auto nextEvent = OS.gdk_event_peek (); - if (nextEvent !is null) { - int eventType = OS.GDK_EVENT_TYPE (nextEvent); - if (eventType is OS.GDK_2BUTTON_PRESS) display.clickCount = 2; - if (eventType is OS.GDK_3BUTTON_PRESS) display.clickCount = 3; - OS.gdk_event_free (nextEvent); - } - bool dragging = false; - if ((state & DRAG_DETECT) !is 0 && hooks (SWT.DragDetect)) { - if (gdkEvent.button is 1) { - bool consume = false; - if (dragDetect (cast(int) gdkEvent.x, cast(int) gdkEvent.y, true, &consume)) { - dragging = true; - if (consume ) result = 1; - } - if (isDisposed ()) return 1; - } - } - if (!sendMouseEvent (SWT.MouseDown, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state)) { - result = 1; - } - if (isDisposed ()) return 1; - if (dragging) { - sendDragEvent (gdkEvent.button, gdkEvent.state, cast(int) gdkEvent.x, cast(int) gdkEvent.y, false); - if (isDisposed ()) return 1; - } - /* - * Pop up the context menu in the button press event for widgets - * that have default operating system menus in order to stop the - * operating system from displaying the menu if necessary. - */ - if ((state & MENU) !is 0) { - if (gdkEvent.button is 3) { - if (showMenu (cast(int)gdkEvent.x_root, cast(int)gdkEvent.y_root)) { - result = 1; - } - } - } - } else { - display.clickCount = 2; - result = sendMouseEvent (SWT.MouseDoubleClick, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; - if (isDisposed ()) return 1; - } - if (!shell.isDisposed ()) shell.setActiveControl (this); - return result; + if (gdkEvent.type is OS.GDK_3BUTTON_PRESS) return 0; + /* + * When a shell is created with SWT.ON_TOP and SWT.NO_FOCUS, + * do not activate the shell when the user clicks on the + * the client area or on the border or a control within the + * shell that does not take focus. + */ + Shell shell = _getShell (); + if (((shell.style & SWT.ON_TOP) !is 0) && (((shell.style & SWT.NO_FOCUS) is 0) || ((style & SWT.NO_FOCUS) is 0))) { + shell.forceActive(); + } + int /*long*/ result = 0; + if (gdkEvent.type is OS.GDK_BUTTON_PRESS) { + display.clickCount = 1; + auto nextEvent = OS.gdk_event_peek (); + if (nextEvent !is null) { + int eventType = OS.GDK_EVENT_TYPE (nextEvent); + if (eventType is OS.GDK_2BUTTON_PRESS) display.clickCount = 2; + if (eventType is OS.GDK_3BUTTON_PRESS) display.clickCount = 3; + OS.gdk_event_free (nextEvent); + } + bool dragging = false; + if ((state & DRAG_DETECT) !is 0 && hooks (SWT.DragDetect)) { + if (gdkEvent.button is 1) { + bool consume = false; + if (dragDetect (cast(int) gdkEvent.x, cast(int) gdkEvent.y, true, &consume)) { + dragging = true; + if (consume ) result = 1; + } + if (isDisposed ()) return 1; + } + } + if (!sendMouseEvent (SWT.MouseDown, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state)) { + result = 1; + } + if (isDisposed ()) return 1; + if (dragging) { + sendDragEvent (gdkEvent.button, gdkEvent.state, cast(int) gdkEvent.x, cast(int) gdkEvent.y, false); + if (isDisposed ()) return 1; + } + /* + * Pop up the context menu in the button press event for widgets + * that have default operating system menus in order to stop the + * operating system from displaying the menu if necessary. + */ + if ((state & MENU) !is 0) { + if (gdkEvent.button is 3) { + if (showMenu (cast(int)gdkEvent.x_root, cast(int)gdkEvent.y_root)) { + result = 1; + } + } + } + } else { + display.clickCount = 2; + result = sendMouseEvent (SWT.MouseDoubleClick, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + if (isDisposed ()) return 1; + } + if (!shell.isDisposed ()) shell.setActiveControl (this); + return result; } override int /*long*/ gtk_button_release_event (GtkWidget* widget, GdkEventButton* gdkEvent) { - /* - * Feature in GTK. When button 4, 5, 6, or 7 is released, GTK - * does not deliver a corresponding GTK event. Button 6 and 7 - * are mapped to buttons 4 and 5 in SWT. The fix is to change - * the button number of the event to a negative number so that - * it gets dispatched by GTK. SWT has been modified to look - * for negative button numbers. - */ - int button = gdkEvent.button; - switch (button) { - case -6: button = 4; break; - case -7: button = 5; break; + /* + * Feature in GTK. When button 4, 5, 6, or 7 is released, GTK + * does not deliver a corresponding GTK event. Button 6 and 7 + * are mapped to buttons 4 and 5 in SWT. The fix is to change + * the button number of the event to a negative number so that + * it gets dispatched by GTK. SWT has been modified to look + * for negative button numbers. + */ + int button = gdkEvent.button; + switch (button) { + case -6: button = 4; break; + case -7: button = 5; break; default: - } - return sendMouseEvent (SWT.MouseUp, button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + } + return sendMouseEvent (SWT.MouseUp, button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; } override int /*long*/ gtk_commit (GtkIMContext* imcontext, char* text) { - char [] chars = fromUtf8z( text ); + char [] chars = fromUtf8z( text ); if (chars.length is 0) return 0; - sendIMKeyEvent (SWT.KeyDown, null, chars); - return 0; + sendIMKeyEvent (SWT.KeyDown, null, chars); + return 0; } override int /*long*/ gtk_enter_notify_event (GtkWidget* widget, GdkEventCrossing* gdkEvent) { - if (display.currentControl is this) return 0; - if (gdkEvent.mode !is OS.GDK_CROSSING_NORMAL && gdkEvent.mode !is OS.GDK_CROSSING_UNGRAB) return 0; - if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) !is 0) return 0; - if (display.currentControl !is null && !display.currentControl.isDisposed ()) { - display.removeMouseHoverTimeout (display.currentControl.handle); - display.currentControl.sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state); - } - if (!isDisposed ()) { - display.currentControl = this; - return sendMouseEvent (SWT.MouseEnter, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; - } - return 0; + if (display.currentControl is this) return 0; + if (gdkEvent.mode !is OS.GDK_CROSSING_NORMAL && gdkEvent.mode !is OS.GDK_CROSSING_UNGRAB) return 0; + if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) !is 0) return 0; + if (display.currentControl !is null && !display.currentControl.isDisposed ()) { + display.removeMouseHoverTimeout (display.currentControl.handle); + display.currentControl.sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state); + } + if (!isDisposed ()) { + display.currentControl = this; + return sendMouseEvent (SWT.MouseEnter, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + } + return 0; } override int /*long*/ gtk_event_after (GtkWidget* widget, GdkEvent* gdkEvent) { - switch (cast(int)gdkEvent.type) { - case OS.GDK_BUTTON_PRESS: { - if (widget !is eventHandle ()) break; - /* - * Pop up the context menu in the event_after signal to allow - * the widget to process the button press. This allows widgets - * such as GtkTreeView to select items before a menu is shown. - */ - if ((state & MENU) is 0) { - GdkEventButton* gdkEventButton = cast(GdkEventButton*)gdkEvent; - if (gdkEventButton.button is 3) { - showMenu (cast(int) gdkEventButton.x_root, cast(int) gdkEventButton.y_root); - } - } - break; - } - case OS.GDK_FOCUS_CHANGE: { - if (widget !is focusHandle ()) break; - GdkEventFocus* gdkEventFocus = cast(GdkEventFocus*)gdkEvent; - - /* - * Feature in GTK. The GTK combo box popup under some window managers - * is implemented as a GTK_MENU. When it pops up, it causes the combo - * box to lose focus when focus is received for the menu. The - * fix is to check the current grab handle and see if it is a GTK_MENU - * and ignore the focus event when the menu is both shown and hidden. - */ - Display display = this.display; - if (gdkEventFocus.in_ !is 0) { - if (display.ignoreFocus) { - display.ignoreFocus = false; - break; - } - } else { - display.ignoreFocus = false; - auto grabHandle = OS.gtk_grab_get_current (); - if (grabHandle !is null) { - if (OS.G_OBJECT_TYPE ( cast(GTypeInstance*)grabHandle) is OS.GTK_TYPE_MENU ()) { - display.ignoreFocus = true; - break; - } - } - } - - sendFocusEvent (gdkEventFocus.in_ !is 0 ? SWT.FocusIn : SWT.FocusOut); - break; + switch (cast(int)gdkEvent.type) { + case OS.GDK_BUTTON_PRESS: { + if (widget !is eventHandle ()) break; + /* + * Pop up the context menu in the event_after signal to allow + * the widget to process the button press. This allows widgets + * such as GtkTreeView to select items before a menu is shown. + */ + if ((state & MENU) is 0) { + GdkEventButton* gdkEventButton = cast(GdkEventButton*)gdkEvent; + if (gdkEventButton.button is 3) { + showMenu (cast(int) gdkEventButton.x_root, cast(int) gdkEventButton.y_root); + } + } + break; + } + case OS.GDK_FOCUS_CHANGE: { + if (widget !is focusHandle ()) break; + GdkEventFocus* gdkEventFocus = cast(GdkEventFocus*)gdkEvent; + + /* + * Feature in GTK. The GTK combo box popup under some window managers + * is implemented as a GTK_MENU. When it pops up, it causes the combo + * box to lose focus when focus is received for the menu. The + * fix is to check the current grab handle and see if it is a GTK_MENU + * and ignore the focus event when the menu is both shown and hidden. + */ + Display display = this.display; + if (gdkEventFocus.in_ !is 0) { + if (display.ignoreFocus) { + display.ignoreFocus = false; + break; + } + } else { + display.ignoreFocus = false; + auto grabHandle = OS.gtk_grab_get_current (); + if (grabHandle !is null) { + if (OS.G_OBJECT_TYPE ( cast(GTypeInstance*)grabHandle) is OS.GTK_TYPE_MENU ()) { + display.ignoreFocus = true; + break; + } + } + } + + sendFocusEvent (gdkEventFocus.in_ !is 0 ? SWT.FocusIn : SWT.FocusOut); + break; default: - } - } - return 0; + } + } + return 0; } override int /*long*/ gtk_expose_event (GtkWidget* widget, GdkEventExpose* gdkEvent) { - if ((state & OBSCURED) !is 0) return 0; - if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; - Event event = new Event (); - event.count = gdkEvent.count; - event.x = gdkEvent.area.x; - event.y = gdkEvent.area.y; - event.width = gdkEvent.area.width; - event.height = gdkEvent.area.height; - GCData data = new GCData (); - data.damageRgn = gdkEvent.region; - GC gc = event.gc = GC.gtk_new (this, data); - OS.gdk_gc_set_clip_region (gc.handle, gdkEvent.region); - sendEvent (SWT.Paint, event); - gc.dispose (); - event.gc = null; - return 0; + if ((state & OBSCURED) !is 0) return 0; + if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; + Event event = new Event (); + event.count = gdkEvent.count; + event.x = gdkEvent.area.x; + event.y = gdkEvent.area.y; + event.width = gdkEvent.area.width; + event.height = gdkEvent.area.height; + GCData data = new GCData (); + data.damageRgn = gdkEvent.region; + GC gc = event.gc = GC.gtk_new (this, data); + OS.gdk_gc_set_clip_region (gc.handle, gdkEvent.region); + sendEvent (SWT.Paint, event); + gc.dispose (); + event.gc = null; + return 0; } override int /*long*/ gtk_focus (GtkWidget* widget, int directionType) { - /* Stop GTK traversal for every widget */ - return 1; + /* Stop GTK traversal for every widget */ + return 1; } override int /*long*/ gtk_focus_in_event (GtkWidget* widget, GdkEventFocus* event) { - // widget could be disposed at this point - if (handle !is null) { - Control oldControl = display.imControl; - if (oldControl !is this) { - if (oldControl !is null && !oldControl.isDisposed ()) { - auto oldIMHandle = oldControl.imHandle (); - if (oldIMHandle !is null) OS.gtk_im_context_reset (oldIMHandle); - } - } - if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { - auto imHandle = imHandle (); - if (imHandle !is null) OS.gtk_im_context_focus_in (imHandle); - } - } - return 0; + // widget could be disposed at this point + if (handle !is null) { + Control oldControl = display.imControl; + if (oldControl !is this) { + if (oldControl !is null && !oldControl.isDisposed ()) { + auto oldIMHandle = oldControl.imHandle (); + if (oldIMHandle !is null) OS.gtk_im_context_reset (oldIMHandle); + } + } + if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { + auto imHandle = imHandle (); + if (imHandle !is null) OS.gtk_im_context_focus_in (imHandle); + } + } + return 0; } override int /*long*/ gtk_focus_out_event (GtkWidget* widget, GdkEventFocus* event) { - // widget could be disposed at this point - if (handle !is null) { - if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { - auto imHandle = imHandle (); - if (imHandle !is null) { - OS.gtk_im_context_focus_out (imHandle); - } - } - } - return 0; + // widget could be disposed at this point + if (handle !is null) { + if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { + auto imHandle = imHandle (); + if (imHandle !is null) { + OS.gtk_im_context_focus_out (imHandle); + } + } + } + return 0; } override int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* gdkEvent) { - if (!hasFocus ()) return 0; - - if (translateMnemonic (gdkEvent.keyval, gdkEvent)) return 1; - // widget could be disposed at this point - if (isDisposed ()) return 0; - - if (filterKey (gdkEvent.keyval, gdkEvent)) return 1; - // widget could be disposed at this point - if (isDisposed ()) return 0; - - if (translateTraversal (gdkEvent)) return 1; - // widget could be disposed at this point - if (isDisposed ()) return 0; - return super.gtk_key_press_event (widget, gdkEvent); + if (!hasFocus ()) return 0; + + if (translateMnemonic (gdkEvent.keyval, gdkEvent)) return 1; + // widget could be disposed at this point + if (isDisposed ()) return 0; + + if (filterKey (gdkEvent.keyval, gdkEvent)) return 1; + // widget could be disposed at this point + if (isDisposed ()) return 0; + + if (translateTraversal (gdkEvent)) return 1; + // widget could be disposed at this point + if (isDisposed ()) return 0; + return super.gtk_key_press_event (widget, gdkEvent); } override int /*long*/ gtk_key_release_event (GtkWidget* widget, GdkEventKey* event) { - if (!hasFocus ()) return 0; - auto imHandle = imHandle (); - if (imHandle !is null) { - if (OS.gtk_im_context_filter_keypress (imHandle, event)) return 1; - } - return super.gtk_key_release_event (widget, event); + if (!hasFocus ()) return 0; + auto imHandle = imHandle (); + if (imHandle !is null) { + if (OS.gtk_im_context_filter_keypress (imHandle, event)) return 1; + } + return super.gtk_key_release_event (widget, event); } override int /*long*/ gtk_leave_notify_event (GtkWidget* widget, GdkEventCrossing* gdkEvent) { - if (display.currentControl !is this) return 0; - display.removeMouseHoverTimeout (handle); - int result = 0; - if (sendLeaveNotify () || display.getCursorControl () is null) { - if (gdkEvent.mode !is OS.GDK_CROSSING_NORMAL && gdkEvent.mode !is OS.GDK_CROSSING_UNGRAB) return 0; - if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) !is 0) return 0; - result = sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; - display.currentControl = null; - } - return result; + if (display.currentControl !is this) return 0; + display.removeMouseHoverTimeout (handle); + int result = 0; + if (sendLeaveNotify () || display.getCursorControl () is null) { + if (gdkEvent.mode !is OS.GDK_CROSSING_NORMAL && gdkEvent.mode !is OS.GDK_CROSSING_UNGRAB) return 0; + if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) !is 0) return 0; + result = sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + display.currentControl = null; + } + return result; } override int /*long*/ gtk_mnemonic_activate (GtkWidget* widget, int /*long*/ arg1) { - int result = 0; - auto eventPtr = OS.gtk_get_current_event (); - if (eventPtr !is null) { - GdkEventKey* keyEvent = cast(GdkEventKey*)eventPtr; - if (keyEvent.type is OS.GDK_KEY_PRESS) { - Control focusControl = display.getFocusControl (); - auto focusHandle = focusControl !is null ? focusControl.focusHandle () : null; - if (focusHandle !is null) { - display.mnemonicControl = this; - OS.gtk_widget_event (focusHandle, eventPtr); - display.mnemonicControl = null; - } - result = 1; - } - OS.gdk_event_free (eventPtr); - } - return result; + int result = 0; + auto eventPtr = OS.gtk_get_current_event (); + if (eventPtr !is null) { + GdkEventKey* keyEvent = cast(GdkEventKey*)eventPtr; + if (keyEvent.type is OS.GDK_KEY_PRESS) { + Control focusControl = display.getFocusControl (); + auto focusHandle = focusControl !is null ? focusControl.focusHandle () : null; + if (focusHandle !is null) { + display.mnemonicControl = this; + OS.gtk_widget_event (focusHandle, eventPtr); + display.mnemonicControl = null; + } + result = 1; + } + OS.gdk_event_free (eventPtr); + } + return result; } override int /*long*/ gtk_motion_notify_event (GtkWidget* widget, GdkEventMotion* gdkEvent) { - if (this is display.currentControl && (hooks (SWT.MouseHover) || filters (SWT.MouseHover))) { - display.addMouseHoverTimeout (handle); - } - double x = gdkEvent.x_root, y = gdkEvent.y_root; - int state = gdkEvent.state; - if (gdkEvent.is_hint !is 0) { - int pointer_x, pointer_y; + if (this is display.currentControl && (hooks (SWT.MouseHover) || filters (SWT.MouseHover))) { + display.addMouseHoverTimeout (handle); + } + double x = gdkEvent.x_root, y = gdkEvent.y_root; + int state = gdkEvent.state; + if (gdkEvent.is_hint !is 0) { + int pointer_x, pointer_y; int mask; - auto window = eventWindow (); - OS.gdk_window_get_pointer (window, &pointer_x, &pointer_y, &mask); - x = pointer_x; - y = pointer_y; - state = mask; - } - int result = sendMouseEvent (SWT.MouseMove, 0, gdkEvent.time, x, y, gdkEvent.is_hint !is 0, state) ? 0 : 1; - return result; + auto window = eventWindow (); + OS.gdk_window_get_pointer (window, &pointer_x, &pointer_y, &mask); + x = pointer_x; + y = pointer_y; + state = mask; + } + int result = sendMouseEvent (SWT.MouseMove, 0, gdkEvent.time, x, y, gdkEvent.is_hint !is 0, state) ? 0 : 1; + return result; } override int /*long*/ gtk_popup_menu (GtkWidget* widget) { - if (!hasFocus()) return 0; - int x, y ; - OS.gdk_window_get_pointer (null, &x, &y, null); - return showMenu (x, y) ? 1 : 0; + if (!hasFocus()) return 0; + int x, y ; + OS.gdk_window_get_pointer (null, &x, &y, null); + return showMenu (x, y) ? 1 : 0; } override int /*long*/ gtk_preedit_changed (GtkIMContext* imcontext) { - display.showIMWindow (this); - return 0; + display.showIMWindow (this); + return 0; } override int /*long*/ gtk_realize (GtkWidget* widget) { - auto imHandle = imHandle (); - if (imHandle !is null) { - auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); - OS.gtk_im_context_set_client_window (imHandle, window); - } - if (backgroundImage !is null) { - auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); - if (window !is null) OS.gdk_window_set_back_pixmap (window, cast(GdkPixmap*)backgroundImage.pixmap, false); - } - return 0; + auto imHandle = imHandle (); + if (imHandle !is null) { + auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); + OS.gtk_im_context_set_client_window (imHandle, window); + } + if (backgroundImage !is null) { + auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); + if (window !is null) OS.gdk_window_set_back_pixmap (window, cast(GdkPixmap*)backgroundImage.pixmap, false); + } + return 0; } override int /*long*/ gtk_scroll_event (GtkWidget* widget, GdkEventScroll* gdkEvent) { - switch (cast(int)gdkEvent.direction) { - case OS.GDK_SCROLL_UP: - return sendMouseEvent (SWT.MouseWheel, 0, 3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; - case OS.GDK_SCROLL_DOWN: - return sendMouseEvent (SWT.MouseWheel, 0, -3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; - case OS.GDK_SCROLL_LEFT: - return sendMouseEvent (SWT.MouseDown, 4, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; - case OS.GDK_SCROLL_RIGHT: - return sendMouseEvent (SWT.MouseDown, 5, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + switch (cast(int)gdkEvent.direction) { + case OS.GDK_SCROLL_UP: + return sendMouseEvent (SWT.MouseWheel, 0, 3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + case OS.GDK_SCROLL_DOWN: + return sendMouseEvent (SWT.MouseWheel, 0, -3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + case OS.GDK_SCROLL_LEFT: + return sendMouseEvent (SWT.MouseDown, 4, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; + case OS.GDK_SCROLL_RIGHT: + return sendMouseEvent (SWT.MouseDown, 5, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; default: - } - return 0; + } + return 0; } override int /*long*/ gtk_show_help (GtkWidget* widget, int /*long*/ helpType) { - if (!hasFocus ()) return 0; - return sendHelpEvent (helpType) ? 1 : 0; + if (!hasFocus ()) return 0; + return sendHelpEvent (helpType) ? 1 : 0; } override int /*long*/ gtk_style_set (GtkWidget* widget, int /*long*/ previousStyle) { - if (backgroundImage !is null) { - setBackgroundPixmap (backgroundImage.pixmap); - } - return 0; + if (backgroundImage !is null) { + setBackgroundPixmap (backgroundImage.pixmap); + } + return 0; } override int /*long*/ gtk_unrealize (GtkWidget* widget) { - auto imHandle = imHandle (); - if (imHandle !is null) OS.gtk_im_context_set_client_window (imHandle, null); - return 0; + auto imHandle = imHandle (); + if (imHandle !is null) OS.gtk_im_context_set_client_window (imHandle, null); + return 0; } override int /*long*/ gtk_visibility_notify_event (GtkWidget* widget, GdkEventVisibility* gdkEvent) { - auto paintWindow = paintWindow(); - auto window = gdkEvent.window; - if (window is paintWindow) { - if (gdkEvent.state is OS.GDK_VISIBILITY_FULLY_OBSCURED) { - state |= OBSCURED; - } else { - if ((state & OBSCURED) !is 0) { - int width, height; - OS.gdk_drawable_get_size (cast(GdkDrawable*)window, &width, &height); - GdkRectangle rect; - rect.width = width; - rect.height = height; - OS.gdk_window_invalidate_rect (window, &rect, false); - } - state &= ~OBSCURED; - } - } - return 0; + auto paintWindow = paintWindow(); + auto window = gdkEvent.window; + if (window is paintWindow) { + if (gdkEvent.state is OS.GDK_VISIBILITY_FULLY_OBSCURED) { + state |= OBSCURED; + } else { + if ((state & OBSCURED) !is 0) { + int width, height; + OS.gdk_drawable_get_size (cast(GdkDrawable*)window, &width, &height); + GdkRectangle rect; + rect.width = width; + rect.height = height; + OS.gdk_window_invalidate_rect (window, &rect, false); + } + state &= ~OBSCURED; + } + } + return 0; } /*no override*/ void gtk_widget_size_request (GtkWidget* widget, GtkRequisition* requisition) { - OS.gtk_widget_size_request (widget, requisition); + OS.gtk_widget_size_request (widget, requisition); } /** @@ -2717,29 +2717,29 @@ * @return the platform specific GC handle */ public GdkGC* internal_new_GC (GCData data) { - checkWidget (); - auto window = paintWindow (); - if (window is null) SWT.error (SWT.ERROR_NO_HANDLES); - auto gdkGC = OS.gdk_gc_new (cast(GdkDrawable*)window); - if (gdkGC is null) error (SWT.ERROR_NO_HANDLES); - if (data !is null) { - int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; - if ((data.style & mask) is 0) { - data.style |= style & (mask | SWT.MIRRORED); - } - data.drawable = cast(GdkDrawable*)window; - data.device = display; - data.foreground = getForegroundColor (); - Control control = findBackgroundControl (); - if (control is null) control = this; - data.background = control.getBackgroundColor (); - data.font = font !is null ? font.handle : defaultFont (); - } - return gdkGC; + checkWidget (); + auto window = paintWindow (); + if (window is null) SWT.error (SWT.ERROR_NO_HANDLES); + auto gdkGC = OS.gdk_gc_new (cast(GdkDrawable*)window); + if (gdkGC is null) error (SWT.ERROR_NO_HANDLES); + if (data !is null) { + int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; + if ((data.style & mask) is 0) { + data.style |= style & (mask | SWT.MIRRORED); + } + data.drawable = cast(GdkDrawable*)window; + data.device = display; + data.foreground = getForegroundColor (); + Control control = findBackgroundControl (); + if (control is null) control = this; + data.background = control.getBackgroundColor (); + data.font = font !is null ? font.handle : defaultFont (); + } + return gdkGC; } GtkIMContext* imHandle () { - return null; + return null; } /** @@ -2756,8 +2756,8 @@ * @param data the platform specific GC data */ public void internal_dispose_GC (GdkGC* gdkGC, GCData data) { - checkWidget (); - OS.g_object_unref (gdkGC); + checkWidget (); + OS.g_object_unref (gdkGC); } /** @@ -2772,45 +2772,45 @@ * </ul> */ public bool isReparentable () { - checkWidget(); - return true; + checkWidget(); + return true; } bool isShowing () { - /* - * This is not complete. Need to check if the - * widget is obscurred by a parent or sibling. - */ - if (!isVisible ()) return false; - Control control = this; - while (control !is null) { - Point size = control.getSize (); - if (size.x is 0 || size.y is 0) { - return false; - } - control = control.parent; - } - return true; + /* + * This is not complete. Need to check if the + * widget is obscurred by a parent or sibling. + */ + if (!isVisible ()) return false; + Control control = this; + while (control !is null) { + Point size = control.getSize (); + if (size.x is 0 || size.y is 0) { + return false; + } + control = control.parent; + } + return true; } bool isTabGroup () { - Control [] tabList = parent._getTabList (); - if (tabList !is null) { - for (int i=0; i<tabList.length; i++) { - if (tabList [i] is this) return true; - } - } - int code = traversalCode (0, null); - if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) !is 0) return false; - return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) !is 0; + Control [] tabList = parent._getTabList (); + if (tabList !is null) { + for (int i=0; i<tabList.length; i++) { + if (tabList [i] is this) return true; + } + } + int code = traversalCode (0, null); + if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) !is 0) return false; + return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) !is 0; } bool isTabItem () { - Control [] tabList = parent._getTabList (); - if (tabList !is null) { - for (int i=0; i<tabList.length; i++) { - if (tabList [i] is this) return false; - } - } - int code = traversalCode (0, null); - return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) !is 0; + Control [] tabList = parent._getTabList (); + if (tabList !is null) { + for (int i=0; i<tabList.length; i++) { + if (tabList [i] is this) return false; + } + } + int code = traversalCode (0, null); + return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) !is 0; } /** @@ -2830,15 +2830,15 @@ * @see #getEnabled */ public bool isEnabled () { - checkWidget (); - return getEnabled () && parent.isEnabled (); + checkWidget (); + return getEnabled () && parent.isEnabled (); } bool isFocusAncestor (Control control) { - while (control !is null && control !is this && !( null !is cast(Shell)control )) { - control = control.parent; - } - return control is this; + while (control !is null && control !is this && !( null !is cast(Shell)control )) { + control = control.parent; + } + return control is this; } /** @@ -2853,12 +2853,12 @@ * </ul> */ public bool isFocusControl () { - checkWidget(); - Control focusControl = display.focusControl; - if (focusControl !is null && !focusControl.isDisposed ()) { - return this is focusControl; - } - return hasFocus (); + checkWidget(); + Control focusControl = display.focusControl; + if (focusControl !is null && !focusControl.isDisposed ()) { + return this is focusControl; + } + return hasFocus (); } /** @@ -2876,29 +2876,29 @@ * @see #getVisible */ public bool isVisible () { - checkWidget(); - return getVisible () && parent.isVisible (); + checkWidget(); + return getVisible () && parent.isVisible (); } Decorations menuShell () { - return parent.menuShell (); + return parent.menuShell (); } alias Widget.mnemonicHit mnemonicHit; bool mnemonicHit (char key) { - return false; + return false; } alias Widget.mnemonicMatch mnemonicMatch; bool mnemonicMatch (char key) { - return false; + return false; } override void register () { - super.register (); - if (fixedHandle !is null) display.addWidget (fixedHandle, this); - auto imHandle = imHandle (); - if (imHandle !is null) display.addWidget (cast(GtkWidget*)imHandle, this); + super.register (); + if (fixedHandle !is null) display.addWidget (fixedHandle, this); + auto imHandle = imHandle (); + if (imHandle !is null) display.addWidget (cast(GtkWidget*)imHandle, this); } /** @@ -2921,14 +2921,14 @@ * @see SWT#DOUBLE_BUFFERED */ public void redraw () { - checkWidget(); - redraw (false); + checkWidget(); + redraw (false); } void redraw (bool all) { -// checkWidget(); - if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; - redrawWidget (0, 0, 0, 0, true, all, false); +// checkWidget(); + if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; + redrawWidget (0, 0, 0, 0, true, all, false); } /** @@ -2962,185 +2962,185 @@ * @see SWT#DOUBLE_BUFFERED */ public void redraw (int x, int y, int width, int height, bool all) { - checkWidget(); - if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; - redrawWidget (x, y, width, height, false, all, false); + checkWidget(); + if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; + redrawWidget (x, y, width, height, false, all, false); } void redrawChildren () { } void redrawWidget (int x, int y, int width, int height, bool redrawAll, bool all, bool trim) { - if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) is 0) return; - auto window = paintWindow (); - GdkRectangle rect; - if (redrawAll) { - int w, h; - OS.gdk_drawable_get_size (cast(GdkDrawable*)window, &w, &h); - rect.width = w; - rect.height = h; - } else { - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - } - OS.gdk_window_invalidate_rect (window, &rect, all); + if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) is 0) return; + auto window = paintWindow (); + GdkRectangle rect; + if (redrawAll) { + int w, h; + OS.gdk_drawable_get_size (cast(GdkDrawable*)window, &w, &h); + rect.width = w; + rect.height = h; + } else { + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + } + OS.gdk_window_invalidate_rect (window, &rect, all); } override void release (bool destroy) { - Control next = null, previous = null; - if (destroy && parent !is null) { - Control[] children = parent._getChildren (); - int index = 0; - while (index < children.length) { - if (children [index] is this) break; - index++; - } - if (0 < index && (index + 1) < children.length) { - next = children [index + 1]; - previous = children [index - 1]; - } - } - super.release (destroy); - if (destroy) { - if (previous !is null) previous.addRelation (next); - } + Control next = null, previous = null; + if (destroy && parent !is null) { + Control[] children = parent._getChildren (); + int index = 0; + while (index < children.length) { + if (children [index] is this) break; + index++; + } + if (0 < index && (index + 1) < children.length) { + next = children [index + 1]; + previous = children [index - 1]; + } + } + super.release (destroy); + if (destroy) { + if (previous !is null) previous.addRelation (next); + } } override void releaseHandle () { - super.releaseHandle (); - fixedHandle = null; - parent = null; + super.releaseHandle (); + fixedHandle = null; + parent = null; } override void releaseParent () { - parent.removeControl (this); + parent.removeControl (this); } override void releaseWidget () { - super.releaseWidget (); - if (display.currentControl is this) display.currentControl = null; - display.removeMouseHoverTimeout (handle); - auto imHandle = imHandle (); - if (imHandle !is null) { - OS.gtk_im_context_reset (imHandle); - OS.gtk_im_context_set_client_window (imHandle, null); - } - if (enableWindow !is null) { - OS.gdk_window_set_user_data (enableWindow, null); - OS.gdk_window_destroy (enableWindow); - enableWindow = null; - } - redrawWindow = null; - if (menu !is null && !menu.isDisposed ()) { - menu.dispose (); - } - menu = null; - cursor = null; - toolTipText = null; - layoutData = null; - accessible = null; + super.releaseWidget (); + if (display.currentControl is this) display.currentControl = null; + display.removeMouseHoverTimeout (handle); + auto imHandle = imHandle (); + if (imHandle !is null) { + OS.gtk_im_context_reset (imHandle); + OS.gtk_im_context_set_client_window (imHandle, null); + } + if (enableWindow !is null) { + OS.gdk_window_set_user_data (enableWindow, null); + OS.gdk_window_destroy (enableWindow); + enableWindow = null; + } + redrawWindow = null; + if (menu !is null && !menu.isDisposed ()) { + menu.dispose (); + } + menu = null; + cursor = null; + toolTipText = null; + layoutData = null; + accessible = null; } bool sendDragEvent (int button, int stateMask, int x, int y, bool isStateMask) { - Event event = new Event (); - event.button = button; - event.x = x; - event.y = y; - if (isStateMask) { - event.stateMask = stateMask; - } else { - setInputState (event, stateMask); - } - postEvent (SWT.DragDetect, event); - if (isDisposed ()) return false; - return event.doit; + Event event = new Event (); + event.button = button; + event.x = x; + event.y = y; + if (isStateMask) { + event.stateMask = stateMask; + } else { + setInputState (event, stateMask); + } + postEvent (SWT.DragDetect, event); + if (isDisposed ()) return false; + return event.doit; } void sendFocusEvent (int type) { - Shell shell = _getShell (); - Display display = this.display; - display.focusControl = this; - display.focusEvent = type; - sendEvent (type); - display.focusControl = null; - display.focusEvent = SWT.None; - /* - * It is possible that the shell may be - * disposed at this point. If this happens - * don't send the activate and deactivate - * events. - */ - if (!shell.isDisposed ()) { - switch (type) { - case SWT.FocusIn: - shell.setActiveControl (this); - break; - case SWT.FocusOut: - if (shell !is display.activeShell) { - shell.setActiveControl (null); - } - break; + Shell shell = _getShell (); + Display display = this.display; + display.focusControl = this; + display.focusEvent = type; + sendEvent (type); + display.focusControl = null; + display.focusEvent = SWT.None; + /* + * It is possible that the shell may be + * disposed at this point. If this happens + * don't send the activate and deactivate + * events. + */ + if (!shell.isDisposed ()) { + switch (type) { + case SWT.FocusIn: + shell.setActiveControl (this); + break; + case SWT.FocusOut: + if (shell !is display.activeShell) { + shell.setActiveControl (null); + } + break; default: - } - } + } + } } bool sendHelpEvent (int /*long*/ helpType) { - Control control = this; - while (control !is null) { - if (control.hooks (SWT.Help)) { - control.postEvent (SWT.Help); - return true; - } - control = control.parent; - } - return false; + Control control = this; + while (control !is null) { + if (control.hooks (SWT.Help)) { + control.postEvent (SWT.Help); + return true; + } + control = control.parent; + } + return false; } bool sendLeaveNotify() { - return false; + return false; } bool sendMouseEvent (int type, int button, int time, double x, double y, bool is_hint, int state) { - return sendMouseEvent (type, button, 0, 0, false, time, x, y, is_hint, state); + return sendMouseEvent (type, button, 0, 0, false, time, x, y, is_hint, state); } bool sendMouseEvent (int type, int button, int count, int detail, bool send, int time, double x, double y, bool is_hint, int state) { - if (!hooks (type) && !filters (type)) return true; - Event event = new Event (); - event.time = time; - event.button = button; - event.detail = detail; - event.count = count; - if (is_hint) { - event.x = cast(int)x; - event.y = cast(int)y; - } else { - auto window = eventWindow (); - int origin_x, origin_y; - OS.gdk_window_get_origin (window, &origin_x, &origin_y); - event.x = cast(int)x - origin_x; - event.y = cast(int)y - origin_y; - } - setInputState (event, state); - if (send) { - sendEvent (type, event); - if (isDisposed ()) return false; - } else { - postEvent (type, event); - } - return event.doit; + if (!hooks (type) && !filters (type)) return true; + Event event = new Event (); + event.time = time; + event.button = button; + event.detail = detail; + event.count = count; + if (is_hint) { + event.x = cast(int)x; + event.y = cast(int)y; + } else { + auto window = eventWindow (); + int origin_x, origin_y; + OS.gdk_window_get_origin (window, &origin_x, &origin_y); + event.x = cast(int)x - origin_x; + event.y = cast(int)y - origin_y; + } + setInputState (event, state); + if (send) { + sendEvent (type, event); + if (isDisposed ()) return false; + } else { + postEvent (type, event); + } + return event.doit; } void setBackground () { - if ((state & PARENT_BACKGROUND) !is 0 && (state & BACKGROUND) is 0 && backgroundImage is null) { - setParentBackground (); - } else { - setWidgetBackground (); - } - redrawWidget (0, 0, 0, 0, true, false, false); + if ((state & PARENT_BACKGROUND) !is 0 && (state & BACKGROUND) is 0 && backgroundImage is null) { + setParentBackground (); + } else { + setWidgetBackground (); + } + redrawWidget (0, 0, 0, 0, true, false, false); } /** @@ -3162,51 +3162,51 @@ * </ul> */ public void setBackground (Color color) { - checkWidget(); - if (((state & BACKGROUND) is 0) && color is null) return; - GdkColor* gdkColor = null; - if (color !is null) { - if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - gdkColor = color.handle; - } - bool set = false; - if (gdkColor is null) { - auto style = OS.gtk_widget_get_modifier_style (handle); - set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_BG) !is 0; - } else { - GdkColor* oldColor = getBackgroundColor (); - set = oldColor.pixel !is gdkColor.pixel; - } - if (set) { - if (color is null) { - state &= ~BACKGROUND; - } else { - state |= BACKGROUND; - } - setBackgroundColor (gdkColor); - redrawChildren (); - } + checkWidget(); + if (((state & BACKGROUND) is 0) && color is null) return; + GdkColor* gdkColor = null; + if (color !is null) { + if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + gdkColor = color.handle; + } + bool set = false; + if (gdkColor is null) { + auto style = OS.gtk_widget_get_modifier_style (handle); + set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_BG) !is 0; + } else { + GdkColor* oldColor = getBackgroundColor (); + set = oldColor.pixel !is gdkColor.pixel; + } + if (set) { + if (color is null) { + state &= ~BACKGROUND; + } else { + state |= BACKGROUND; + } + setBackgroundColor (gdkColor); + redrawChildren (); + } } void setBackgroundColor (GtkWidget* handle, GdkColor* color) { - int index = OS.GTK_STATE_NORMAL; - auto style = OS.gtk_widget_get_modifier_style (handle); - auto ptr = OS.gtk_rc_style_get_bg_pixmap_name (style, index); - if (ptr !is null) OS.g_free (ptr); - char[] name = color is null ? "<parent>" : "<none>" ; - ptr = cast(char*)OS.g_malloc (name.length+1); + int index = OS.GTK_STATE_NORMAL; + auto style = OS.gtk_widget_get_modifier_style (handle); + auto ptr = OS.gtk_rc_style_get_bg_pixmap_name (style, index); + if (ptr !is null) OS.g_free (ptr); + char[] name = color is null ? "<parent>" : "<none>" ; + ptr = cast(char*)OS.g_malloc (name.length+1); ptr[ 0 .. name.length ] = name; ptr[ name.length ] = '\0'; - OS.gtk_rc_style_set_bg_pixmap_name (style, index, ptr); - OS.gtk_rc_style_set_bg (style, index, color); - int flags = OS.gtk_rc_style_get_color_flags (style, index); - flags = (color is null) ? flags & ~OS.GTK_RC_BG : flags | OS.GTK_RC_BG; - OS.gtk_rc_style_set_color_flags (style, index, flags); - OS.gtk_widget_modify_style (handle, style); + OS.gtk_rc_style_set_bg_pixmap_name (style, index, ptr); + OS.gtk_rc_style_set_bg (style, index, color); + int flags = OS.gtk_rc_style_get_color_flags (style, index); + flags = (color is null) ? flags & ~OS.GTK_RC_BG : flags | OS.GTK_RC_BG; + OS.gtk_rc_style_set_color_flags (style, index, flags); + OS.gtk_widget_modify_style (handle, style); } void setBackgroundColor (GdkColor* color) { - setBackgroundColor (handle, color); + setBackgroundColor (handle, color); } /** @@ -3232,22 +3232,22 @@ * @since 3.2 */ public void setBackgroundImage (Image image) { - checkWidget (); - if (image !is null && image.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - if (image is backgroundImage) return; - this.backgroundImage = image; - if (backgroundImage !is null) { - setBackgroundPixmap (backgroundImage.pixmap); - redrawWidget (0, 0, 0, 0, true, false, false); - } else { - setWidgetBackground (); - } - redrawChildren (); + checkWidget (); + if (image !is null && image.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + if (image is backgroundImage) return; + this.backgroundImage = image; + if (backgroundImage !is null) { + setBackgroundPixmap (backgroundImage.pixmap); + redrawWidget (0, 0, 0, 0, true, false, false); + } else { + setWidgetBackground (); + } + redrawChildren (); } void setBackgroundPixmap (GdkDrawable* pixmap) { - auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); - if (window !is null) OS.gdk_window_set_back_pixmap (window, cast(GdkPixmap*)backgroundImage.pixmap, false); + auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); + if (window !is null) OS.gdk_window_set_back_pixmap (window, cast(GdkPixmap*)backgroundImage.pixmap, false); } /** @@ -3263,15 +3263,15 @@ * </ul> */ public void setCapture (bool capture) { - checkWidget(); - /* FIXME !!!!! */ - /* - if (capture) { - OS.gtk_widget_grab_focus (handle); - } else { - OS.gtk_widget_grab_default (handle); - } - */ + checkWidget(); + /* FIXME !!!!! */ + /* + if (capture) { + OS.gtk_widget_grab_focus (handle); + } else { + OS.gtk_widget_grab_default (handle); + } + */ } /** * Sets the receiver's cursor to the cursor specified by the @@ -3293,23 +3293,23 @@ * </ul> */ public void setCursor (Cursor cursor) { - checkWidget(); - if (cursor !is null && cursor.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - this.cursor = cursor; - setCursor (cursor !is null ? cursor.handle : null); + checkWidget(); + if (cursor !is null && cursor.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + this.cursor = cursor; + setCursor (cursor !is null ? cursor.handle : null); } void setCursor (GdkCursor* cursor) { - auto window = eventWindow (); - if (window !is null) { - OS.gdk_window_set_cursor (window, cursor); - if (!OS.GDK_WINDOWING_X11 ()) { - OS.gdk_flush (); - } else { - auto xDisplay = OS.GDK_DISPLAY (); - OS.XFlush (xDisplay); - } - } + auto window = eventWindow (); + if (window !is null) { + OS.gdk_window_set_cursor (window, cursor); + if (!OS.GDK_WINDOWING_X11 ()) { + OS.gdk_flush (); + } else { + auto xDisplay = OS.GDK_DISPLAY (); + OS.XFlush (xDisplay); + } + } } /** @@ -3327,12 +3327,12 @@ * @since 3.3 */ public void setDragDetect (bool dragDetect) { - checkWidget (); - if (dragDetect) { - state |= DRAG_DETECT; - } else { - state &= ~DRAG_DETECT; - } + checkWidget (); + if (dragDetect) { + state |= DRAG_DETECT; + } else { + state &= ~DRAG_DETECT; + } } /** @@ -3349,63 +3349,63 @@ * </ul> */ public void setEnabled (bool enabled) { - checkWidget(); - if (((state & DISABLED) is 0) is enabled) return; - Control control = null; - bool fixFocus_ = false; - if (!enabled) { - if (display.focusEvent !is SWT.FocusOut) { - control = display.getFocusControl (); - fixFocus_ = isFocusAncestor (control); - } - } - if (enabled) { - state &= ~DISABLED; - } else { - state |= DISABLED; - } - enableWidget (enabled); - if (isDisposed ()) return; - if (enabled) { - if (enableWindow !is null) { - OS.gdk_window_set_user_data (enableWindow, null); - OS.gdk_window_destroy (enableWindow); - enableWindow = null; - } - } else { - OS.gtk_widget_realize (handle); - auto parentHandle = parent.parentingHandle (); - auto window = OS.GTK_WIDGET_WINDOW (parentHandle); - Rectangle rect = getBounds (); - GdkWindowAttr attributes; - attributes.x = rect.x; - attributes.y = rect.y; - attributes.width = rect.width; - attributes.height = rect.height; - attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); - attributes.wclass = OS.GDK_INPUT_ONLY; - attributes.window_type = OS.GDK_WINDOW_CHILD; - enableWindow = OS.gdk_window_new (window, &attributes, OS.GDK_WA_X | OS.GDK_WA_Y); - if (enableWindow !is null) { - auto topHandle = topHandle (); - OS.gdk_window_set_user_data (enableWindow, parentHandle); - if (!OS.GDK_WINDOWING_X11 ()) { - OS.gdk_window_raise (enableWindow); - } else { - auto topWindow = OS.GTK_WIDGET_WINDOW (topHandle); - auto xDisplay = OS.gdk_x11_drawable_get_xdisplay (cast(GdkDrawable*)topWindow); - auto xWindow = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)enableWindow); - int xScreen = OS.XDefaultScreen (xDisplay); - int flags = OS.CWStackMode | OS.CWSibling; - XWindowChanges changes; - changes.sibling = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)topWindow); - changes.stack_mode = OS.Above; - OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, &changes); - } - if (OS.GTK_WIDGET_VISIBLE (topHandle)) OS.gdk_window_show_unraised (enableWindow); - } - } - if (fixFocus_) fixFocus (control); + checkWidget(); + if (((state & DISABLED) is 0) is enabled) return; + Control control = null; + bool fixFocus_ = false; + if (!enabled) { + if (display.focusEvent !is SWT.FocusOut) { + control = display.getFocusControl (); + fixFocus_ = isFocusAncestor (control); + } + } + if (enabled) { + state &= ~DISABLED; + } else { + state |= DISABLED; + } + enableWidget (enabled); + if (isDisposed ()) return; + if (enabled) { + if (enableWindow !is null) { + OS.gdk_window_set_user_data (enableWindow, null); + OS.gdk_window_destroy (enableWindow); + enableWindow = null; + } + } else { + OS.gtk_widget_realize (handle); + auto parentHandle = parent.parentingHandle (); + auto window = OS.GTK_WIDGET_WINDOW (parentHandle); + Rectangle rect = getBounds (); + GdkWindowAttr attributes; + attributes.x = rect.x; + attributes.y = rect.y; + attributes.width = rect.width; + attributes.height = rect.height; + attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); + attributes.wclass = OS.GDK_INPUT_ONLY; + attributes.window_type = OS.GDK_WINDOW_CHILD; + enableWindow = OS.gdk_window_new (window, &attributes, OS.GDK_WA_X | OS.GDK_WA_Y); + if (enableWindow !is null) { + auto topHandle = topHandle (); + OS.gdk_window_set_user_data (enableWindow, parentHandle); + if (!OS.GDK_WINDOWING_X11 ()) { + OS.gdk_window_raise (enableWindow); + } else { + auto topWindow = OS.GTK_WIDGET_WINDOW (topHandle); + auto xDisplay = OS.gdk_x11_drawable_get_xdisplay (cast(GdkDrawable*)topWindow); + auto xWindow = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)enableWindow); + int xScreen = OS.XDefaultScreen (xDisplay); + int flags = OS.CWStackMode | OS.CWSibling; + XWindowChanges changes; + changes.sibling = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)topWindow); + changes.stack_mode = OS.Above; + OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, &changes); + } + if (OS.GTK_WIDGET_VISIBLE (topHandle)) OS.gdk_window_show_unraised (enableWindow); + } + } + if (fixFocus_) fixFocus (control); } /** @@ -3423,9 +3423,9 @@ * @see #forceFocus */ public bool setFocus () { - checkWidget(); - if ((style & SWT.NO_FOCUS) !is 0) return false; - return forceFocus (); + checkWidget(); + if ((style & SWT.NO_FOCUS) !is 0) return false; + return forceFocus (); } /** @@ -3444,26 +3444,26 @@ * </ul> */ public void setFont (Font font) { - checkWidget(); - if (((state & FONT) is 0) && font is null) return; - this.font = font; - PangoFontDescription* fontDesc; - if (font is null) { - fontDesc = defaultFont (); - } else { - if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - fontDesc = font.handle; - } - if (font is null) { - state &= ~FONT; - } else { - state |= FONT; - } - setFontDescription (fontDesc); + checkWidget(); + if (((state & FONT) is 0) && font is null) return; + this.font = font; + PangoFontDescription* fontDesc; + if (font is null) { + fontDesc = defaultFont (); + } else { + if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + fontDesc = font.handle; + } + if (font is null) { + state &= ~FONT; + } else { + state |= FONT; + } + setFontDescription (fontDesc); } void setFontDescription (PangoFontDescription* font) { - OS.gtk_widget_modify_font (handle, font); + OS.gtk_widget_modify_font (handle, font); } /** @@ -3484,51 +3484,51 @@ * </ul> */ public void setForeground (Color color) { - checkWidget(); - if (((state & FOREGROUND) is 0) && color is null) return; - GdkColor* gdkColor = null; - if (color !is null) { - if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - gdkColor = color.handle; - } - bool set = false; - if (gdkColor is null) { - auto style = OS.gtk_widget_get_modifier_style (handle); - set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_FG) !is 0; - } else { - GdkColor* oldColor = getForegroundColor (); - set = oldColor.pixel !is gdkColor.pixel; - } - if (set) { - if (color is null) { - state &= ~FOREGROUND; - } else { - state |= FOREGROUND; - } - setForegroundColor (gdkColor); - } + checkWidget(); + if (((state & FOREGROUND) is 0) && color is null) return; + GdkColor* gdkColor = null; + if (color !is null) { + if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + gdkColor = color.handle; + } + bool set = false; + if (gdkColor is null) { + auto style = OS.gtk_widget_get_modifier_style (handle); + set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_FG) !is 0; + } else { + GdkColor* oldColor = getForegroundColor (); + set = oldColor.pixel !is gdkColor.pixel; + } + if (set) { + if (color is null) { + state &= ~FOREGROUND; + } else { + state |= FOREGROUND; + } + setForegroundColor (gdkColor); + } } alias Widget.setForegroundColor setForegroundColor; void setForegroundColor (GdkColor* color) { - setForegroundColor (handle, color); + setForegroundColor (handle, color); } void setInitialBounds () { - if ((state & ZERO_WIDTH) !is 0 && (state & ZERO_HEIGHT) !is 0) { - /* - * Feature in GTK. On creation, each widget's allocation is - * initialized to a position of (-1, -1) until the widget is - * first sized. The fix is to set the value to (0, 0) as - * expected by SWT. - */ - auto topHandle = topHandle (); - OS.GTK_WIDGET_SET_X (topHandle, 0); - OS.GTK_WIDGET_SET_Y (topHandle, 0); - } else { - resizeHandle (1, 1); - forceResize (); - } + if ((state & ZERO_WIDTH) !is 0 && (state & ZERO_HEIGHT) !is 0) { + /* + * Feature in GTK. On creation, each widget's allocation is + * initialized to a position of (-1, -1) until the widget is + * first sized. The fix is to set the value to (0, 0) as + * expected by SWT. + */ + auto topHandle = topHandle (); + OS.GTK_WIDGET_SET_X (topHandle, 0); + OS.GTK_WIDGET_SET_Y (topHandle, 0); + } else { + resizeHandle (1, 1); + forceResize (); + } Stdout.formatln( "{}: setInitialBounds gtk_container_get_children {:x}", __LINE__, parent.parentingHandle() ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parent.parentingHandle()) ); } @@ -3559,23 +3559,23 @@ * </ul> */ public void setMenu (Menu menu) { - checkWidget(); - if (menu !is null) { - if ((menu.style & SWT.POP_UP) is 0) { - error (SWT.ERROR_MENU_NOT_POP_UP); - } - if (menu.parent !is menuShell ()) { - error (SWT.ERROR_INVALID_PARENT); - } - } - this.menu = menu; + checkWidget(); + if (menu !is null) { + if ((menu.style & SWT.POP_UP) is 0) { + error (SWT.ERROR_MENU_NOT_POP_UP); + } + if (menu.parent !is menuShell ()) { + error (SWT.ERROR_INVALID_PARENT); + } + } + this.menu = menu; } override void setOrientation () { - if ((style & SWT.RIGHT_TO_LEFT) !is 0) { - if (handle !is null) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL); - if (fixedHandle !is null) OS.gtk_widget_set_direction (fixedHandle, OS.GTK_TEXT_DIR_RTL); - } + if ((style & SWT.RIGHT_TO_LEFT) !is 0) { + if (handle !is null) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL); + if (fixedHandle !is null) OS.gtk_widget_set_direction (fixedHandle, OS.GTK_TEXT_DIR_RTL); + } } /** @@ -3593,44 +3593,44 @@ * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> + * </ul> */ public bool setParent (Composite parent) { - checkWidget (); - if (parent is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - if (parent.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT); - if (this.parent is parent) return true; - if (!isReparentable ()) return false; - releaseParent (); - Shell newShell = parent.getShell (), oldShell = getShell (); - Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell (); - Menu [] menus = oldShell.findMenus (this); - if (oldShell !is newShell || oldDecorations !is newDecorations) { - fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); - newDecorations.fixAccelGroup (); - oldDecorations.fixAccelGroup (); - } - auto topHandle = topHandle (); - auto newParent = parent.parentingHandle(); - int x = OS.GTK_WIDGET_X (topHandle); - int y = OS.GTK_WIDGET_Y (topHandle); - OS.gtk_widget_reparent (topHandle, newParent); - OS.gtk_fixed_move (cast(GtkFixed*)newParent, topHandle, x, y); - this.parent = parent; - setZOrder (null, false, true); - return true; + checkWidget (); + if (parent is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + if (parent.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT); + if (this.parent is parent) return true; + if (!isReparentable ()) return false; + releaseParent (); + Shell newShell = parent.getShell (), oldShell = getShell (); + Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell (); + Menu [] menus = oldShell.findMenus (this); + if (oldShell !is newShell || oldDecorations !is newDecorations) { + fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); + newDecorations.fixAccelGroup (); + oldDecorations.fixAccelGroup (); + } + auto topHandle = topHandle (); + auto newParent = parent.parentingHandle(); + int x = OS.GTK_WIDGET_X (topHandle); + int y = OS.GTK_WIDGET_Y (topHandle); + OS.gtk_widget_reparent (topHandle, newParent); + OS.gtk_fixed_move (cast(GtkFixed*)newParent, topHandle, x, y); + this.parent = parent; + setZOrder (null, false, true); + return true; } void setParentBackground () { - setBackgroundColor (handle, null); - if (fixedHandle !is null) setBackgroundColor (fixedHandle, null); + setBackgroundColor (handle, null); + if (fixedHandle !is null) setBackgroundColor (fixedHandle, null); } void setParentWindow (GtkWidget* widget) { } bool setRadioSelection (bool value) { - return false; + return false; } /** @@ -3657,50 +3657,50 @@ * @see #update() */ public void setRedraw (bool redraw) { - checkWidget(); - if (redraw) { - if (--drawCount is 0) { - if (redrawWindow !is null) { - auto window = paintWindow (); - /* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */ - OS.gdk_window_hide (redrawWindow); - OS.gdk_window_destroy (redrawWindow); - OS.gdk_window_set_events (window, OS.gtk_widget_get_events (paintHandle ())); - redrawWindow = null; - } - } - } else { - if (drawCount++ is 0) { - if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) !is 0) { - auto window = paintWindow (); - Rectangle rect = getBounds (); - GdkWindowAttr attributes; - attributes.width = rect.width; - attributes.height = rect.height; - attributes.event_mask = OS.GDK_EXPOSURE_MASK; - attributes.window_type = OS.GDK_WINDOW_CHILD; - redrawWindow = OS.gdk_window_new (window, &attributes, 0); - if (redrawWindow !is null) { - int mouseMask = OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | - OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | - OS.GDK_POINTER_MOTION_MASK | OS.GDK_POINTER_MOTION_HINT_MASK | - OS.GDK_BUTTON_MOTION_MASK | OS.GDK_BUTTON1_MOTION_MASK | - OS.GDK_BUTTON2_MOTION_MASK | OS.GDK_BUTTON3_MOTION_MASK; - OS.gdk_window_set_events (window, OS.gdk_window_get_events (window) & ~mouseMask); - OS.gdk_window_set_back_pixmap (redrawWindow, null, false); - OS.gdk_window_show (redrawWindow); - } - } - } - } + checkWidget(); + if (redraw) { + if (--drawCount is 0) { + if (redrawWindow !is null) { + auto window = paintWindow (); + /* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */ + OS.gdk_window_hide (redrawWindow); + OS.gdk_window_destroy (redrawWindow); + OS.gdk_window_set_events (window, OS.gtk_widget_get_events (paintHandle ())); + redrawWindow = null; + } + } + } else { + if (drawCount++ is 0) { + if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) !is 0) { + auto window = paintWindow (); + Rectangle rect = getBounds (); + GdkWindowAttr attributes; + attributes.width = rect.width; + attributes.height = rect.height; + attributes.event_mask = OS.GDK_EXPOSURE_MASK; + attributes.window_type = OS.GDK_WINDOW_CHILD; + redrawWindow = OS.gdk_window_new (window, &attributes, 0); + if (redrawWindow !is null) { + int mouseMask = OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | + OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | + OS.GDK_POINTER_MOTION_MASK | OS.GDK_POINTER_MOTION_HINT_MASK | + OS.GDK_BUTTON_MOTION_MASK | OS.GDK_BUTTON1_MOTION_MASK | + OS.GDK_BUTTON2_MOTION_MASK | OS.GDK_BUTTON3_MOTION_MASK; + OS.gdk_window_set_events (window, OS.gdk_window_get_events (window) & ~mouseMask); + OS.gdk_window_set_back_pixmap (redrawWindow, null, false); + OS.gdk_window_show (redrawWindow); + } + } + } + } } bool setTabGroupFocus (bool next) { - return setTabItemFocus (next); + return setTabItemFocus (next); } bool setTabItemFocus (bool next) { - if (!isShowing ()) return false; - return forceFocus (); + if (!isShowing ()) return false; + return forceFocus (); } /** @@ -3715,13 +3715,13 @@ * </ul> */ public void setToolTipText (char[] str) { - checkWidget(); - setToolTipText (_getShell (), str); - toolTipText = str; + checkWidget(); + setToolTipText (_getShell (), str); + toolTipText = str; } void setToolTipText (Shell shell, char[] newString) { - shell.setToolTipText (eventHandle (), newString); + shell.setToolTipText (eventHandle (), newString); } /** @@ -3741,251 +3741,251 @@ * </ul> */ public void setVisible (bool visible) { - checkWidget(); - if (((state & HIDDEN) is 0) is visible) return; - auto topHandle = topHandle(); - if (visible) { - /* - * It is possible (but unlikely), that application - * code could have disposed the widget in the show - * event. If this happens, just return. - */ - sendEvent (SWT.Show); - if (isDisposed ()) return; - state &= ~HIDDEN; - if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) is 0) { - if (enableWindow !is null) OS.gdk_window_show_unraised (enableWindow); - OS.gtk_widget_show (topHandle); - } - } else { - /* - * Bug in GTK. Invoking gtk_widget_hide() on a widget that has - * focus causes a focus_out_event to be sent. If the client disposes - * the widget inside the event, GTK GP's. The fix is to reassign focus - * before hiding the widget. - * - * NOTE: In order to stop the same widget from taking focus, - * temporarily clear and set the GTK_VISIBLE flag. - */ - Control control = null; - bool fixFocus_ = false; - if (display.focusEvent !is SWT.FocusOut) { - control = display.getFocusControl (); - fixFocus_ = isFocusAncestor (control); - } - state |= HIDDEN; - if (fixFocus_) { - OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE); - fixFocus (control); - if (isDisposed ()) return; - OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE); - } - OS.gtk_widget_hide (topHandle); - if (isDisposed ()) return; - if (enableWindow !is null) OS.gdk_window_hide (enableWindow); - sendEvent (SWT.Hide); - } + checkWidget(); + if (((state & HIDDEN) is 0) is visible) return; + auto topHandle = topHandle(); + if (visible) { + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the show + * event. If this happens, just return. + */ + sendEvent (SWT.Show); + if (isDisposed ()) return; + state &= ~HIDDEN; + if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) is 0) { + if (enableWindow !is null) OS.gdk_window_show_unraised (enableWindow); + OS.gtk_widget_show (topHandle); + } + } else { + /* + * Bug in GTK. Invoking gtk_widget_hide() on a widget that has + * focus causes a focus_out_event to be sent. If the client disposes + * the widget inside the event, GTK GP's. The fix is to reassign focus + * before hiding the widget. + * + * NOTE: In order to stop the same widget from taking focus, + * temporarily clear and set the GTK_VISIBLE flag. + */ + Control control = null; + bool fixFocus_ = false; + if (display.focusEvent !is SWT.FocusOut) { + control = display.getFocusControl (); + fixFocus_ = isFocusAncestor (control); + } + state |= HIDDEN; + if (fixFocus_) { + OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE); + fixFocus (control); + if (isDisposed ()) return; + OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE); + } + OS.gtk_widget_hide (topHandle); + if (isDisposed ()) return; + if (enableWindow !is null) OS.gdk_window_hide (enableWindow); + sendEvent (SWT.Hide); + } } void setZOrder (Control sibling, bool above, bool fixRelations) { - setZOrder (sibling, above, fixRelations, true); + setZOrder (sibling, above, fixRelations, true); } void setZOrder (Control sibling, bool above, bool fixRelations, bool fixChildren) { - int index = 0, siblingIndex = 0, oldNextIndex = -1; - Control[] children = null; - if (fixRelations) { - /* determine the receiver's and sibling's indexes in the parent */ - children = parent._getChildren (); - while (index < children.length) { - if (children [index] is this) break; - index++; - } - if (sibling !is null) { - while (siblingIndex < children.length) { - if (children [siblingIndex] is sibling) break; - siblingIndex++; - } - } - /* remove "Labelled by" relationships that will no longer be valid */ - removeRelation (); - if (index + 1 < children.length) { - oldNextIndex = index + 1; - children [oldNextIndex].removeRelation (); - } - if (sibling !is null) { - if (above) { - sibling.removeRelation (); - } else { - if (siblingIndex + 1 < children.length) { - children [siblingIndex + 1].removeRelation (); - } - } - } - } - - auto topHandle = topHandle (); - auto siblingHandle = sibling !is null ? sibling.topHandle () : null; - auto window = OS.GTK_WIDGET_WINDOW (topHandle); - if (window !is null) { - GdkWindow* siblingWindow; - if (sibling !is null) { - if (above && sibling.enableWindow !is null) { - siblingWindow = enableWindow; - } else { - siblingWindow = OS.GTK_WIDGET_WINDOW (siblingHandle); - } - } - auto redrawWindow = fixChildren ? parent.redrawWindow : null; - if (!OS.GDK_WINDOWING_X11 () || (siblingWindow is null && (!above || redrawWindow is null))) { - if (above) { - OS.gdk_window_raise (window); - if (redrawWindow !is null) OS.gdk_window_raise (redrawWindow); - if (enableWindow !is null) OS.gdk_window_raise (enableWindow); - } else { - if (enableWindow !is null) OS.gdk_window_lower (enableWindow); - OS.gdk_window_lower (window); - } - } else { - XWindowChanges changes; - changes.sibling = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)(siblingWindow !is null ? siblingWindow : redrawWindow)); - changes.stack_mode = above ? OS.Above : OS.Below; - if (redrawWindow !is null && siblingWindow is null) changes.stack_mode = OS.Below; - auto xDisplay = OS.gdk_x11_drawable_get_xdisplay (cast(GdkDrawable*)window); - auto xWindow = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)window); - int xScreen = OS.XDefaultScreen (xDisplay); - int flags = OS.CWStackMode | OS.CWSibling; - /* - * Feature in X. If the receiver is a top level, XConfigureWindow () - * will fail (with a BadMatch error) for top level shells because top - * level shells are reparented by the window manager and do not share - * the same X window parent. This is the correct behavior but it is - * unexpected. The fix is to use XReconfigureWMWindow () instead. - * When the receiver is not a top level shell, XReconfigureWMWindow () - * behaves the same as XConfigureWindow (). - */ - OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, &changes); - if (enableWindow !is null) { - changes.sibling = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)window); - changes.stack_mode = OS.Above; - xWindow = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)enableWindow); - OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, &changes); - } - } - } + int index = 0, siblingIndex = 0, oldNextIndex = -1; + Control[] children = null; + if (fixRelations) { + /* determine the receiver's and sibling's indexes in the parent */ + children = parent._getChildren (); + while (index < children.length) { + if (children [index] is this) break; + index++; + } + if (sibling !is null) { + while (siblingIndex < children.length) { + if (children [siblingIndex] is sibling) break; + siblingIndex++; + } + } + /* remove "Labelled by" relationships that will no longer be valid */ + removeRelation (); + if (index + 1 < children.length) { + oldNextIndex = index + 1; + children [oldNextIndex].removeRelation (); + } + if (sibling !is null) { + if (above) { + sibling.removeRelation (); + } else { + if (siblingIndex + 1 < children.length) { + children [siblingIndex + 1].removeRelation (); + } + } + } + } + + auto topHandle = topHandle (); + auto siblingHandle = sibling !is null ? sibling.topHandle () : null; + auto window = OS.GTK_WIDGET_WINDOW (topHandle); + if (window !is null) { + GdkWindow* siblingWindow; + if (sibling !is null) { + if (above && sibling.enableWindow !is null) { + siblingWindow = enableWindow; + } else { + siblingWindow = OS.GTK_WIDGET_WINDOW (siblingHandle); + } + } + auto redrawWindow = fixChildren ? parent.redrawWindow : null; + if (!OS.GDK_WINDOWING_X11 () || (siblingWindow is null && (!above || redrawWindow is null))) { + if (above) { + OS.gdk_window_raise (window); + if (redrawWindow !is null) OS.gdk_window_raise (redrawWindow); + if (enableWindow !is null) OS.gdk_window_raise (enableWindow); + } else { + if (enableWindow !is null) OS.gdk_window_lower (enableWindow); + OS.gdk_window_lower (window); + } + } else { + XWindowChanges changes; + changes.sibling = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)(siblingWindow !is null ? siblingWindow : redrawWindow)); + changes.stack_mode = above ? OS.Above : OS.Below; + if (redrawWindow !is null && siblingWindow is null) changes.stack_mode = OS.Below; + auto xDisplay = OS.gdk_x11_drawable_get_xdisplay (cast(GdkDrawable*)window); + auto xWindow = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)window); + int xScreen = OS.XDefaultScreen (xDisplay); + int flags = OS.CWStackMode | OS.CWSibling; + /* + * Feature in X. If the receiver is a top level, XConfigureWindow () + * will fail (with a BadMatch error) for top level shells because top + * level shells are reparented by the window manager and do not share + * the same X window parent. This is the correct behavior but it is + * unexpected. The fix is to use XReconfigureWMWindow () instead. + * When the receiver is not a top level shell, XReconfigureWMWindow () + * behaves the same as XConfigureWindow (). + */ + OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, &changes); + if (enableWindow !is null) { + changes.sibling = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)window); + changes.stack_mode = OS.Above; + xWindow = OS.gdk_x11_drawable_get_xid (cast(GdkDrawable*)enableWindow); + OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, &changes); + } + } + } Stdout.formatln( "{}: setZOrder gtk_container_get_children {:x}", __LINE__, parent.parentingHandle() ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parent.parentingHandle()) ); - if (fixChildren) { - if (above) { + if (fixChildren) { + if (above) { Stdout.formatln( "{}: setZOrder gtk_container_get_children {:x}", __LINE__, parent.parentingHandle() ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parent.parentingHandle()) ); - parent.moveAbove (topHandle, siblingHandle); - } else { + parent.moveAbove (topHandle, siblingHandle); + } else { Stdout.formatln( "{}: setZOrder gtk_container_get_children {:x}", __LINE__, parent.parentingHandle() ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parent.parentingHandle()) ); - parent.moveBelow (topHandle, siblingHandle); - } - } + parent.moveBelow (topHandle, siblingHandle); + } + } Stdout.formatln( "{}: setZOrder gtk_container_get_children {:x}", __LINE__, parent.parentingHandle() ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parent.parentingHandle()) ); - /* Make sure that the parent internal windows are on the bottom of the stack */ - if (!above && fixChildren) parent.fixZOrder (); + /* Make sure that the parent internal windows are on the bottom of the stack */ + if (!above && fixChildren) parent.fixZOrder (); Stdout.formatln( "{}: setZOrder gtk_container_get_children {:x}", __LINE__, parent.parentingHandle() ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parent.parentingHandle()) ); - if (fixRelations) { - /* determine the receiver's new index in the parent */ - if (sibling !is null) { - if (above) { - index = siblingIndex - (index < siblingIndex ? 1 : 0); - } else { - index = siblingIndex + (siblingIndex < index ? 1 : 0); - } - } else { - if (above) { - index = 0; - } else { - index = children.length - 1; - } - } - - /* add new "Labelled by" relations as needed */ - children = parent._getChildren (); - if (0 < index) { - children [index - 1].addRelation (this); - } - if (index + 1 < children.length) { - addRelation (children [index + 1]); - } - if (oldNextIndex !is -1) { - if (oldNextIndex <= index) oldNextIndex--; - /* the last two conditions below ensure that duplicate relations are not hooked */ - if (0 < oldNextIndex && oldNextIndex !is index && oldNextIndex !is index + 1) { - children [oldNextIndex - 1].addRelation (children [oldNextIndex]); - } - } - } + if (fixRelations) { + /* determine the receiver's new index in the parent */ + if (sibling !is null) { + if (above) { + index = siblingIndex - (index < siblingIndex ? 1 : 0); + } else { + index = siblingIndex + (siblingIndex < index ? 1 : 0); + } + } else { + if (above) { + index = 0; + } else { + index = children.length - 1; + } + } + + /* add new "Labelled by" relations as needed */ + children = parent._getChildren (); + if (0 < index) { + children [index - 1].addRelation (this); + } + if (index + 1 < children.length) { + addRelation (children [index + 1]); + } + if (oldNextIndex !is -1) { + if (oldNextIndex <= index) oldNextIndex--; + /* the last two conditions below ensure that duplicate relations are not hooked */ + if (0 < oldNextIndex && oldNextIndex !is index && oldNextIndex !is index + 1) { + children [oldNextIndex - 1].addRelation (children [oldNextIndex]); + } + } + } } void setWidgetBackground () { - if (fixedHandle !is null) { - auto style = OS.gtk_widget_get_modifier_style (fixedHandle); - OS.gtk_widget_modify_style (fixedHandle, style); - } - auto style = OS.gtk_widget_get_modifier_style (handle); - OS.gtk_widget_modify_style (handle, style); + if (fixedHandle !is null) { + auto style = OS.gtk_widget_get_modifier_style (fixedHandle); + OS.gtk_widget_modify_style (fixedHandle, style); + } + auto style = OS.gtk_widget_get_modifier_style (handle); + OS.gtk_widget_modify_style (handle, style); } bool showMenu (int x, int y) { - Event event = new Event (); - event.x = x; - event.y = y; - sendEvent (SWT.MenuDetect, event); - if (event.doit) { - if (menu !is null && !menu.isDisposed ()) { - bool hooksKeys = hooks (SWT.KeyDown) || hooks (SWT.KeyUp); - menu.createIMMenu (hooksKeys ? imHandle() : null); - if (event.x !is x || event.y !is y) { - menu.setLocation (event.x, event.y); - } - menu.setVisible (true); - return true; - } - } - return false; + Event event = new Event (); + event.x = x; + event.y = y; + sendEvent (SWT.MenuDetect, event); + if (event.doit) { + if (menu !is null && !menu.isDisposed ()) { + bool hooksKeys = hooks (SWT.KeyDown) || hooks (SWT.KeyUp); + menu.createIMMenu (hooksKeys ? imHandle() : null); + if (event.x !is x || event.y !is y) { + menu.setLocation (event.x, event.y); + } + menu.setVisible (true); + return true; + } + } + return false; } void showWidget () { - // Comment this line to disable zero-sized widgets - state |= ZERO_WIDTH | ZERO_HEIGHT; - auto topHandle = topHandle (); - auto parentHandle = parent.parentingHandle (); - parent.setParentWindow (topHandle); + // Comment this line to disable zero-sized widgets + state |= ZERO_WIDTH | ZERO_HEIGHT; + auto topHandle = topHandle (); + auto parentHandle = parent.parentingHandle (); + parent.setParentWindow (topHandle); Stdout.formatln( "showWidget {:x} {}", parentHandle, topHandle ); Stdout.formatln( "showWidget gtk_container_get_children {:x}", parentHandle ); Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentHandle) ); - OS.gtk_container_add (cast(GtkContainer*)parentHandle, topHandle); + OS.gtk_container_add (cast(GtkContainer*)parentHandle, topHandle); if (handle !is null && handle !is topHandle) OS.gtk_widget_show (handle); - if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) is 0) { - if (fixedHandle !is null) OS.gtk_widget_show (fixedHandle); - } - if (fixedHandle !is null) fixStyle (fixedHandle); + if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) is 0) { + if (fixedHandle !is null) OS.gtk_widget_show (fixedHandle); + } + if (fixedHandle !is null) fixStyle (fixedHandle); } void sort (int [] items) { - /* Shell Sort from K&R, pg 108 */ - int length = items.length; - for (int gap=length/2; gap>0; gap/=2) { - for (int i=gap; i<length; i++) { - for (int j=i-gap; j>=0; j-=gap) { - if (items [j] <= items [j + gap]) { - int swap = items [j]; - items [j] = items [j + gap]; - items [j + gap] = swap; - } - } - } - } + /* Shell Sort from K&R, pg 108 */ + int length = items.length; + for (int gap=length/2; gap>0; gap/=2) { + for (int i=gap; i<length; i++) { + for (int j=i-gap; j>=0; j-=gap) { + if (items [j] <= items [j + gap]) { + int swap = items [j]; + items [j] = items [j + gap]; + items [j + gap] = swap; + } + } + } + } } /** @@ -4004,199 +4004,199 @@ * </ul> */ public bool traverse (int traversal) { - checkWidget (); - Event event = new Event (); - event.doit = true; - event.detail = traversal; - return traverse (event); + checkWidget (); + Event event = new Event (); + event.doit = true; + event.detail = traversal; + return traverse (event); } bool translateMnemonic (Event event, Control control) { - if (control is this) return false; - if (!isVisible () || !isEnabled ()) return false; - event.doit = this is display.mnemonicControl || mnemonicMatch (event.character); - return traverse (event); + if (control is this) return false; + if (!isVisible () || !isEnabled ()) return false; + event.doit = this is display.mnemonicControl || mnemonicMatch (event.character); + return traverse (event); } bool translateMnemonic (int keyval, GdkEventKey* gdkEvent) { - int key = OS.gdk_keyval_to_unicode (keyval); - if (key < 0x20) return false; - if (gdkEvent.state is 0) { - int code = traversalCode (keyval, gdkEvent); - if ((code & SWT.TRAVERSE_MNEMONIC) is 0) return false; - } else { - Shell shell = _getShell (); - int mask = OS.GDK_CONTROL_MASK | OS.GDK_SHIFT_MASK | OS.GDK_MOD1_MASK; - if ((gdkEvent.state & mask) !is OS.gtk_window_get_mnemonic_modifier (cast(GtkWindow*)shell.shellHandle)) return false; - } - Decorations shell = menuShell (); - if (shell.isVisible () && shell.isEnabled ()) { - Event event = new Event (); - event.detail = SWT.TRAVERSE_MNEMONIC; - if (setKeyState (event, gdkEvent)) { - return translateMnemonic (event, null) || shell.translateMnemonic (event, this); - } - } - return false; + int key = OS.gdk_keyval_to_unicode (keyval); + if (key < 0x20) return false; + if (gdkEvent.state is 0) { + int code = traversalCode (keyval, gdkEvent); + if ((code & SWT.TRAVERSE_MNEMONIC) is 0) return false; + } else { + Shell shell = _getShell (); + int mask = OS.GDK_CONTROL_MASK | OS.GDK_SHIFT_MASK | OS.GDK_MOD1_MASK; + if ((gdkEvent.state & mask) !is OS.gtk_window_get_mnemonic_modifier (cast(GtkWindow*)shell.shellHandle)) return false; + } + Decorations shell = menuShell (); + if (shell.isVisible () && shell.isEnabled ()) { + Event event = new Event (); + event.detail = SWT.TRAVERSE_MNEMONIC; + if (setKeyState (event, gdkEvent)) { + return translateMnemonic (event, null) || shell.translateMnemonic (event, this); + } + } + return false; } bool translateTraversal (GdkEventKey* keyEvent) { - int detail = SWT.TRAVERSE_NONE; - int key = keyEvent.keyval; - int code = traversalCode (key, keyEvent); - bool all = false; - switch (key) { - case OS.GDK_Escape: { - all = true; - detail = SWT.TRAVERSE_ESCAPE; - break; - } - case OS.GDK_KP_Enter: - case OS.GDK_Return: { - all = true; - detail = SWT.TRAVERSE_RETURN; - break; - } - case OS.GDK_ISO_Left_Tab: - case OS.GDK_Tab: { - bool next = (keyEvent.state & OS.GDK_SHIFT_MASK) is 0; - detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS; - break; - } - case OS.GDK_Up: - case OS.GDK_Left: - case OS.GDK_Down: - case OS.GDK_Right: { - bool next = key is OS.GDK_Down || key is OS.GDK_Right; - detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS; - break; - } - case OS.GDK_Page_Up: - case OS.GDK_Page_Down: { - all = true; - if ((keyEvent.state & OS.GDK_CONTROL_MASK) is 0) return false; - detail = key is OS.GDK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS; - break; - } - default: - return false; - } - Event event = new Event (); - event.doit = (code & detail) !is 0; - event.detail = detail; - event.time = keyEvent.time; - if (!setKeyState (event, keyEvent)) return false; - Shell shell = getShell (); - Control control = this; - do { - if (control.traverse (event)) return true; - if (!event.doit && control.hooks (SWT.Traverse)) return false; - if (control is shell) return false; - control = control.parent; - } while (all && control !is null); - return false; + int detail = SWT.TRAVERSE_NONE; + int key = keyEvent.keyval; + int code = traversalCode (key, keyEvent); + bool all = false; + switch (key) { + case OS.GDK_Escape: { + all = true; + detail = SWT.TRAVERSE_ESCAPE; + break; + } + case OS.GDK_KP_Enter: + case OS.GDK_Return: { + all = true; + detail = SWT.TRAVERSE_RETURN; + break; + } + case OS.GDK_ISO_Left_Tab: + case OS.GDK_Tab: { + bool next = (keyEvent.state & OS.GDK_SHIFT_MASK) is 0; + detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS; + break; + } + case OS.GDK_Up: + case OS.GDK_Left: + case OS.GDK_Down: + case OS.GDK_Right: { + bool next = key is OS.GDK_Down || key is OS.GDK_Right; + detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS; + break; + } + case OS.GDK_Page_Up: + case OS.GDK_Page_Down: { + all = true; + if ((keyEvent.state & OS.GDK_CONTROL_MASK) is 0) return false; + detail = key is OS.GDK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS; + break; + } + default: + return false; + } + Event event = new Event (); + event.doit = (code & detail) !is 0; + event.detail = detail; + event.time = keyEvent.time; + if (!setKeyState (event, keyEvent)) return false; + Shell shell = getShell (); + Control control = this; + do { + if (control.traverse (event)) return true; + if (!event.doit && control.hooks (SWT.Traverse)) return false; + if (control is shell) return false; + control = control.parent; + } while (all && control !is null); + return false; } int traversalCode (int key, GdkEventKey* event) { - int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS; - Shell shell = getShell (); - if (shell.parent !is null) code |= SWT.TRAVERSE_ESCAPE; - return code; + int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS; + Shell shell = getShell (); + if (shell.parent !is null) code |= SWT.TRAVERSE_ESCAPE; + return code; } bool traverse (Event event) { - /* - * It is possible (but unlikely), that application - * code could have disposed the widget in the traverse - * event. If this happens, return true to stop further - * event processing. - */ - sendEvent (SWT.Traverse, event); - if (isDisposed ()) return true; - if (!event.doit) return false; - switch (event.detail) { - case SWT.TRAVERSE_NONE: return true; - case SWT.TRAVERSE_ESCAPE: return traverseEscape (); - case SWT.TRAVERSE_RETURN: return traverseReturn (); - case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true); - case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false); - case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true); - case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false); - case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character); - case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true); - case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false); + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the traverse + * event. If this happens, return true to stop further + * event processing. + */ + sendEvent (SWT.Traverse, event); + if (isDisposed ()) return true; + if (!event.doit) return false; + switch (event.detail) { + case SWT.TRAVERSE_NONE: return true; + case SWT.TRAVERSE_ESCAPE: return traverseEscape (); + case SWT.TRAVERSE_RETURN: return traverseReturn (); + case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true); + case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false); + case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true); + case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false); + case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character); + case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true); + case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false); default: - } - return false; + } + return false; } bool traverseEscape () { - return false; + return false; } bool traverseGroup (bool next) { - Control root = computeTabRoot (); - Control group = computeTabGroup (); - Control [] list = root.computeTabList (); - int length = list.length; - int index = 0; - while (index < length) { - if (list [index] is group) break; - index++; - } - /* - * It is possible (but unlikely), that application - * code could have disposed the widget in focus in - * or out events. Ensure that a disposed widget is - * not accessed. - */ - if (index is length) return false; - int start = index, offset = (next) ? 1 : -1; - while ((index = ((index + offset + length) % length)) !is start) { - Control control = list [index]; - if (!control.isDisposed () && control.setTabGroupFocus (next)) { - return true; - } - } - if (group.isDisposed ()) return false; - return group.setTabGroupFocus (next); + Control root = computeTabRoot (); + Control group = computeTabGroup (); + Control [] list = root.computeTabList (); + int length = list.length; + int index = 0; + while (index < length) { + if (list [index] is group) break; + index++; + } + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in focus in + * or out events. Ensure that a disposed widget is + * not accessed. + */ + if (index is length) return false; + int start = index, offset = (next) ? 1 : -1; + while ((index = ((index + offset + length) % length)) !is start) { + Control control = list [index]; + if (!control.isDisposed () && control.setTabGroupFocus (next)) { + return true; + } + } + if (group.isDisposed ()) return false; + return group.setTabGroupFocus (next); } bool traverseItem (bool next) { - Control [] children = parent._getChildren (); - int length = children.length; - int index = 0; - while (index < length) { - if (children [index] is this) break; - index++; - } - /* - * It is possible (but unlikely), that application - * code could have disposed the widget in focus in - * or out events. Ensure that a disposed widget is - * not accessed. - */ - if (index is length) return false; - int start = index, offset = (next) ? 1 : -1; - while ((index = (index + offset + length) % length) !is start) { - Control child = children [index]; - if (!child.isDisposed () && child.isTabItem ()) { - if (child.setTabItemFocus (next)) return true; - } - } - return false; + Control [] children = parent._getChildren (); + int length = children.length; + int index = 0; + while (index < length) { + if (children [index] is this) break; + index++; + } + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in focus in + * or out events. Ensure that a disposed widget is + * not accessed. + */ + if (index is length) return false; + int start = index, offset = (next) ? 1 : -1; + while ((index = (index + offset + length) % length) !is start) { + Control child = children [index]; + if (!child.isDisposed () && child.isTabItem ()) { + if (child.setTabItemFocus (next)) return true; + } + } + return false; } bool traverseReturn () { - return false; + return false; } bool traversePage (bool next) { - return false; + return false; } bool traverseMnemonic (char key) { - return mnemonicHit (key); + return mnemonicHit (key); } /** @@ -4219,57 +4219,57 @@ * @see SWT#Paint */ public void update () { - checkWidget (); - update (false, true); + checkWidget (); + update (false, true); } void update (bool all, bool flush) { -// checkWidget(); - if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; - if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) is 0) return; - auto window = paintWindow (); - if (flush) display.flushExposes (window, all); - OS.gdk_window_process_updates (window, all); - OS.gdk_flush (); +// checkWidget(); + if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; + if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) is 0) return; + auto window = paintWindow (); + if (flush) display.flushExposes (window, all); + OS.gdk_window_process_updates (window, all); + OS.gdk_flush (); } void updateBackgroundMode () { - int oldState = state & PARENT_BACKGROUND; - checkBackground (); - if (oldState !is (state & PARENT_BACKGROUND)) { - setBackground (); - } + int oldState = state & PARENT_BACKGROUND; + checkBackground (); + if (oldState !is (state & PARENT_BACKGROUND)) { + setBackground (); + } } void updateLayout (bool all) { - /* Do nothing */ + /* Do nothing */ } override int /*long*/ windowProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ user_data) { - switch (cast(int)/*64*/user_data) { - case EXPOSE_EVENT_INVERSE: { - if ((OS.GTK_VERSION < OS.buildVERSION (2, 8, 0)) && ((state & OBSCURED) is 0)) { - Control control = findBackgroundControl (); - if (control !is null && control.backgroundImage !is null) { - GdkEventExpose* gdkEvent = cast(GdkEventExpose*)arg0; - auto paintWindow = paintWindow(); - auto window = gdkEvent.window; - if (window !is paintWindow) break; - auto gdkGC = OS.gdk_gc_new (cast(GdkDrawable*)window); - OS.gdk_gc_set_clip_region (gdkGC, gdkEvent.region); - int dest_x, dest_y; - OS.gtk_widget_translate_coordinates (paintHandle (), control.paintHandle (), 0, 0, &dest_x, &dest_y); - OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); - OS.gdk_gc_set_ts_origin (gdkGC, -dest_x, -dest_y); - OS.gdk_gc_set_tile (gdkGC, cast(GdkPixmap*)control.backgroundImage.pixmap); - OS.gdk_draw_rectangle (cast(GdkDrawable*)window, gdkGC, 1, gdkEvent.area.x, gdkEvent.area.y, gdkEvent.area.width, gdkEvent.area.height); - OS.g_object_unref (gdkGC); - } - } - break; + switch (cast(int)/*64*/user_data) { + case EXPOSE_EVENT_INVERSE: { + if ((OS.GTK_VERSION < OS.buildVERSION (2, 8, 0)) && ((state & OBSCURED) is 0)) { + Control control = findBackgroundControl (); + if (control !is null && control.backgroundImage !is null) { + GdkEventExpose* gdkEvent = cast(GdkEventExpose*)arg0; + auto paintWindow = paintWindow(); + auto window = gdkEvent.window; + if (window !is paintWindow) break; + auto gdkGC = OS.gdk_gc_new (cast(GdkDrawable*)window); + OS.gdk_gc_set_clip_region (gdkGC, gdkEvent.region); + int dest_x, dest_y; + OS.gtk_widget_translate_coordinates (paintHandle (), control.paintHandle (), 0, 0, &dest_x, &dest_y); + OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); + OS.gdk_gc_set_ts_origin (gdkGC, -dest_x, -dest_y); + OS.gdk_gc_set_tile (gdkGC, cast(GdkPixmap*)control.backgroundImage.pixmap); + OS.gdk_draw_rectangle (cast(GdkDrawable*)window, gdkGC, 1, gdkEvent.area.x, gdkEvent.area.y, gdkEvent.area.width, gdkEvent.area.height); + OS.g_object_unref (gdkGC); + } + } + break; default: - } - } - return super.windowProc (handle, arg0, user_data); + } + } + return super.windowProc (handle, arg0, user_data); } }