diff options
author | Grant Gayed <ggayed> | 2006-03-20 21:45:42 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2006-03-20 21:45:42 +0000 |
commit | 0b4695242b97e383735d212b1017881e4894ee6e (patch) | |
tree | 9e1a3151282b46cc6d3b89d0d9d7e5f174af5ec3 | |
parent | 472c9b739603521426ce11305bdae1f051c8454a (diff) | |
download | eclipse.platform.swt-0b4695242b97e383735d212b1017881e4894ee6e.tar.gz eclipse.platform.swt-0b4695242b97e383735d212b1017881e4894ee6e.tar.xz eclipse.platform.swt-0b4695242b97e383735d212b1017881e4894ee6e.zip |
add TreeItem.getBounds()
3 files changed, 27 insertions, 16 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java index 14acfec6bb..8724f11eaa 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Table.java @@ -257,7 +257,7 @@ static int checkStyle (int style) { public void clear (int index) { checkWidget (); if (!(0 <= index && index < itemsCount)) error (SWT.ERROR_INVALID_RANGE); - Rectangle bounds = items [index].getBounds (); + Rectangle bounds = items [index].getBounds (false); int oldRightX = bounds.x + bounds.width; items [index].clear (); if (columns.length == 0) updateHorizontalBar (0, -oldRightX); @@ -380,7 +380,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) { } else { if (columns.length == 0) { for (int i = 0; i < itemsCount; i++) { - Rectangle itemBounds = items [i].getBounds (); + Rectangle itemBounds = items [i].getBounds (false); width = Math.max (width, itemBounds.x + itemBounds.width); } } else { @@ -458,7 +458,7 @@ void createItem (TableItem item) { /* update scrollbars */ updateVerticalBar (); - Rectangle bounds = item.getBounds (); + Rectangle bounds = item.getBounds (false); int rightX = bounds.x + bounds.width; updateHorizontalBar (rightX, rightX); /* @@ -662,7 +662,7 @@ void destroyItem (TableItem item) { if (item == focusItem) reassignFocus (); int index = item.index; - Rectangle bounds = item.getBounds (); + Rectangle bounds = item.getBounds (false); int rightX = bounds.x + bounds.width; if (index != itemsCount - 1) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java index d7f464cacc..9af315c37c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TableItem.java @@ -419,10 +419,22 @@ public Color getBackground (int columnIndex) { if (cellBackgrounds == null || cellBackgrounds [columnIndex] == null) return getBackground (); return cellBackgrounds [columnIndex]; } -/*public*/ Rectangle getBounds () { +public Rectangle getBounds () { checkWidget (); - int textPaintWidth = textWidths [0] + 2 * MARGIN_TEXT; - return new Rectangle (getTextX (0), parent.getItemY (this), textPaintWidth, parent.itemHeight - 1); + return getBounds (true); +} +Rectangle getBounds (boolean checkData) { + if (checkData && !parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); + int x = getTextX (0); + int width = textWidths [0] + 2 * MARGIN_TEXT; + if (parent.columns.length > 0) { + TableColumn column = parent.columns [0]; + int right = column.getX () + column.width; + if (x + width > right) { + width = Math.max (0, right - x); + } + } + return new Rectangle (x, parent.getItemY (this), width, parent.itemHeight - 1); } /** * Returns a rectangle describing the receiver's size and location @@ -1464,7 +1476,7 @@ public void setFont (Font value) { if (font == value) return; if (value != null && value.equals (font)) return; - Rectangle bounds = getBounds (); + Rectangle bounds = getBounds (false); int oldRightX = bounds.x + bounds.width; font = value; if ((parent.style & SWT.VIRTUAL) != 0) cached = true; @@ -1479,7 +1491,7 @@ public void setFont (Font value) { /* horizontal bar could be affected if table has no columns */ if (parent.columns.length == 0) { - bounds = getBounds (); + bounds = getBounds (false); int newRightX = bounds.x + bounds.width; parent.updateHorizontalBar (newRightX, newRightX - oldRightX); } @@ -1813,7 +1825,7 @@ public void setText (int columnIndex, String value) { gc.dispose (); if (parent.columns.length == 0) { - Rectangle bounds = getBounds (); + Rectangle bounds = getBounds (false); int rightX = bounds.x + bounds.width; parent.updateHorizontalBar (rightX, textWidths [columnIndex] - oldWidth); } @@ -1828,12 +1840,12 @@ public void setText (int columnIndex, String value) { } public void setText (String value) { checkWidget (); - Rectangle bounds = getBounds (); + Rectangle bounds = getBounds (false); int oldRightX = bounds.x + bounds.width; setText (0, value); /* horizontal bar could be affected if table has no columns */ if (parent.columns.length == 0) { - bounds = getBounds (); + bounds = getBounds (false); int newRightX = bounds.x + bounds.width; parent.updateHorizontalBar (newRightX, newRightX - oldRightX); } @@ -1854,7 +1866,7 @@ public void setText (String value) { public void setText (String[] value) { checkWidget (); if (value == null) error (SWT.ERROR_NULL_ARGUMENT); - Rectangle bounds = getBounds (); + Rectangle bounds = getBounds (false); int oldRightX = bounds.x + bounds.width; // TODO make a smarter implementation of this for (int i = 0; i < value.length; i++) { @@ -1862,7 +1874,7 @@ public void setText (String[] value) { } /* horizontal bar could be affected if table has no columns */ if (parent.columns.length == 0) { - bounds = getBounds (); + bounds = getBounds (false); int newRightX = bounds.x + bounds.width; parent.updateHorizontalBar (newRightX, newRightX - oldRightX); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java index 4343629b2c..2eb5870a91 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/TreeItem.java @@ -802,8 +802,7 @@ Rectangle getBounds (boolean checkData) { TreeColumn[] orderedColumns = parent.getOrderedColumns (); int orderedCol0Index = orderedColumns.length == 0 ? 0 : orderedColumns [0].getIndex (); int x = getTextX (orderedCol0Index); - int textPaintWidth = textWidths [orderedCol0Index] + 2 * MARGIN_TEXT; - int width = textPaintWidth; + int width = textWidths [orderedCol0Index] + 2 * MARGIN_TEXT; if (orderedColumns.length > 0) { TreeColumn column = orderedColumns [0]; int right = column.getX () + column.width; |