diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-08-01 11:14:15 -0400 |
---|---|---|
committer | Arun Thondapu <arunkumar.thondapu@in.ibm.com> | 2012-08-03 22:58:20 +0530 |
commit | 195c35fb4aaf6777b97d64fa53ba79208d6d54ee (patch) | |
tree | 632df079706f08fc234f5b8c8926b6e352e30723 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java | |
parent | 165a14baa4f28638048d0b616f73e1b86413e4a2 (diff) | |
download | eclipse.platform.swt-195c35fb4aaf6777b97d64fa53ba79208d6d54ee.tar.gz eclipse.platform.swt-195c35fb4aaf6777b97d64fa53ba79208d6d54ee.tar.xz eclipse.platform.swt-195c35fb4aaf6777b97d64fa53ba79208d6d54ee.zip |
Use gtk_widget_get_allocation in newer GTK+
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java index 4f60fc0def..2f3366309d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java @@ -605,15 +605,31 @@ public Rectangle getClientArea () { } 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); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation(); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(clientHandle, allocation); + width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; + height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; + } else { + width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); + height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); + } return new Rectangle (0, 0, width, height); } return super.getClientArea(); } int getClientWidth() { - return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle ()); + GtkAllocation allocation = new GtkAllocation(); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(clientHandle (), allocation); + return (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; + } else { + return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle ()); + } + } /** @@ -1201,9 +1217,20 @@ void moveChildren(int oldWidth) { for (int i = 0; i < children.length; i++) { Control child = children[i]; int /*long*/ topHandle = child.topHandle (); - int x = OS.GTK_WIDGET_X (topHandle); - int y = OS.GTK_WIDGET_Y (topHandle); - int controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); + int x = 0; + int y = 0; + int controlWidth = 0; + GtkAllocation allocation = new GtkAllocation(); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(topHandle, allocation); + x = allocation.x; + y = allocation.y; + controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : allocation.width; + } else { + x = OS.GTK_WIDGET_X (topHandle); + y = OS.GTK_WIDGET_Y (topHandle); + controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle); + } if (oldWidth > 0) x = oldWidth - controlWidth - x; int clientWidth = getClientWidth (); x = clientWidth - controlWidth - x; @@ -1218,11 +1245,14 @@ void moveChildren(int oldWidth) { */ GtkRequisition requisition = new GtkRequisition (); gtk_widget_size_request (topHandle, requisition); - GtkAllocation allocation = new GtkAllocation (); allocation.x = x; allocation.y = y; - allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); - allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(topHandle, allocation); + } else { + allocation.width = OS.GTK_WIDGET_WIDTH (topHandle); + allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle); + } OS.gtk_widget_size_allocate (topHandle, allocation); Control control = child.findBackgroundControl (); if (control != null && control.backgroundImage != null) { |