diff dwt/widgets/Composite.d @ 58:a5c274fa5af9

extended helloworld crashing
author Frank Benoit <benoit@tionex.de>
date Sat, 12 Jan 2008 07:02:08 +0100
parents 93981635e709
children 8cec8f536af3
line wrap: on
line diff
--- a/dwt/widgets/Composite.d	Sat Jan 12 01:53:16 2008 +0100
+++ b/dwt/widgets/Composite.d	Sat Jan 12 07:02:08 2008 +0100
@@ -29,6 +29,8 @@
 import dwt.internal.gtk.OS;
 import dwt.graphics.Rectangle;
 
+import tango.io.Stdout;
+
 /**
  * Instances of this class are controls which are capable
  * of containing other controls.
@@ -198,23 +200,23 @@
 	}
 }
 
-void checkBuffered () {
+override void checkBuffered () {
 	if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) {
 		return;
 	}
 	super.checkBuffered();
 }
 
-protected void checkSubclass () {
+override protected void checkSubclass () {
 	/* Do nothing - Subclassing is allowed */
 }
 
-GtkStyle* childStyle () {
+override GtkStyle* childStyle () {
 	if (scrolledHandle !is null) return null;
 	return super.childStyle ();
 }
 
-public Point computeSize (int wHint, int hHint, bool changed) {
+override public Point computeSize (int wHint, int hHint, bool changed) {
 	checkWidget ();
 	if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0;
 	if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0;
@@ -238,7 +240,7 @@
 	return new Point (trim.width, trim.height);
 }
 
-Control [] computeTabList () {
+override Control [] computeTabList () {
 	Control result [] = super.computeTabList ();
 	if (result.length is 0) return result;
 	Control [] list = tabList !is null ? _getTabList () : _getChildren ();
@@ -255,7 +257,7 @@
 	return result;
 }
 
-void createHandle (int index) {
+override void createHandle (int index) {
 	state |= HANDLE | CANVAS;
 	bool scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) !is 0;
 	if (!scrolled) state |= THEME_BACKGROUND;
@@ -330,7 +332,7 @@
 	}
 }
 
-void deregister () {
+override void deregister () {
 	super.deregister ();
 	if (socketHandle !is null) display.removeWidget (cast(GtkWidget*)socketHandle);
 }
@@ -393,7 +395,7 @@
 	}
 }
 
-void enableWidget (bool enabled) {
+override void enableWidget (bool enabled) {
 	if ((state & CANVAS) !is 0) return;
 	super.enableWidget (enabled);
 }
@@ -402,7 +404,7 @@
 	return layoutCount > 0 ? this : parent.findDeferredControl ();
 }
 
-Menu [] findMenus (Control control) {
+override Menu [] findMenus (Control control) {
 	if (control is this) return new Menu [0];
 	Menu result [] = super.findMenus (control);
 	Control [] children = _getChildren ();
@@ -419,7 +421,7 @@
 	return result;
 }
 
-void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+override void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
 	super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
 	Control [] children = _getChildren ();
 	for (int i=0; i<children.length; i++) {
@@ -428,7 +430,7 @@
 }
 
 alias Scrollable.fixStyle fixStyle;
-void fixStyle () {
+override void fixStyle () {
 	super.fixStyle ();
 	if (scrolledHandle is null) fixStyle (handle);
 	Control[] children = _getChildren ();
@@ -459,6 +461,8 @@
 }
 
 void fixZOrder () {
+        Stdout.formatln( "{}: parent.fixZOrder gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+        Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
 	if ((state & CANVAS) !is 0) return;
 	auto parentHandle = parentingHandle ();
 	auto parentWindow = OS.GTK_WIDGET_WINDOW (cast(GtkWidget*)parentHandle);
@@ -479,14 +483,16 @@
 		}
 		OS.g_list_free (windowList);
 	}
+        Stdout.formatln( "{}: parent.fixZOrder gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+        Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
 }
 
-GtkWidget* focusHandle () {
+override GtkWidget* focusHandle () {
 	if (socketHandle !is null) return socketHandle;
 	return super.focusHandle ();
 }
 
-bool forceFocus (GtkWidget* focusHandle) {
+override 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);
@@ -554,7 +560,7 @@
 	return count;
 }
 
-public Rectangle getClientArea () {
+override public Rectangle getClientArea () {
 	checkWidget();
 	if ((state & CANVAS) !is 0) {
 		if ((state & ZERO_WIDTH) !is 0 && (state & ZERO_HEIGHT) !is 0) {
@@ -757,7 +763,7 @@
 	return (style & SWT.BORDER) !is 0;
 }
 
-void hookEvents () {
+override void hookEvents () {
 	super.hookEvents ();
 	if ((state & CANVAS) !is 0) {
 		OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK);
@@ -771,7 +777,7 @@
 	return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
 }
 
-GtkIMContext* imHandle () {
+override GtkIMContext* imHandle () {
 	return imHandle_;
 }
 
@@ -798,7 +804,7 @@
 	return findDeferredControl () !is null;
 }
 
-bool isTabGroup() {
+override bool isTabGroup() {
 	if ((state & CANVAS) !is 0) return true;
 	return super.isTabGroup();
 }
@@ -976,7 +982,7 @@
 	}
 }
 
-void markLayout (bool changed, bool all) {
+override void markLayout (bool changed, bool all) {
 	if (layout_ !is null) {
 		state |= LAYOUT_NEEDED;
 		if (changed) state |= LAYOUT_CHANGED;
@@ -989,19 +995,21 @@
 	}
 }
 
+alias Scrollable.moveAbove moveAbove;
 void moveAbove (GtkWidget* child, GtkWidget* sibling) {
 	if (child is sibling) return;
 	auto parentHandle = parentingHandle ();
 	auto fixed = cast(GtkFixed*)parentHandle;
-	auto children = fixed.children;
+	GList* children = fixed.children;
 	if (children is null) return;
-	GList* data;
+	void* data;
 	GtkWidget* widget;
-	GList* childData, childLink, siblingLink;
+	void* childData;
+    GList* childLink, siblingLink;
     GList* temp = children;
 	while (temp !is null) {
-		data = temp;
-		widget = cast(GtkWidget*) data;
+		data = temp.data;
+		widget = *cast(GtkWidget**) data;
 		if (child is widget) {
 			childLink = temp;
 			childData = data;
@@ -1026,6 +1034,7 @@
 	parentHandle = cast(GtkWidget*)fixed;
 }
 
+alias Scrollable.moveBelow moveBelow;
 void moveBelow (GtkWidget* child, GtkWidget* sibling) {
 	if (child is sibling) return;
 	auto parentHandle = parentingHandle ();
@@ -1034,36 +1043,54 @@
 		return;
 	}
 	auto fixed = cast(GtkFixed*)parentHandle;
-	auto children = fixed.children;
+	GList* children = fixed.children;
 	if (children is null) return;
-	GList* data;
+	void* data;
 	GtkWidget* widget;
-	GList* childData, childLink, siblingLink, temp = children;
+	void* childData;
+    GList* childLink, siblingLink, temp = children;
+    Stdout.formatln( "{}: before loop child={} sibling={}", __LINE__, child, sibling );
+            Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+            Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
 	while (temp !is null) {
-        data = temp;
+        Stdout.formatln( "{}: loop start {}->{}", __LINE__, temp, cast(void*)temp.data );
+        data = (*temp).data;
         widget = cast(GtkWidget*) data;
 		if (child is widget) {
+            Stdout.formatln( "{}: child is widget", __LINE__ );
 			childLink = temp;
 			childData = data;
 		} else if (sibling is widget) {
+            Stdout.formatln( "{}: sibling is widget", __LINE__ );
 			siblingLink = temp;
 		}
 		if (childData !is null && (sibling is null || siblingLink !is null)) break;
-		temp = temp.next;
+		temp = OS.g_list_next(temp);
+        Stdout.formatln( "{}: loop end", __LINE__ );
 	}
+    Stdout.formatln( "{}: after loop childLink={}", __LINE__, childLink );
 	children = OS.g_list_remove_link (children, childLink);
-	if (siblingLink is null || siblingLink.next is null) {
+	if (siblingLink is null || OS.g_list_next(siblingLink) is null) {
 		OS.g_list_free_1 (childLink);
+            Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+            Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
+            Stdout.formatln( " {} {}", children, childData );
 		children = OS.g_list_append (children, childData);
+            Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+            Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
 	} else {
-		temp = siblingLink.next;
-		childLink.next = temp;
-		temp.prev = childLink;
-		childLink.prev = siblingLink;
-		siblingLink.next =  childLink;
+        Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+        Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
+		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);
 	}
 	fixed.children = children;
     parentHandle = cast(GtkWidget*)fixed;
+        Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() );
+        Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) );
 }
 
 Point minimumSize (int wHint, int hHint, bool changed) {
@@ -1082,7 +1109,7 @@
 	return fixedHandle !is null ? fixedHandle : handle;
 }
 
-void redrawChildren () {
+override void redrawChildren () {
 	super.redrawChildren ();
 	Control [] children = _getChildren ();
 	for (int i = 0; i < children.length; i++) {
@@ -1094,12 +1121,12 @@
 	}
 }
 
-void register () {
+override void register () {
 	super.register ();
 	if (socketHandle !is null) display.addWidget (socketHandle, this);
 }
 
-void releaseChildren (bool destroy) {
+override void releaseChildren (bool destroy) {
 	Control [] children = _getChildren ();
 	for (int i=0; i<children.length; i++) {
 		Control child = children [i];
@@ -1110,13 +1137,13 @@
 	super.releaseChildren (destroy);
 }
 
-void releaseHandle () {
+override void releaseHandle () {
 	super.releaseHandle ();
 	socketHandle = null;
     embeddedHandle = 0;
 }
 
-void releaseWidget () {
+override void releaseWidget () {
 	super.releaseWidget ();
 	if (imHandle_ !is null) OS.g_object_unref (imHandle_);
 	imHandle_ = null;
@@ -1128,7 +1155,7 @@
 	fixTabList (control);
 }
 
-void resizeHandle (int width, int height) {
+override void resizeHandle (int width, int height) {
 	super.resizeHandle (width, height);
 	if (socketHandle !is null) OS.gtk_widget_set_size_request (socketHandle, width, height);
 }
@@ -1159,7 +1186,8 @@
 	}
 }
 
-int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+alias Scrollable.setBounds setBounds;
+override 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) !is 0 && layout_ !is null) {
 		markLayout (false, false);
@@ -1168,7 +1196,7 @@
 	return result;
 }
 
-public bool setFocus () {
+override public bool setFocus () {
 	checkWidget();
 	Control [] children = _getChildren ();
 	for (int i=0; i<children.length; i++) {
@@ -1228,7 +1256,7 @@
 	}
 }
 
-bool setScrollBarVisible (ScrollBar bar, bool visible) {
+override bool setScrollBarVisible (ScrollBar bar, bool visible) {
 	bool changed = super.setScrollBarVisible (bar, visible);
 	if (changed && layout_ !is null) {
 		markLayout (false, false);
@@ -1237,7 +1265,7 @@
 	return changed;
 }
 
-bool setTabGroupFocus (bool next) {
+override bool setTabGroupFocus (bool next) {
 	if (isTabItem ()) return setTabItemFocus (next);
 	bool takeFocus = (style & SWT.NO_FOCUS) is 0;
 	if ((state & CANVAS) !is 0) takeFocus = hooksKeys ();
@@ -1251,7 +1279,7 @@
 	return false;
 }
 
-bool setTabItemFocus (bool next) {
+override bool setTabItemFocus (bool next) {
 	if (!super.setTabItemFocus (next)) return false;
 	if (socketHandle !is null) {
 		int direction = next ? OS.GTK_DIR_TAB_FORWARD : OS.GTK_DIR_TAB_BACKWARD;
@@ -1293,7 +1321,7 @@
 	this.tabList = tabList;
 }
 
-void showWidget () {
+override void showWidget () {
 	super.showWidget ();
 	if (socketHandle !is null) {
 		OS.gtk_widget_show (socketHandle);
@@ -1302,7 +1330,7 @@
 	if (scrolledHandle is null) fixStyle (handle);
 }
 
-bool translateMnemonic (Event event, Control control) {
+override bool translateMnemonic (Event event, Control control) {
 	if (super.translateMnemonic (event, control)) return true;
 	if (control !is null) {
 		Control [] children = _getChildren ();
@@ -1314,7 +1342,7 @@
 	return false;
 }
 
-int traversalCode(int key, GdkEventKey* event) {
+override int traversalCode(int key, GdkEventKey* event) {
 	if ((state & CANVAS) !is 0) {
 		if ((style & SWT.NO_FOCUS) !is 0) return 0;
 		if (hooksKeys ()) return 0;
@@ -1322,7 +1350,7 @@
 	return super.traversalCode (key, event);
 }
 
-bool translateTraversal (GdkEventKey* keyEvent) {
+override bool translateTraversal (GdkEventKey* keyEvent) {
 	if (socketHandle !is null) return false;
 	return super.translateTraversal (keyEvent);
 }