summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2003-07-15 17:09:16 +0000
committerFelipe Heidrich <fheidric>2003-07-15 17:09:16 +0000
commit41ac31787f9983e1a0e05b99817fd634ad3d7cef (patch)
treefda9e05e4613c03c7d56f21c7eb8ffa88f2b1c32
parent27eb91e1a341a10874a106937a8c94059fba3e4f (diff)
downloadeclipse.platform.swt-41ac31787f9983e1a0e05b99817fd634ad3d7cef.tar.gz
eclipse.platform.swt-41ac31787f9983e1a0e05b99817fd634ad3d7cef.tar.xz
eclipse.platform.swt-41ac31787f9983e1a0e05b99817fd634ad3d7cef.zip
get rid of WidgetTable
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java122
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java107
19 files changed, 152 insertions, 193 deletions
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 b7aee79c73..947d1a7b10 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
@@ -236,10 +236,10 @@ void createWidget (int index) {
void deregister () {
super.deregister ();
- if (boxHandle != 0) WidgetTable.remove (boxHandle);
- if (labelHandle != 0) WidgetTable.remove (labelHandle);
- if (imageHandle != 0) WidgetTable.remove (imageHandle);
- if (arrowHandle != 0) WidgetTable.remove (arrowHandle);
+ if (boxHandle != 0) display.removeWidget (boxHandle);
+ if (labelHandle != 0) display.removeWidget (labelHandle);
+ if (imageHandle != 0) display.removeWidget (imageHandle);
+ if (arrowHandle != 0) display.removeWidget (arrowHandle);
}
int fontHandle () {
@@ -401,10 +401,10 @@ void hookEvents () {
void register () {
super.register ();
- if (boxHandle != 0) WidgetTable.put (boxHandle, this);
- if (labelHandle != 0) WidgetTable.put (labelHandle, this);
- if (imageHandle != 0) WidgetTable.put (imageHandle, this);
- if (arrowHandle != 0) WidgetTable.put (arrowHandle, this);
+ if (boxHandle != 0) display.addWidget (boxHandle, this);
+ if (labelHandle != 0) display.addWidget (labelHandle, this);
+ if (imageHandle != 0) display.addWidget (imageHandle, this);
+ if (arrowHandle != 0) display.addWidget (arrowHandle, this);
}
void releaseHandle () {
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 2be2396cd8..01cfb58bc9 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
@@ -407,11 +407,11 @@ GdkColor defaultForeground () {
void deregister () {
super.deregister ();
- if (arrowHandle != 0) WidgetTable.remove (arrowHandle);
- WidgetTable.remove (entryHandle);
- WidgetTable.remove (listHandle);
+ if (arrowHandle != 0) display.removeWidget (arrowHandle);
+ display.removeWidget (entryHandle);
+ display.removeWidget (listHandle);
int imContext = imContext ();
- if (imContext != 0) WidgetTable.remove (imContext);
+ if (imContext != 0) display.removeWidget (imContext);
}
int fontHandle () {
@@ -872,11 +872,11 @@ int parentingHandle() {
void register () {
super.register ();
- if (arrowHandle != 0) WidgetTable.put (arrowHandle, this);
- WidgetTable.put (entryHandle, this);
- WidgetTable.put (listHandle, this);
+ if (arrowHandle != 0) display.addWidget (arrowHandle, this);
+ display.addWidget (entryHandle, this);
+ display.addWidget (listHandle, this);
int imContext = imContext ();
- if (imContext != 0) WidgetTable.put (imContext, this);
+ if (imContext != 0) display.addWidget (imContext, this);
}
void releaseHandle () {
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 993effbcea..887f39515f 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
@@ -92,7 +92,7 @@ Control [] _getChildren () {
while (i < count) {
int handle = OS.g_list_nth_data (list, i);
if (handle != 0) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = display.getWidget (handle);
if (widget != null && widget != this) {
if (widget instanceof Control) {
children [j++] = (Control) widget;
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 65a78c5249..ffb03147a8 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
@@ -100,9 +100,9 @@ GdkColor defaultForeground () {
void deregister () {
super.deregister ();
- if (fixedHandle != 0) WidgetTable.remove (fixedHandle);
+ if (fixedHandle != 0) display.removeWidget (fixedHandle);
int imHandle = imHandle ();
- if (imHandle != 0) WidgetTable.remove (imHandle);
+ if (imHandle != 0) display.removeWidget (imHandle);
}
void enableWidget (boolean enabled) {
@@ -1997,9 +1997,9 @@ Decorations menuShell () {
void register () {
super.register ();
- if (fixedHandle != 0) WidgetTable.put (fixedHandle, this);
+ if (fixedHandle != 0) display.addWidget (fixedHandle, this);
int imHandle = imHandle ();
- if (imHandle != 0) WidgetTable.put (imHandle, this);
+ if (imHandle != 0) display.addWidget (imHandle, this);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 8ab3d6aa1d..111776571c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -102,6 +102,17 @@ public class Display extends Device {
EventTable eventTable, filterTable;
static String APP_NAME = "SWT";
+ /* Widget Table */
+ int freeSlot;
+ int [] indexTable;
+ Widget [] widgetTable;
+ final static int GROW_SIZE = 1024;
+ static final int SWT_OBJECT_INDEX;
+ static {
+ byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true);
+ SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer);
+ }
+
/* Input method resources */
Control imControl;
int preeditWindow, preeditLabel;
@@ -368,6 +379,29 @@ void addPopup (Menu menu) {
popups [index] = menu;
}
+void addWidget (int handle, Widget widget) {
+ if (handle == 0) return;
+ if (freeSlot == -1) {
+ int length = (freeSlot = indexTable.length) + GROW_SIZE;
+ int[] newIndexTable = new int[length];
+ Widget[] newWidgetTable = new Widget [length];
+ System.arraycopy (indexTable, 0, newIndexTable, 0, freeSlot);
+ System.arraycopy (widgetTable, 0, newWidgetTable, 0, freeSlot);
+ for (int i = freeSlot; i < length - 1; i++) {
+ newIndexTable[i] = i + 1;
+ }
+ newIndexTable[length - 1] = -1;
+ indexTable = newIndexTable;
+ widgetTable = newWidgetTable;
+ }
+ int index = freeSlot + 1;
+ OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, index);
+ int oldSlot = freeSlot;
+ freeSlot = indexTable[oldSlot];
+ indexTable [oldSlot] = -2;
+ widgetTable [oldSlot] = widget;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -604,7 +638,7 @@ int eventProc (int event, int data) {
OS.gdk_window_get_user_data (window, user_data);
int handle = user_data [0];
if (handle != 0) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget != null && widget instanceof Control) {
control = (Control) widget;
if (control.isEnabled ()) break;
@@ -653,7 +687,7 @@ int eventProc (int event, int data) {
*/
public Widget findWidget (int handle) {
checkDevice ();
- return WidgetTable.get (handle);
+ return getWidget (handle);
}
/**
@@ -730,7 +764,7 @@ public Control getCursorControl () {
int handle = user_data [0];
if (handle == 0) return null;
do {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget != null && widget instanceof Control) {
Control control = (Control) widget;
if (control.getEnabled ()) return control;
@@ -927,7 +961,7 @@ public Control getFocusControl () {
int handle = OS.gtk_window_get_focus (shellHandle);
if (handle == 0) return null;
do {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget != null && widget instanceof Control) {
Control window = (Control) widget;
if (window.getEnabled ()) return window;
@@ -1043,23 +1077,28 @@ public Monitor getPrimaryMonitor () {
*/
public Shell [] getShells () {
checkDevice ();
- int count = 0;
- Shell [] shells = WidgetTable.shells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed () && (this == shell.display)) {
- count++;
- }
+ int length = 0;
+ for (int i=0; i<widgetTable.length; i++) {
+ Widget widget = widgetTable [i];
+ if (widget != null && widget instanceof Shell) length++;
}
int index = 0;
- Shell [] result = new Shell [count];
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed () && (this == shell.display)) {
- result [index++] = shell;
+ Shell [] result = new Shell [length];
+ for (int i=0; i<widgetTable.length; i++) {
+ Widget widget = widgetTable [i];
+ if (widget != null && widget instanceof Shell) {
+ int j = 0;
+ while (j < index) {
+ if (result [j] == widget) break;
+ j++;
+ }
+ if (j == index) result [index++] = (Shell) widget;
}
}
- return result;
+ if (index == length) return result;
+ Shell [] newResult = new Shell [index];
+ System.arraycopy (result, 0, newResult, 0, index);
+ return newResult;
}
/**
@@ -1334,6 +1373,13 @@ public Thread getThread () {
return thread;
}
+Widget getWidget (int handle) {
+ if (handle == 0) return null;
+ int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
+ if (0 <= index && index < widgetTable.length) return widgetTable [index];
+ return null;
+}
+
/**
* Initializes any internal resources needed by the
* device.
@@ -1347,6 +1393,7 @@ protected void init () {
super.init ();
initializeCallbacks ();
initializeSystemResources ();
+ initializeWidgetTable ();
}
void initializeCallbacks () {
@@ -1387,6 +1434,13 @@ void initializeCallbacks () {
if (treeSelectionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
}
+void initializeWidgetTable () {
+ indexTable = new int [GROW_SIZE];
+ widgetTable = new Widget [GROW_SIZE];
+ for (int i=0; i<GROW_SIZE-1; i++) indexTable [i] = i + 1;
+ indexTable [GROW_SIZE - 1] = -1;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -1510,7 +1564,7 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
}
int mouseHoverProc (int handle) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget == null) return 0;
return widget.hoverProc (handle);
}
@@ -1611,12 +1665,10 @@ synchronized void register () {
*/
protected void release () {
sendEvent (SWT.Dispose, new Event ());
- Shell [] shells = WidgetTable.shells ();
+ Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
- if (!shell.isDisposed ()) {
- if (this == shell.display) shell.dispose ();
- }
+ if (!shell.isDisposed ()) shell.dispose ();
}
while (readAndDispatch ()) {};
if (disposeList != null) {
@@ -1740,6 +1792,20 @@ void removePopup (Menu menu) {
}
}
+Widget removeWidget (int handle) {
+ if (handle == 0) return null;
+ Widget widget = null;
+ int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
+ if (0 <= index && index < widgetTable.length) {
+ widget = widgetTable [index];
+ widgetTable [index] = null;
+ indexTable [index] = freeSlot;
+ freeSlot = index;
+ OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, 0);
+ }
+ return widget;
+}
+
boolean runAsyncMessages () {
return synchronizer.runAsyncMessages ();
}
@@ -2123,7 +2189,7 @@ int caretProc (int clientData) {
}
int treeSelectionProc (int model, int path, int iter, int data) {
- Widget widget = WidgetTable.get (data);
+ Widget widget = getWidget (data);
if (widget == null) return 0;
return widget.treeSelectionProc (model, path, iter, treeSelection, treeSelectionLength++);
}
@@ -2222,31 +2288,31 @@ public void wake () {
}
int windowProc (int handle, int user_data) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget == null) return 0;
return widget.windowProc (handle, user_data);
}
int windowProc (int handle, int arg0, int user_data) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget == null) return 0;
return widget.windowProc (handle, arg0, user_data);
}
int windowProc (int handle, int arg0, int arg1, int user_data) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget == null) return 0;
return widget.windowProc (handle, arg0, arg1, user_data);
}
int windowProc (int handle, int arg0, int arg1, int arg2, int user_data) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget == null) return 0;
return widget.windowProc (handle, arg0, arg1, arg2, user_data);
}
int windowTimerProc (int handle) {
- Widget widget = WidgetTable.get (handle);
+ Widget widget = getWidget (handle);
if (widget == null) return 0;
return widget.timerProc (handle);
}
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 780651ed3d..dabd4b57c6 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
@@ -179,8 +179,8 @@ void createHandle(int index) {
void deregister () {
super.deregister ();
- WidgetTable.remove (clientHandle);
- WidgetTable.remove (labelHandle);
+ display.removeWidget (clientHandle);
+ display.removeWidget (labelHandle);
}
void enableWidget (boolean enabled) {
@@ -239,8 +239,8 @@ int parentingHandle() {
void register () {
super.register ();
- WidgetTable.put (clientHandle, this);
- WidgetTable.put (labelHandle, this);
+ display.addWidget (clientHandle, this);
+ display.addWidget (labelHandle, this);
}
void releaseHandle () {
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 5ccadc9cd8..8f4e642eed 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
@@ -196,9 +196,9 @@ void createWidget (int index) {
void deregister () {
super.deregister ();
- if (frameHandle != 0) WidgetTable.remove (frameHandle);
- if (labelHandle != 0) WidgetTable.remove (labelHandle);
- if (imageHandle != 0) WidgetTable.remove (imageHandle);
+ if (frameHandle != 0) display.removeWidget (frameHandle);
+ if (labelHandle != 0) display.removeWidget (labelHandle);
+ if (imageHandle != 0) display.removeWidget (imageHandle);
}
int eventHandle () {
@@ -293,9 +293,9 @@ void hookEvents () {
void register () {
super.register ();
- if (frameHandle != 0) WidgetTable.put (frameHandle, this);
- if (labelHandle != 0) WidgetTable.put (labelHandle, this);
- if (imageHandle != 0) WidgetTable.put (imageHandle, this);
+ if (frameHandle != 0) display.addWidget (frameHandle, this);
+ if (labelHandle != 0) display.addWidget (labelHandle, this);
+ if (imageHandle != 0) display.addWidget (imageHandle, this);
}
void releaseHandle () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index 57adf80ef0..a2d203fc37 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -242,7 +242,7 @@ GdkColor defaultForeground () {
void deregister() {
super.deregister ();
- WidgetTable.remove (OS.gtk_tree_view_get_selection (handle));
+ display.removeWidget (OS.gtk_tree_view_get_selection (handle));
}
/**
@@ -798,7 +798,7 @@ int paintWindow () {
void register () {
super.register ();
- WidgetTable.put (OS.gtk_tree_view_get_selection (handle), this);
+ display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
}
void releaseWidget () {
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 ad00d817d2..8d4e774158 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
@@ -347,7 +347,7 @@ public MenuItem getItem (int index) {
int data = OS.g_list_nth_data (list, index);
OS.g_list_free (list);
if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
- return (MenuItem) WidgetTable.get (data);
+ return (MenuItem) display.getWidget (data);
}
/**
@@ -397,7 +397,7 @@ public MenuItem [] getItems () {
MenuItem [] items = new MenuItem [count];
for (int i=0; i<count; i++) {
int data = OS.g_list_nth_data (list, i);
- items [i] = (MenuItem) WidgetTable.get (data);
+ items [i] = (MenuItem) display.getWidget (data);
}
OS.g_list_free (list);
return items;
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 58738ecf39..60e3d55929 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
@@ -143,7 +143,7 @@ void createWidget (int index) {
void deregister () {
super.deregister ();
- if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
+ if (scrolledHandle != 0) display.removeWidget (scrolledHandle);
}
/**
@@ -221,7 +221,7 @@ boolean isTabGroup() {
void register () {
super.register ();
- if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
+ if (scrolledHandle != 0) display.addWidget (scrolledHandle, this);
}
void releaseHandle () {
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 dc2bbd2bcc..1316cb1a34 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
@@ -528,7 +528,7 @@ public boolean isVisible () {
void register () {
super.register ();
- WidgetTable.put (shellHandle, this);
+ display.addWidget (shellHandle, this);
}
int topHandle () {
@@ -998,7 +998,7 @@ int trimWidth () {
void deregister () {
super.deregister ();
- WidgetTable.remove (shellHandle);
+ display.removeWidget (shellHandle);
}
public void dispose () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
index 89b39c43cd..1611a262d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
@@ -176,13 +176,13 @@ void hookEvents () {
void register () {
super.register ();
int hAdjustment = OS.gtk_range_get_adjustment (handle);
- WidgetTable.put (hAdjustment, this);
+ display.addWidget (hAdjustment, this);
}
void deregister () {
super.deregister ();
int hAdjustment = OS.gtk_range_get_adjustment (handle);
- WidgetTable.remove (hAdjustment);
+ display.removeWidget (hAdjustment);
}
public Point computeSize (int wHint, int hHint, boolean changed) {
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 d5d0a2f356..8ea8cb8e40 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
@@ -367,8 +367,8 @@ GdkColor defaultForeground () {
void deregister() {
super.deregister ();
- WidgetTable.remove (OS.gtk_tree_view_get_selection (handle));
- if (checkRenderer != 0) WidgetTable.remove (checkRenderer);
+ display.removeWidget (OS.gtk_tree_view_get_selection (handle));
+ if (checkRenderer != 0) display.removeWidget (checkRenderer);
}
/**
@@ -1222,8 +1222,8 @@ void releaseWidget () {
void register () {
super.register ();
- WidgetTable.put (OS.gtk_tree_view_get_selection (handle), this);
- if (checkRenderer != 0) WidgetTable.put (checkRenderer, this);
+ display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
+ if (checkRenderer != 0) display.addWidget (checkRenderer, this);
}
/**
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 77608b04f9..ef5169d933 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
@@ -185,7 +185,7 @@ void createWidget (int index) {
void deregister() {
super.deregister ();
- WidgetTable.remove (handle);
+ display.removeWidget (handle);
}
/**
@@ -315,7 +315,7 @@ public void pack () {
void register () {
super.register ();
- WidgetTable.put (handle, this);
+ display.addWidget (handle, this);
}
void releaseChild () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index 9aedfa7e3b..ae777c0ffa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -374,9 +374,9 @@ GdkColor defaultForeground () {
void deregister () {
super.deregister ();
- if (bufferHandle != 0) WidgetTable.remove (bufferHandle);
+ if (bufferHandle != 0) display.removeWidget (bufferHandle);
int imContext = imContext ();
- if (imContext != 0) WidgetTable.remove (imContext);
+ if (imContext != 0) display.removeWidget (imContext);
}
GdkColor getBackgroundColor () {
@@ -1030,9 +1030,9 @@ public void paste () {
void register () {
super.register ();
- if (bufferHandle != 0) WidgetTable.put (bufferHandle, this);
+ if (bufferHandle != 0) display.addWidget (bufferHandle, this);
int imContext = imContext ();
- if (imContext != 0) WidgetTable.put (imContext, this);
+ if (imContext != 0) display.addWidget (imContext, this);
}
/**
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 19395c956e..32a03ee806 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
@@ -235,7 +235,7 @@ public ToolItem [] getItems () {
ToolItem [] result = new ToolItem [count];
for (int i=0; i<count; i++) {
int data = OS.g_list_nth_data (list, i);
- Widget widget = WidgetTable.get (data);
+ Widget widget = display.getWidget (data);
result [i] = (ToolItem) widget;
}
OS.g_list_free (list);
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 2b28ffda8a..22c3ce65cf 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
@@ -286,8 +286,8 @@ GdkColor defaultForeground () {
void deregister () {
super.deregister ();
- WidgetTable.remove (OS.gtk_tree_view_get_selection (handle));
- if (checkRenderer != 0) WidgetTable.remove (checkRenderer);
+ display.removeWidget (OS.gtk_tree_view_get_selection (handle));
+ if (checkRenderer != 0) display.removeWidget (checkRenderer);
}
/**
@@ -725,8 +725,8 @@ int paintWindow () {
void register () {
super.register ();
- WidgetTable.put (OS.gtk_tree_view_get_selection (handle), this);
- if (checkRenderer != 0) WidgetTable.put (checkRenderer, this);
+ display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
+ if (checkRenderer != 0) display.addWidget (checkRenderer, this);
}
boolean releaseItem (TreeItem item, int [] index) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 3d4de0a77a..71f33b0ab2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -325,7 +325,7 @@ void createWidget (int index) {
void deregister () {
if (handle == 0) return;
- if ((state & HANDLE) != 0) WidgetTable.remove (handle);
+ if ((state & HANDLE) != 0) display.removeWidget (handle);
}
void destroyWidget () {
@@ -832,7 +832,7 @@ void postEvent (int eventType, Event event) {
void register () {
if (handle == 0) return;
- if ((state & HANDLE) != 0) WidgetTable.put (handle, this);
+ if ((state & HANDLE) != 0) display.addWidget (handle, this);
}
void releaseChild () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java
deleted file mode 100644
index 9bf0870f59..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/WidgetTable.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-
-class WidgetTable {
- static int FreeSlot = 0;
- static int GrowSize = 1024;
- static int [] IndexTable = new int [GrowSize];
- static Widget [] WidgetTable = new Widget [GrowSize];
- static final int SWT_OBJECT_INDEX;
- static {
- byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true);
- SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer);
- for (int i=0; i<GrowSize-1; i++) IndexTable [i] = i + 1;
- IndexTable [GrowSize - 1] = -1;
- }
-
-public static synchronized Widget get (int handle) {
- if (handle == 0) return null;
- int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
- if (0 <= index && index < WidgetTable.length) return WidgetTable [index];
- return null;
-}
-
-public synchronized static void put(int handle, Widget widget) {
- if (handle == 0) return;
- if (FreeSlot == -1) {
- int length = (FreeSlot = IndexTable.length) + GrowSize;
- int[] newIndexTable = new int[length];
- Widget[] newWidgetTable = new Widget [length];
- System.arraycopy (IndexTable, 0, newIndexTable, 0, FreeSlot);
- System.arraycopy (WidgetTable, 0, newWidgetTable, 0, FreeSlot);
- for (int i = FreeSlot; i < length - 1; i++) {
- newIndexTable[i] = i + 1;
- }
- newIndexTable[length - 1] = -1;
- IndexTable = newIndexTable;
- WidgetTable = newWidgetTable;
- }
- int index = FreeSlot + 1;
- OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, index);
- int oldSlot = FreeSlot;
- FreeSlot = IndexTable[oldSlot];
- IndexTable [oldSlot] = -2;
- WidgetTable [oldSlot] = widget;
-}
-
-public static synchronized Widget remove (int handle) {
- if (handle == 0) return null;
- Widget widget = null;
- int index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
- if (0 <= index && index < WidgetTable.length) {
- widget = WidgetTable [index];
- WidgetTable [index] = null;
- IndexTable [index] = FreeSlot;
- FreeSlot = index;
- OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, 0);
- }
- return widget;
-}
-
-public static synchronized Shell [] shells () {
- int length = 0;
- for (int i=0; i<WidgetTable.length; i++) {
- Widget widget = WidgetTable [i];
- if (widget != null && widget instanceof Shell) length++;
- }
- int index = 0;
- Shell [] result = new Shell [length];
- for (int i=0; i<WidgetTable.length; i++) {
- Widget widget = WidgetTable [i];
- if (widget != null && widget instanceof Shell) {
- int j = 0;
- while (j < index) {
- if (result [j] == widget) break;
- j++;
- }
- if (j == index) result [index++] = (Shell) widget;
- }
- }
- if (index == length) return result;
- Shell [] newResult = new Shell [index];
- System.arraycopy (result, 0, newResult, 0, index);
- return newResult;
-}
-
-public static synchronized int size () {
- int size = 0;
- for (int i=0; i<WidgetTable.length; i++) {
- if (WidgetTable [i] != null) size++;
- }
- return size;
-}
-
-}