summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java1435
1 files changed, 0 insertions, 1435 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
deleted file mode 100644
index 2027e55e11..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java
+++ /dev/null
@@ -1,1435 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * 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
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.carbon.DataBrowserCallbacks;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class represent a selectable user interface object
- * that represents a hierarchy of tree items in a tree widget.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#tree">Tree, TreeItem, TreeColumn snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class TreeItem extends Item {
- Tree parent;
- TreeItem parentItem;
- String [] strings;
- Image [] images;
- boolean checked, grayed, cached;
- Color foreground, background;
- Color[] cellForeground, cellBackground;
- Font font;
- Font[] cellFont;
- int id, width = -1;
- int itemCount = 0;
- int [] childIds;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TreeItem (Tree parent, int style) {
- this (checkNull (parent), null, style, -1, true);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the zero-relative index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TreeItem (Tree parent, int style, int index) {
- this (checkNull (parent), null, style, checkIndex (index), true);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TreeItem (TreeItem parentItem, int style) {
- this (checkNull (parentItem).parent, parentItem, style, -1, true);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the zero-relative index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TreeItem (TreeItem parentItem, int style, int index) {
- this (checkNull (parentItem).parent, parentItem, style, checkIndex (index), true);
-}
-
-TreeItem (Tree parent, TreeItem parentItem, int style, int index, boolean create) {
- super (parent, style);
- this.parent = parent;
- this.parentItem = parentItem;
- if (create) parent.createItem (this, parentItem, index);
-}
-
-boolean _getExpanded () {
- int [] state = new int [1];
- OS.GetDataBrowserItemState (parent.handle, id, state);
- return (state [0] & OS.kDataBrowserContainerIsOpen) != 0;
-}
-
-static TreeItem checkNull (TreeItem item) {
- if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return item;
-}
-
-static Tree checkNull (Tree parent) {
- if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return parent;
-}
-
-static int checkIndex (int index) {
- if (index < 0) SWT.error (SWT.ERROR_INVALID_RANGE);
- return index;
-}
-
-int calculateWidth (int index, GC gc) {
- if (index == 0 && width != -1) return width;
- int width = 0;
- Image image = index == 0 ? this.image : (images == null ? null : images [index]);
- String text = index == 0 ? this.text : (strings == null ? "" : strings [index]);
- Font font = null;
- if (cellFont != null) font = cellFont[index];
- if (font == null) font = this.font;
- if (font == null) font = parent.getFont();
- gc.setFont (font);
- if (image != null) width += image.getBounds ().width + parent.getGap ();
- if (text != null && text.length () > 0) width += gc.stringExtent (text).x;
- boolean sendMeasure = true;
- if ((parent.style & SWT.VIRTUAL) != 0) {
- sendMeasure = cached;
- }
- if (sendMeasure && parent.hooks (SWT.MeasureItem)) {
- Event event = new Event ();
- event.item = this;
- event.index = index;
- event.gc = gc;
- short [] height = new short [1];
- OS.GetDataBrowserTableViewRowHeight (parent.handle, height);
- event.width = width;
- event.height = height [0];
- parent.sendEvent (SWT.MeasureItem, event);
- if (height [0] < event.height) {
- OS.SetDataBrowserTableViewRowHeight (parent.handle, (short) event.height);
- redrawWidget (parent.handle, false);
- }
- width = event.width;
- }
- if (index == 0) this.width = width;
- return width;
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-void clear () {
- cached = false;
- text = "";
- image = null;
- strings = null;
- images = null;
- checked = grayed = false;
- foreground = background = null;
- cellForeground = cellBackground = null;
- font = null;
- cellFont = null;
-}
-
-/**
- * Clears the item at the given zero-relative index in the receiver.
- * The text, icon and other attributes of the item are set to the default
- * value. If the tree was created with the <code>SWT.VIRTUAL</code> style,
- * these attributes are requested again as needed.
- *
- * @param index the index of the item to clear
- * @param all <code>true</code> if all child items of the indexed item should be
- * cleared recursively, and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @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 SWT#VIRTUAL
- * @see SWT#SetData
- *
- * @since 3.2
- */
-public void clear (int index, boolean all) {
- checkWidget ();
- int count = parent.getItemCount (this);
- if (index < 0 || index >= count) SWT.error (SWT.ERROR_INVALID_RANGE);
- parent.clear (this, index, all);
-}
-
-
-/**
- * Clears all the items in the receiver. The text, icon and other
- * attributes of the items are set to their default values. If the
- * tree was created with the <code>SWT.VIRTUAL</code> style, these
- * attributes are requested again as needed.
- *
- * @param all <code>true</code> if all child items should be cleared
- * recursively, and <code>false</code> otherwise
- *
- * @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 SWT#VIRTUAL
- * @see SWT#SetData
- *
- * @since 3.2
- */
-public void clearAll (boolean all) {
- checkWidget ();
- parent.clearAll (this, all);
-}
-
-void destroyWidget () {
- //TEMPORARY CODE
-// parent.releaseItem (this, false);
- parent.destroyItem (this);
- releaseHandle ();
-}
-
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @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 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return background != null ? background : parent.getBackground ();
-}
-
-/**
- * Returns the background color at the given column index in the receiver.
- *
- * @param index the column index
- * @return the background color
- *
- * @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 Color getBackground (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- int count = Math.max (1, parent.columnCount);
- if (0 > index || index > count -1) return getBackground ();
- if (cellBackground == null || cellBackground [index] == null) return getBackground ();
- return cellBackground [index];
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @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>
- */
-public Rectangle getBounds () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- Rect rect = new Rect();
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [0].id;
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- int x = rect.left, y = rect.top;
- int width = 0;
- if (image != null) {
- Rectangle bounds = image.getBounds ();
- x += bounds.width + parent.getGap ();
- }
- GC gc = new GC (parent);
- Point extent = gc.stringExtent (text);
- gc.dispose ();
- width += extent.x;
- if (parent.columnCount > 0) {
- width = Math.min (width, rect.right - x);
- }
- int height = rect.bottom - rect.top;
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent at a column in the tree.
- *
- * @param index the index that specifies the column
- * @return the receiver's bounding column rectangle
- *
- * @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 Rectangle getBounds (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
- Rect rect = new Rect();
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- int[] disclosure = new int [1];
- OS.GetDataBrowserListViewDisclosureColumn (parent.handle, disclosure, new boolean [1]);
- int x, y, width, height;
- if (OS.VERSION >= 0x1040 && disclosure [0] != columnId) {
- if (parent.getLinesVisible ()) {
- rect.left += Tree.GRID_WIDTH;
- rect.top += Tree.GRID_WIDTH;
- }
- x = rect.left;
- y = rect.top;
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
- } else {
- Rect rect2 = new Rect();
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect2) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- x = rect2.left;
- y = rect2.top;
- width = rect.right - rect2.left + 1;
- height = rect2.bottom - rect2.top + 1;
- }
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Returns <code>true</code> if the receiver is checked,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- * <p>
- *
- * @return the checked state
- *
- * @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>
- */
-public boolean getChecked () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((parent.style & SWT.CHECK) == 0) return false;
- return checked;
-}
-
-/**
- * Returns <code>true</code> if the receiver is expanded,
- * and false otherwise.
- * <p>
- *
- * @return the expanded state
- *
- * @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>
- */
-public boolean getExpanded () {
- checkWidget ();
- return (state & EXPANDING) != 0 ? false : _getExpanded ();
-}
-
-/**
- * Returns the font that the receiver will use to paint textual information for this item.
- *
- * @return the receiver's font
- *
- * @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.0
- */
-public Font getFont () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return font != null ? font : parent.getFont ();
-}
-
-/**
- * Returns the font that the receiver will use to paint textual information
- * for the specified cell in this item.
- *
- * @param index the column index
- * @return the receiver's font
- *
- * @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 Font getFont (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- int count = Math.max (1, parent.columnCount);
- if (0 > index || index > count -1) return getFont ();
- if (cellFont == null || cellFont [index] == null) return getFont ();
- return cellFont [index];
-}
-
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @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 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return foreground != null ? foreground : parent.getForeground ();
-}
-
-/**
- *
- * Returns the foreground color at the given column index in the receiver.
- *
- * @param index the column index
- * @return the foreground color
- *
- * @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 Color getForeground (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- int count = Math.max (1, parent.columnCount);
- if (0 > index || index > count -1) return getForeground ();
- if (cellForeground == null || cellForeground [index] == null) return getForeground ();
- return cellForeground [index];
-}
-
-/**
- * Returns <code>true</code> if the receiver is grayed,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- * <p>
- *
- * @return the grayed state of the checkbox
- *
- * @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>
- */
-public boolean getGrayed () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((parent.style & SWT.CHECK) == 0) return false;
- return grayed;
-}
-
-public Image getImage () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return super.getImage ();
-}
-
-/**
- * Returns the image stored at the given column index in the receiver,
- * or null if the image has not been set or if the column does not exist.
- *
- * @param index the column index
- * @return the image stored at the given column index in the receiver
- *
- * @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 Image getImage (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if (index == 0) return getImage ();
- if (images != null) {
- if (0 <= index && index < images.length) return images [index];
- }
- return null;
-}
-
-/**
- * Returns a rectangle describing the size and location
- * relative to its parent of an image at a column in the
- * tree.
- *
- * @param index the index that specifies the column
- * @return the receiver's bounding image rectangle
- *
- * @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 Rectangle getImageBounds (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
- Rect rect = new Rect();
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- int x = rect.left, y = rect.top;
- int width = 0;
- if (index == 0 && image != null) {
- Rectangle bounds = image.getBounds ();
- width += bounds.width;
- }
- if (index != 0 && images != null && images[index] != null) {
- Rectangle bounds = images [index].getBounds ();
- width += bounds.width;
- }
- int height = rect.bottom - rect.top + 1;
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @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 TreeItem getItem (int index) {
- checkWidget ();
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if (index >= itemCount) error (SWT.ERROR_INVALID_RANGE);
- return parent._getItem (this, index);
-}
-
-/**
- * Returns the number of items contained in the receiver
- * that are direct item children of the receiver.
- *
- * @return the number of items
- *
- * @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>
- */
-public int getItemCount () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getItemCount (this);
-}
-
-/**
- * Returns a (possibly empty) array of <code>TreeItem</code>s which
- * are the direct item children of the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the receiver's items
- *
- * @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>
- */
-public TreeItem [] getItems () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getItems (this);
-}
-
-String getNameText () {
- if ((parent.style & SWT.VIRTUAL) != 0) {
- if (!cached) return "*virtual*"; //$NON-NLS-1$
- }
- return super.getNameText ();
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Tree</code>.
- *
- * @return the receiver's parent
- *
- * @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>
- */
-public Tree getParent () {
- checkWidget ();
- return parent;
-}
-
-/**
- * Returns the receiver's parent item, which must be a
- * <code>TreeItem</code> or null when the receiver is a
- * root.
- *
- * @return the receiver's parent item
- *
- * @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>
- */
-public TreeItem getParentItem () {
- checkWidget ();
- return parentItem;
-}
-
-public String getText () {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- return super.getText ();
-}
-
-/**
- * Returns the text stored at the given column index in the receiver,
- * or empty string if the text has not been set.
- *
- * @param index the column index
- * @return the text stored at the given column index in the receiver
- *
- * @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 String getText (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if (index == 0) return getText ();
- if (strings != null) {
- if (0 <= index && index < strings.length) {
- String string = strings [index];
- return string != null ? string : "";
- }
- }
- return "";
-}
-
-/**
- * Returns a rectangle describing the size and location
- * relative to its parent of the text at a column in the
- * tree.
- *
- * @param index the index that specifies the column
- * @return the receiver's bounding text rectangle
- *
- * @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.3
- */
-public Rectangle getTextBounds (int index) {
- checkWidget ();
- if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
- if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
- Rect rect = new Rect();
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- int[] disclosure = new int [1];
- OS.GetDataBrowserListViewDisclosureColumn (parent.handle, disclosure, new boolean [1]);
- int imageWidth = 0;
- int margin = index == 0 ? 0 : parent.getInsetWidth (columnId, false) / 2;
- Image image = getImage (index);
- if (image != null) {
- Rectangle bounds = image.getBounds ();
- imageWidth = bounds.width + parent.getGap ();
- }
- int x, y, width, height;
- if (OS.VERSION >= 0x1040 && disclosure [0] != columnId) {
- if (parent.getLinesVisible ()) {
- rect.left += Tree.GRID_WIDTH;
- rect.top += Tree.GRID_WIDTH;
- }
- x = rect.left + imageWidth + margin;
- y = rect.top;
- width = Math.max (0, rect.right - rect.left - imageWidth - margin * 2);;
- height = rect.bottom - rect.top;
- } else {
- Rect rect2 = new Rect();
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect2) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- x = rect2.left + imageWidth + margin;
- y = rect2.top;
- width = Math.max (0, rect.right - rect2.left + 1 - imageWidth - margin * 2);
- height = rect2.bottom - rect2.top + 1;
- }
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param item the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
- * </ul>
- * @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 int indexOf (TreeItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (item.parentItem != this) return -1;
- return parent._indexOf (this, item);
-}
-
-void redraw (int propertyID) {
- if (parent.ignoreRedraw) return;
- if (!getDrawing () && propertyID != Tree.CHECK_COLUMN_ID) return;
- int parentHandle = parent.handle;
- int parentID = parentItem == null ? OS.kDataBrowserNoItem : parentItem.id;
- /*
- * Feature in Carbon. Calling UpdateDataBrowserItems with kDataBrowserNoItem
- * updates all columns associated with the items in the items array. This is
- * much slower than updating the items array for a specific column. The fix
- * is to give the specific column ids instead.
- */
- DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
- OS.GetDataBrowserCallbacks (parent.handle, callbacks);
- callbacks.v1_itemCompareCallback = 0;
- OS.SetDataBrowserCallbacks (parent.handle, callbacks);
- int [] ids = new int [] {id};
- if (propertyID == OS.kDataBrowserNoItem) {
- if ((parent.style & SWT.CHECK) != 0) {
- OS.UpdateDataBrowserItems (parentHandle, parentID, ids.length, ids, OS.kDataBrowserItemNoProperty, Tree.CHECK_COLUMN_ID);
- }
- if (parent.columnCount == 0) {
- OS.UpdateDataBrowserItems (parentHandle, parentID, ids.length, ids, OS.kDataBrowserItemNoProperty, parent.column_id);
- } else {
- for (int i=0; i<parent.columnCount; i++) {
- OS.UpdateDataBrowserItems (parentHandle, parentID, ids.length, ids, OS.kDataBrowserItemNoProperty, parent.columns[i].id);
- }
- }
- } else {
- OS.UpdateDataBrowserItems (parentHandle, parentID, ids.length, ids, OS.kDataBrowserItemNoProperty, propertyID);
- }
- callbacks.v1_itemCompareCallback = display.itemCompareProc;
- OS.SetDataBrowserCallbacks (parent.handle, callbacks);
- /*
- * Bug in the Macintosh. When the height of the row is smaller than the
- * check box, the tail of the check mark draws outside of the item part
- * bounds. This means it will not be redrawn when the item is unckeched.
- * The fix is to redraw the area.
- */
- if (propertyID == Tree.CHECK_COLUMN_ID) {
- Rect rect = new Rect();
- if (OS.GetDataBrowserItemPartBounds (parentHandle, id, propertyID, OS.kDataBrowserPropertyEnclosingPart, rect) == OS.noErr) {
- int x = rect.left;
- int y = rect.top - 1;
- int width = rect.right - rect.left;
- int height = 1;
- redrawWidget (parentHandle, x, y, width, height, false);
- }
- }
-}
-
-void releaseChildren (boolean destroy) {
- if (destroy) {
- parent.releaseItems (childIds);
- }
- super.releaseChildren (destroy);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- parentItem = null;
- id = 0;
- parent = null;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- strings = null;
- images = null;
- background = foreground = null;
- font = null;
- cellBackground = cellForeground = null;
- cellFont = null;
-}
-
-/**
- * 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 ();
- for (int i=itemCount - 1; i >= 0; i--) {
- TreeItem item = parent._getItem (childIds [i], false);
- if (item != null && !item.isDisposed ()) {
- item.dispose ();
- }
- }
-}
-
-/**
- * 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.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- Color oldColor = background;
- if (oldColor == color) return;
- background = color;
- if (oldColor != null && oldColor.equals (color)) return;
- cached = true;
- redraw (OS.kDataBrowserNoItem);
-}
-
-/**
- * Sets the background color at the given column index in the receiver
- * to the color specified by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param index the column index
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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 setBackground (int index, Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int count = Math.max (1, parent.columnCount);
- if (0 > index || index > count - 1) return;
- if (cellBackground == null) {
- if (color == null) return;
- cellBackground = new Color [count];
- }
- Color oldColor = cellBackground [index];
- if (oldColor == color) return;
- cellBackground [index] = color;
- if (oldColor != null && oldColor.equals (color)) return;
- cached = true;
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- redraw (columnId);
-}
-
-/**
- * Sets the checked state of the receiver.
- * <p>
- *
- * @param checked the new checked state
- *
- * @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>
- */
-public void setChecked (boolean checked) {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return;
- if (this.checked == checked) return;
- setChecked (checked, false);
-}
-
-void setChecked (boolean checked, boolean notify) {
- this.checked = checked;
- cached = true;
- redraw (Tree.CHECK_COLUMN_ID);
- if (notify) {
- Event event = new Event ();
- event.item = this;
- event.detail = SWT.CHECK;
- parent.postEvent (SWT.Selection, event);
- }
-}
-
-/**
- * Sets the expanded state of the receiver.
- * <p>
- *
- * @param expanded the new expanded state
- *
- * @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>
- */
-public void setExpanded (boolean expanded) {
- checkWidget ();
- if (expanded == getExpanded ()) return;
- parent.ignoreExpand = true;
- if (expanded) {
- OS.OpenDataBrowserContainer (parent.handle, id);
- } else {
- OS.CloseDataBrowserContainer (parent.handle, id);
- }
- parent.ignoreExpand = false;
- cached = true;
- if (expanded) {
- parent.setScrollWidth (false, childIds, false);
- } else {
- parent.setScrollWidth (true);
- parent.fixScrollBar ();
- }
-}
-
-/**
- * Sets the font that the receiver will use to paint textual information
- * for this item to the font specified by the argument, or to the default font
- * for that kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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.0
- */
-public void setFont (Font font) {
- checkWidget ();
- if (font != null && font.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- Font oldFont = this.font;
- if (oldFont == font) return;
- this.font = font;
- if (oldFont != null && oldFont.equals (font)) return;
- cached = true;
- redraw (OS.kDataBrowserNoItem);
-}
-
-/**
- * Sets the font that the receiver will use to paint textual information
- * for the specified cell in this item to the font specified by the
- * argument, or to the default font for that kind of control if the
- * argument is null.
- *
- * @param index the column index
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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 setFont (int index, Font font) {
- checkWidget ();
- if (font != null && font.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int count = Math.max (1, parent.columnCount);
- if (0 > index || index > count - 1) return;
- if (cellFont == null) {
- if (font == null) return;
- cellFont = new Font [count];
- }
- Font oldFont = cellFont [index];
- if (oldFont == font) return;
- cellFont [index] = font;
- if (oldFont != null && oldFont.equals (font)) return;
- cached = true;
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- redraw (columnId);
-}
-
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @since 2.0
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- Color oldColor = this.foreground;
- if (oldColor == color) return;
- foreground = color;
- if (oldColor != null && oldColor.equals (color)) return;
- cached = true;
- redraw (OS.kDataBrowserNoItem);
-}
-
-/**
- * Sets the foreground color at the given column index in the receiver
- * to the color specified by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param index the column index
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @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 setForeground (int index, Color color){
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- int count = Math.max (1, parent.columnCount);
- if (0 > index || index > count - 1) return;
- if (cellForeground == null) {
- if (color == null) return;
- cellForeground = new Color [count];
- }
- Color oldColor = cellForeground [index];
- if (oldColor == color) return;
- cellForeground [index] = color;
- if (oldColor != null && oldColor.equals (color)) return;
- cached = true;
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- redraw (columnId);
-}
-
-/**
- * Sets the grayed state of the checkbox for this item. This state change
- * only applies if the Tree was created with the SWT.CHECK style.
- *
- * @param grayed the new grayed state of the checkbox
- *
- * @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>
- */
-public void setGrayed (boolean grayed) {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return;
- if (this.grayed == grayed) return;
- this.grayed = grayed;
- cached = true;
- redraw (Tree.CHECK_COLUMN_ID);
-}
-
-/**
- * Sets the image for multiple columns in the tree.
- *
- * @param images the array of new images
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
- * </ul>
- * @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 setImage (Image [] images) {
- checkWidget ();
- if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<images.length; i++) {
- setImage (i, images [i]);
- }
-}
-
-/**
- * Sets the receiver's image at a column.
- *
- * @param index the column index
- * @param image the new image
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @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 setImage (int index, Image image) {
- checkWidget ();
- if (image != null && image.isDisposed ()) {
- error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (parent.imageBounds == null && image != null) {
- parent.setItemHeight (image);
- }
- if (index == 0) {
- if (image != null && image.type == SWT.ICON) {
- if (image.equals (this.image)) return;
- }
- width = -1;
- super.setImage (image);
- }
- int count = Math.max (1, parent.columnCount);
- if (0 <= index && index < count) {
- if (images == null) images = new Image [count];
- if (image != null && image.type == SWT.ICON) {
- if (image.equals (images [index])) return;
- }
- images [index] = image;
- }
- cached = true;
- if (index == 0) parent.setScrollWidth (this);
- if (0 <= index && index < count) {
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- redraw (columnId);
- }
-}
-
-public void setImage (Image image) {
- checkWidget ();
- setImage (0, image);
-}
-
-/**
- * Sets the number of child items contained in the receiver.
- *
- * @param count the number of items
- *
- * @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.2
- */
-public void setItemCount (int count) {
- checkWidget ();
- count = Math.max (0, count);
- parent.setItemCount (this, count);
-}
-
-/**
- * Sets the text for multiple columns in the tree.
- *
- * @param strings the array of new strings
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @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 setText (String [] strings) {
- checkWidget ();
- if (strings == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<strings.length; i++) {
- String string = strings [i];
- if (string != null) setText (i, string);
- }
-}
-
-/**
- * Sets the receiver's text at a column
- *
- * @param index the column index
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @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 setText (int index, String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (index == 0) {
- if (string.equals (text)) return;
- width = -1;
- super.setText (string);
- }
- int count = Math.max (1, parent.columnCount);
- if (0 <= index && index < count) {
- if (strings == null) strings = new String [count];
- if (string.equals (strings [index])) return;
- strings [index] = string;
- }
- cached = true;
- if (index == 0) parent.setScrollWidth (this);
- if (0 <= index && index < count) {
- int columnId = parent.columnCount == 0 ? parent.column_id : parent.columns [index].id;
- redraw (columnId);
- }
-}
-
-public void setText (String string) {
- checkWidget ();
- setText (0, string);
-}
-
-}