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/Shell.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/Shell.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | 119 |
1 files changed, 101 insertions, 18 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 2fe47280e9..78f8e6ea52 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -451,8 +451,17 @@ void addToolTip (ToolTip toolTip) { void adjustTrim () { if (display.ignoreTrim) return; - int width = OS.GTK_WIDGET_WIDTH (shellHandle); - int height = OS.GTK_WIDGET_HEIGHT (shellHandle); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(shellHandle, allocation); + width = allocation.width; + height = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (shellHandle); + height = OS.GTK_WIDGET_HEIGHT (shellHandle); + } int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle); GdkRectangle rect = new GdkRectangle (); OS.gdk_window_get_frame_extents (window, rect); @@ -635,7 +644,14 @@ public Rectangle computeTrim (int x, int y, int width, int height) { trim.height += trimHeight + border * 2; if (menuBar != null) { forceResize (); - int menuBarHeight = OS.GTK_WIDGET_HEIGHT (menuBar.handle); + int menuBarHeight = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(menuBar.handle, allocation); + menuBarHeight = allocation.height; + } else { + menuBarHeight = OS.GTK_WIDGET_HEIGHT (menuBar.handle); + } trim.y -= menuBarHeight; trim.height += menuBarHeight; } @@ -892,7 +908,13 @@ void fixStyle (int /*long*/ handle) { } void forceResize () { - forceResize (OS.GTK_WIDGET_WIDTH (vboxHandle), OS.GTK_WIDGET_HEIGHT (vboxHandle)); + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(vboxHandle, allocation); + forceResize (allocation.width, allocation.height); + } else { + forceResize (OS.GTK_WIDGET_WIDTH (vboxHandle), OS.GTK_WIDGET_HEIGHT (vboxHandle)); + } } void forceResize (int width, int height) { @@ -931,8 +953,17 @@ public int getAlpha () { } int getResizeMode (double x, double y) { - int width = OS.GTK_WIDGET_WIDTH (shellHandle); - int height = OS.GTK_WIDGET_HEIGHT (shellHandle); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(shellHandle, allocation); + width = allocation.width; + height = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (shellHandle); + height = OS.GTK_WIDGET_HEIGHT (shellHandle); + } int border = OS.gtk_container_get_border_width (shellHandle); int mode = 0; if (y >= height - border) { @@ -1055,8 +1086,17 @@ public boolean getModified () { public Point getSize () { checkWidget (); - int width = OS.GTK_WIDGET_WIDTH (vboxHandle); - int height = OS.GTK_WIDGET_HEIGHT (vboxHandle); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(vboxHandle, allocation); + width = allocation.width; + height = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (vboxHandle); + height = OS.GTK_WIDGET_HEIGHT (vboxHandle); + } int border = 0; if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) { border = OS.gtk_container_get_border_width (shellHandle); @@ -1165,8 +1205,15 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { OS.gtk_window_get_position (shellHandle, x, y); display.resizeBoundsX = x [0]; display.resizeBoundsY = y [0]; - display.resizeBoundsWidth = OS.GTK_WIDGET_WIDTH (shellHandle); - display.resizeBoundsHeight = OS.GTK_WIDGET_HEIGHT (shellHandle); + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(shellHandle, allocation); + display.resizeBoundsWidth = allocation.width; + display.resizeBoundsHeight = allocation.height; + } else { + display.resizeBoundsWidth = OS.GTK_WIDGET_WIDTH (shellHandle); + display.resizeBoundsHeight = OS.GTK_WIDGET_HEIGHT (shellHandle); + } } } return 0; @@ -1377,8 +1424,17 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) { } int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) { - int width = OS.GTK_WIDGET_WIDTH (shellHandle); - int height = OS.GTK_WIDGET_HEIGHT (shellHandle); + int width = 0; + int height = 0; + GtkAllocation widgetAllocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(shellHandle, widgetAllocation); + width = widgetAllocation.width; + height = widgetAllocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (shellHandle); + height = OS.GTK_WIDGET_HEIGHT (shellHandle); + } if (!resized || oldWidth != width || oldHeight != height) { oldWidth = width; oldHeight = height; @@ -1859,8 +1915,17 @@ public void setMenuBar (Menu menu) { createAccelGroup (); menuBar.addAccelerators (accelGroup); } - int width = OS.GTK_WIDGET_WIDTH (vboxHandle); - int height = OS.GTK_WIDGET_HEIGHT (vboxHandle); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(vboxHandle, allocation); + width = allocation.width; + height = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (vboxHandle); + height = OS.GTK_WIDGET_HEIGHT (vboxHandle); + } resizeBounds (width, height, !both); } @@ -2144,8 +2209,17 @@ int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*lon int monitorNumber = OS.gdk_screen_get_monitor_at_point (screen, x[0], y[0]); GdkRectangle dest = new GdkRectangle (); OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest); - 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); + } if (x[0] + width > dest.x + dest.width) { x [0] = (dest.x + dest.width) - width; } @@ -2337,8 +2411,17 @@ public Rectangle getBounds () { checkWidget (); int [] x = new int [1], y = new int [1]; OS.gtk_window_get_position (shellHandle, x, y); - int width = OS.GTK_WIDGET_WIDTH (vboxHandle); - int height = OS.GTK_WIDGET_HEIGHT (vboxHandle); + int width = 0; + int height = 0; + GtkAllocation allocation = new GtkAllocation (); + if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { + OS.gtk_widget_get_allocation(vboxHandle, allocation); + width = allocation.width; + height = allocation.height; + } else { + width = OS.GTK_WIDGET_WIDTH (vboxHandle); + height = OS.GTK_WIDGET_HEIGHT (vboxHandle); + } int border = 0; if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) { border = OS.gtk_container_get_border_width (shellHandle); |