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/Sash.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/Sash.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java | 85 |
1 files changed, 70 insertions, 15 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java index 94e31dba50..0094b87af4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java @@ -177,10 +177,23 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr) OS.gdk_window_get_origin (window, origin_x, origin_y); startX = (int) (gdkEvent.x_root - origin_x [0]); startY = (int) (gdkEvent.y_root - origin_y [0]); - int x = OS.GTK_WIDGET_X (handle); - int y = OS.GTK_WIDGET_Y (handle); - int width = OS.GTK_WIDGET_WIDTH (handle); - int height = OS.GTK_WIDGET_HEIGHT (handle); + int x = 0; + int y = 0; + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(handle, allocation); + x = allocation.x; + y = allocation.y; + width = allocation.width; + height = allocation.height; + } else { + x = OS.GTK_WIDGET_X (handle); + y = OS.GTK_WIDGET_Y (handle); + width = OS.GTK_WIDGET_WIDTH (handle); + height = OS.GTK_WIDGET_HEIGHT (handle); + } lastX = x; lastY = y; Event event = new Event (); @@ -219,8 +232,17 @@ int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ eventPt if (button != 1) return 0; if (!dragging) return 0; dragging = false; - int width = OS.GTK_WIDGET_WIDTH (handle); - int height = OS.GTK_WIDGET_HEIGHT (handle); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(handle, allocation); + width = allocation.width; + height = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (handle); + height = OS.GTK_WIDGET_HEIGHT (handle); + } Event event = new Event (); event.time = gdkEvent.time; event.x = lastX; @@ -245,8 +267,15 @@ int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) { if (result != 0) return result; // widget could be disposed at this point if (handle != 0) { + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(handle, allocation); + lastX = allocation.x; + lastY = allocation.y; + } else { lastX = OS.GTK_WIDGET_X (handle); lastY = OS.GTK_WIDGET_Y (handle); + } } return 0; } @@ -272,12 +301,25 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) { if (keyval == OS.GDK_Left ||keyval == OS.GDK_Right) break; yChange = keyval == OS.GDK_Up ? -stepSize : stepSize; } - - int width = OS.GTK_WIDGET_WIDTH (handle); - int height = OS.GTK_WIDGET_HEIGHT (handle); + int width = 0; + int height = 0; int parentBorder = 0; - int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle); - int parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle); + int parentWidth = 0; + int parentHeight = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(handle, allocation); + width = allocation.width; + height = allocation.height; + OS.gtk_widget_get_allocation(parent.handle, allocation); + parentWidth = allocation.width; + parentHeight = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (handle); + height = OS.GTK_WIDGET_HEIGHT (handle); + parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle); + parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle); + } int newX = lastX, newY = lastY; if ((style & SWT.VERTICAL) != 0) { newX = Math.min (Math.max (0, lastX + xChange - parentBorder - startX), parentWidth - width); @@ -347,10 +389,23 @@ int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ eventPtr eventState = gdkEvent.state; } if ((eventState & OS.GDK_BUTTON1_MASK) == 0) return 0; - int x = OS.GTK_WIDGET_X (handle); - int y = OS.GTK_WIDGET_Y (handle); - int width = OS.GTK_WIDGET_WIDTH (handle); - int height = OS.GTK_WIDGET_HEIGHT (handle); + int x = 0; + int y = 0; + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(handle, allocation); + x = allocation.x; + y = allocation.y; + width = allocation.width; + height = allocation.height; + } else { + x = OS.GTK_WIDGET_X (handle); + y = OS.GTK_WIDGET_Y (handle); + width = OS.GTK_WIDGET_WIDTH (handle); + height = OS.GTK_WIDGET_HEIGHT (handle); + } int parentBorder = 0; int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle); int parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle); |