diff options
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java | 96 |
1 files changed, 25 insertions, 71 deletions
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 40eb65b2a9..b6ae773f1f 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 @@ -316,20 +316,12 @@ public Rectangle getBounds () { checkWidget(); parent.forceResize (); int /*long*/ topHandle = topHandle (); - int x, y, width, height; 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); - } + gtk_widget_get_allocation (topHandle, allocation); + int x = allocation.x; + int y = allocation.y; + int width = allocation.width; + int height = allocation.height; 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); @@ -478,32 +470,18 @@ public int getWidth () { checkWidget(); parent.forceResize (); int /*long*/ topHandle = 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); - } + GtkAllocation allocation = new GtkAllocation(); + gtk_widget_get_allocation (topHandle, allocation); + return allocation.width; } 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; 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; - if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { - gdkEvent.y += allocation.y; - } else { - gdkEvent.y += OS.GTK_WIDGET_Y (handle); - } + gtk_widget_get_allocation (handle, allocation); + double x = gdkEvent.x + allocation.x; + double y = gdkEvent.y + allocation.y; OS.memmove (event, gdkEvent, GdkEventButton.sizeof); int /*long*/ result = parent.gtk_button_press_event (widget, event); gdkEvent.x = x; @@ -515,20 +493,10 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { 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; 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; - if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { - gdkEvent.y += allocation.y; - } else { - gdkEvent.y += OS.GTK_WIDGET_Y (handle); - } + gtk_widget_get_allocation (handle, allocation); + double x = gdkEvent.x + allocation.x; + double y = gdkEvent.y + allocation.y; OS.memmove (event, gdkEvent, GdkEventButton.sizeof); int /*long*/ result = parent.gtk_button_release_event (widget, event); gdkEvent.x = x; @@ -557,18 +525,12 @@ int /*long*/ gtk_clicked (int /*long*/ widget) { OS.gdk_event_get_coords (eventPtr, x_win, y_win); 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); - } - + GtkAllocation allocation = new GtkAllocation (); + gtk_widget_get_allocation (arrowHandle, allocation); + x = allocation.x; + width = allocation.width; + gtk_widget_get_allocation (handle, allocation); + x -= allocation.x; 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; @@ -587,17 +549,10 @@ int /*long*/ gtk_clicked (int /*long*/ widget) { if (isArrow) { event.detail = SWT.ARROW; 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); - } - + 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; } break; } @@ -906,8 +861,7 @@ void resizeHandle(int width, int height) { GtkRequisition requisition = new GtkRequisition (); parent.gtk_widget_size_request (handle, requisition); GtkAllocation allocation = new GtkAllocation (); - allocation.x = OS.GTK_WIDGET_X(handle); - allocation.y = OS.GTK_WIDGET_Y(handle); + gtk_widget_get_allocation (handle, allocation); allocation.width = width; allocation.height = height; OS.gtk_widget_size_allocate (handle, allocation); |