changeset 44:dfcb4aee42d4

Button and ImageList
author Frank Benoit <benoit@tionex.de>
date Fri, 11 Jan 2008 06:21:10 +0100
parents ecf39b275c8d
children 2618d7245bce
files dwt/internal/gtk/OS.d dwt/widgets/Button.d dwt/widgets/Control.d dwt/widgets/ImageList.d dwt/widgets/Widget.d
diffstat 5 files changed, 367 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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.
  * </p>
  */
-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 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-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 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-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; i<children.length; i++) {
 		Control child = children [i];
-		if (this != child) child.setRadioSelection (false);
+		if (this !is child) child.setRadioSelection (false);
 	}
 	setSelection (true);
 }
@@ -542,92 +544,94 @@
 }
 
 void _setAlignment (int alignment) {
-	if ((style & SWT.ARROW) != 0) {
-		if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) == 0) return;
+	if ((style & SWT.ARROW) !is 0) {
+		if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) is 0) return;
 		style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
 		style |= alignment & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
 		int arrow_type = OS.GTK_ARROW_UP;
-		boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
+		bool isRTL = (style & SWT.RIGHT_TO_LEFT) !is 0;
 		switch (alignment) {
 			case SWT.UP: arrow_type = OS.GTK_ARROW_UP; break;
 			case SWT.DOWN: arrow_type = OS.GTK_ARROW_DOWN; break;
 			case SWT.LEFT: arrow_type = isRTL ? OS.GTK_ARROW_RIGHT : OS.GTK_ARROW_LEFT; break;
 			case SWT.RIGHT: arrow_type = isRTL ? OS.GTK_ARROW_LEFT : OS.GTK_ARROW_RIGHT; break;
 		}
-		OS.gtk_arrow_set (arrowHandle, arrow_type, OS.GTK_SHADOW_OUT);
+		OS.gtk_arrow_set (cast(GtkArrow*)arrowHandle, arrow_type, OS.GTK_SHADOW_OUT);
 		return;
 	}
-	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) is 0) return;
 	style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
 	style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
 	/* Alignment not honoured when image and text are visible */
-	boolean bothVisible = OS.GTK_WIDGET_VISIBLE (labelHandle) && OS.GTK_WIDGET_VISIBLE (imageHandle);
+	bool bothVisible = OS.GTK_WIDGET_VISIBLE (labelHandle) && OS.GTK_WIDGET_VISIBLE (imageHandle);
 	if (bothVisible) {
-		if ((style & (SWT.RADIO | SWT.CHECK)) != 0) alignment = SWT.LEFT;
-		if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) alignment = SWT.CENTER;
+		if ((style & (SWT.RADIO | SWT.CHECK)) !is 0) alignment = SWT.LEFT;
+		if ((style & (SWT.PUSH | SWT.TOGGLE)) !is 0) alignment = SWT.CENTER;
 	}
-	if ((alignment & SWT.LEFT) != 0) {
+	if ((alignment & SWT.LEFT) !is 0) {
 		if (bothVisible) {
-			OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_START);
-			OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_START);
+			OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_START);
+			OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_START);
 		}
-		OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.5f);
-		OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_LEFT);
-		OS.gtk_misc_set_alignment (imageHandle, 0.0f, 0.5f);
+		OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.0f, 0.5f);
+		OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_LEFT);
+		OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 0.0f, 0.5f);
 		return;
 	}
-	if ((alignment & SWT.CENTER) != 0) {
+	if ((alignment & SWT.CENTER) !is 0) {
 		if (bothVisible) {
-			OS.gtk_box_set_child_packing (boxHandle, labelHandle, true, true, 0, OS.GTK_PACK_END);
-			OS.gtk_box_set_child_packing (boxHandle, imageHandle, true, true, 0, OS.GTK_PACK_START);
-			OS.gtk_misc_set_alignment (labelHandle, 0f, 0.5f);
-			OS.gtk_misc_set_alignment (imageHandle, 1f, 0.5f);
+			OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, labelHandle, true, true, 0, OS.GTK_PACK_END);
+			OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, imageHandle, true, true, 0, OS.GTK_PACK_START);
+			OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0f, 0.5f);
+			OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 1f, 0.5f);
 		} else {
-			OS.gtk_misc_set_alignment (labelHandle, 0.5f, 0.5f);
-			OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_CENTER);
-			OS.gtk_misc_set_alignment (imageHandle, 0.5f, 0.5f);
+			OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.5f, 0.5f);
+			OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_CENTER);
+			OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 0.5f, 0.5f);
 		}
 		return;
 	}
-	if ((alignment & SWT.RIGHT) != 0) {
+	if ((alignment & SWT.RIGHT) !is 0) {
 		if (bothVisible) {
-			OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_END);
-			OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_END);
+			OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_END);
+			OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_END);
 		}
-		OS.gtk_misc_set_alignment (labelHandle, 1.0f, 0.5f);
-		OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_RIGHT);
-		OS.gtk_misc_set_alignment (imageHandle, 1.0f, 0.5f);
+		OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 1.0f, 0.5f);
+		OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_RIGHT);
+		OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 1.0f, 0.5f);
 		return;
 	}
 }
 
-void setBackgroundColor (GdkColor color) {
+alias Control.setBackgroundColor setBackgroundColor;
+override void setBackgroundColor (GdkColor* color) {
 	super.setBackgroundColor (color);
 	setBackgroundColor(fixedHandle, color);
-	if (labelHandle != 0) setBackgroundColor(labelHandle, color);
-	if (imageHandle != 0) setBackgroundColor(imageHandle, color);
+	if (labelHandle !is null) setBackgroundColor(labelHandle, color);
+	if (imageHandle !is null) setBackgroundColor(imageHandle, color);
 }
 
-void setFontDescription (int /*long*/ font) {
+void setFontDescription (PangoFontDescription* font) {
 	super.setFontDescription (font);
-	if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
-	if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+	if (labelHandle !is null) OS.gtk_widget_modify_font (labelHandle, font);
+	if (imageHandle !is null) OS.gtk_widget_modify_font (imageHandle, font);
 }
 
-boolean setRadioSelection (boolean value) {
-	if ((style & SWT.RADIO) == 0) return false;
-	if (getSelection () != value) {
+bool setRadioSelection (bool value) {
+	if ((style & SWT.RADIO) is 0) return false;
+	if (getSelection () !is value) {
 		setSelection (value);
 		postEvent (SWT.Selection);
 	}
 	return true;
 }
 
-void setForegroundColor (GdkColor color) {
+alias Control.setForegroundColor setForegroundColor;
+override void setForegroundColor (GdkColor* color) {
 	super.setForegroundColor (color);
 	setForegroundColor (fixedHandle, color);
-	if (labelHandle != 0) setForegroundColor (labelHandle, color);
-	if (imageHandle != 0) setForegroundColor (imageHandle, color);
+	if (labelHandle !is null) setForegroundColor (labelHandle, color);
+	if (imageHandle !is null) setForegroundColor (imageHandle, color);
 }
 
 /**
@@ -651,19 +655,19 @@
  */
 public void setImage (Image image) {
 	checkWidget ();
-	if ((style & SWT.ARROW) != 0) return;
-	if (imageList != null) imageList.dispose ();
+	if ((style & SWT.ARROW) !is 0) return;
+	if (imageList !is null) imageList.dispose ();
 	imageList = null;
-	if (image != null) {
+	if (image !is null) {
 		if (image.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
 		imageList = new ImageList ();
 		int imageIndex = imageList.add (image);
-		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
-		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
-		if (text.length () == 0) OS.gtk_widget_hide (labelHandle);
+		auto pixbuf = imageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (cast(GtkImage*)imageHandle, pixbuf);
+		if (text.length is 0) OS.gtk_widget_hide (labelHandle);
 		OS.gtk_widget_show (imageHandle);
 	} else {
-		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_image_set_from_pixbuf (cast(GtkImage*)imageHandle, null);
 		OS.gtk_widget_show (labelHandle);
 		OS.gtk_widget_hide (imageHandle);
 	}
@@ -673,13 +677,13 @@
 
 void setOrientation () {
 	super.setOrientation ();
-	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
-		if (labelHandle != 0) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
-		if (imageHandle != 0) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
-		if (arrowHandle != 0) {
+	if ((style & SWT.RIGHT_TO_LEFT) !is 0) {
+		if (labelHandle !is null) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
+		if (imageHandle !is null) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
+		if (arrowHandle !is null) {
 			switch (style & (SWT.LEFT | SWT.RIGHT)) {
-				case SWT.LEFT: OS.gtk_arrow_set (arrowHandle, OS.GTK_ARROW_RIGHT, OS.GTK_SHADOW_OUT); break;
-				case SWT.RIGHT: OS.gtk_arrow_set (arrowHandle, OS.GTK_ARROW_LEFT, OS.GTK_SHADOW_OUT); break;
+				case SWT.LEFT: OS.gtk_arrow_set (cast(GtkArrow*)arrowHandle, OS.GTK_ARROW_RIGHT, OS.GTK_SHADOW_OUT); break;
+				case SWT.RIGHT: OS.gtk_arrow_set (cast(GtkArrow*)arrowHandle, OS.GTK_ARROW_LEFT, OS.GTK_SHADOW_OUT); break;
 			}
 		}
 	}
@@ -701,13 +705,13 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-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 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-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
--- 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;
 }
--- /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<pixbufs.length; index++) {
+		if (pixbufs [index] !is null) OS.g_object_unref (pixbufs [index]);
+	}
+	images = null;
+	pixbufs = null;
+}
+
+public Image get (int index) {
+	return images [index];
+}
+
+GdkPixbuf* getPixbuf (int index) {
+	return pixbufs [index];
+}
+
+public int indexOf (Image image) {
+	if (image is null) return -1;
+	for (int index=0; index<images.length; index++) {
+		if (image is images [index]) return index;
+	}
+	return -1;
+}
+
+int indexOf (GdkPixbuf* pixbuf) {
+	if (pixbuf is null) return -1;
+	for (int index=0; index<images.length; index++) {
+		if (pixbuf is pixbufs [index]) return index;
+	}
+	return -1;
+}
+
+public bool isDisposed () {
+	return images is null;
+}
+
+public void put (int index, Image image) {
+	int count = images.length;
+	if (!(0 <= index && index < count)) return;
+	if (image !is null) {
+		set (index, image);
+	} else {
+		images [index] = null;
+		if (pixbufs [index] !is null) OS.g_object_unref (pixbufs [index]);
+		pixbufs [index] = null;
+	}
+}
+
+public void remove (Image image) {
+	if (image is null) return;
+	for (int index=0; index<images.length; index++) {
+		if (image is images [index]){
+			OS.g_object_unref (pixbufs [index]);
+			images [index] = null;
+			pixbufs [index] = null;
+		}
+	}
+}
+
+void set (int index, Image image) {
+	int w, h;
+ 	OS.gdk_drawable_get_size (image.pixmap, &w, &h);
+	auto pixbuf = Display.createPixbuf (image);
+	if (width is -1 || height is -1) {
+		width = w;
+		height = h;
+	}
+	if (w !is width || h !is height) {
+		auto scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, width, height, OS.GDK_INTERP_BILINEAR);
+		OS.g_object_unref (pixbuf);
+		pixbuf = scaledPixbuf;
+	}
+	auto oldPixbuf = pixbufs [index];
+	if (oldPixbuf !is null) {
+		if (images [index] is image) {
+			OS.gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, oldPixbuf, 0, 0);
+			OS.g_object_unref (pixbuf);
+			pixbuf = oldPixbuf;
+		} else {
+			OS.g_object_unref (oldPixbuf);
+		}
+	}
+	pixbufs [index] = pixbuf;
+	images [index] = image;
+}
+
+public int size () {
+	int result = 0;
+	for (int index=0; index<images.length; index++) {
+		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) result++;
+		}
+	}
+	return result;
+}
+
+}
--- a/dwt/widgets/Widget.d	Fri Jan 11 05:22:12 2008 +0100
+++ b/dwt/widgets/Widget.d	Fri Jan 11 06:21:10 2008 +0100
@@ -918,7 +918,7 @@
 	return 0;
 }
 
-bool mnemonicHit (int /*long*/ mnemonicHandle, char key) {
+bool mnemonicHit (GtkWidget* mnemonicHandle, char key) {
 	if (!mnemonicMatch (mnemonicHandle, key)) return false;
 	OS.g_signal_handlers_block_matched ( cast(void*)mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, cast(void*)MNEMONIC_ACTIVATE);
 	bool result = cast(bool)OS.gtk_widget_mnemonic_activate (cast(GtkWidget*)mnemonicHandle, false);
@@ -926,7 +926,7 @@
 	return result;
 }
 
-bool mnemonicMatch (int /*long*/ mnemonicHandle, char key) {
+bool mnemonicMatch (GtkWidget* mnemonicHandle, char key) {
 	int keyval1 = OS.gdk_keyval_to_lower (OS.gdk_unicode_to_keyval (key));
 	int keyval2 = OS.gdk_keyval_to_lower (OS.gtk_label_get_mnemonic_keyval (cast(GtkLabel*)mnemonicHandle));
 	return keyval1 is keyval2;