diff options
author | Veronika Irvine <veronika> | 2005-03-22 13:53:15 +0000 |
---|---|---|
committer | Veronika Irvine <veronika> | 2005-03-22 13:53:15 +0000 |
commit | 226d349ac9ca22240bc56e4676ede7bfeaccd06d (patch) | |
tree | 9477cfc27cab946b5d8ee2f099f298b1ff26d170 | |
parent | 63d72189b4ef99815e5db5a60e268d2d374cd3bc (diff) | |
download | eclipse.platform.swt-226d349ac9ca22240bc56e4676ede7bfeaccd06d.tar.gz eclipse.platform.swt-226d349ac9ca22240bc56e4676ede7bfeaccd06d.tar.xz eclipse.platform.swt-226d349ac9ca22240bc56e4676ede7bfeaccd06d.zip |
adding Tree.indexOf and TreeItem.indexOf
7 files changed, 77 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties index f835f2635d..60fdadb3ce 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties @@ -4,7 +4,7 @@ # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html -# +# # Contributors: # IBM Corporation - initial API and implementation ############################################################################### @@ -3109,6 +3109,10 @@ OS__gtk_tree_path_append_index= OS__gtk_tree_path_append_index_0=cast=(GtkTreePath *) OS__gtk_tree_path_append_index_1= +OS__gtk_tree_path_compare= +OS__gtk_tree_path_compare_0=cast=(const GtkTreePath *) +OS__gtk_tree_path_compare_1=cast=(const GtkTreePath *) + OS__gtk_tree_path_down= OS__gtk_tree_path_down_0=cast=(GtkTreePath *) 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 5670e33e0f..ace2f54b71 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 @@ -8808,6 +8808,18 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1path_1append_1index) } #endif +#ifndef NO__1gtk_1tree_1path_1compare +JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1compare) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1compare_FUNC); + rc = (jint)gtk_tree_path_compare((const GtkTreePath *)arg0, (const GtkTreePath *)arg1); + OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1compare_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1tree_1path_1down JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1path_1down) (JNIEnv *env, jclass that, jint arg0) 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 a0a9fae930..115b570044 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 = 976; -int OS_nativeFunctionCallCount[976]; +int OS_nativeFunctionCount = 977; +int OS_nativeFunctionCallCount[977]; char * OS_nativeFunctionNames[] = { "Call", "GDK_1WINDOWING_1X11", @@ -699,6 +699,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1tree_1model_1iter_1next", "_1gtk_1tree_1model_1iter_1nth_1child", "_1gtk_1tree_1path_1append_1index", + "_1gtk_1tree_1path_1compare", "_1gtk_1tree_1path_1down", "_1gtk_1tree_1path_1free", "_1gtk_1tree_1path_1get_1depth", 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 4cec90f3c1..37765efe80 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 @@ -703,6 +703,7 @@ typedef enum { _1gtk_1tree_1model_1iter_1next_FUNC, _1gtk_1tree_1model_1iter_1nth_1child_FUNC, _1gtk_1tree_1path_1append_1index_FUNC, + _1gtk_1tree_1path_1compare_FUNC, _1gtk_1tree_1path_1down_FUNC, _1gtk_1tree_1path_1free_FUNC, _1gtk_1tree_1path_1get_1depth_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 7cabfaaf8b..617a3eff1f 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 @@ -5991,6 +5991,15 @@ public static final void gtk_tree_path_append_index(int /*long*/ path, int index lock.unlock(); } } +public static final native int /*long*/ _gtk_tree_path_compare(int /*long*/ a, int /*long*/ b); +public static final int /*long*/ gtk_tree_path_compare(int /*long*/ a, int /*long*/ b) { + lock.lock(); + try { + return _gtk_tree_path_compare(a, b); + } finally { + lock.unlock(); + } +} public static final native void _gtk_tree_path_down(int /*long*/ path); public static final void gtk_tree_path_down(int /*long*/ path) { lock.lock(); 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 d00c1ebcd8..c935f3f4a2 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 @@ -1414,6 +1414,25 @@ void hookEvents () { return -1; } +/*public*/ int indexOf (TreeItem item) { + checkWidget(); + if (item == null) error (SWT.ERROR_NULL_ARGUMENT); + if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + int index = -1; + int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle); + int depth = OS.gtk_tree_path_get_depth (path); + if (depth == 1) { + int /*long*/ indices = OS.gtk_tree_path_get_indices (path); + if (indices != 0) { + int[] temp = new int[1]; + OS.memmove (temp, indices, 4); + index = temp[0]; + } + } + OS.gtk_tree_path_free (path); + return index; +} + boolean mnemonicHit (char key) { for (int i=0; i<columnCount; i++) { int /*long*/ labelHandle = columns [i].labelHandle; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java index 4dfcfd911f..78f4832c54 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java @@ -785,6 +785,34 @@ public String getText (int index) { return new String (Converter.mbcsToWcs (null, buffer)); } +/*public*/ int indexOf (TreeItem item) { + checkWidget(); + if (item == null) error (SWT.ERROR_NULL_ARGUMENT); + if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + int index = -1; + boolean isParent = false; + int /*long*/ currentPath = OS.gtk_tree_model_get_path (parent.modelHandle, handle); + int /*long*/ parentPath = OS.gtk_tree_model_get_path (parent.modelHandle, item.handle); + int depth = OS.gtk_tree_path_get_depth (parentPath); + if (depth > 1 && OS.gtk_tree_path_up(parentPath)) { + if (OS.gtk_tree_path_compare(currentPath, parentPath) == 0) isParent = true; + } + OS.gtk_tree_path_free (currentPath); + OS.gtk_tree_path_free (parentPath); + if (!isParent) return index; + int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, item.handle); + if (depth > 1) { + int /*long*/ indices = OS.gtk_tree_path_get_indices (path); + if (indices != 0) { + int[] temp = new int[depth]; + OS.memmove (temp, indices, 4 * temp.length); + index = temp[temp.length - 1]; + } + } + OS.gtk_tree_path_free (path); + return index; +} + void releaseChild () { super.releaseChild (); parent.destroyItem (this); |