diff options
author | Veronika Irvine <veronika> | 2005-07-20 18:48:30 +0000 |
---|---|---|
committer | Veronika Irvine <veronika> | 2005-07-20 18:48:30 +0000 |
commit | 690ff1b3ef838cb6fbfea1439ae28ab810f251de (patch) | |
tree | c1d4c27a9416a0e10bbc7c122272586c0102790e /bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java | |
parent | 3dfc8f3ec633310286d6764dac83cfe55f22b7e9 (diff) | |
download | eclipse.platform.swt-690ff1b3ef838cb6fbfea1439ae28ab810f251de.tar.gz eclipse.platform.swt-690ff1b3ef838cb6fbfea1439ae28ab810f251de.tar.xz eclipse.platform.swt-690ff1b3ef838cb6fbfea1439ae28ab810f251de.zip |
Add support for reorderable columns in Tree
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java index 834cc4af4f..43c4ca331f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeColumn.java @@ -36,7 +36,7 @@ import org.eclipse.swt.events.*; */ public class TreeColumn extends Item { Tree parent; - int id, lastWidth, iconRef; + int id, lastWidth, lastPosition, iconRef; boolean resizable; /** @@ -225,6 +225,33 @@ public Tree getParent () { } /** + * Gets the moveable attribute. A column that is + * not moveable cannot be reordered by the user + * by dragging the header but may be reordered + * by the programmer. + * + * @return the moveable attribute + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see Tree#getColumnOrder() + * @see Tree#setColumnOrder(int[]) + * @see TreeColumn#setMoveable(boolean) + * @see SWT#Move + * + * @since 3.1 + */ +public boolean getMoveable () { + checkWidget (); + int [] flags = new int [1]; + OS.GetDataBrowserPropertyFlags (parent.handle, id, flags); + return (flags [0] & OS.kDataBrowserListViewMovableColumn) != 0; +} + +/** * Gets the resizable attribute. A column that is * not resizable cannot be dragged by the user but * may be resized by the programmer. @@ -365,10 +392,16 @@ public void removeSelectionListener(SelectionListener listener) { void resized (int newWidth) { lastWidth = newWidth; sendEvent (SWT.Resize); - int index = parent.indexOf(this); - for (int j = index + 1; j < parent.columnCount; j++) { - TreeColumn column = parent.columns [j]; - column.sendEvent (SWT.Move); + if (isDisposed ()) return; + boolean moved = false; + int [] order = parent.getColumnOrder (); + TreeColumn [] columns = parent.getColumns (); + for (int i=0; i<order.length; i++) { + TreeColumn column = columns [order [i]]; + if (moved && !column.isDisposed ()) { + column.sendEvent (SWT.Move); + } + if (column == this) moved = true; } } @@ -413,6 +446,39 @@ public void setImage (Image image) { } /** + * Sets the moveable attribute. A column that is + * moveable can be reordered by the user by dragging + * the header. A column that is not moveable cannot be + * dragged by the user but may be reordered + * by the programmer. + * + * @param moveable the moveable attribute + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see Tree#setColumnOrder(int[]) + * @see Tree#getColumnOrder() + * @see TreeColumn#getMoveable() + * @see SWT#Move + * + * @since 3.1 + */ +public void setMoveable (boolean moveable) { + checkWidget (); + int [] flags = new int [1]; + OS.GetDataBrowserPropertyFlags (parent.handle, id, flags); + if (moveable) { + flags [0] |= OS.kDataBrowserListViewMovableColumn; + } else { + flags [0] &= ~OS.kDataBrowserListViewMovableColumn; + } + OS.SetDataBrowserPropertyFlags (parent.handle, id, flags [0]); +} + +/** * Sets the resizable attribute. A column that is * not resizable cannot be dragged by the user but * may be resized by the programmer. |