summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk
diff options
context:
space:
mode:
authorAlexander Kurtakov <akurtako@redhat.com>2012-01-20 11:14:14 +0200
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-01-20 13:03:38 -0500
commit704f9377fdfbc3f0c12e11665b0fc2e8c6f9b051 (patch)
tree17dc198d2a65e9578740e7b17b550d3c54a86234 /bundles/org.eclipse.swt/Eclipse SWT/gtk
parenta07db21f2dc02d806d74ab0e60154800444f5429 (diff)
downloadeclipse.platform.swt-704f9377fdfbc3f0c12e11665b0fc2e8c6f9b051.tar.gz
eclipse.platform.swt-704f9377fdfbc3f0c12e11665b0fc2e8c6f9b051.tar.xz
eclipse.platform.swt-704f9377fdfbc3f0c12e11665b0fc2e8c6f9b051.zip
Cleanup pre GTK 2.4 leftovers.
This is a lot of code that can not be used nowadays but just makes it harder to kill deprecated functions in order to use newer GTK versions.
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java367
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java175
2 files changed, 126 insertions, 416 deletions
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 ed692d2f7e..7950613463 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
@@ -114,85 +114,34 @@ protected void checkSubclass () {
}
public Point computeSize (int wHint, int hHint, boolean changed) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
- if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
- Point size = computeNativeSize (handle, wHint, hHint, changed);
- int border = OS.gtk_container_get_border_width (handle);
- size.x += 2 * border;
- size.y += 2 * border;
- return size;
- } else {
- int height = 0, width = 0;
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- if (itemCount > 0) {
- height += spacing;
- GC gc = new GC (this);
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items [i];
- height += item.getHeaderHeight ();
- if (item.expanded) height += item.height;
- height += spacing;
- width = Math.max (width, item.getPreferredWidth (gc));
- }
- gc.dispose ();
- }
- }
- if (width == 0) width = DEFAULT_WIDTH;
- if (height == 0) height = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) width = wHint;
- if (hHint != SWT.DEFAULT) height = hHint;
- return new Point (width, height);
- }
+ if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+ if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+ Point size = computeNativeSize (handle, wHint, hHint, changed);
+ int border = OS.gtk_container_get_border_width (handle);
+ size.x += 2 * border;
+ size.y += 2 * border;
+ return size;
}
void createHandle (int index) {
state |= HANDLE;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
- if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (fixedHandle, true);
- handle = OS.gtk_vbox_new (false, 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- if ((style & SWT.V_SCROLL) != 0) {
- scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, OS.GTK_POLICY_AUTOMATIC);
- OS.gtk_container_add (fixedHandle, scrolledHandle);
- OS.gtk_scrolled_window_add_with_viewport (scrolledHandle, handle);
- int /*long*/ viewport = OS.gtk_bin_get_child (scrolledHandle);
- OS.gtk_viewport_set_shadow_type (viewport, OS.GTK_SHADOW_NONE);
- } else {
- OS.gtk_container_add (fixedHandle, handle);
- }
- OS.gtk_container_set_border_width (handle, 0);
+ fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ handle = OS.gtk_vbox_new (false, 0);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.V_SCROLL) != 0) {
+ scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+ if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, OS.GTK_POLICY_AUTOMATIC);
+ OS.gtk_container_add (fixedHandle, scrolledHandle);
+ OS.gtk_scrolled_window_add_with_viewport (scrolledHandle, handle);
+ int /*long*/ viewport = OS.gtk_bin_get_child (scrolledHandle);
+ OS.gtk_viewport_set_shadow_type (viewport, OS.GTK_SHADOW_NONE);
} else {
- int /*long*/ topHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
- if (topHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (topHandle, true);
- if ((style & SWT.V_SCROLL) != 0) {
- fixedHandle = topHandle;
- scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
- handle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_fixed_set_has_window (handle, true);
- OS.gtk_container_add (fixedHandle, scrolledHandle);
-
- /*
- * Force the scrolledWindow to have a single child that is
- * not scrolled automatically. Calling gtk_container_add()
- * seems to add the child correctly but cause a warning.
- */
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.gtk_container_add (scrolledHandle, handle);
- display.setWarnings (warnings);
- } else {
- handle = topHandle;
- }
- OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+ OS.gtk_container_add (fixedHandle, handle);
}
+ OS.gtk_container_set_border_width (handle, 0);
}
void createItem (ExpandItem item, int style, int index) {
@@ -205,9 +154,6 @@ void createItem (ExpandItem item, int style, int index) {
System.arraycopy (items, index, items, index + 1, itemCount - index);
items [index] = item;
itemCount++;
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if (lastFocus == null) lastFocus = item;
- }
item.width = Math.max (0, getClientArea ().width - spacing * 2);
layoutItems (index, true);
}
@@ -224,17 +170,6 @@ void destroyItem (ExpandItem item) {
index++;
}
if (index == itemCount) return;
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if (item == lastFocus) {
- int focusIndex = index > 0 ? index - 1 : 1;
- if (focusIndex < itemCount) {
- lastFocus = items [focusIndex];
- lastFocus.redraw ();
- } else {
- lastFocus = null;
- }
- }
- }
System.arraycopy (items, index + 1, items, index, --itemCount - index);
items [itemCount] = null;
item.redraw ();
@@ -242,36 +177,30 @@ void destroyItem (ExpandItem item) {
}
int /*long*/ eventHandle () {
- return OS.GTK_VERSION >= OS.VERSION (2, 4, 0) ? fixedHandle : handle;
+ return fixedHandle;
}
boolean forceFocus (int /*long*/ focusHandle) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (lastFocus != null && lastFocus.setFocus ()) return true;
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items [i];
- if (item.setFocus ()) return true;
- }
+ if (lastFocus != null && lastFocus.setFocus ()) return true;
+ for (int i = 0; i < itemCount; i++) {
+ ExpandItem item = items [i];
+ if (item.setFocus ()) return true;
}
return super.forceFocus (focusHandle);
}
boolean hasFocus () {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- for (int i=0; i<itemCount; i++) {
- ExpandItem item = items [i];
- if (item.hasFocus ()) return true;
- }
+ for (int i=0; i<itemCount; i++) {
+ ExpandItem item = items [i];
+ if (item.hasFocus ()) return true;
}
return super.hasFocus();
}
void hookEvents () {
super.hookEvents ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (scrolledHandle != 0) {
- OS.g_signal_connect_closure (scrolledHandle, OS.size_allocate, display.closures [SIZE_ALLOCATE], true);
- }
+ if (scrolledHandle != 0) {
+ OS.g_signal_connect_closure (scrolledHandle, OS.size_allocate, display.closures [SIZE_ALLOCATE], true);
}
}
@@ -284,10 +213,8 @@ int getBandHeight () {
}
GdkColor getForegroundColor () {
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if ((state & FOREGROUND) == 0) {
- return display.getSystemColor (SWT.COLOR_TITLE_FOREGROUND).handle;
- }
+ if ((state & FOREGROUND) == 0) {
+ return display.getSystemColor (SWT.COLOR_TITLE_FOREGROUND).handle;
}
return super.getForegroundColor ();
}
@@ -366,142 +293,36 @@ public int getSpacing () {
return spacing;
}
-int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- GdkEventButton gdkEvent = new GdkEventButton ();
- OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
- int x = (int)gdkEvent.x;
- int y = (int)gdkEvent.y;
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items[i];
- boolean hover = item.x <= x && x < (item.x + item.width) && item.y <= y && y < (item.y + getBandHeight ());
- if (hover && item != lastFocus) {
- lastFocus.redraw ();
- lastFocus = item;
- lastFocus.redraw ();
- forceFocus ();
- break;
- }
- }
- }
- return super.gtk_button_press_event (widget, event);
-}
-
-int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if (lastFocus != null) {
- GdkEventButton gdkEvent = new GdkEventButton ();
- OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
- int x = (int)gdkEvent.x;
- int y = (int)gdkEvent.y;
- boolean hover = lastFocus.x <= x && x < (lastFocus.x + lastFocus.width) && lastFocus.y <= y && y < (lastFocus.y + getBandHeight ());
- if (hover) {
- Event ev = new Event ();
- ev.item = lastFocus;
- notifyListeners (lastFocus.expanded ? SWT.Collapse : SWT.Expand, ev);
- lastFocus.expanded = !lastFocus.expanded;
- showItem (lastFocus);
- }
- }
- }
- return super.gtk_button_release_event (widget, event);
-}
-
int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
if ((state & OBSCURED) != 0) return 0;
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- GdkEventExpose gdkEvent = new GdkEventExpose ();
- OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
- GCData data = new GCData ();
- data.damageRgn = gdkEvent.region;
- GC gc = GC.gtk_new (this, data);
- boolean hasFocus = isFocusControl ();
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items [i];
- item.drawItem (gc, hasFocus && item == lastFocus);
- }
- gc.dispose ();
- }
return super.gtk_expose_event (widget, eventPtr);
}
-int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if (lastFocus != null) lastFocus.redraw ();
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+ if (!hasFocus ()) return 0;
+ int /*long*/ result = super.gtk_key_press_event (widget, event);
+ if (result != 0) return result;
+ int index = 0;
+ while (index < itemCount) {
+ if (items [index].hasFocus ()) break;
+ index++;
}
- return super.gtk_focus_in_event(widget, event);
-}
-
-int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if (lastFocus != null) lastFocus.redraw ();
+ GdkEventKey gdkEvent = new GdkEventKey ();
+ OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
+ boolean next = false;
+ switch (gdkEvent.keyval) {
+ case OS.GDK_Up:
+ case OS.GDK_Left: next = false; break;
+ case OS.GDK_Down:
+ case OS.GDK_Right: next = true; break;
+ default: return result;
}
- return super.gtk_focus_out_event (widget, event);
-}
-
-int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (!hasFocus ()) return 0;
- int /*long*/ result = super.gtk_key_press_event (widget, event);
- if (result != 0) return result;
- int index = 0;
- while (index < itemCount) {
- if (items [index].hasFocus ()) break;
- index++;
- }
- GdkEventKey gdkEvent = new GdkEventKey ();
- OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
- boolean next = false;
- switch (gdkEvent.keyval) {
- case OS.GDK_Up:
- case OS.GDK_Left: next = false; break;
- case OS.GDK_Down:
- case OS.GDK_Right: next = true; break;
- default: return result;
- }
- int start = index, offset = next ? 1 : -1;
- while ((index = (index + offset + itemCount) % itemCount) != start) {
- ExpandItem item = items [index];
- if (item.setFocus ()) return result;
- }
- return result;
- } else {
- if (lastFocus != null) {
- GdkEventKey keyEvent = new GdkEventKey ();
- OS.memmove (keyEvent, event, GdkEventKey.sizeof);
- switch (keyEvent.keyval) {
- case OS.GDK_Return:
- case OS.GDK_space:
- Event ev = new Event ();
- ev.item = lastFocus;
- sendEvent (lastFocus.expanded ? SWT.Collapse :SWT.Expand, ev);
- lastFocus.expanded = !lastFocus.expanded;
- showItem (lastFocus);
- break;
- case OS.GDK_Up:
- case OS.GDK_KP_Up: {
- int focusIndex = indexOf (lastFocus);
- if (focusIndex > 0) {
- lastFocus.redraw ();
- lastFocus = items [focusIndex - 1];
- lastFocus.redraw ();
- }
- break;
- }
- case OS.GDK_Down:
- case OS.GDK_KP_Down: {
- int focusIndex = indexOf (lastFocus);
- if (focusIndex < itemCount - 1) {
- lastFocus.redraw ();
- lastFocus = items [focusIndex + 1];
- lastFocus.redraw ();
- }
- break;
- }
- }
- }
+ int start = index, offset = next ? 1 : -1;
+ while ((index = (index + offset + itemCount) % itemCount) != start) {
+ ExpandItem item = items [index];
+ if (item.setFocus ()) return result;
}
- return super.gtk_key_press_event (widget, event);
+ return result;
}
/**
@@ -532,27 +353,9 @@ public int indexOf (ExpandItem item) {
}
void layoutItems (int index, boolean setScrollbar) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items [i];
- if (item != null) item.resizeControl (yCurrentScroll);
- }
- } else {
- if (index < itemCount) {
- int y = spacing - yCurrentScroll;
- for (int i = 0; i < index; i++) {
- ExpandItem item = items [i];
- if (item.expanded) y += item.height;
- y += item.getHeaderHeight() + spacing;
- }
- for (int i = index; i < itemCount; i++) {
- ExpandItem item = items [i];
- item.setBounds (spacing, y, 0, 0, true, false);
- if (item.expanded) y += item.height;
- y += item.getHeaderHeight() + spacing;
- }
- }
- if (setScrollbar) setScrollbar ();
+ for (int i = 0; i < itemCount; i++) {
+ ExpandItem item = items [i];
+ if (item != null) item.resizeControl (yCurrentScroll);
}
}
@@ -563,7 +366,7 @@ int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
}
int /*long*/ parentingHandle () {
- return OS.GTK_VERSION >= OS.VERSION (2, 4, 0) ? fixedHandle : handle;
+ return fixedHandle;
}
void releaseChildren (boolean destroy) {
@@ -611,42 +414,18 @@ void reskinChildren (int flags) {
super.reskinChildren (flags);
}
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- int result = super.setBounds (x, y, width, height, move, resize);
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- if (resize) {
- if ((style & SWT.V_SCROLL) != 0) {
- setScrollbar ();
- } else {
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items [i];
- int newWidth = Math.max (0, getClientArea ().width - spacing * 2);
- if (item.width != newWidth) {
- item.setBounds (0, 0, newWidth, item.height, false, true);
- }
- }
- }
- }
- }
- return result;
-}
-
void setFontDescription (int /*long*/ font) {
super.setFontDescription (font);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- for (int i = 0; i < itemCount; i++) {
- items[i].setFontDescription (font);
- }
- layoutItems (0, true);
+ for (int i = 0; i < itemCount; i++) {
+ items[i].setFontDescription (font);
}
+ layoutItems (0, true);
}
void setForegroundColor (GdkColor color) {
super.setForegroundColor (color);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- for (int i = 0; i < itemCount; i++) {
- items[i].setForegroundColor (color);
- }
+ for (int i = 0; i < itemCount; i++) {
+ items[i].setForegroundColor (color);
}
}
@@ -714,20 +493,8 @@ public void setSpacing (int spacing) {
if (spacing < 0) return;
if (spacing == this.spacing) return;
this.spacing = spacing;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.gtk_box_set_spacing (handle, spacing);
- OS.gtk_container_set_border_width (handle, spacing);
- } else {
- if ((style & SWT.V_SCROLL) == 0) {
- int width = Math.max (0, getClientArea ().width - spacing * 2);
- for (int i = 0; i < itemCount; i++) {
- ExpandItem item = items [i];
- if (item.width != width) item.setBounds (0, 0, width, item.height, false, true);
- }
- }
- layoutItems (0, true);
- redraw ();
- }
+ OS.gtk_box_set_spacing (handle, spacing);
+ OS.gtk_container_set_border_width (handle, spacing);
}
void showItem (ExpandItem item) {
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 4ac69e4ef8..f1c27e463f 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
@@ -121,24 +121,22 @@ protected void checkSubclass () {
}
void createHandle (int index) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- state |= HANDLE;
- handle = OS.gtk_expander_new (null);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- clientHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
- if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_container_add (handle, clientHandle);
- boxHandle = OS.gtk_hbox_new (false, 4);
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
- labelHandle = OS.gtk_label_new (null);
- if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
- imageHandle = OS.gtk_image_new ();
- if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_container_add (boxHandle, imageHandle);
- OS.gtk_container_add (boxHandle, labelHandle);
- OS.gtk_expander_set_label_widget (handle, boxHandle);
- OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
- }
+ state |= HANDLE;
+ handle = OS.gtk_expander_new (null);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ clientHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+ if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (handle, clientHandle);
+ boxHandle = OS.gtk_hbox_new (false, 4);
+ if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ labelHandle = OS.gtk_label_new (null);
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ imageHandle = OS.gtk_image_new ();
+ if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (boxHandle, imageHandle);
+ OS.gtk_container_add (boxHandle, labelHandle);
+ OS.gtk_expander_set_label_widget (handle, boxHandle);
+ OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
}
void createWidget (int index) {
@@ -149,12 +147,10 @@ void createWidget (int index) {
void deregister() {
super.deregister();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- display.removeWidget (clientHandle);
- display.removeWidget (boxHandle);
- display.removeWidget (labelHandle);
- display.removeWidget (imageHandle);
- }
+ display.removeWidget (clientHandle);
+ display.removeWidget (boxHandle);
+ display.removeWidget (labelHandle);
+ display.removeWidget (imageHandle);
}
void destroyWidget () {
@@ -269,10 +265,7 @@ public boolean getExpanded () {
*/
public int getHeaderHeight () {
checkWidget ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- return OS.GTK_WIDGET_HEIGHT (handle) - (expanded ? height : 0);
- }
- return Math.max (parent.getBandHeight (), imageHeight);
+ return OS.GTK_WIDGET_HEIGHT (handle) - (expanded ? height : 0);
}
/**
@@ -351,34 +344,23 @@ boolean hasFocus () {
void hookEvents () {
super.hookEvents ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE], false);
- OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE_INVERSE], true);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false);
- OS.g_signal_connect_closure (clientHandle, OS.size_allocate, display.closures [SIZE_ALLOCATE], true);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
- }
+ OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE], false);
+ OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE_INVERSE], true);
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false);
+ OS.g_signal_connect_closure (clientHandle, OS.size_allocate, display.closures [SIZE_ALLOCATE], true);
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
}
void redraw () {
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- int headerHeight = parent.getBandHeight ();
- if (imageHeight > headerHeight) {
- parent.redraw (x + ExpandItem.TEXT_INSET, y + headerHeight - imageHeight, imageWidth, imageHeight, false);
- }
- parent.redraw (x, y, width, headerHeight + height, false);
- }
}
void register () {
super.register ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- display.addWidget (clientHandle, this);
- display.addWidget (boxHandle, this);
- display.addWidget (labelHandle, this);
- display.addWidget (imageHandle, this);
- }
+ display.addWidget (clientHandle, this);
+ display.addWidget (boxHandle, this);
+ display.addWidget (labelHandle, this);
+ display.addWidget (imageHandle, this);
}
void releaseHandle () {
@@ -390,9 +372,7 @@ void releaseHandle () {
void releaseWidget () {
super.releaseWidget ();
if (imageList != null) imageList.dispose ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (parent.lastFocus == this) parent.lastFocus = null;
- }
+ if (parent.lastFocus == this) parent.lastFocus = null;
imageList = null;
control = null;
}
@@ -478,14 +458,8 @@ public void setControl (Control control) {
this.control = control;
if (control != null) {
control.setVisible (expanded);
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- int headerHeight = parent.getBandHeight ();
- control.setBounds (x + BORDER, y + headerHeight, Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
- }
- }
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- parent.layoutItems (0, true);
}
+ parent.layoutItems (0, true);
}
/**
@@ -501,12 +475,8 @@ public void setControl (Control control) {
public void setExpanded (boolean expanded) {
checkWidget ();
this.expanded = expanded;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.gtk_expander_set_expanded (handle, expanded);
- parent.layoutItems (0, true);
- } else {
- parent.showItem (this);
- }
+ OS.gtk_expander_set_expanded (handle, expanded);
+ parent.layoutItems (0, true);
}
boolean setFocus () {
@@ -546,48 +516,27 @@ void setForegroundColor (GdkColor color) {
public void setHeight (int height) {
checkWidget ();
if (height < 0) return;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- this.height = height;
- OS.gtk_widget_set_size_request (clientHandle, -1, height);
- parent.layoutItems (0, false);
- } else {
- setBounds (0, 0, width, height, false, true);
- if (expanded) parent.layoutItems (parent.indexOf (this) + 1, true);
- }
+ this.height = height;
+ OS.gtk_widget_set_size_request (clientHandle, -1, height);
+ parent.layoutItems (0, false);
}
public void setImage (Image image) {
super.setImage (image);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (imageList != null) imageList.dispose ();
- imageList = null;
- if (image != null) {
- if (image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- imageList = new ImageList ();
- int imageIndex = imageList.add (image);
- int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
- OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
- if (text.length () == 0) OS.gtk_widget_hide (labelHandle);
- OS.gtk_widget_show (imageHandle);
- } else {
- OS.gtk_image_set_from_pixbuf (imageHandle, 0);
- OS.gtk_widget_show (labelHandle);
- OS.gtk_widget_hide (imageHandle);
- }
+ if (imageList != null) imageList.dispose ();
+ imageList = null;
+ if (image != null) {
+ if (image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ imageList = new ImageList ();
+ int imageIndex = imageList.add (image);
+ int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+ OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+ if (text.length () == 0) OS.gtk_widget_hide (labelHandle);
+ OS.gtk_widget_show (imageHandle);
} else {
- int oldImageHeight = imageHeight;
- if (image != null) {
- Rectangle bounds = image.getBounds ();
- imageHeight = bounds.height;
- imageWidth = bounds.width;
- } else {
- imageHeight = imageWidth = 0;
- }
- if (oldImageHeight != imageHeight) {
- parent.layoutItems (parent.indexOf (this), true);
- } else {
- redraw ();
- }
+ OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+ OS.gtk_widget_show (labelHandle);
+ OS.gtk_widget_hide (imageHandle);
}
}
@@ -602,23 +551,17 @@ void setOrientation (boolean create) {
public void setText (String string) {
super.setText (string);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- OS.gtk_label_set_text (labelHandle, buffer);
- } else {
- redraw ();
- }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ OS.gtk_label_set_text (labelHandle, buffer);
}
void showWidget (int index) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.gtk_widget_show (handle);
- OS.gtk_widget_show (clientHandle);
- OS.gtk_container_add (parent.handle, handle);
- OS.gtk_box_set_child_packing (parent.handle, handle, false, false, 0, OS.GTK_PACK_START);
- if (boxHandle != 0) OS.gtk_widget_show (boxHandle);
- if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
- }
+ OS.gtk_widget_show (handle);
+ OS.gtk_widget_show (clientHandle);
+ OS.gtk_container_add (parent.handle, handle);
+ OS.gtk_box_set_child_packing (parent.handle, handle, false, false, 0, OS.GTK_PACK_START);
+ if (boxHandle != 0) OS.gtk_widget_show (boxHandle);
+ if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
}
int /*long*/ windowProc (int /*long*/ handle, int /*long*/ user_data) {