diff options
author | Veronika Irvine <veronika> | 2005-03-28 21:22:30 +0000 |
---|---|---|
committer | Veronika Irvine <veronika> | 2005-03-28 21:22:30 +0000 |
commit | 186c1b053d2f9373b4a2ad00579fa998f8be311d (patch) | |
tree | 4c9e7d53cfe2d88c177696c730235c783e6b5341 | |
parent | efe582148d050444aa11106f233053bff26fc630 (diff) | |
download | eclipse.platform.swt-186c1b053d2f9373b4a2ad00579fa998f8be311d.tar.gz eclipse.platform.swt-186c1b053d2f9373b4a2ad00579fa998f8be311d.tar.xz eclipse.platform.swt-186c1b053d2f9373b4a2ad00579fa998f8be311d.zip |
add removeAll for TreeItem
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java | 14 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java | 31 |
2 files changed, 45 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java index 3545a2999f..2a5308f518 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java @@ -707,6 +707,20 @@ void releaseWidget () { cellFont = null; } +public void removeAll () { + checkWidget (); + TreeItem [] items = parent.items; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == this) { + TreeItem item = items [i]; + item.releaseChild (); + item.releaseWidget (); + item.destroyWidget (); + } + } + redraw (OS.kDataBrowserNoItem); +} + /** * Sets the receiver's background color to the color specified * by the argument, or to the default system color for the item diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java index ae613b8789..98ab619688 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java @@ -782,6 +782,37 @@ void releaseWidget () { } /** + * Removes all of the items from the receiver. + * <p> + * @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> + * + * @since 3.1 + */ +public void removeAll () { + checkWidget (); + int hwnd = parent.handle; + int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle); + if (hItem == 0) return; + + TVITEM tvItem = new TVITEM (); + tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM; + tvItem.hItem = hItem; + while (tvItem.hItem != 0) { + OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem); + TreeItem item = parent.items [tvItem.lParam]; + tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, tvItem.hItem); + if (item != null) { + item.releaseChild (); + item.releaseWidget (); + item.destroyWidget (); + } + } +} + +/** * Sets the receiver's background color to the color specified * by the argument, or to the default system color for the item * if the argument is null. |