# HG changeset patch # User Frank Benoit # Date 1200028870 -3600 # Node ID dfcb4aee42d4e12b237761a19a8be78dc4584756 # Parent ecf39b275c8dd7e04f294e3a39cd4562c924c7aa Button and ImageList diff -r ecf39b275c8d -r dfcb4aee42d4 dwt/internal/gtk/OS.d --- a/dwt/internal/gtk/OS.d Fri Jan 11 05:22:12 2008 +0100 +++ b/dwt/internal/gtk/OS.d Fri Jan 11 06:21:10 2008 +0100 @@ -126,6 +126,14 @@ public alias dwt.internal.c.gtk.GtkSocket GtkSocket; public alias dwt.internal.c.gtk.GtkAccelGroup GtkAccelGroup; public alias dwt.internal.c.gtk.GtkTooltips GtkTooltips; +public alias dwt.internal.c.gtk.GtkBorder GtkBorder; +public alias dwt.internal.c.gtk.GtkObject GtkObject; +public alias dwt.internal.c.gtk.GtkRadioButton GtkRadioButton; +public alias dwt.internal.c.gtk.GtkToggleButton GtkToggleButton; +public alias dwt.internal.c.gtk.GtkArrow GtkArrow; +public alias dwt.internal.c.gtk.GtkBox GtkBox; +public alias dwt.internal.c.gtk.GtkMisc GtkMisc; +public alias dwt.internal.c.gtk.GtkImage GtkImage; public alias dwt.internal.c.Xlib.XErrorEvent XErrorEvent; public alias dwt.internal.c.Xlib.XExposeEvent XExposeEvent; diff -r ecf39b275c8d -r dfcb4aee42d4 dwt/widgets/Button.d --- a/dwt/widgets/Button.d Fri Jan 11 05:22:12 2008 +0100 +++ b/dwt/widgets/Button.d Fri Jan 11 06:21:10 2008 +0100 @@ -12,15 +12,17 @@ import dwt.widgets.Control; -class Button : Control { -} +import dwt.internal.gtk.OS; +import dwt.SWT; +import dwt.graphics.Point; +import dwt.graphics.Image; +import dwt.widgets.ImageList; +import dwt.widgets.Composite; +import dwt.events.SelectionListener; +import dwt.widgets.TypedListener; +import dwt.widgets.Decorations; -/+ -import dwt.internal.*; -import dwt.internal.gtk.*; -import dwt.*; -import dwt.graphics.*; -import dwt.events.*; +import tango.stdc.stringz; /** * Instances of this class represent a selectable user interface object that @@ -45,12 +47,12 @@ * within the SWT implementation. *

*/ -public class Button extends Control { - int /*long*/ boxHandle, labelHandle, imageHandle, arrowHandle, groupHandle; - boolean selected; +public class Button : Control { + GtkWidget* boxHandle, labelHandle, imageHandle, arrowHandle, groupHandle; + bool selected; ImageList imageList; Image image; - String text; + char[] text; /** * Constructs a new instance of this class given its parent @@ -88,19 +90,19 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public Button (Composite parent, int style) { +public this (Composite parent, int style) { super (parent, checkStyle (style)); } static int checkStyle (int style) { style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0); - if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) { + if ((style & (SWT.PUSH | SWT.TOGGLE)) !is 0) { return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0); } - if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { + if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) { return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0); } - if ((style & SWT.ARROW) != 0) { + if ((style & SWT.ARROW) !is 0) { style |= SWT.NO_FOCUS; return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0); } @@ -133,16 +135,16 @@ */ public void addSelectionListener (SelectionListener listener) { checkWidget (); - if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Selection,typedListener); addListener (SWT.DefaultSelection,typedListener); } -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; /* * Feature in GTK, GtkCheckButton and GtkRadioButton allocate * only the minimum size necessary for its child. This causes the child @@ -150,30 +152,28 @@ * of the button. */ forceResize (); - int [] reqWidth = null, reqHeight = null; - if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { - reqWidth = new int [1]; - reqHeight = new int [1]; - OS.gtk_widget_get_size_request (boxHandle, reqWidth, reqHeight); + int reqWidth = -1, reqHeight = -1; + if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) { + OS.gtk_widget_get_size_request (boxHandle, &reqWidth, &reqHeight); OS.gtk_widget_set_size_request (boxHandle, -1, -1); } Point size = computeNativeSize (handle, wHint, hHint, changed); - if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { - OS.gtk_widget_set_size_request (boxHandle, reqWidth [0], reqHeight [0]); + if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) { + OS.gtk_widget_set_size_request (boxHandle, reqWidth, reqHeight); } - if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) { - if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_CAN_DEFAULT) != 0) { - int /*long*/ [] buffer = new int /*long*/ [1]; - GtkBorder border = new GtkBorder (); - OS.gtk_widget_style_get (handle, OS.default_border, buffer, 0); - if (buffer[0] != 0) { - OS.memmove (border, buffer[0], GtkBorder.sizeof); + if (wHint !is SWT.DEFAULT || hHint !is SWT.DEFAULT) { + if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_CAN_DEFAULT) !is 0) { + GtkBorder* border = new GtkBorder (); + GtkBorder* buffer; + OS.gtk_widget_style_get1 (handle, OS.default_border.ptr, cast(int*)&buffer ); + if (buffer !is null) { + border = buffer; } else { /* Use the GTK+ default value of 1 for each. */ border.left = border.right = border.top = border.bottom = 1; } - if (wHint != SWT.DEFAULT) size.x += border.left + border.right; - if (hHint != SWT.DEFAULT) size.y += border.top + border.bottom; + if (wHint !is SWT.DEFAULT) size.x += border.left + border.right; + if (hHint !is SWT.DEFAULT) size.y += border.top + border.bottom; } } return size; @@ -181,30 +181,30 @@ void createHandle (int index) { state |= HANDLE; - if ((style & SWT.PUSH) == 0) state |= THEME_BACKGROUND; + if ((style & SWT.PUSH) is 0) state |= THEME_BACKGROUND; int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH; - 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); switch (style & bits) { case SWT.ARROW: int arrow_type = OS.GTK_ARROW_UP; - if ((style & SWT.UP) != 0) arrow_type = OS.GTK_ARROW_UP; - if ((style & SWT.DOWN) != 0) arrow_type = OS.GTK_ARROW_DOWN; - if ((style & SWT.LEFT) != 0) arrow_type = OS.GTK_ARROW_LEFT; - if ((style & SWT.RIGHT) != 0) arrow_type = OS.GTK_ARROW_RIGHT; + if ((style & SWT.UP) !is 0) arrow_type = OS.GTK_ARROW_UP; + if ((style & SWT.DOWN) !is 0) arrow_type = OS.GTK_ARROW_DOWN; + if ((style & SWT.LEFT) !is 0) arrow_type = OS.GTK_ARROW_LEFT; + if ((style & SWT.RIGHT) !is 0) arrow_type = OS.GTK_ARROW_RIGHT; handle = OS.gtk_button_new (); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + if (handle is null) error (SWT.ERROR_NO_HANDLES); arrowHandle = OS.gtk_arrow_new (arrow_type, OS.GTK_SHADOW_OUT); - if (arrowHandle == 0) error (SWT.ERROR_NO_HANDLES); + if (arrowHandle is null) error (SWT.ERROR_NO_HANDLES); break; case SWT.TOGGLE: handle = OS.gtk_toggle_button_new (); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + if (handle is null) error (SWT.ERROR_NO_HANDLES); break; case SWT.CHECK: handle = OS.gtk_check_button_new (); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + if (handle is null) error (SWT.ERROR_NO_HANDLES); break; case SWT.RADIO: /* @@ -218,36 +218,36 @@ * to the same group. This allows the visible button to be * unselected. */ - groupHandle = OS.gtk_radio_button_new (0); - if (groupHandle == 0) error (SWT.ERROR_NO_HANDLES); + groupHandle = cast(GtkWidget*)OS.gtk_radio_button_new (null); + if (groupHandle is null) error (SWT.ERROR_NO_HANDLES); OS.g_object_ref (groupHandle); - OS.gtk_object_sink (groupHandle); - handle = OS.gtk_radio_button_new (OS.gtk_radio_button_get_group (groupHandle)); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + OS.gtk_object_sink (cast(GtkObject*)groupHandle); + handle = OS.gtk_radio_button_new ( OS.gtk_radio_button_get_group (cast(GtkRadioButton*)groupHandle)); + if (handle is null) error (SWT.ERROR_NO_HANDLES); break; case SWT.PUSH: default: handle = OS.gtk_button_new (); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + if (handle is null) error (SWT.ERROR_NO_HANDLES); OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_DEFAULT); break; } - if ((style & SWT.ARROW) != 0) { - OS.gtk_container_add (handle, arrowHandle); + if ((style & SWT.ARROW) !is 0) { + OS.gtk_container_add (cast(GtkContainer*)handle, arrowHandle); } else { boxHandle = OS.gtk_hbox_new (false, 4); - if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); + if (boxHandle is null) error (SWT.ERROR_NO_HANDLES); labelHandle = OS.gtk_label_new_with_mnemonic (null); - if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); + if (labelHandle is null) error (SWT.ERROR_NO_HANDLES); imageHandle = OS.gtk_image_new (); - if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES); - OS.gtk_container_add (handle, boxHandle); - OS.gtk_container_add (boxHandle, imageHandle); - OS.gtk_container_add (boxHandle, labelHandle); + if (imageHandle is null) error (SWT.ERROR_NO_HANDLES); + OS.gtk_container_add (cast(GtkContainer*)handle, boxHandle); + OS.gtk_container_add (cast(GtkContainer*)boxHandle, imageHandle); + OS.gtk_container_add (cast(GtkContainer*)boxHandle, labelHandle); } - OS.gtk_container_add (fixedHandle, handle); + OS.gtk_container_add (cast(GtkContainer*)fixedHandle, handle); - if ((style & SWT.ARROW) != 0) return; + if ((style & SWT.ARROW) !is 0) return; _setAlignment (style & (SWT.LEFT | SWT.CENTER | SWT.RIGHT)); } @@ -258,14 +258,14 @@ void deregister () { super.deregister (); - if (boxHandle != 0) display.removeWidget (boxHandle); - if (labelHandle != 0) display.removeWidget (labelHandle); - if (imageHandle != 0) display.removeWidget (imageHandle); - if (arrowHandle != 0) display.removeWidget (arrowHandle); + if (boxHandle !is null) display.removeWidget (boxHandle); + if (labelHandle !is null) display.removeWidget (labelHandle); + if (imageHandle !is null) display.removeWidget (imageHandle); + if (arrowHandle !is null) display.removeWidget (arrowHandle); } -int /*long*/ fontHandle () { - if (labelHandle != 0) return labelHandle; +override GtkWidget* fontHandle () { + if (labelHandle !is null) return labelHandle; return super.fontHandle (); } @@ -287,16 +287,16 @@ */ public int getAlignment () { checkWidget (); - if ((style & SWT.ARROW) != 0) { - if ((style & SWT.UP) != 0) return SWT.UP; - if ((style & SWT.DOWN) != 0) return SWT.DOWN; - if ((style & SWT.LEFT) != 0) return SWT.LEFT; - if ((style & SWT.RIGHT) != 0) return SWT.RIGHT; + if ((style & SWT.ARROW) !is 0) { + if ((style & SWT.UP) !is 0) return SWT.UP; + if ((style & SWT.DOWN) !is 0) return SWT.DOWN; + if ((style & SWT.LEFT) !is 0) return SWT.LEFT; + if ((style & SWT.RIGHT) !is 0) return SWT.RIGHT; return SWT.UP; } - if ((style & SWT.LEFT) != 0) return SWT.LEFT; - if ((style & SWT.CENTER) != 0) return SWT.CENTER; - if ((style & SWT.RIGHT) != 0) return SWT.RIGHT; + if ((style & SWT.LEFT) !is 0) return SWT.LEFT; + if ((style & SWT.CENTER) !is 0) return SWT.CENTER; + if ((style & SWT.RIGHT) !is 0) return SWT.RIGHT; return SWT.LEFT; } @@ -316,7 +316,7 @@ return image; } -String getNameText () { +char[] getNameText () { return getText (); } @@ -336,10 +336,10 @@ *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • * */ -public boolean getSelection () { +public bool getSelection () { checkWidget (); - if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false; - return OS.gtk_toggle_button_get_active (handle); + if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) is 0) return false; + return cast(bool)OS.gtk_toggle_button_get_active (cast(GtkToggleButton*)handle); } /** @@ -354,22 +354,22 @@ *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • * */ -public String getText () { +public char[] getText () { checkWidget(); - if ((style & SWT.ARROW) != 0) return ""; + if ((style & SWT.ARROW) !is 0) return ""; return text; } -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 ((style & SWT.RADIO) != 0) selected = getSelection (); +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 ((style & SWT.RADIO) !is 0) selected = getSelection (); return result; } -int /*long*/ gtk_clicked (int /*long*/ widget) { - if ((style & SWT.RADIO) != 0) { - if ((parent.getStyle () & SWT.NO_RADIO_GROUP) != 0) { +override int /*long*/ gtk_clicked (GtkWidget* widget) { + if ((style & SWT.RADIO) !is 0) { + if ((parent.getStyle () & SWT.NO_RADIO_GROUP) !is 0) { setSelection (!selected); } else { selectRadio (); @@ -379,79 +379,81 @@ return 0; } -int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) { - int /*long*/ result = super.gtk_focus_in_event (widget, event); +override int /*long*/ gtk_focus_in_event (GtkWidget* widget, GdkEventFocus* event) { + auto result = super.gtk_focus_in_event (widget, event); // widget could be disposed at this point - if (handle == 0) return 0; - if ((style & SWT.PUSH) != 0 && OS.GTK_WIDGET_HAS_DEFAULT (handle)) { + if (handle is null) return 0; + if ((style & SWT.PUSH) !is 0 && OS.GTK_WIDGET_HAS_DEFAULT (handle)) { Decorations menuShell = menuShell (); menuShell.defaultButton = this; } return result; } -int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) { - int /*long*/ result = super.gtk_focus_out_event (widget, event); +override int /*long*/ gtk_focus_out_event (GtkWidget* widget, GdkEventFocus* event) { + auto result = super.gtk_focus_out_event (widget, event); // widget could be disposed at this point - if (handle == 0) return 0; - if ((style & SWT.PUSH) != 0 && !OS.GTK_WIDGET_HAS_DEFAULT (handle)) { + if (handle is null) return 0; + if ((style & SWT.PUSH) !is 0 && !OS.GTK_WIDGET_HAS_DEFAULT (handle)) { Decorations menuShell = menuShell (); - if (menuShell.defaultButton == this) { + if (menuShell.defaultButton is this) { menuShell.defaultButton = null; } } return result; } -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; - if ((style & SWT.RADIO) != 0) selected = getSelection (); +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; + if ((style & SWT.RADIO) !is 0) selected = getSelection (); return result; } void hookEvents () { super.hookEvents(); - OS.g_signal_connect_closure (handle, OS.clicked, display.closures [CLICKED], false); - if (labelHandle != 0) { - OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false); + OS.g_signal_connect_closure (handle, OS.clicked.ptr, display.closures [CLICKED], false); + if (labelHandle !is null) { + OS.g_signal_connect_closure_by_id (cast(void*)labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false); } } -boolean isDescribedByLabel () { +bool isDescribedByLabel () { return false; } -boolean mnemonicHit (char key) { - if (labelHandle == 0) return false; - boolean result = super.mnemonicHit (labelHandle, key); +alias Control.mnemonicHit mnemonicHit; +bool mnemonicHit (char key) { + if (labelHandle is null) return false; + bool result = super.mnemonicHit (labelHandle, key); if (result) setFocus (); return result; } -boolean mnemonicMatch (char key) { - if (labelHandle == 0) return false; +alias Control.mnemonicMatch mnemonicMatch; +bool mnemonicMatch (char key) { + if (labelHandle is null) return false; return mnemonicMatch (labelHandle, key); } void register () { super.register (); - if (boxHandle != 0) display.addWidget (boxHandle, this); - if (labelHandle != 0) display.addWidget (labelHandle, this); - if (imageHandle != 0) display.addWidget (imageHandle, this); - if (arrowHandle != 0) display.addWidget (arrowHandle, this); + if (boxHandle !is null) display.addWidget (boxHandle, this); + if (labelHandle !is null) display.addWidget (labelHandle, this); + if (imageHandle !is null) display.addWidget (imageHandle, this); + if (arrowHandle !is null) display.addWidget (arrowHandle, this); } void releaseHandle () { super.releaseHandle (); - boxHandle = imageHandle = labelHandle = arrowHandle = 0; + boxHandle = imageHandle = labelHandle = arrowHandle = null; } void releaseWidget () { super.releaseWidget (); - if (groupHandle != 0) OS.g_object_unref (groupHandle); - groupHandle = 0; - if (imageList != null) imageList.dispose (); + if (groupHandle !is null) OS.g_object_unref (groupHandle); + groupHandle = null; + if (imageList !is null) imageList.dispose (); imageList = null; image = null; text = null; @@ -476,8 +478,8 @@ */ public void removeSelectionListener (SelectionListener listener) { checkWidget(); - if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable == null) return; + if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable is null) return; eventTable.unhook (SWT.Selection, listener); eventTable.unhook (SWT.DefaultSelection,listener); } @@ -490,7 +492,7 @@ * alignment to fail. The fix is to set the child size to the size * of the button. */ - if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { + if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) { OS.gtk_widget_set_size_request (boxHandle, width, -1); } } @@ -506,7 +508,7 @@ */ // int index = 0; // Control [] children = parent._getChildren (); -// while (index < children.length && children [index] != this) index++; +// while (index < children.length && children [index] !is this) index++; // int i = index - 1; // while (i >= 0 && children [i].setRadioSelection (false)) --i; // int j = index + 1; @@ -515,7 +517,7 @@ Control [] children = parent._getChildren (); for (int i=0; iERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * */ -public void setSelection (boolean selected) { +public void setSelection (bool selected) { checkWidget(); - if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return; - OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED); - OS.gtk_toggle_button_set_active (handle, selected); - if ((style & SWT.RADIO) != 0) OS.gtk_toggle_button_set_active (groupHandle, !selected); - OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED); + if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) is 0) return; + OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, cast(void*)CLICKED); + OS.gtk_toggle_button_set_active (cast(GtkToggleButton*)handle, selected); + if ((style & SWT.RADIO) !is 0) OS.gtk_toggle_button_set_active (cast(GtkToggleButton*)groupHandle, !selected); + OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, cast(void*)CLICKED); } /** @@ -741,31 +745,30 @@ *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • * */ -public void setText (String string) { +public void setText (char[] string) { checkWidget (); - if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - if ((style & SWT.ARROW) != 0) return; + if (string is null) error (SWT.ERROR_NULL_ARGUMENT); + if ((style & SWT.ARROW) !is 0) return; text = string; char [] chars = fixMnemonic (string); - byte [] buffer = Converter.wcsToMbcs (null, chars, true); - OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer); - if (image == null) OS.gtk_widget_hide (imageHandle); + OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, toStringz(chars)); + if (image is null) OS.gtk_widget_hide (imageHandle); OS.gtk_widget_show (labelHandle); _setAlignment (style); } void showWidget () { super.showWidget (); - if (boxHandle != 0) OS.gtk_widget_show (boxHandle); - if (labelHandle != 0) OS.gtk_widget_show (labelHandle); - if (arrowHandle != 0) OS.gtk_widget_show (arrowHandle); + if (boxHandle !is null) OS.gtk_widget_show (boxHandle); + if (labelHandle !is null) OS.gtk_widget_show (labelHandle); + if (arrowHandle !is null) OS.gtk_widget_show (arrowHandle); } -int traversalCode (int key, GdkEventKey event) { +alias Control.traversalCode traversalCode; +override int traversalCode (int key, GdkEventKey* event) { int code = super.traversalCode (key, event); - if ((style & SWT.RADIO) != 0) code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS; + if ((style & SWT.RADIO) !is 0) code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS; return code; } } -+/ \ No newline at end of file diff -r ecf39b275c8d -r dfcb4aee42d4 dwt/widgets/Control.d --- a/dwt/widgets/Control.d Fri Jan 11 05:22:12 2008 +0100 +++ b/dwt/widgets/Control.d Fri Jan 11 06:21:10 2008 +0100 @@ -2922,10 +2922,12 @@ return parent.menuShell (); } +alias Widget.mnemonicHit mnemonicHit; bool mnemonicHit (char key) { return false; } +alias Widget.mnemonicMatch mnemonicMatch; bool mnemonicMatch (char key) { return false; } diff -r ecf39b275c8d -r dfcb4aee42d4 dwt/widgets/ImageList.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/widgets/ImageList.d Fri Jan 11 06:21:10 2008 +0100 @@ -0,0 +1,155 @@ +/******************************************************************************* + * 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.ImageList; + + +import dwt.internal.gtk.OS; +import dwt.graphics.Image; +import dwt.dwthelper.System; +import dwt.widgets.Display; + + +class ImageList { + GdkPixbuf* [] pixbufs; + int width = -1, height = -1; + Image [] images; + +public this() { + images = new Image [4]; + pixbufs = new GdkPixbuf*[4]; +} + +public int add (Image image) { + int index = 0; + while (index < images.length) { + if (images [index] !is null) { + if (images [index].isDisposed ()) { + OS.g_object_unref (pixbufs [index]); + images [index] = null; + pixbufs [index] = null; + } + } + if (images [index] is null) break; + index++; + } + if (index is images.length) { + Image [] newImages = new Image [images.length + 4]; + System.arraycopy (images, 0, newImages, 0, images.length); + images = newImages; + pixbufs.length = pixbufs.length + 4; + } + set (index, image); + return index; +} + +public void dispose () { + if (pixbufs is null) return; + for (int index=0; index