Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover2003-01-21 22:08:04 +0000
committerSteve Northover2003-01-21 22:08:04 +0000
commite194e982b0c0420468f28e572aaa3c621dddd9d5 (patch)
treedd60c05f2ba7316a5c662d278636132450bc36fc /bundles/org.eclipse.swt/Eclipse SWT/gtk
parent0b4558318e4eed379cb09413e1022c4c42bcfd30 (diff)
downloadeclipse.platform.swt-e194e982b0c0420468f28e572aaa3c621dddd9d5.tar.gz
eclipse.platform.swt-e194e982b0c0420468f28e572aaa3c621dddd9d5.tar.xz
eclipse.platform.swt-e194e982b0c0420468f28e572aaa3c621dddd9d5.zip
24333
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java47
1 files changed, 32 insertions, 15 deletions
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 70844238dc..610669c2ef 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
@@ -517,6 +517,18 @@ public int getSelectionCount () {
return display.treeSelectionLength;
}
+public TreeItem getTopItem () {
+ checkWidget ();
+ int [] path = new int [1];
+ if (!OS.gtk_tree_view_get_path_at_pos (handle, 1, 1, path, null, null, null)) return null;
+ int iter = OS.g_malloc (OS.GtkTreeIter_sizeof());
+ OS.gtk_tree_model_get_iter (modelHandle, iter, path [0]);
+ int [] index = new int [1];
+ OS.gtk_tree_model_get (modelHandle, iter, 4, index, -1);
+ OS.g_free (iter);
+ OS.gtk_tree_path_free (path [0]);
+ return items [index [0]];
+}
int gtk_changed (int widget) {
TreeItem item = getFocusItem ();
if (item != null) {
@@ -645,12 +657,6 @@ void hookEvents () {
}
}
-boolean isItemVisible (int path) {
- GdkRectangle rect = new GdkRectangle ();
- OS.gtk_tree_view_get_cell_area (handle, path, 0, rect);
- return !(rect.y == 0 && rect.height == 0);
-}
-
int paintWindow () {
OS.gtk_widget_realize (handle);
return OS.gtk_tree_view_get_bin_window (handle);
@@ -841,20 +847,27 @@ public void setSelection (TreeItem [] items) {
if (item.isDisposed ()) break;
if (first) {
int path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
- showItem (path);
+ showItem (path, true);
OS.gtk_tree_view_set_cursor (handle, path, 0, false);
OS.gtk_tree_path_free (path);
first = false;
}
OS.gtk_tree_selection_select_iter (selection, item.handle);
- if ((style & SWT.SINGLE) != 0) {
- OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- return;
- }
+ if ((style & SWT.SINGLE) != 0) break;
}
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
}
+public void setTopItem (TreeItem item) {
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+ int path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+ showItem (path, false);
+ int depth = OS.gtk_tree_path_get_depth (path);
+ OS.gtk_tree_view_scroll_to_cell (handle, path, 0, depth != 1, 0.0f, 0.5f);
+ OS.gtk_tree_path_free (path);
+}
+
/**
* Shows the selection. If the selection is already showing in the receiver,
* this method simply returns. Otherwise, the items are scrolled until
@@ -876,8 +889,10 @@ public void showSelection () {
if (items.length != 0 && items [0] != null) showItem (items [0]);
}
-void showItem (int path) {
- if (isItemVisible (path)) return;
+void showItem (int path, boolean scroll) {
+ GdkRectangle rect = new GdkRectangle ();
+ OS.gtk_tree_view_get_cell_area (handle, path, 0, rect);
+ if (rect.y != 0 || rect.height != 0) return;
int depth = OS.gtk_tree_path_get_depth (path);
if (depth > 1) {
int [] indices = new int [depth - 1];
@@ -890,7 +905,9 @@ void showItem (int path) {
}
OS.gtk_tree_path_free (tempPath);
}
- OS.gtk_tree_view_scroll_to_cell (handle, path, 0, depth != 1, 0.5f, 0.5f);
+ if (scroll) {
+ OS.gtk_tree_view_scroll_to_cell (handle, path, 0, depth != 1, 0.5f, 0.5f);
+ }
}
/**
@@ -916,7 +933,7 @@ public void showItem (TreeItem item) {
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
int path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
- showItem (path);
+ showItem (path, true);
OS.gtk_tree_path_free (path);
}

Back to the top