Mercurial > projects > dwt-linux
changeset 34:3a3e3aa76b66
Composite
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 10 Jan 2008 03:51:48 +0100 |
parents | 27324bbbac70 |
children | 0b417301f404 f0cac58ac62b |
files | dwt/internal/gtk/OS.d dwt/widgets/Composite.d dwt/widgets/Layout.d dwt/widgets/Scrollable.d todo.txt |
diffstat | 5 files changed, 456 insertions(+), 355 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/internal/gtk/OS.d Thu Jan 10 02:18:07 2008 +0100 +++ b/dwt/internal/gtk/OS.d Thu Jan 10 03:51:48 2008 +0100 @@ -113,6 +113,7 @@ public alias dwt.internal.c.gtk.GtkWidgetClass GtkWidgetClass; public alias dwt.internal.c.gtk.GtkCellRendererClass GtkCellRendererClass; public alias dwt.internal.c.gtk.GtkAllocation GtkAllocation; +public alias dwt.internal.c.gtk.GtkSocket GtkSocket; public alias dwt.internal.c.Xlib.XErrorEvent XErrorEvent; public alias dwt.internal.c.Xlib.XExposeEvent XExposeEvent; @@ -1163,7 +1164,7 @@ mixin ForwardGtkOsCFunc!(.g_list_nth_data); mixin ForwardGtkOsCFunc!(.g_list_prepend); // mixin ForwardGtkOsCFunc!(.g_list_set_previous); -// mixin ForwardGtkOsCFunc!(.g_list_previous); + //mixin ForwardGtkOsCFunc!(.g_list_previous); mixin ForwardGtkOsCFunc!(.g_list_remove_link); mixin ForwardGtkOsCFunc!(.g_list_reverse); mixin ForwardGtkOsCFunc!(.g_locale_from_utf8);
--- a/dwt/widgets/Composite.d Thu Jan 10 02:18:07 2008 +0100 +++ b/dwt/widgets/Composite.d Thu Jan 10 03:51:48 2008 +0100 @@ -9,25 +9,25 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ module dwt.widgets.Composite; -import dwt.widgets.Control; -import dwt.internal.c.gtk; -class Composite : Control { - Control [] _getTabList (); - int backgroundMode; - GtkWidget* parentingHandle (); - Control [] _getChildren () ; - void removeControl (Control control); - void moveAbove (GtkWidget* child, GtkWidget* sibling); - void moveBelow (GtkWidget* child, GtkWidget* sibling); - void fixZOrder () ; -} +import dwt.widgets.Control; +import dwt.widgets.Scrollable; +import dwt.widgets.Layout; +import dwt.widgets.Decorations; +import dwt.widgets.ScrollBar; +import dwt.widgets.Shell; +import dwt.widgets.Menu; +import dwt.widgets.Event; +import dwt.widgets.Widget; +import dwt.widgets.Display; +import dwt.graphics.GCData; -/+ -import dwt.*; -import dwt.internal.cairo.*; -import dwt.internal.gtk.*; -import dwt.graphics.*; +import dwt.internal.gtk.OS; +import dwt.graphics.GC; +import dwt.SWT; +import dwt.internal.cairo.Cairo; +import dwt.internal.gtk.OS; +import dwt.graphics.Rectangle; /** * Instances of this class are controls which are capable @@ -58,16 +58,17 @@ * * @see Canvas */ -public class Composite extends Scrollable { - public int /*long*/ embeddedHandle; - int /*long*/ imHandle, socketHandle; - Layout layout; +public class Composite : Scrollable { + public int embeddedHandle; + GtkIMContext* imHandle_; + GtkWidget* socketHandle; + Layout layout_; Control[] tabList; int layoutCount, backgroundMode; - static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ + static const char[] NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ -Composite () { +this () { /* Do nothing */ } @@ -101,44 +102,44 @@ * @see SWT#NO_RADIO_GROUP * @see Widget#getStyle */ -public Composite (Composite parent, int style) { +public this (Composite parent, int style) { super (parent, style); } Control [] _getChildren () { - int /*long*/ parentHandle = parentingHandle (); - int /*long*/ list = OS.gtk_container_get_children (parentHandle); - if (list == 0) return new Control [0]; + auto parentHandle = parentingHandle (); + auto list = OS.gtk_container_get_children (cast(GtkContainer*)parentHandle); + if (list is null) return new Control [0]; int count = OS.g_list_length (list); Control [] children = new Control [count]; int i = 0; - int /*long*/ temp = list; - while (temp != 0) { - int /*long*/ handle = OS.g_list_data (temp); - if (handle != 0) { + auto temp = list; + while (temp !is null) { + auto handle = cast(GtkWidget*)OS.g_list_data (temp); + if (handle !is null) { Widget widget = display.getWidget (handle); - if (widget != null && widget != this) { - if (widget instanceof Control) { - children [i++] = (Control) widget; + if (widget !is null && widget !is this) { + if (auto c = cast(Control)widget) { + children [i++] = c; } } } - temp = OS.g_list_next (temp); + temp = cast(GList*)OS.g_list_next (temp); } OS.g_list_free (list); - if (i == count) return children; + if (i is count) return children; Control [] newChildren = new Control [i]; System.arraycopy (children, 0, newChildren, 0, i); return newChildren; } Control [] _getTabList () { - if (tabList == null) return tabList; + if (tabList is null) return tabList; int count = 0; for (int i=0; i<tabList.length; i++) { if (!tabList [i].isDisposed ()) count++; } - if (count == tabList.length) return tabList; + if (count is tabList.length) return tabList; Control [] newList = new Control [count]; int index = 0; for (int i=0; i<tabList.length; i++) { @@ -170,15 +171,15 @@ */ public void changed (Control[] changed) { checkWidget (); - if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); for (int i=0; i<changed.length; i++) { Control control = changed [i]; - if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - boolean ancestor = false; + bool ancestor = false; Composite composite = control.parent; - while (composite != null) { - ancestor = composite == this; + while (composite !is null) { + ancestor = composite is this; if (ancestor) break; composite = composite.parent; } @@ -187,8 +188,8 @@ for (int i=0; i<changed.length; i++) { Control child = changed [i]; Composite composite = child.parent; - while (child != this) { - if (composite.layout == null || !composite.layout.flushCache (child)) { + while (child !is this) { + if (composite.layout_ is null || !composite.layout_.flushCache (child)) { composite.state |= LAYOUT_CHANGED; } child = composite; @@ -198,7 +199,7 @@ } void checkBuffered () { - if ((style & SWT.DOUBLE_BUFFERED) == 0 && (style & SWT.NO_BACKGROUND) != 0) { + if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { return; } super.checkBuffered(); @@ -208,20 +209,20 @@ /* Do nothing - Subclassing is allowed */ } -int /*long*/ childStyle () { - if (scrolledHandle != 0) return 0; +GtkStyle* childStyle () { + if (scrolledHandle !is null) return null; return super.childStyle (); } -public Point computeSize (int wHint, int hHint, boolean changed) { +public Point computeSize (int wHint, int hHint, bool changed) { checkWidget (); - if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; - if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; + if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0; + if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0; Point size; - if (layout != null) { - if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) { - changed |= (state & LAYOUT_CHANGED) != 0; - size = layout.computeSize (this, wHint, hHint, changed); + if (layout_ !is null) { + if (wHint is SWT.DEFAULT || hHint is SWT.DEFAULT) { + changed |= (state & LAYOUT_CHANGED) !is 0; + size = layout_.computeSize (this, wHint, hHint, changed); state &= ~LAYOUT_CHANGED; } else { size = new Point (wHint, hHint); @@ -229,22 +230,22 @@ } else { size = minimumSize (wHint, hHint, changed); } - if (size.x == 0) size.x = DEFAULT_WIDTH; - if (size.y == 0) size.y = DEFAULT_HEIGHT; - if (wHint != SWT.DEFAULT) size.x = wHint; - if (hHint != SWT.DEFAULT) size.y = hHint; + if (size.x is 0) size.x = DEFAULT_WIDTH; + if (size.y is 0) size.y = DEFAULT_HEIGHT; + if (wHint !is SWT.DEFAULT) size.x = wHint; + if (hHint !is SWT.DEFAULT) size.y = hHint; Rectangle trim = computeTrim (0, 0, size.x, size.y); return new Point (trim.width, trim.height); } Control [] computeTabList () { Control result [] = super.computeTabList (); - if (result.length == 0) return result; - Control [] list = tabList != null ? _getTabList () : _getChildren (); + if (result.length is 0) return result; + Control [] list = tabList !is null ? _getTabList () : _getChildren (); for (int i=0; i<list.length; i++) { Control child = list [i]; Control [] childList = child.computeTabList (); - if (childList.length != 0) { + if (childList.length !is 0) { Control [] newResult = new Control [result.length + childList.length]; System.arraycopy (result, 0, newResult, 0, result.length); System.arraycopy (childList, 0, newResult, result.length, childList.length); @@ -256,63 +257,63 @@ void createHandle (int index) { state |= HANDLE | CANVAS; - boolean scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0; + bool scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) !is 0; if (!scrolled) state |= THEME_BACKGROUND; - createHandle (index, true, scrolled || (style & SWT.BORDER) != 0); + createHandle (index, true, scrolled || (style & SWT.BORDER) !is 0); } -void createHandle (int index, boolean fixed, boolean scrolled) { +void createHandle (int index, bool fixed, bool scrolled) { if (scrolled) { if (fixed) { - fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); - if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - OS.gtk_fixed_set_has_window (fixedHandle, true); + fixedHandle = cast(GtkWidget*) OS.g_object_new (display.gtk_fixed_get_type (), null); + if (fixedHandle is null) error (SWT.ERROR_NO_HANDLES); + OS.gtk_fixed_set_has_window (cast(GtkFixed*)fixedHandle, true); } - int /*long*/ vadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); - if (vadj == 0) error (SWT.ERROR_NO_HANDLES); - int /*long*/ hadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); - if (hadj == 0) error (SWT.ERROR_NO_HANDLES); - scrolledHandle = OS.gtk_scrolled_window_new (hadj, vadj); - if (scrolledHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES); + auto vadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); + if (vadj is null) error (SWT.ERROR_NO_HANDLES); + auto hadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); + if (hadj is null) error (SWT.ERROR_NO_HANDLES); + scrolledHandle = cast(GtkWidget*) OS.gtk_scrolled_window_new (hadj, vadj); + if (scrolledHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); } - handle = OS.g_object_new (display.gtk_fixed_get_type (), 0); - if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES); - OS.gtk_fixed_set_has_window (handle, true); + handle = cast(GtkWidget*)OS.g_object_new (display.gtk_fixed_get_type (), null); + if (handle is null) SWT.error (SWT.ERROR_NO_HANDLES); + OS.gtk_fixed_set_has_window (cast(GtkFixed*)handle, true); OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS); - if ((style & SWT.EMBEDDED) == 0) { - if ((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0) { + if ((style & SWT.EMBEDDED) is 0) { + if ((state & CANVAS) !is 0 && (style & SWT.NO_FOCUS) is 0) { /* Prevent an input method context from being created for the Browser widget */ - if (display.getData (NO_INPUT_METHOD) == null) { - imHandle = OS.gtk_im_multicontext_new (); - if (imHandle == 0) error (SWT.ERROR_NO_HANDLES); + if (display.getData (NO_INPUT_METHOD) is null) { + imHandle_ = OS.gtk_im_multicontext_new (); + if (imHandle_ is null) error (SWT.ERROR_NO_HANDLES); } } } if (scrolled) { - if (fixed) OS.gtk_container_add (fixedHandle, scrolledHandle); + if (fixed) OS.gtk_container_add (cast(GtkContainer*)fixedHandle, scrolledHandle); /* * Force the scrolledWindow to have a single child that is * not scrolled automatically. Calling gtk_container_add() * seems to add the child correctly but cause a warning. */ - boolean warnings = display.getWarnings (); + bool warnings = display.getWarnings (); display.setWarnings (false); - OS.gtk_container_add (scrolledHandle, handle); + OS.gtk_container_add (cast(GtkContainer*)scrolledHandle, handle); display.setWarnings (warnings); - int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; - int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; - OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp); + int hsp = (style & SWT.H_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; + int vsp = (style & SWT.V_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; + OS.gtk_scrolled_window_set_policy (cast(GtkScrolledWindow*)scrolledHandle, hsp, vsp); if (hasBorder ()) { - OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); + OS.gtk_scrolled_window_set_shadow_type (cast(GtkScrolledWindow*)scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); } } - if ((style & SWT.EMBEDDED) != 0) { + if ((style & SWT.EMBEDDED) !is 0) { socketHandle = OS.gtk_socket_new (); - if (socketHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES); - OS.gtk_container_add (handle, socketHandle); + if (socketHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); + OS.gtk_container_add (cast(GtkContainer*)handle, cast(GtkWidget*)socketHandle); } - if ((style & SWT.NO_REDRAW_RESIZE) != 0) { + if ((style & SWT.NO_REDRAW_RESIZE) !is 0) { OS.gtk_widget_set_redraw_on_allocate (handle, false); } /* @@ -324,54 +325,54 @@ * when NO_BACKGROUND is set and DOUBLE_BUFFERED * is not explicitly set. */ - if ((style & SWT.DOUBLE_BUFFERED) == 0 && (style & SWT.NO_BACKGROUND) != 0) { + if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { OS.gtk_widget_set_double_buffered (handle, false); } } void deregister () { super.deregister (); - if (socketHandle != 0) display.removeWidget (socketHandle); + if (socketHandle !is null) display.removeWidget (cast(GtkWidget*)socketHandle); } void drawBackground (GC gc, int x, int y, int width, int height) { Control control = findBackgroundControl (); - if (control != null) { + if (control !is null) { GCData data = gc.getGCData (); - int /*long*/ cairo = data.cairo; - if (cairo != 0) { + auto cairo = data.cairo; + if (cairo !is null) { Cairo.cairo_save (cairo); - if (control.backgroundImage != null) { + if (control.backgroundImage !is null) { Point pt = display.map (this, control, 0, 0); Cairo.cairo_translate (cairo, -pt.x, -pt.y); x += pt.x; y += pt.y; - int /*long*/ xDisplay = OS.GDK_DISPLAY (); - int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system()); - int /*long*/ drawable = control.backgroundImage.pixmap; - int /*long*/ xDrawable = OS.GDK_PIXMAP_XID (drawable); - int [] w = new int [1], h = new int [1]; - OS.gdk_drawable_get_size (drawable, w, h); - int /*long*/ surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w [0], h [0]); - if (surface == 0) error (SWT.ERROR_NO_HANDLES); - int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface (surface); - if (pattern == 0) error (SWT.ERROR_NO_HANDLES); + auto xDisplay = OS.GDK_DISPLAY (); + auto xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system()); + auto drawable = control.backgroundImage.pixmap; + auto xDrawable = OS.GDK_PIXMAP_XID (drawable); + int w, h; + OS.gdk_drawable_get_size (cast(GdkDrawable*)drawable, &w, &h); + auto surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w, h); + if (surface is null) error (SWT.ERROR_NO_HANDLES); + auto pattern = Cairo.cairo_pattern_create_for_surface (surface); + if (pattern is null) error (SWT.ERROR_NO_HANDLES); Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); Cairo.cairo_set_source (cairo, pattern); Cairo.cairo_surface_destroy (surface); Cairo.cairo_pattern_destroy (pattern); } else { - GdkColor color = control.getBackgroundColor (); - Cairo.cairo_set_source_rgba (cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF); + GdkColor* color = control.getBackgroundColor (); + Cairo.cairo_set_source_rgba (cairo, (color.red & 0xFFFF) / cast(float)0xFFFF, (color.green & 0xFFFF) / cast(float)0xFFFF, (color.blue & 0xFFFF) / cast(float)0xFFFF, data.alpha / cast(float)0xFF); } Cairo.cairo_rectangle (cairo, x, y, width, height); Cairo.cairo_fill (cairo); Cairo.cairo_restore (cairo); } else { - int /*long*/ gdkGC = gc.handle; - GdkGCValues values = new GdkGCValues (); + auto gdkGC = gc.handle; + GdkGCValues* values = new GdkGCValues (); OS.gdk_gc_get_values (gdkGC, values); - if (control.backgroundImage != null) { + if (control.backgroundImage !is null) { Point pt = display.map (this, control, 0, 0); OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y); @@ -380,10 +381,10 @@ OS.gdk_gc_set_fill (gdkGC, values.fill); OS.gdk_gc_set_ts_origin (gdkGC, values.ts_x_origin, values.ts_y_origin); } else { - GdkColor color = control.getBackgroundColor (); + GdkColor* color = control.getBackgroundColor (); OS.gdk_gc_set_foreground (gdkGC, color); OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); - color.pixel = values.foreground_pixel; + color.pixel = values.foreground.pixel; OS.gdk_gc_set_foreground (gdkGC, color); } } @@ -392,8 +393,8 @@ } } -void enableWidget (boolean enabled) { - if ((state & CANVAS) != 0) return; +void enableWidget (bool enabled) { + if ((state & CANVAS) !is 0) return; super.enableWidget (enabled); } @@ -402,13 +403,13 @@ } Menu [] findMenus (Control control) { - if (control == this) return new Menu [0]; + if (control is this) return new Menu [0]; Menu result [] = super.findMenus (control); Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { Control child = children [i]; Menu [] menuList = child.findMenus (control); - if (menuList.length != 0) { + if (menuList.length !is 0) { Menu [] newResult = new Menu [result.length + menuList.length]; System.arraycopy (result, 0, newResult, 0, result.length); System.arraycopy (menuList, 0, newResult, result.length, menuList.length); @@ -426,9 +427,10 @@ } } +alias Scrollable.fixStyle fixStyle; void fixStyle () { super.fixStyle (); - if (scrolledHandle == 0) fixStyle (handle); + if (scrolledHandle is null) fixStyle (handle); Control[] children = _getChildren (); for (int i = 0; i < children.length; i++) { children [i].fixStyle (); @@ -436,19 +438,19 @@ } void fixTabList (Control control) { - if (tabList == null) return; + if (tabList is null) return; int count = 0; for (int i=0; i<tabList.length; i++) { - if (tabList [i] == control) count++; + if (tabList [i] is control) count++; } - if (count == 0) return; + if (count is 0) return; Control [] newList = null; int length = tabList.length - count; - if (length != 0) { + if (length !is 0) { newList = new Control [length]; int index = 0; for (int i=0; i<tabList.length; i++) { - if (tabList [i] != control) { + if (tabList [i] !is control) { newList [index++] = tabList [i]; } } @@ -457,37 +459,37 @@ } void fixZOrder () { - if ((state & CANVAS) != 0) return; - int /*long*/ parentHandle = parentingHandle (); - int /*long*/ parentWindow = OS.GTK_WIDGET_WINDOW (parentHandle); - if (parentWindow == 0) return; - int /*long*/ [] userData = new int /*long*/ [1]; - int /*long*/ windowList = OS.gdk_window_get_children (parentWindow); - if (windowList != 0) { - int /*long*/ windows = windowList; - while (windows != 0) { - int /*long*/ window = OS.g_list_data (windows); - if (window != redrawWindow) { - OS.gdk_window_get_user_data (window, userData); - if (userData [0] == 0 || OS.G_OBJECT_TYPE (userData [0]) != display.gtk_fixed_get_type ()) { + if ((state & CANVAS) !is 0) return; + auto parentHandle = parentingHandle (); + auto parentWindow = OS.GTK_WIDGET_WINDOW (cast(GtkWidget*)parentHandle); + if (parentWindow is null) return; + GObject* userData; + auto windowList = OS.gdk_window_get_children (parentWindow); + if (windowList !is null) { + auto windows = windowList; + while (windows !is null) { + auto window = cast(GdkDrawable*)OS.g_list_data (windows); + if (window !is redrawWindow) { + OS.gdk_window_get_user_data (window, cast(void**)&userData); + if (userData is null || OS.G_OBJECT_TYPE (userData) !is display.gtk_fixed_get_type ()) { OS.gdk_window_lower (window); } } - windows = OS.g_list_next (windows); + windows = cast(GList*)OS.g_list_next (windows); } OS.g_list_free (windowList); } } -int /*long*/ focusHandle () { - if (socketHandle != 0) return socketHandle; +GtkWidget* focusHandle () { + if (socketHandle !is null) return socketHandle; return super.focusHandle (); } -boolean forceFocus (int /*long*/ focusHandle) { - if (socketHandle != 0) OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); - boolean result = super.forceFocus (focusHandle); - if (socketHandle != 0) OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); +bool forceFocus (GtkWidget* focusHandle) { + if (socketHandle !is null) OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); + bool result = super.forceFocus (focusHandle); + if (socketHandle !is null) OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); return result; } @@ -545,8 +547,8 @@ * NOTE: The current implementation will count * non-registered children. */ - int /*long*/ list = OS.gtk_container_get_children (handle); - if (list == 0) return 0; + auto list = OS.gtk_container_get_children (cast(GtkContainer*)handle); + if (list is null) return 0; int count = OS.g_list_length (list); OS.g_list_free (list); return count; @@ -554,14 +556,14 @@ public Rectangle getClientArea () { checkWidget(); - if ((state & CANVAS) != 0) { - if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) { + if ((state & CANVAS) !is 0) { + if ((state & ZERO_WIDTH) !is 0 && (state & ZERO_HEIGHT) !is 0) { return new Rectangle (0, 0, 0, 0); } forceResize (); - int /*long*/ clientHandle = clientHandle (); - int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); - int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); + auto clientHandle = clientHandle (); + int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); + int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); return new Rectangle (0, 0, width, height); } return super.getClientArea(); @@ -580,7 +582,7 @@ */ public Layout getLayout () { checkWidget(); - return layout; + return layout_; } /** @@ -594,12 +596,12 @@ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * - * @see #setLayoutDeferred(boolean) + * @see #setLayoutDeferred(bool) * @see #isLayoutDeferred() * * @since 3.1 */ -public boolean getLayoutDeferred () { +public bool getLayoutDeferred () { checkWidget (); return layoutCount > 0 ; } @@ -619,7 +621,7 @@ public Control [] getTabList () { checkWidget (); Control [] tabList = _getTabList (); - if (tabList == null) { + if (tabList is null) { int count = 0; Control [] list =_getChildren (); for (int i=0; i<list.length; i++) { @@ -636,45 +638,40 @@ return tabList; } -int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { - int /*long*/ result = super.gtk_button_press_event (widget, event); - if (result != 0) return result; - if ((state & CANVAS) != 0) { - if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) { - GdkEventButton gdkEvent = new GdkEventButton (); - OS.memmove (gdkEvent, event, GdkEventButton.sizeof); - if (gdkEvent.button == 1) { - if (getChildrenCount () == 0) setFocus (); +override int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* event) { + auto result = super.gtk_button_press_event (widget, event); + if (result !is 0) return result; + if ((state & CANVAS) !is 0) { + if ((style & SWT.NO_FOCUS) is 0 && hooksKeys ()) { + if (event.button is 1) { + if (getChildrenCount () is 0) setFocus (); } } } return result; } -int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) { - if ((state & OBSCURED) != 0) return 0; - if ((state & CANVAS) == 0) { +override int /*long*/ gtk_expose_event (GtkWidget* widget, GdkEventExpose* eventPtr) { + if ((state & OBSCURED) !is 0) return 0; + if ((state & CANVAS) is 0) { return super.gtk_expose_event (widget, eventPtr); } - if ((style & SWT.NO_MERGE_PAINTS) == 0) { + if ((style & SWT.NO_MERGE_PAINTS) is 0) { return super.gtk_expose_event (widget, eventPtr); } if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; - GdkEventExpose gdkEvent = new GdkEventExpose (); - OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof); - int /*long*/ [] rectangles = new int /*long*/ [1]; - int [] n_rectangles = new int [1]; - OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles); - GdkRectangle rect = new GdkRectangle (); - for (int i=0; i<n_rectangles[0]; i++) { + GdkEventExpose* gdkEvent = eventPtr; + GdkRectangle* rectangles; + int n_rectangles; + OS.gdk_region_get_rectangles (gdkEvent.region, &rectangles, &n_rectangles); + for (int i=0; i<n_rectangles; i++) { Event event = new Event (); - OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof); - event.x = rect.x; - event.y = rect.y; - event.width = rect.width; - event.height = rect.height; - int /*long*/ damageRgn = OS.gdk_region_new (); - OS.gdk_region_union_with_rect (damageRgn, rect); + event.x = rectangles[i].x; + event.y = rectangles[i].y; + event.width = rectangles[i].width; + event.height = rectangles[i].height; + auto damageRgn = OS.gdk_region_new (); + OS.gdk_region_union_with_rect (damageRgn, rectangles + i ); GCData data = new GCData (); data.damageRgn = damageRgn; GC gc = event.gc = GC.gtk_new (this, data); @@ -684,22 +681,21 @@ OS.gdk_region_destroy (damageRgn); event.gc = null; } - OS.g_free (rectangles [0]); + OS.g_free (rectangles); return 0; } -int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) { - int /*long*/ result = super.gtk_key_press_event (widget, event); - if (result != 0) return result; +override int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* event) { + auto result = super.gtk_key_press_event (widget, event); + if (result !is 0) return result; /* * Feature in GTK. The default behavior when the return key * is pressed is to select the default button. This is not the * expected behavior for Composite and its subclasses. The * fix is to avoid calling the default handler. */ - if ((state & CANVAS) != 0 && socketHandle == 0) { - GdkEventKey keyEvent = new GdkEventKey (); - OS.memmove (keyEvent, event, GdkEventKey.sizeof); + if ((state & CANVAS) !is 0 && socketHandle is null) { + GdkEventKey* keyEvent = event; int key = keyEvent.keyval; switch (key) { case OS.GDK_Return: @@ -709,73 +705,73 @@ return result; } -int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) { - if (widget == socketHandle) return 0; +override int /*long*/ gtk_focus (GtkWidget* widget, int /*long*/ directionType) { + if (widget is socketHandle) return 0; return super.gtk_focus (widget, directionType); } -int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) { +override int /*long*/ gtk_focus_in_event (GtkWidget* widget, int /*long*/ event) { int /*long*/ result = super.gtk_focus_in_event (widget, event); - return (state & CANVAS) != 0 ? 1 : result; + return (state & CANVAS) !is 0 ? 1 : result; } -int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) { - int /*long*/ result = super.gtk_focus_out_event (widget, event); - return (state & CANVAS) != 0 ? 1 : result; +override int /*long*/ gtk_focus_out_event (GtkWidget* widget, int /*long*/ event) { + auto result = super.gtk_focus_out_event (widget, event); + return (state & CANVAS) !is 0 ? 1 : result; } -int /*long*/ gtk_map (int /*long*/ widget) { +override int /*long*/ gtk_map (GtkWidget* widget) { fixZOrder (); return 0; } -int /*long*/ gtk_realize (int /*long*/ widget) { - int /*long*/ result = super.gtk_realize (widget); - if ((style & SWT.NO_BACKGROUND) != 0) { - int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ()); - if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, false); +override int /*long*/ gtk_realize (GtkWidget* widget) { + auto result = super.gtk_realize (widget); + if ((style & SWT.NO_BACKGROUND) !is 0) { + auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); + if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); } - if (socketHandle != 0) { - embeddedHandle = OS.gtk_socket_get_id (socketHandle); + if (socketHandle !is null) { + embeddedHandle = OS.gtk_socket_get_id (cast(GtkSocket*)socketHandle); } return result; } -int /*long*/ gtk_scroll_child (int /*long*/ widget, int /*long*/ scrollType, int /*long*/ horizontal) { +override int /*long*/ gtk_scroll_child (GtkWidget* widget, int /*long*/ scrollType, int /*long*/ horizontal) { /* Stop GTK scroll child signal for canvas */ - OS.g_signal_stop_emission_by_name (widget, OS.scroll_child); + OS.g_signal_stop_emission_by_name (widget, OS.scroll_child.ptr); return 1; } -int /*long*/ gtk_style_set (int /*long*/ widget, int /*long*/ previousStyle) { - int /*long*/ result = super.gtk_style_set (widget, previousStyle); - if ((style & SWT.NO_BACKGROUND) != 0) { - int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ()); - if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, false); +override int /*long*/ gtk_style_set (GtkWidget* widget, int /*long*/ previousStyle) { + auto result = super.gtk_style_set (widget, previousStyle); + if ((style & SWT.NO_BACKGROUND) !is 0) { + auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); + if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); } return result; } -boolean hasBorder () { - return (style & SWT.BORDER) != 0; +bool hasBorder () { + return (style & SWT.BORDER) !is 0; } void hookEvents () { super.hookEvents (); - if ((state & CANVAS) != 0) { + if ((state & CANVAS) !is 0) { OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK); - if (scrolledHandle != 0) { - OS.g_signal_connect_closure (scrolledHandle, OS.scroll_child, display.closures [SCROLL_CHILD], false); + if (scrolledHandle !is null) { + OS.g_signal_connect_closure (scrolledHandle, OS.scroll_child.ptr, display.closures [SCROLL_CHILD], false); } } } -boolean hooksKeys () { +bool hooksKeys () { return hooks (SWT.KeyDown) || hooks (SWT.KeyUp); } -int /*long*/ imHandle () { - return imHandle; +GtkIMContext* imHandle () { + return imHandle_; } /** @@ -791,18 +787,18 @@ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * - * @see #setLayoutDeferred(boolean) + * @see #setLayoutDeferred(bool) * @see #getLayoutDeferred() * * @since 3.1 */ -public boolean isLayoutDeferred () { +public bool isLayoutDeferred () { checkWidget (); - return findDeferredControl () != null; + return findDeferredControl () !is null; } -boolean isTabGroup() { - if ((state & CANVAS) != 0) return true; +bool isTabGroup() { + if ((state & CANVAS) !is 0) return true; return super.isTabGroup(); } @@ -861,9 +857,9 @@ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ -public void layout (boolean changed) { +public void layout (bool changed) { checkWidget (); - if (layout == null) return; + if (layout_ is null) return; layout (changed, false); } @@ -902,9 +898,9 @@ * * @since 3.1 */ -public void layout (boolean changed, boolean all) { +public void layout (bool changed, bool all) { checkWidget (); - if (layout == null && !all) return; + if (layout_ is null && !all) return; markLayout (changed, all); updateLayout (all); } @@ -939,15 +935,15 @@ */ public void layout (Control [] changed) { checkWidget (); - if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); for (int i=0; i<changed.length; i++) { Control control = changed [i]; - if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - boolean ancestor = false; + bool ancestor = false; Composite composite = control.parent; - while (composite != null) { - ancestor = composite == this; + while (composite !is null) { + ancestor = composite is this; if (ancestor) break; composite = composite.parent; } @@ -958,14 +954,14 @@ for (int i=0; i<changed.length; i++) { Control child = changed [i]; Composite composite = child.parent; - while (child != this) { - if (composite.layout != null) { + while (child !is this) { + if (composite.layout_ !is null) { composite.state |= LAYOUT_NEEDED; - if (!composite.layout.flushCache (child)) { + if (!composite.layout_.flushCache (child)) { composite.state |= LAYOUT_CHANGED; } } - if (updateCount == update.length) { + if (updateCount is update.length) { Composite [] newUpdate = new Composite [update.length + 16]; System.arraycopy (update, 0, newUpdate, 0, update.length); update = newUpdate; @@ -979,8 +975,8 @@ } } -void markLayout (boolean changed, boolean all) { - if (layout != null) { +void markLayout (bool changed, bool all) { + if (layout_ !is null) { state |= LAYOUT_NEEDED; if (changed) state |= LAYOUT_CHANGED; } @@ -992,85 +988,84 @@ } } -void moveAbove (int /*long*/ child, int /*long*/ sibling) { - if (child == sibling) return; - int /*long*/ parentHandle = parentingHandle (); - GtkFixed fixed = new GtkFixed (); - OS.memmove (fixed, parentHandle); - int /*long*/ children = fixed.children; - if (children == 0) return; - int /*long*/ [] data = new int /*long*/ [1]; - int /*long*/ [] widget = new int /*long*/ [1]; - int /*long*/ childData = 0, childLink = 0, siblingLink = 0, temp = children; - while (temp != 0) { - OS.memmove (data, temp, OS.PTR_SIZEOF); - OS.memmove (widget, data [0], OS.PTR_SIZEOF); - if (child == widget [0]) { +void moveAbove (GtkWidget* child, GtkWidget* sibling) { + if (child is sibling) return; + auto parentHandle = parentingHandle (); + auto fixed = cast(GtkFixed*)parentHandle; + auto children = fixed.children; + if (children is null) return; + GList* data; + GtkWidget* widget; + GList* childData, childLink, siblingLink; + GList* temp = children; + while (temp !is null) { + data = temp; + widget = cast(GtkWidget*) data; + if (child is widget) { childLink = temp; - childData = data [0]; - } else if (sibling == widget [0]) { + childData = data; + } else if (sibling is widget) { siblingLink = temp; } - if (childData != 0 && (sibling == 0 || siblingLink != 0)) break; - temp = OS.g_list_next (temp); + if (childData !is null && (sibling is null || siblingLink !is null)) break; + temp = cast(GList*)OS.g_list_next (temp); } children = OS.g_list_remove_link (children, childLink); - if (siblingLink == 0 || OS.g_list_previous (siblingLink) == 0) { + if (siblingLink is null || siblingLink.prev is null) { OS.g_list_free_1 (childLink); children = OS.g_list_prepend (children, childData); } else { - temp = OS.g_list_previous (siblingLink); - OS.g_list_set_previous (childLink, temp); - OS.g_list_set_next (temp, childLink); - OS.g_list_set_next (childLink, siblingLink); - OS.g_list_set_previous (siblingLink, childLink); + temp = siblingLink.prev; + childLink.prev = temp; + temp.next = childLink; + childLink.next = siblingLink; + siblingLink.prev = childLink; } fixed.children = children; - OS.memmove (parentHandle, fixed); + parentHandle = cast(GtkWidget*)fixed; } -void moveBelow (int /*long*/ child, int /*long*/ sibling) { - if (child == sibling) return; - int /*long*/ parentHandle = parentingHandle (); - if (sibling == 0 && parentHandle == fixedHandle) { - moveAbove (child, scrolledHandle != 0 ? scrolledHandle : handle); +void moveBelow (GtkWidget* child, GtkWidget* sibling) { + if (child is sibling) return; + auto parentHandle = parentingHandle (); + if (sibling is null && cast(GtkWidget*)parentHandle is cast(GtkWidget*)fixedHandle) { + moveAbove (child, scrolledHandle !is null ? cast(GtkWidget*)scrolledHandle : handle); return; } - GtkFixed fixed = new GtkFixed (); - OS.memmove (fixed, parentHandle); - int /*long*/ children = fixed.children; - if (children == 0) return; - int /*long*/ [] data = new int /*long*/ [1]; - int /*long*/ [] widget = new int /*long*/ [1]; - int /*long*/ childData = 0, childLink = 0, siblingLink = 0, temp = children; - while (temp != 0) { - OS.memmove (data, temp, OS.PTR_SIZEOF); - OS.memmove (widget, data [0], OS.PTR_SIZEOF); - if (child == widget [0]) { + auto fixed = cast(GtkFixed*)parentHandle; + auto children = fixed.children; + if (children is null) return; + GList* data; + GtkWidget* widget; + GList* childData, childLink, siblingLink, temp = children; + while (temp !is null) { + data = temp; + widget = cast(GtkWidget*) data; + if (child is widget) { childLink = temp; - childData = data [0]; - } else if (sibling == widget [0]) { + childData = data; + } else if (sibling is widget) { siblingLink = temp; } - if (childData != 0 && (sibling == 0 || siblingLink != 0)) break; - temp = OS.g_list_next (temp); + if (childData !is null && (sibling is null || siblingLink !is null)) break; + temp = temp.next; } children = OS.g_list_remove_link (children, childLink); - if (siblingLink == 0 || OS.g_list_next (siblingLink) == 0) { + if (siblingLink is null || siblingLink.next is null) { OS.g_list_free_1 (childLink); children = OS.g_list_append (children, childData); } else { - temp = OS.g_list_next (siblingLink); - OS.g_list_set_next (childLink, temp); - OS.g_list_set_previous (temp, childLink); - OS.g_list_set_previous (childLink, siblingLink); - OS.g_list_set_next (siblingLink, childLink); + temp = siblingLink.next; + childLink.next = temp; + temp.prev = childLink; + childLink.prev = siblingLink; + siblingLink.next = childLink; } fixed.children = children; - OS.memmove (parentHandle, fixed); + parentHandle = cast(GtkWidget*)fixed; } -Point minimumSize (int wHint, int hHint, boolean changed) { +Point minimumSize (int wHint, int hHint, bool changed) { Control [] children = _getChildren (); int width = 0, height = 0; for (int i=0; i<children.length; i++) { @@ -1081,9 +1076,9 @@ return new Point (width, height); } -int /*long*/ parentingHandle () { - if ((state & CANVAS) != 0) return handle; - return fixedHandle != 0 ? fixedHandle : handle; +GtkWidget* parentingHandle () { + if ((state & CANVAS) !is 0) return handle; + return fixedHandle !is null ? fixedHandle : handle; } void redrawChildren () { @@ -1091,7 +1086,7 @@ Control [] children = _getChildren (); for (int i = 0; i < children.length; i++) { Control child = children [i]; - if ((child.state & PARENT_BACKGROUND) != 0) { + if ((child.state & PARENT_BACKGROUND) !is 0) { child.redrawWidget (0, 0, 0, 0, true, false, true); child.redrawChildren (); } @@ -1100,14 +1095,14 @@ void register () { super.register (); - if (socketHandle != 0) display.addWidget (socketHandle, this); + if (socketHandle !is null) display.addWidget (socketHandle, this); } -void releaseChildren (boolean destroy) { +void releaseChildren (bool destroy) { Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { Control child = children [i]; - if (child != null && !child.isDisposed ()) { + if (child !is null && !child.isDisposed ()) { child.release (false); } } @@ -1116,14 +1111,15 @@ void releaseHandle () { super.releaseHandle (); - socketHandle = embeddedHandle = 0; + socketHandle = null; + embeddedHandle = 0; } void releaseWidget () { super.releaseWidget (); - if (imHandle != 0) OS.g_object_unref (imHandle); - imHandle = 0; - layout = null; + if (imHandle_ !is null) OS.g_object_unref (imHandle_); + imHandle_ = null; + layout_ = null; tabList = null; } @@ -1133,7 +1129,7 @@ void resizeHandle (int width, int height) { super.resizeHandle (width, height); - if (socketHandle != 0) OS.gtk_widget_set_size_request (socketHandle, width, height); + if (socketHandle !is null) OS.gtk_widget_set_size_request (socketHandle, width, height); } /** @@ -1162,16 +1158,16 @@ } } -int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { +int setBounds (int x, int y, int width, int height, bool move, bool resize) { int result = super.setBounds (x, y, width, height, move, resize); - if ((result & RESIZED) != 0 && layout != null) { + if ((result & RESIZED) !is 0 && layout_ !is null) { markLayout (false, false); updateLayout (false); } return result; } -public boolean setFocus () { +public bool setFocus () { checkWidget(); Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { @@ -1194,7 +1190,7 @@ */ public void setLayout (Layout layout) { checkWidget(); - this.layout = layout; + this.layout_ = layout; } /** @@ -1214,15 +1210,15 @@ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * - * @see #layout(boolean) + * @see #layout(bool) * @see #layout(Control[]) * * @since 3.1 */ -public void setLayoutDeferred (boolean defer) { +public void setLayoutDeferred (bool defer) { if (!defer) { - if (--layoutCount == 0) { - if ((state & LAYOUT_CHILD) != 0 || (state & LAYOUT_NEEDED) != 0) { + if (--layoutCount is 0) { + if ((state & LAYOUT_CHILD) !is 0 || (state & LAYOUT_NEEDED) !is 0) { updateLayout (true); } } @@ -1231,20 +1227,20 @@ } } -boolean setScrollBarVisible (ScrollBar bar, boolean visible) { - boolean changed = super.setScrollBarVisible (bar, visible); - if (changed && layout != null) { +bool setScrollBarVisible (ScrollBar bar, bool visible) { + bool changed = super.setScrollBarVisible (bar, visible); + if (changed && layout_ !is null) { markLayout (false, false); updateLayout (false); } return changed; } -boolean setTabGroupFocus (boolean next) { +bool setTabGroupFocus (bool next) { if (isTabItem ()) return setTabItemFocus (next); - boolean takeFocus = (style & SWT.NO_FOCUS) == 0; - if ((state & CANVAS) != 0) takeFocus = hooksKeys (); - if (socketHandle != 0) takeFocus = true; + bool takeFocus = (style & SWT.NO_FOCUS) is 0; + if ((state & CANVAS) !is 0) takeFocus = hooksKeys (); + if (socketHandle !is null) takeFocus = true; if (takeFocus && setTabItemFocus (next)) return true; Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { @@ -1254,9 +1250,9 @@ return false; } -boolean setTabItemFocus (boolean next) { +bool setTabItemFocus (bool next) { if (!super.setTabItemFocus (next)) return false; - if (socketHandle != 0) { + if (socketHandle !is null) { int direction = next ? OS.GTK_DIR_TAB_FORWARD : OS.GTK_DIR_TAB_BACKWARD; OS.GTK_WIDGET_UNSET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); OS.gtk_widget_child_focus (socketHandle, direction); @@ -1282,12 +1278,12 @@ */ public void setTabList (Control [] tabList) { checkWidget (); - if (tabList != null) { + if (tabList !is null) { for (int i=0; i<tabList.length; i++) { Control control = tabList [i]; - if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - if (control.parent != this) error (SWT.ERROR_INVALID_PARENT); + if (control.parent !is this) error (SWT.ERROR_INVALID_PARENT); } Control [] newList = new Control [tabList.length]; System.arraycopy (tabList, 0, newList, 0, tabList.length); @@ -1298,16 +1294,16 @@ void showWidget () { super.showWidget (); - if (socketHandle != 0) { + if (socketHandle !is null) { OS.gtk_widget_show (socketHandle); - embeddedHandle = OS.gtk_socket_get_id (socketHandle); + embeddedHandle = OS.gtk_socket_get_id (cast(GtkSocket*)socketHandle); } - if (scrolledHandle == 0) fixStyle (handle); + if (scrolledHandle is null) fixStyle (handle); } -boolean translateMnemonic (Event event, Control control) { +bool translateMnemonic (Event event, Control control) { if (super.translateMnemonic (event, control)) return true; - if (control != null) { + if (control !is null) { Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { Control child = children [i]; @@ -1317,16 +1313,16 @@ return false; } -int traversalCode(int key, GdkEventKey event) { - if ((state & CANVAS) != 0) { - if ((style & SWT.NO_FOCUS) != 0) return 0; +int traversalCode(int key, GdkEventKey* event) { + if ((state & CANVAS) !is 0) { + if ((style & SWT.NO_FOCUS) !is 0) return 0; if (hooksKeys ()) return 0; } return super.traversalCode (key, event); } -boolean translateTraversal (GdkEventKey keyEvent) { - if (socketHandle != 0) return false; +bool translateTraversal (GdkEventKey* keyEvent) { + if (socketHandle !is null) return false; return super.translateTraversal (keyEvent); } @@ -1338,16 +1334,16 @@ } } -void updateLayout (boolean all) { +void updateLayout (bool all) { Composite parent = findDeferredControl (); - if (parent != null) { + if (parent !is null) { parent.state |= LAYOUT_CHILD; return; } - if ((state & LAYOUT_NEEDED) != 0) { - boolean changed = (state & LAYOUT_CHANGED) != 0; + if ((state & LAYOUT_NEEDED) !is 0) { + bool changed = (state & LAYOUT_CHANGED) !is 0; state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED); - layout.layout (this, changed); + layout_.layout (this, changed); } if (all) { state &= ~LAYOUT_CHILD; @@ -1358,4 +1354,3 @@ } } } -+/ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/widgets/Layout.d Thu Jan 10 03:51:48 2008 +0100 @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.widgets.Layout; + + +import dwt.graphics.Point; +import dwt.widgets.Control; +import dwt.widgets.Composite; + +/** + * A layout controls the position and size + * of the children of a composite widget. + * This class is the abstract base class for + * layouts. + * + * @see Composite#setLayout(Layout) + */ +public abstract class Layout { + +/** + * Computes and returns the size of the specified + * composite's client area according to this layout. + * <p> + * This method computes the size that the client area + * of the composite must be in order to position all + * children at their preferred size inside the + * composite according to the layout algorithm + * encoded by this layout. + * </p> + * <p> + * When a width or height hint is supplied, it is + * used to constrain the result. For example, if a + * width hint is provided that is less than the + * width of the client area, the layout may choose + * to wrap and increase height, clip, overlap, or + * otherwise constrain the children. + * </p> + * + * @param composite a composite widget using this layout + * @param wHint width (<code>SWT.DEFAULT</code> for preferred size) + * @param hHint height (<code>SWT.DEFAULT</code> for preferred size) + * @param flushCache <code>true</code> means flush cached layout values + * @return a point containing the computed size (width, height) + * + * @see #layout + * @see Control#getBorderWidth + * @see Control#getBounds + * @see Control#getSize + * @see Control#pack(boolean) + * @see "computeTrim, getClientArea for controls that implement them" + */ +abstract Point computeSize (Composite composite, int wHint, int hHint, bool flushCache); + +/** + * Instruct the layout to flush any cached values + * associated with the control specified in the argument + * <code>control</code>. + * + * @param control a control managed by this layout + * @return true if the Layout has flushed all cached information associated with control + * + * @since 3.1 + */ +bool flushCache (Control control) { + return false; +} + +/** + * Lays out the children of the specified composite + * according to this layout. + * <p> + * This method positions and sizes the children of a + * composite using the layout algorithm encoded by this + * layout. Children of the composite are positioned in + * the client area of the composite. The position of + * the composite is not altered by this method. + * </p> + * <p> + * When the flush cache hint is true, the layout is + * instructed to flush any cached values associated + * with the children. Typically, a layout will cache + * the preferred sizes of the children to avoid the + * expense of computing these values each time the + * widget is laid out. + * </p> + * <p> + * When layout is triggered explicitly by the programmer + * the flush cache hint is true. When layout is triggered + * by a resize, either caused by the programmer or by the + * user, the hint is false. + * </p> + * + * @param composite a composite widget using this layout + * @param flushCache <code>true</code> means flush cached layout values + */ +abstract void layout (Composite composite, bool flushCache); +}
--- a/dwt/widgets/Scrollable.d Thu Jan 10 02:18:07 2008 +0100 +++ b/dwt/widgets/Scrollable.d Thu Jan 10 03:51:48 2008 +0100 @@ -38,7 +38,7 @@ * </p> */ public abstract class Scrollable : Control { - GtkScrolledWindow* scrolledHandle; + GtkWidget* scrolledHandle; ScrollBar horizontalBar, verticalBar; /** @@ -141,10 +141,10 @@ bar.display = display; bar.state |= HANDLE; if ((style & SWT.H_SCROLL) !is 0) { - bar.handle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR (scrolledHandle); - bar.adjustmentHandle = OS.gtk_scrolled_window_get_hadjustment (scrolledHandle); + bar.handle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR (cast(GtkScrolledWindow*)scrolledHandle); + bar.adjustmentHandle = OS.gtk_scrolled_window_get_hadjustment (cast(GtkScrolledWindow*)scrolledHandle); } else { - bar.handle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR (scrolledHandle); + bar.handle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR (cast(GtkScrolledWindow*)scrolledHandle); bar.adjustmentHandle = OS.gtk_scrolled_window_get_vadjustment (cast(GtkScrolledWindow*)scrolledHandle); } bar.hookEvents (); @@ -266,11 +266,11 @@ int hScrollBarWidth() { if (horizontalBar is null) return 0; - auto hBarHandle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR(scrolledHandle); + auto hBarHandle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR(cast(GtkScrolledWindow*)scrolledHandle); if (hBarHandle is null) return 0; GtkRequisition* requisition = new GtkRequisition(); OS.gtk_widget_size_request(cast(GtkWidget*)hBarHandle, requisition); - int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(scrolledHandle); + int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(cast(GtkScrolledWindow*)scrolledHandle); return requisition.height + spacing; } @@ -290,7 +290,7 @@ bool setScrollBarVisible (ScrollBar bar, bool visible) { if (scrolledHandle is null) return false; int hsp, vsp; - OS.gtk_scrolled_window_get_policy (scrolledHandle, &hsp, &vsp); + OS.gtk_scrolled_window_get_policy (cast(GtkScrolledWindow*)scrolledHandle, &hsp, &vsp); int policy = visible ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; if ((bar.style & SWT.HORIZONTAL) !is 0) { if (hsp is policy) return false; @@ -299,7 +299,7 @@ if (vsp is policy) return false; vsp = policy; } - OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp); + OS.gtk_scrolled_window_set_policy (cast(GtkScrolledWindow*)scrolledHandle, hsp, vsp); bar.sendEvent (visible ? SWT.Show : SWT.Hide); sendEvent (SWT.Resize); return true; @@ -364,7 +364,7 @@ GtkWidget* topHandle () { if (fixedHandle !is null) return fixedHandle; - if (scrolledHandle !is null) return cast(GtkWidget*)scrolledHandle; + if (scrolledHandle !is null) return scrolledHandle; return super.topHandle (); } @@ -374,11 +374,11 @@ int vScrollBarWidth() { if (verticalBar is null) return 0; - auto vBarHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR(scrolledHandle); + auto vBarHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR(cast(GtkScrolledWindow*)scrolledHandle); if (vBarHandle is null) return 0; GtkRequisition* requisition = new GtkRequisition(); OS.gtk_widget_size_request (cast(GtkWidget*)vBarHandle, requisition); - int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(scrolledHandle); + int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(cast(GtkScrolledWindow*)scrolledHandle); return requisition.width + spacing; } }
--- a/todo.txt Thu Jan 10 02:18:07 2008 +0100 +++ b/todo.txt Thu Jan 10 03:51:48 2008 +0100 @@ -5,7 +5,7 @@ Questions: Whats needed at minimum to make a test with empty window? How about memory management? - + Check to remove "package", it non-virtual. SWT // left: getMessage -> Compatibility:ResourceBundle SWTError // OK