Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java146
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java85
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java119
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java25
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java84
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java13
30 files changed, 785 insertions, 160 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 266b466b85..8098b20651 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -18308,6 +18308,28 @@ JNIEXPORT void JNICALL OS_NATIVE(gdk_1threads_1set_1lock_1functions)
}
#endif
+#ifndef NO_gtk_1widget_1get_1allocation
+JNIEXPORT void JNICALL OS_NATIVE(gtk_1widget_1get_1allocation)
+ (JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
+{
+ GtkAllocation _arg1, *lparg1=NULL;
+ OS_NATIVE_ENTER(env, that, gtk_1widget_1get_1allocation_FUNC);
+ if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+/*
+ gtk_widget_get_allocation(arg0, (GtkAllocation *)lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_widget_get_allocation)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, GtkAllocation *))fp)(arg0, (GtkAllocation *)lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) setGtkAllocationFields(env, arg1, lparg1);
+ OS_NATIVE_EXIT(env, that, gtk_1widget_1get_1allocation_FUNC);
+}
+#endif
+
#ifndef NO_localeconv_1decimal_1point
JNIEXPORT jintLong JNICALL OS_NATIVE(localeconv_1decimal_1point)
(JNIEnv *env, jclass that)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 67b65566a5..12e59d11e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -202,6 +202,7 @@
#define gtk_window_set_opacity_LIB LIB_GTK
#define gtk_window_set_skip_taskbar_hint_LIB LIB_GTK
#define gtk_widget_is_composited_LIB LIB_GTK
+#define gtk_widget_get_allocation_LIB LIB_GTK
#define gtk_widget_get_tooltip_text_LIB LIB_GTK
#define gtk_widget_has_default_LIB LIB_GTK
#define gtk_widget_set_tooltip_text_LIB LIB_GTK
@@ -382,15 +383,27 @@
#ifndef GTK_OBJECT_FLAGS
#define GTK_OBJECT_FLAGS(arg0) 0
#endif
+#if GTK_CHECK_VERSION(2,18,0)
+#define GTK_WIDGET_HEIGHT(arg0) 0
+#else
#define GTK_WIDGET_HEIGHT(arg0) (arg0)->allocation.height
+#endif
#define GTK_WIDGET_SET_HEIGHT(arg0, arg1) (arg0)->allocation.height = arg1
#ifndef GTK_WIDGET_MAPPED
#define GTK_WIDGET_MAPPED(arg0) 0
#endif
+#if GTK_CHECK_VERSION(2,18,0)
+#define GTK_WIDGET_WIDTH(arg0) 0
+#else
#define GTK_WIDGET_WIDTH(arg0) (arg0)->allocation.width
+#endif
#define GTK_WIDGET_SET_WIDTH(arg0, arg1) (arg0)->allocation.width = arg1
#define GTK_WIDGET_WINDOW(arg0) (arg0)->window
+#if GTK_CHECK_VERSION(2,18,0)
+#define GTK_WIDGET_X(arg0) 0
+#else
#define GTK_WIDGET_X(arg0) (arg0)->allocation.x
+#endif
#define GTK_WIDGET_SET_X(arg0, arg1) (arg0)->allocation.x = arg1
#define GTK_ENTRY_IM_CONTEXT(arg0) (arg0)->im_context
#define GTK_TEXTVIEW_IM_CONTEXT(arg0) (arg0)->im_context
@@ -405,7 +418,11 @@
#else
#define GTK_TOOLTIPS_GET_TIP_TEXT(arg0) (arg0)->tip_text
#endif
+#if GTK_CHECK_VERSION(2,18,0)
+#define GTK_WIDGET_Y(arg0) 0
+#else
#define GTK_WIDGET_Y(arg0) ((GtkWidget *)arg0)->allocation.y
+#endif
#define GTK_WIDGET_SET_Y(arg0, arg1) (arg0)->allocation.y = arg1
#define GTK_WIDGET_REQUISITION_WIDTH(arg0) (arg0)->requisition.width
#define GTK_WIDGET_REQUISITION_HEIGHT(arg0) (arg0)->requisition.height
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 579ba0029a..ee9407c878 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1329;
-int OS_nativeFunctionCallCount[1329];
+int OS_nativeFunctionCount = 1330;
+int OS_nativeFunctionCallCount[1330];
char * OS_nativeFunctionNames[] = {
#ifndef JNI64
"Call__IIII",
@@ -1446,6 +1446,7 @@ char * OS_nativeFunctionNames[] = {
"gdk_1threads_1init",
"gdk_1threads_1leave",
"gdk_1threads_1set_1lock_1functions",
+ "gtk_1widget_1get_1allocation",
"localeconv_1decimal_1point",
#ifndef JNI64
"memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index b0e3596a81..942c86578a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -1454,6 +1454,7 @@ typedef enum {
gdk_1threads_1init_FUNC,
gdk_1threads_1leave_FUNC,
gdk_1threads_1set_1lock_1functions_FUNC,
+ gtk_1widget_1get_1allocation_FUNC,
localeconv_1decimal_1point_FUNC,
#ifndef JNI64
memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 1b09c73484..4e9374deaf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -12269,6 +12269,19 @@ public static final int /*long*/ gtk_widget_get_parent_window(int /*long*/ widge
lock.unlock();
}
}
+/**
+ * @method flags=dynamic
+ * @param allocation cast=(GtkAllocation *),flags=no_in
+ * */
+public static final native void gtk_widget_get_allocation (int /*long*/ widget, GtkAllocation allocation);
+public static final void _gtk_widget_get_allocation (int /*long*/ widget, int /*long*/ allocation) {
+ lock.lock();
+ try {
+ _gtk_widget_get_allocation (widget, allocation);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param widget cast=(GtkWidget *) */
public static final native int /*long*/ _gtk_widget_get_style(int /*long*/ widget);
public static final int /*long*/ gtk_widget_get_style(int /*long*/ widget) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 0be15510e2..bc11b73d58 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -752,8 +752,17 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* resized so that it will draw wrapped.
*/
if (wrap) {
- int boxWidth = OS.GTK_WIDGET_WIDTH (boxHandle);
- int boxHeight = OS.GTK_WIDGET_HEIGHT (boxHandle);
+ int boxWidth = 0;
+ int boxHeight = 0;
+ GtkAllocation allocation = new GtkAllocation();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(boxHandle, allocation);
+ boxWidth = allocation.width;
+ boxHeight = allocation.height;
+ } else {
+ boxWidth = OS.GTK_WIDGET_WIDTH (boxHandle);
+ boxHeight = OS.GTK_WIDGET_HEIGHT (boxHandle);
+ }
int /*long*/ labelLayout = OS.gtk_label_get_layout (labelHandle);
int pangoWidth = OS.pango_layout_get_width (labelLayout);
OS.pango_layout_set_width (labelLayout, -1);
@@ -776,9 +785,12 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (boxHandle, requisition);
- GtkAllocation allocation = new GtkAllocation ();
- allocation.x = OS.GTK_WIDGET_X (boxHandle);
- allocation.y = OS.GTK_WIDGET_Y (boxHandle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(boxHandle, allocation);
+ } else {
+ allocation.x = OS.GTK_WIDGET_X (boxHandle);
+ allocation.y = OS.GTK_WIDGET_Y (boxHandle);
+ }
allocation.width = boxWidth;
allocation.height = boxHeight;
OS.gtk_widget_size_allocate (boxHandle, allocation);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 50a66e4581..efaa7dddf5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -1027,8 +1027,6 @@ String getText (int start, int stop) {
*/
public int getTextHeight () {
checkWidget();
- GtkRequisition requisition = new GtkRequisition ();
- gtk_widget_size_request (handle, requisition);
return OS.GTK_WIDGET_REQUISITION_HEIGHT (handle);
}
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) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 7d512cb331..6fb59684c9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -682,10 +682,14 @@ void forceResize () {
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_size_request (topHandle, requisition);
GtkAllocation allocation = new GtkAllocation ();
- allocation.x = OS.GTK_WIDGET_X (topHandle);
- allocation.y = OS.GTK_WIDGET_Y (topHandle);
- 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.x = OS.GTK_WIDGET_X (topHandle);
+ allocation.y = OS.GTK_WIDGET_Y (topHandle);
+ allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
+ allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
OS.gtk_widget_size_allocate (topHandle, allocation);
}
@@ -737,10 +741,23 @@ Accessible _getAccessible () {
public Rectangle getBounds () {
checkWidget();
int /*long*/ topHandle = topHandle ();
- int x = OS.GTK_WIDGET_X (topHandle);
- int y = OS.GTK_WIDGET_Y (topHandle);
- int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ 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(topHandle, allocation);
+ x = allocation.x;
+ y = allocation.y;
+ width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ height = (state & ZERO_HEIGHT) != 0 ? 0 :allocation.height;
+ } else {
+ x = OS.GTK_WIDGET_X (topHandle);
+ y = OS.GTK_WIDGET_Y (topHandle);
+ width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
return new Rectangle (x, y, width, height);
}
@@ -841,8 +858,18 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
boolean sendMove = move;
if ((parent.style & SWT.MIRRORED) != 0) {
int clientWidth = parent.getClientWidth ();
- int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- int oldX = clientWidth - oldWidth - OS.GTK_WIDGET_X (topHandle);
+ int oldWidth = 0;
+ int oldX = 0;
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ oldX = clientWidth - oldWidth - allocation.x;
+ } else {
+ oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ oldX = clientWidth - oldWidth - OS.GTK_WIDGET_X (topHandle);
+ }
+
if (move) {
sendMove &= x != oldX;
x = clientWidth - (resize ? width : oldWidth) - x;
@@ -866,8 +893,17 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
}
int clientWidth = 0;
if (resize) {
- int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- int oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ int oldWidth = 0;
+ int oldHeight = 0;
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ } else {
+ oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
sameExtent = width == oldWidth && height == oldHeight;
if (!sameExtent && (style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();
if (!sameExtent && !(width == 0 && height == 0)) {
@@ -895,15 +931,24 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
allocation.x = x;
allocation.y = y;
} else {
- allocation.x = OS.GTK_WIDGET_X (topHandle);
- allocation.y = OS.GTK_WIDGET_Y (topHandle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ } else {
+ allocation.x = OS.GTK_WIDGET_X (topHandle);
+ allocation.y = OS.GTK_WIDGET_Y (topHandle);
+ }
+
}
if (resize) {
allocation.width = width;
allocation.height = height;
} else {
- 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);
}
@@ -962,10 +1007,24 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
public Point getLocation () {
checkWidget();
int /*long*/ topHandle = topHandle ();
- int x = OS.GTK_WIDGET_X (topHandle);
- int y = OS.GTK_WIDGET_Y (topHandle);
+ int x = 0;
+ int y = 0;
+ int width = 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;
+ } else {
+ x = OS.GTK_WIDGET_X (topHandle);
+ y = OS.GTK_WIDGET_Y (topHandle);
+ }
if ((parent.style & SWT.MIRRORED) != 0) {
- int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ } else {
+ width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ }
x = parent.getClientWidth () - width - x;
}
return new Point (x, y);
@@ -1027,8 +1086,17 @@ public void setLocation(int x, int y) {
public Point getSize () {
checkWidget();
int /*long*/ topHandle = topHandle ();
- int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ int width = 0;
+ int height = 0;
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, 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 (topHandle);
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
return new Point (width, height);
}
@@ -3977,10 +4045,20 @@ public void setEnabled (boolean enabled) {
int /*long*/ window = parent.eventWindow ();
int /*long*/ topHandle = topHandle ();
GdkWindowAttr attributes = new GdkWindowAttr ();
- attributes.x = OS.GTK_WIDGET_X (topHandle);
- attributes.y = OS.GTK_WIDGET_Y (topHandle);
- attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+
+ } else {
+ attributes.x = OS.GTK_WIDGET_X (topHandle);
+ attributes.y = OS.GTK_WIDGET_Y (topHandle);
+ attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask);
attributes.wclass = OS.GDK_INPUT_ONLY;
attributes.window_type = OS.GDK_WINDOW_CHILD;
@@ -4221,9 +4299,20 @@ public boolean setParent (Composite parent) {
if (!isReparentable ()) return false;
OS.gtk_widget_realize (parent.handle);
int /*long*/ topHandle = topHandle ();
- int x = OS.GTK_WIDGET_X (topHandle);
- int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
- int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ int x = 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(topHandle, allocation);
+ x = allocation.x;
+ width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ } else {
+ x = OS.GTK_WIDGET_X (topHandle);
+ width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
if ((this.parent.style & SWT.MIRRORED) != 0) {
x = this.parent.getClientWidth () - width - x;
}
@@ -4266,7 +4355,6 @@ public boolean setParent (Composite parent) {
*/
GtkRequisition requisition = new GtkRequisition ();
gtk_widget_size_request (topHandle, requisition);
- GtkAllocation allocation = new GtkAllocation ();
allocation.x = x;
allocation.y = y;
allocation.width = width;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index c6f7003860..1bdae2b97b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
@@ -453,7 +453,14 @@ void setScrollbar () {
OS.gtk_adjustment_changed (adjustmentHandle);
int policy = maxHeight > height ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, policy);
- int width = OS.GTK_WIDGET_WIDTH (fixedHandle) - spacing * 2;
+ int width = 0;
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(fixedHandle, allocation);
+ width = allocation.width - spacing * 2;
+ } else {
+ width = OS.GTK_WIDGET_WIDTH (fixedHandle) - spacing * 2;
+ }
if (policy == OS.GTK_POLICY_ALWAYS) {
int /*long*/ vHandle = 0;
if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
index 5bd836678d..c354332c85 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
@@ -265,7 +265,13 @@ public boolean getExpanded () {
*/
public int getHeaderHeight () {
checkWidget ();
- return OS.GTK_WIDGET_HEIGHT (handle) - (expanded ? height : 0);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ return allocation.height - (expanded ? height : 0);
+ } else {
+ return OS.GTK_WIDGET_HEIGHT (handle) - (expanded ? height : 0);
+ }
}
/**
@@ -378,14 +384,31 @@ void releaseWidget () {
}
void resizeControl (int yScroll) {
+ GtkAllocation allocation = new GtkAllocation ();
if (control != null && !control.isDisposed ()) {
boolean visible = OS.gtk_expander_get_expanded (handle);
if (visible) {
- int x = OS.GTK_WIDGET_X (clientHandle);
- int y = OS.GTK_WIDGET_Y (clientHandle);
+ int x = 0;
+ int y = 0;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(clientHandle, allocation);
+ x = allocation.x;
+ y = allocation.y;
+ } else {
+ x = OS.GTK_WIDGET_X (clientHandle);
+ y = OS.GTK_WIDGET_Y (clientHandle);
+ }
if (x != -1 && y != -1) {
- int width = OS.GTK_WIDGET_WIDTH (clientHandle);
- int height = OS.GTK_WIDGET_HEIGHT (clientHandle);
+ int width = 0;
+ int height = 0;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(clientHandle, allocation);
+ width = allocation.width;
+ height = allocation.height;
+ } else {
+ width = OS.GTK_WIDGET_WIDTH (clientHandle);
+ height = OS.GTK_WIDGET_HEIGHT (clientHandle);
+ }
int [] property = new int [1];
OS.gtk_widget_style_get (handle, OS.focus_line_width, property, 0);
y += property [0] * 2;
@@ -402,7 +425,12 @@ void resizeControl (int yScroll) {
ScrollBar vBar = parent.verticalBar;
if (vBar != null) {
if (OS.GTK_WIDGET_VISIBLE (vBar.handle)) {
- width = OS.GTK_WIDGET_WIDTH (parent.scrolledHandle) - parent.vScrollBarWidth () - 2 * parent.spacing;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(parent.scrolledHandle, allocation);
+ width = allocation.width - parent.vScrollBarWidth () - 2 * parent.spacing;
+ } else {
+ width = OS.GTK_WIDGET_WIDTH (parent.scrolledHandle) - parent.vScrollBarWidth () - 2 * parent.spacing;
+ }
}
}
control.setBounds (x, y - yScroll, width, Math.max (0, height), true, true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 64968d6e78..4351547a44 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -109,8 +109,17 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
forceResize ();
- int clientX = OS.GTK_WIDGET_X (clientHandle);
- int clientY = OS.GTK_WIDGET_Y (clientHandle);
+ int clientX = 0;
+ int clientY = 0;
+ GtkAllocation allocation = new GtkAllocation();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(clientHandle, allocation);
+ clientX = allocation.x;
+ clientY = allocation.y;
+ } else {
+ clientX = OS.GTK_WIDGET_X (clientHandle);
+ clientY = OS.GTK_WIDGET_Y (clientHandle);
+ }
x -= clientX;
y -= clientY;
width += clientX + clientX;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index 1d11b629e9..66ffce244d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -465,8 +465,17 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* resized so that it will draw wrapped.
*/
if (fixWrap) {
- int labelWidth = OS.GTK_WIDGET_WIDTH (handle);
- int labelHeight = OS.GTK_WIDGET_HEIGHT (handle);
+ int labelWidth = 0;
+ int labelHeight = 0;
+ GtkAllocation allocation = new GtkAllocation();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ labelWidth = allocation.width;
+ labelHeight = allocation.height;
+ } else {
+ labelWidth = OS.GTK_WIDGET_WIDTH (handle);
+ labelHeight = OS.GTK_WIDGET_HEIGHT (handle);
+ }
OS.gtk_widget_set_size_request (labelHandle, labelWidth, labelHeight);
/*
* Bug in GTK. Setting the size request should invalidate the label's
@@ -474,9 +483,12 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (labelHandle, requisition);
- GtkAllocation allocation = new GtkAllocation ();
- allocation.x = OS.GTK_WIDGET_X (labelHandle);
- allocation.y = OS.GTK_WIDGET_Y (labelHandle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(labelHandle, allocation);
+ } else {
+ allocation.x = OS.GTK_WIDGET_X (labelHandle);
+ allocation.y = OS.GTK_WIDGET_Y (labelHandle);
+ }
allocation.width = labelWidth;
allocation.height = labelHeight;
OS.gtk_widget_size_allocate (labelHandle, allocation);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 55feedb94f..d45f7c2273 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -262,7 +262,13 @@ Rectangle [] getRectangles (int linkIndex) {
}
int getClientWidth () {
- return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
+ GtkAllocation allocation = new GtkAllocation();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ return (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ } else {
+ return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
+ }
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index dfaa240880..519cd150b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -378,10 +378,24 @@ void fixMenus (Decorations newParent) {
int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
- int x = origin_x [0] + OS.GTK_WIDGET_X (handle);
- int y = origin_y [0] + 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 = origin_x [0] + allocation.x;
+ y = origin_x [0] + allocation.y;
+ width = allocation.width;
+ height = allocation.height;
+ } else {
+ x = origin_x [0] + OS.GTK_WIDGET_X (handle);
+ y = origin_y [0] + OS.GTK_WIDGET_Y (handle);
+ width = OS.GTK_WIDGET_WIDTH (handle);
+ height = OS.GTK_WIDGET_HEIGHT (handle);
+ }
+
return new Rectangle (x, y, width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index dfca6d22da..ee8915ea35 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -322,10 +322,23 @@ int /*long*/ getAccelGroup () {
if (!gtk_widget_get_mapped (handle)) {
return new Rectangle (0, 0, 0, 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);
+ }
return new Rectangle (x, y, width, height);
}
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);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index 1551418956..ac426e3c69 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -342,16 +342,29 @@ public Rectangle getThumbBounds () {
int slider_start = OS.GTK_RANGE_SLIDER_START (handle);
int slider_end = OS.GTK_RANGE_SLIDER_END (handle);
int x, y, width, height;
+ GtkAllocation allocation = new GtkAllocation ();
if ((style & SWT.VERTICAL) != 0) {
- x = OS.GTK_WIDGET_X (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ x = allocation.x;
+ width = allocation.width;
+ } else {
+ x = OS.GTK_WIDGET_X (handle);
+ width = OS.GTK_WIDGET_WIDTH (handle);
+ }
y = slider_start;
- width = OS.GTK_WIDGET_WIDTH (handle);
height = slider_end - slider_start;
} else {
x = slider_start;
- y = OS.GTK_WIDGET_Y (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ y = allocation.y;
+ height = allocation.height;
+ } else {
+ y = OS.GTK_WIDGET_Y (handle);
+ height = OS.GTK_WIDGET_HEIGHT (handle);
+ }
width = slider_end - slider_start;
- height = OS.GTK_WIDGET_HEIGHT (handle);
}
Rectangle rect = new Rectangle(x, y, width, height);
int [] origin_x = new int [1], origin_y = new int [1];
@@ -387,13 +400,26 @@ public Rectangle getThumbTrackBounds () {
boolean hasB = OS.GTK_RANGE_HAS_STEPPER_B (handle);
boolean hasC = OS.GTK_RANGE_HAS_STEPPER_C (handle);
boolean hasD = OS.GTK_RANGE_HAS_STEPPER_D (handle);
+ GtkAllocation allocation = new GtkAllocation ();
+ int stepperSize = 0;
if ((style & SWT.VERTICAL) != 0) {
- int stepperSize = OS.GTK_WIDGET_WIDTH (handle);
- x = OS.GTK_WIDGET_X (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ stepperSize = allocation.width;
+ x = allocation.x;
+ } else {
+ stepperSize = OS.GTK_WIDGET_WIDTH (handle);
+ x = OS.GTK_WIDGET_X (handle);
+ }
if (hasA) y += stepperSize;
if (hasB) y += stepperSize;
- width = OS.GTK_WIDGET_WIDTH (handle);
- height = OS.GTK_WIDGET_HEIGHT (handle) - y;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ width = allocation.width;
+ height = allocation.height - y;
+ } else {
+ width = OS.GTK_WIDGET_WIDTH (handle);
+ height = OS.GTK_WIDGET_HEIGHT (handle) - y;
+ }
if (hasC) height -= stepperSize;
if (hasD) height -= stepperSize;
if (height < 0) {
@@ -401,14 +427,28 @@ public Rectangle getThumbTrackBounds () {
height = 0;
}
} else {
- int stepperSize = OS.GTK_WIDGET_HEIGHT (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ stepperSize = allocation.height;
+ } else {
+ stepperSize = OS.GTK_WIDGET_HEIGHT (handle);
+ }
if (hasA) x += stepperSize;
if (hasB) x += stepperSize;
- y = OS.GTK_WIDGET_Y (handle);
- width = OS.GTK_WIDGET_WIDTH (handle) - x;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ y = allocation.y;
+ width = allocation.width -x;
+ } else {
+ y = OS.GTK_WIDGET_Y (handle);
+ width = OS.GTK_WIDGET_WIDTH (handle) - x;
+ }
if (hasC) width -= stepperSize;
if (hasD) width -= stepperSize;
- height = OS.GTK_WIDGET_HEIGHT (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ height = allocation.height;
+ } else {
+ height = OS.GTK_WIDGET_HEIGHT (handle);
+ }
if (width < 0) {
x = OS.GTK_RANGE_SLIDER_START (handle);
width = 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index 261114a3d7..8feccf7df0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -204,10 +204,23 @@ public Rectangle getClientArea () {
checkWidget ();
forceResize ();
int /*long*/ clientHandle = clientHandle ();
- int x = OS.GTK_WIDGET_X (clientHandle);
- int y = OS.GTK_WIDGET_Y (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 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(clientHandle, allocation);
+ x = allocation.x;
+ y = allocation.y;
+ width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ } else {
+ x = OS.GTK_WIDGET_X (clientHandle);
+ y = OS.GTK_WIDGET_Y (clientHandle);
+ 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 (x, y, width, height);
}
/**
@@ -364,8 +377,15 @@ void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boole
int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle);
GdkRectangle rect = new GdkRectangle ();
if (redrawAll) {
- rect.width = OS.GTK_WIDGET_WIDTH (topHandle);
- rect.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ rect.width = allocation.width;
+ rect.height = allocation.height;
+ } else {
+ rect.width = OS.GTK_WIDGET_WIDTH (topHandle);
+ rect.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
} else {
int [] destX = new int [1], destY = new int [1];
OS.gtk_widget_translate_coordinates (paintHandle, topHandle, x, y, destX, destY);
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);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index 1ef9cfdba7..b1e3bbd1f9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -166,14 +166,32 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
forceResize ();
int /*long*/ clientHandle = clientHandle ();
- int clientX = OS.GTK_WIDGET_X (clientHandle);
- int clientY = OS.GTK_WIDGET_Y (clientHandle);
+ int clientX = 0;
+ int clientY = 0;
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(clientHandle, allocation);
+ clientX = allocation.x;
+ clientY = allocation.y;
+ } else {
+ clientX = OS.GTK_WIDGET_X (clientHandle);
+ clientY = OS.GTK_WIDGET_Y (clientHandle);
+ }
x -= clientX;
y -= clientY;
width += clientX + clientX;
if ((style & SWT.BOTTOM) != 0) {
- int parentHeight = OS.GTK_WIDGET_HEIGHT (handle);
- int clientHeight = OS.GTK_WIDGET_HEIGHT (clientHandle);
+ int parentHeight = 0;
+ int clientHeight = 0;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(clientHandle, allocation);
+ clientHeight = allocation.height;
+ OS.gtk_widget_get_allocation(handle, allocation);
+ parentHeight = allocation.height;
+ } else {
+ parentHeight = OS.GTK_WIDGET_HEIGHT (handle);
+ clientHeight = OS.GTK_WIDGET_HEIGHT (clientHandle);
+ }
height += parentHeight - clientHeight;
} else {
height += clientX + clientY;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index 59aea1bb6d..ed57668988 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -150,10 +150,23 @@ void destroyWidget () {
*/
public Rectangle getBounds () {
checkWidget();
- int x = OS.GTK_WIDGET_X (handle);
- int y = OS.GTK_WIDGET_Y (handle);
- int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
- int height = (state & ZERO_HEIGHT) != 0 ? 0 : 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 = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ } else {
+ x = OS.GTK_WIDGET_X (handle);
+ y = OS.GTK_WIDGET_Y (handle);
+ width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
+ height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (handle);
+ }
if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
return new Rectangle (x, y, width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index e60becf080..bedf924054 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -1126,8 +1126,17 @@ public Rectangle getClientArea () {
int [] fixedX = new int [1], fixedY = new int [1];
OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
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 (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index e1a78e1e27..740f2dc6b4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -388,8 +388,17 @@ int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
useFixedWidth = false;
- int x = OS.GTK_WIDGET_X (widget);
- int width = OS.GTK_WIDGET_WIDTH (widget);
+ int x = 0;
+ int width = 0;
+ GtkAllocation widgetAllocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation (widget, widgetAllocation);
+ x = widgetAllocation.x;
+ width = widgetAllocation.width;
+ } else {
+ x = OS.GTK_WIDGET_X (widget);
+ width = OS.GTK_WIDGET_WIDTH (widget);
+ }
if (x != lastX) {
lastX = x;
sendEvent (SWT.Move);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 74c851dba6..c040f92753 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -388,8 +388,15 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
Event event = new Event ();
event.detail = SWT.ARROW;
int /*long*/ topHandle = currentFocusItem.topHandle ();
- event.x = OS.GTK_WIDGET_X (topHandle);
- event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ event.x = allocation.x;
+ event.y = allocation.y + allocation.height;
+ } else {
+ event.x = OS.GTK_WIDGET_X (topHandle);
+ event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - OS.GTK_WIDGET_WIDTH(topHandle) - event.x;
currentFocusItem.sendSelectionEvent (SWT.Selection, event, false);
/*
@@ -461,9 +468,17 @@ int /*long*/ menuItemSelected (int /*long*/ widget, ToolItem item) {
* as Arrow click, in order to popup the drop-down.
*/
event.detail = SWT.ARROW;
- event.x = OS.GTK_WIDGET_X (widget);
- if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - OS.GTK_WIDGET_WIDTH (widget) - event.x;
- event.y = OS.GTK_WIDGET_Y (widget) + OS.GTK_WIDGET_HEIGHT (widget);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(widget, allocation);
+ event.x = allocation.x;
+ if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - allocation.width - event.x;
+ event.y = allocation.y + allocation.height;
+ } else {
+ event.x = OS.GTK_WIDGET_X (widget);
+ if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - OS.GTK_WIDGET_WIDTH (widget) - event.x;
+ event.y = OS.GTK_WIDGET_Y (widget) + OS.GTK_WIDGET_HEIGHT (widget);
+ }
break;
case SWT.RADIO :
if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index ddc31a428a..40eb65b2a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -317,10 +317,19 @@ public Rectangle getBounds () {
parent.forceResize ();
int /*long*/ topHandle = topHandle ();
int x, y, width, height;
- x = OS.GTK_WIDGET_X (topHandle);
- y = OS.GTK_WIDGET_Y (topHandle);
- width = OS.GTK_WIDGET_WIDTH (topHandle);
- height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ 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;
+ width = allocation.width;
+ height = allocation.height;
+ } else {
+ x = OS.GTK_WIDGET_X (topHandle);
+ y = OS.GTK_WIDGET_Y (topHandle);
+ width = OS.GTK_WIDGET_WIDTH (topHandle);
+ height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
if ((style & SWT.SEPARATOR) != 0 && control != null) height = Math.max (height, 23);
return new Rectangle (x, y, width, height);
@@ -469,16 +478,32 @@ public int getWidth () {
checkWidget();
parent.forceResize ();
int /*long*/ topHandle = topHandle ();
- return OS.GTK_WIDGET_WIDTH (topHandle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ GtkAllocation allocation = new GtkAllocation();
+ OS.gtk_widget_get_allocation (topHandle, allocation);
+ return allocation.width;
+ } else {
+ return OS.GTK_WIDGET_WIDTH (topHandle);
+ }
}
int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
double x = gdkEvent.x;
- gdkEvent.x += OS.GTK_WIDGET_X (handle);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ gdkEvent.x += allocation.x;
+ } else {
+ gdkEvent.x += OS.GTK_WIDGET_X (handle);
+ }
double y = gdkEvent.y;
- gdkEvent.y += OS.GTK_WIDGET_Y (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ gdkEvent.y += allocation.y;
+ } else {
+ gdkEvent.y += OS.GTK_WIDGET_Y (handle);
+ }
OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
int /*long*/ result = parent.gtk_button_press_event (widget, event);
gdkEvent.x = x;
@@ -491,9 +516,19 @@ int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event)
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
double x = gdkEvent.x;
- gdkEvent.x += OS.GTK_WIDGET_X (handle);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(handle, allocation);
+ gdkEvent.x += allocation.x;
+ } else {
+ gdkEvent.x += OS.GTK_WIDGET_X (handle);
+ }
double y = gdkEvent.y;
- gdkEvent.y += OS.GTK_WIDGET_Y (handle);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ gdkEvent.y += allocation.y;
+ } else {
+ gdkEvent.y += OS.GTK_WIDGET_Y (handle);
+ }
OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
int /*long*/ result = parent.gtk_button_release_event (widget, event);
gdkEvent.x = x;
@@ -520,8 +555,20 @@ int /*long*/ gtk_clicked (int /*long*/ widget) {
double [] x_win = new double [1];
double [] y_win = new double [1];
OS.gdk_event_get_coords (eventPtr, x_win, y_win);
- int x = OS.GTK_WIDGET_X (arrowHandle) - OS.GTK_WIDGET_X (handle);
- int width = OS.GTK_WIDGET_WIDTH (arrowHandle);
+ int x = 0;
+ int width = 0;
+ GtkAllocation handleAllocation = new GtkAllocation ();
+ GtkAllocation arrowHandleAllocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(arrowHandle, arrowHandleAllocation);
+ OS.gtk_widget_get_allocation(handle, handleAllocation);
+ x = arrowHandleAllocation.x - handleAllocation.x;
+ width = arrowHandleAllocation.width;
+ } else {
+ x = OS.GTK_WIDGET_X (arrowHandle) - OS.GTK_WIDGET_X (handle);
+ width = OS.GTK_WIDGET_WIDTH (arrowHandle);
+ }
+
if ((((parent.style & SWT.RIGHT_TO_LEFT) == 0) && x <= (int)x_win [0])
|| (((parent.style & SWT.RIGHT_TO_LEFT) != 0) && (int)x_win [0] <= x + width)) {
isArrow = true;
@@ -539,9 +586,18 @@ int /*long*/ gtk_clicked (int /*long*/ widget) {
}
if (isArrow) {
event.detail = SWT.ARROW;
- event.x = OS.GTK_WIDGET_X (topHandle);
- if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - OS.GTK_WIDGET_WIDTH (topHandle) - event.x;
- event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
+ GtkAllocation allocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(topHandle, allocation);
+ event.x = allocation.x;
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - allocation.width - event.x;
+ event.y = allocation.y + allocation.height;
+ } else {
+ event.x = OS.GTK_WIDGET_X (topHandle);
+ if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - OS.GTK_WIDGET_WIDTH (topHandle) - event.x;
+ event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
+ }
+
}
break;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index a205e6ef96..d4f5929351 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -582,8 +582,17 @@ int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, OS.GTK_WIDGET_WINDOW (widget));
GdkRectangle dest = new GdkRectangle ();
OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
- int w = OS.GTK_WIDGET_WIDTH (widget);
- int h = OS.GTK_WIDGET_HEIGHT (widget);
+ int w = 0;
+ int h = 0;
+ GtkAllocation widgetAllocation = new GtkAllocation ();
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation (widget, widgetAllocation);
+ w = widgetAllocation.width;
+ h = widgetAllocation.height;
+ } else {
+ w = OS.GTK_WIDGET_WIDTH (widget);
+ h = OS.GTK_WIDGET_HEIGHT (widget);
+ }
if (dest.height < y + h) y -= h;
if (dest.width < x + w) x -= w;
OS.gtk_window_move (widget, x, y);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index 95dad533dc..901de7791f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
@@ -316,9 +316,18 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr)
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
if (image != null && image.mask != 0) {
+ int xoffset = 0;
+ int yoffset = 0;
+ GtkAllocation widgetAllocation = new GtkAllocation();
if (OS.gdk_drawable_get_depth (image.mask) == 1) {
- int xoffset = (int) Math.floor (OS.GTK_WIDGET_X (widget) + ((OS.GTK_WIDGET_WIDTH (widget) - OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
- int yoffset = (int) Math.floor (OS.GTK_WIDGET_Y (widget) + ((OS.GTK_WIDGET_HEIGHT (widget) - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(widget, widgetAllocation);
+ xoffset = (int) Math.floor (widgetAllocation.x + ((widgetAllocation.width -OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
+ yoffset = (int) Math.floor (widgetAllocation.y + ((widgetAllocation.height - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
+ } else {
+ xoffset = (int) Math.floor (OS.GTK_WIDGET_X (widget) + ((OS.GTK_WIDGET_WIDTH (widget) - OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
+ yoffset = (int) Math.floor (OS.GTK_WIDGET_Y (widget) + ((OS.GTK_WIDGET_HEIGHT (widget) - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
+ }
Rectangle b = image.getBounds();
int /*long*/ gdkImagePtr = OS.gdk_drawable_get_image (image.mask, 0, 0, b.width, b.height);
if (gdkImagePtr == 0) error(SWT.ERROR_NO_HANDLES);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index f46c23ffb9..9b3fe340f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -1127,8 +1127,17 @@ public Rectangle getClientArea () {
int [] fixedX = new int [1], fixedY = new int [1];
OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
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 height = 0;
+ int width = 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 (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index 8e835e829d..a362f0bbbc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
@@ -390,8 +390,17 @@ int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
useFixedWidth = false;
- int x = OS.GTK_WIDGET_X (widget);
- int width = OS.GTK_WIDGET_WIDTH (widget);
+ GtkAllocation widgetAllocation = new GtkAllocation();
+ int x = 0;
+ int width = 0;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_widget_get_allocation(widget, widgetAllocation);
+ x = widgetAllocation.x;
+ width = widgetAllocation.width;
+ } else {
+ x = OS.GTK_WIDGET_X (widget);
+ width = OS.GTK_WIDGET_WIDTH (widget);
+ }
if (x != lastX) {
lastX = x;
sendEvent (SWT.Move);

Back to the top