Method from org.eclipse.swt.widgets.TableItem Detail: |
static Table checkNull(Table control) {
if (control == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
return control;
}
|
protected void checkSubclass() {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
|
void clear() {
text = "";
image = null;
strings = null;
images = null;
imageIndent = 0;
checked = grayed = false;
font = null;
background = foreground = -1;
cellFont = null;
cellBackground = cellForeground = null;
if ((parent.style & SWT.VIRTUAL) != 0) cached = false;
}
|
void destroyWidget() {
parent.destroyItem (this);
releaseHandle ();
}
|
int fontHandle(int index) {
if (cellFont != null && cellFont [index] != null) return cellFont [index].handle;
if (font != null) return font.handle;
return -1;
}
|
public Color getBackground() {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if (background == -1) return parent.getBackground ();
return Color.win32_new (display, background);
}
Returns the receiver's background color. |
public Color getBackground(int index) {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return getBackground ();
int pixel = cellBackground != null ? cellBackground [index] : -1;
return pixel == -1 ? getBackground () : Color.win32_new (display, pixel);
}
Returns the background color at the given column index in the receiver. |
public Rectangle getBounds() {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
RECT rect = getBounds (itemIndex, 0, true, false, false);
int width = rect.right - rect.left, height = rect.bottom - rect.top;
return new Rectangle (rect.left, rect.top, width, height);
}
Returns a rectangle describing the receiver's size and location
relative to its parent. |
public Rectangle getBounds(int index) {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
RECT rect = getBounds (itemIndex, index, true, true, true);
int width = rect.right - rect.left, height = rect.bottom - rect.top;
return new Rectangle (rect.left, rect.top, width, height);
}
Returns a rectangle describing the receiver's size and location
relative to its parent at a column in the table. |
RECT getBounds(int row,
int column,
boolean getText,
boolean getImage,
boolean fullText) {
return getBounds (row, column, getText, getImage, fullText, false, 0);
}
|
RECT getBounds(int row,
int column,
boolean getText,
boolean getImage,
boolean fullText,
boolean fullImage,
int hDC) {
if (!getText && !getImage) return new RECT ();
int columnCount = parent.getColumnCount ();
if (!(0 < = column && column < Math.max (1, columnCount))) {
return new RECT ();
}
if (parent.fixScrollWidth) parent.setScrollWidth (null, true);
RECT rect = new RECT ();
int /*long*/ hwnd = parent.handle;
int bits = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
if (column == 0 && (bits & OS.LVS_EX_FULLROWSELECT) == 0) {
if (parent.explorerTheme) {
rect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
int /*long*/ code = OS.SendMessage (hwnd, OS. LVM_GETITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
if (getText) {
int width = 0;
int /*long*/ hFont = fontHandle (column);
if (hFont == -1 && hDC == 0) {
TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);
width = (int)/*64*/OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);
} else {
TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
int /*long*/ textDC = hDC != 0 ? hDC : OS.GetDC (hwnd), oldFont = -1;
if (hDC == 0) {
if (hFont == -1) hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
oldFont = OS.SelectObject (textDC, hFont);
}
RECT textRect = new RECT ();
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
OS.DrawText (textDC, buffer, buffer.length (), textRect, flags);
width = textRect.right - textRect.left;
if (hDC == 0) {
if (oldFont != -1) OS.SelectObject (textDC, oldFont);
OS.ReleaseDC (hwnd, textDC);
}
}
if (!getImage) rect.left = rect.right;
rect.right += width + Table.INSET * 2;
}
} else {
if (getText) {
rect.left = OS.LVIR_SELECTBOUNDS;
parent.ignoreCustomDraw = true;
int /*long*/ code = OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
if (!getImage) {
RECT iconRect = new RECT ();
iconRect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
code = OS.SendMessage (hwnd, OS. LVM_GETITEMRECT, row, iconRect);
parent.ignoreCustomDraw = false;
if (code != 0) rect.left = iconRect.right;
}
} else {
rect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
int /*long*/ code = OS.SendMessage (hwnd, OS.LVM_GETITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
}
}
if (fullText || fullImage) {
RECT headerRect = new RECT ();
int /*long*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, 0, headerRect);
OS.MapWindowPoints (hwndHeader, hwnd, headerRect, 2);
if (getText && fullText) rect.right = headerRect.right;
if (getImage && fullImage) rect.left = headerRect.left;
}
} else {
/*
* Feature in Windows. LVM_GETSUBITEMRECT returns an image width
* even when the subitem does not contain an image. The fix is to
* test for this case and adjust the rectangle to represent the area
* the table is actually drawing.
*/
boolean hasImage = (column == 0 && image != null) || (images != null && images [column] != null);
rect.top = column;
if (fullText || fullImage || hDC == 0) {
/*
* Bug in Windows. Despite the fact that the documentation states
* that LVIR_BOUNDS and LVIR_LABEL are identical when used with
* LVM_GETSUBITEMRECT, LVIR_BOUNDS can return a zero height. The
* fix is to use LVIR_LABEL.
*/
rect.left = getText ? OS.LVIR_LABEL : OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
int /*long*/ code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
/*
* Feature in Windows. Calling LVM_GETSUBITEMRECT with LVIR_LABEL
* and zero for the column number gives the bounds of the first item
* without including the bounds of the icon. This is undocumented.
* When called with values greater than zero, the icon bounds are
* included and this behavior is documented. If the icon is needed
* in the bounds of the first item, the fix is to adjust the item
* bounds using the icon bounds.
*/
if (column == 0 && getText && getImage) {
RECT iconRect = new RECT ();
iconRect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, iconRect);
parent.ignoreCustomDraw = false;
if (code != 0) rect.left = iconRect.left;
}
if (hasImage) {
if (column != 0 && getText && !getImage) {
RECT iconRect = new RECT ();
iconRect.top = column;
iconRect.left = OS.LVIR_ICON;
if (OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, iconRect) != 0) {
rect.left = iconRect.right + Table.INSET / 2;
}
}
} else {
if (getImage && !getText) rect.right = rect.left;
}
if (column == 0 && fullImage) {
RECT headerRect = new RECT ();
int /*long*/ hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, 0, headerRect);
OS.MapWindowPoints (hwndHeader, hwnd, headerRect, 2);
rect.left = headerRect.left;
}
} else {
rect.left = OS.LVIR_ICON;
parent.ignoreCustomDraw = true;
int /*long*/ code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, rect);
parent.ignoreCustomDraw = false;
if (code == 0) return new RECT ();
if (!hasImage) rect.right = rect.left;
if (getText) {
String string = column == 0 ? text : strings != null ? strings [column] : null;
if (string != null) {
RECT textRect = new RECT ();
TCHAR buffer = new TCHAR (parent.getCodePage (), string, false);
int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
OS.DrawText (hDC, buffer, buffer.length (), textRect, flags);
rect.right += textRect.right - textRect.left + Table.INSET * 3 + 1;
}
}
}
}
/*
* Bug in Windows. In version 5.80 of COMCTL32.DLL, the top
* of the rectangle returned by LVM_GETSUBITEMRECT is off by
* the grid width when the grid is visible. The fix is to
* move the top of the rectangle up by the grid width.
*/
int gridWidth = parent.getLinesVisible () ? Table.GRID_WIDTH : 0;
if (OS.COMCTL32_VERSION >= OS.VERSION (5, 80)) rect.top -= gridWidth;
if (column != 0) rect.left += gridWidth;
rect.right = Math.max (rect.right, rect.left);
rect.top += gridWidth;
rect.bottom = Math.max (rect.bottom - gridWidth, rect.top);
return rect;
}
|
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 true if the receiver is checked,
and false otherwise. When the parent does not have
the CHECK style, return false. |
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 this item. |
public Font getFont(int index) {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count -1) return getFont ();
if (cellFont == null || cellFont [index] == null) return getFont ();
return cellFont [index];
}
Returns the font that the receiver will use to paint textual information
for the specified cell in this item. |
public Color getForeground() {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if (foreground == -1) return parent.getForeground ();
return Color.win32_new (display, foreground);
}
Returns the foreground color that the receiver will use to draw. |
public Color getForeground(int index) {
checkWidget ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count -1) return getForeground ();
int pixel = cellForeground != null ? cellForeground [index] : -1;
return pixel == -1 ? getForeground () : Color.win32_new (display, pixel);
}
Returns the foreground color at the given column index in the receiver. |
public boolean getGrayed() {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if ((parent.style & SWT.CHECK) == 0) return false;
return grayed;
}
Returns true if the receiver is grayed,
and false otherwise. When the parent does not have
the CHECK style, return false. |
public Image getImage() {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return super.getImage ();
}
|
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 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. |
public Rectangle getImageBounds(int index) {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
RECT rect = getBounds (itemIndex, index, false, true, false);
int width = rect.right - rect.left, height = rect.bottom - rect.top;
return new Rectangle (rect.left, rect.top, width, height);
}
Returns a rectangle describing the size and location
relative to its parent of an image at a column in the
table. An empty rectangle is returned if index exceeds
the index of the table's last column. |
public int getImageIndent() {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return imageIndent;
}
|
String getNameText() {
if ((parent.style & SWT.VIRTUAL) != 0) {
if (!cached) return "*virtual*"; //$NON-NLS-1$
}
return super.getNameText ();
}
|
public Table getParent() {
checkWidget();
return parent;
}
Returns the receiver's parent, which must be a Table . |
public String getText() {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return super.getText ();
}
|
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 the text stored at the given column index in the receiver,
or empty string if the text has not been set. |
public Rectangle getTextBounds(int index) {
checkWidget();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
RECT rect = getBounds (itemIndex, index, true, false, true);
rect.left += 2;
if (index != 0) rect.left += Table.INSET;
rect.left = Math.min (rect.left, rect.right);
rect.right = rect.right - Table.INSET;
int width = Math.max (0, rect.right - rect.left);
int height = Math.max (0, rect.bottom - rect.top);
return new Rectangle (rect.left, rect.top, width, height);
}
Returns a rectangle describing the size and location
relative to its parent of the text at a column in the
table. An empty rectangle is returned if index exceeds
the index of the table's last column. |
void redraw() {
if (parent.currentItem == this || !parent.getDrawing ()) return;
int /*long*/ hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
int index = parent.indexOf (this);
if (index == -1) return;
OS.SendMessage (hwnd, OS.LVM_REDRAWITEMS, index, index);
}
|
void redraw(int column,
boolean drawText,
boolean drawImage) {
if (parent.currentItem == this || !parent.getDrawing ()) return;
int /*long*/ hwnd = parent.handle;
if (!OS.IsWindowVisible (hwnd)) return;
int index = parent.indexOf (this);
if (index == -1) return;
RECT rect = getBounds (index, column, drawText, drawImage, true);
OS.InvalidateRect (hwnd, rect, true);
}
|
void releaseHandle() {
super.releaseHandle ();
parent = null;
}
|
void releaseWidget() {
super.releaseWidget ();
strings = null;
images = null;
cellFont = null;
cellBackground = cellForeground = null;
}
|
public void setBackground(Color color) {
checkWidget ();
if (color != null && color.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
int pixel = -1;
if (color != null) {
parent.setCustomDraw (true);
pixel = color.handle;
}
if (background == pixel) return;
background = pixel;
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
redraw ();
}
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. |
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.getColumnCount ());
if (0 > index || index > count - 1) return;
int pixel = -1;
if (color != null) {
parent.setCustomDraw (true);
pixel = color.handle;
}
if (cellBackground == null) {
cellBackground = new int [count];
for (int i = 0; i < count; i++) {
cellBackground [i] = -1;
}
}
if (cellBackground [index] == pixel) return;
cellBackground [index] = pixel;
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
redraw (index, true, true);
}
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. |
public void setChecked(boolean checked) {
checkWidget();
if ((parent.style & SWT.CHECK) == 0) return;
if (this.checked == checked) return;
setChecked (checked, false);
}
Sets the checked state of the checkbox for this item. This state change
only applies if the Table was created with the SWT.CHECK style. |
void setChecked(boolean checked,
boolean notify) {
this.checked = checked;
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
if (notify) {
Event event = new Event();
event.item = this;
event.detail = SWT.CHECK;
parent.postEvent (SWT.Selection, event);
}
redraw ();
}
|
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;
if (font != null) parent.setCustomDraw (true);
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
/*
* Bug in Windows. Despite the fact that every item in the
* table always has LPSTR_TEXTCALLBACK, Windows caches the
* bounds for the selected items. This means that
* when you change the string to be something else, Windows
* correctly asks you for the new string but when the item
* is selected, the selection draws using the bounds of the
* previous item. The fix is to reset LPSTR_TEXTCALLBACK
* even though it has not changed, causing Windows to flush
* cached bounds.
*/
if ((parent.style & SWT.VIRTUAL) == 0 && cached) {
int itemIndex = parent.indexOf (this);
if (itemIndex != -1) {
int /*long*/ hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_TEXT;
lvItem.iItem = itemIndex;
lvItem.pszText = OS.LPSTR_TEXTCALLBACK;
OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
cached = false;
}
}
parent.setScrollWidth (this, false);
redraw ();
}
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. |
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.getColumnCount ());
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;
if (font != null) parent.setCustomDraw (true);
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
if (index == 0) {
/*
* Bug in Windows. Despite the fact that every item in the
* table always has LPSTR_TEXTCALLBACK, Windows caches the
* bounds for the selected items. This means that
* when you change the string to be something else, Windows
* correctly asks you for the new string but when the item
* is selected, the selection draws using the bounds of the
* previous item. The fix is to reset LPSTR_TEXTCALLBACK
* even though it has not changed, causing Windows to flush
* cached bounds.
*/
if ((parent.style & SWT.VIRTUAL) == 0 && cached) {
int itemIndex = parent.indexOf (this);
if (itemIndex != -1) {
int /*long*/ hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_TEXT;
lvItem.iItem = itemIndex;
lvItem.pszText = OS.LPSTR_TEXTCALLBACK;
OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
cached = false;
}
}
parent.setScrollWidth (this, false);
}
redraw (index, true, false);
}
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. |
public void setForeground(Color color) {
checkWidget ();
if (color != null && color.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
int pixel = -1;
if (color != null) {
parent.setCustomDraw (true);
pixel = color.handle;
}
if (foreground == pixel) return;
foreground = pixel;
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
redraw ();
}
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. |
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.getColumnCount ());
if (0 > index || index > count - 1) return;
int pixel = -1;
if (color != null) {
parent.setCustomDraw (true);
pixel = color.handle;
}
if (cellForeground == null) {
cellForeground = new int [count];
for (int i = 0; i < count; i++) {
cellForeground [i] = -1;
}
}
if (cellForeground [index] == pixel) return;
cellForeground [index] = pixel;
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
redraw (index, true, false);
}
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. |
public void setGrayed(boolean grayed) {
checkWidget();
if ((parent.style & SWT.CHECK) == 0) return;
if (this.grayed == grayed) return;
this.grayed = grayed;
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
redraw ();
}
Sets the grayed state of the checkbox for this item. This state change
only applies if the Table was created with the SWT.CHECK style. |
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 image for multiple columns in the table. |
public void setImage(Image image) {
checkWidget ();
setImage (0, image);
}
|
public void setImage(int index,
Image image) {
checkWidget();
if (image != null && image.isDisposed ()) {
error(SWT.ERROR_INVALID_ARGUMENT);
}
Image oldImage = null;
if (index == 0) {
if (image != null && image.type == SWT.ICON) {
if (image.equals (this.image)) return;
}
oldImage = this.image;
super.setImage (image);
}
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return;
if (images == null && index != 0) {
images = new Image [count];
images [0] = image;
}
if (images != null) {
if (image != null && image.type == SWT.ICON) {
if (image.equals (images [index])) return;
}
oldImage = images [index];
images [index] = image;
}
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
/* Ensure that the image list is created */
parent.imageIndex (image, index);
if (index == 0) parent.setScrollWidth (this, false);
boolean drawText = (image == null && oldImage != null) || (image != null && oldImage == null);
redraw (index, drawText, true);
}
Sets the receiver's image at a column. |
public void setImageIndent(int indent) {
checkWidget();
if (indent < 0) return;
if (imageIndent == indent) return;
imageIndent = indent;
if ((parent.style & SWT.VIRTUAL) != 0) {
cached = true;
} else {
int index = parent.indexOf (this);
if (index != -1) {
int /*long*/ hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_INDENT;
lvItem.iItem = index;
lvItem.iIndent = indent;
OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
}
}
parent.setScrollWidth (this, false);
redraw ();
} Deprecated! this - functionality is not supported on most platforms
Sets the indent of the first column's image, expressed in terms of the image's width. |
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 text for multiple columns in the table. |
public void setText(String string) {
checkWidget();
setText (0, string);
}
|
public void setText(int index,
String string) {
checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == 0) {
if (string.equals (text)) return;
super.setText (string);
}
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return;
if (strings == null && index != 0) {
strings = new String [count];
strings [0] = text;
}
if (strings != null) {
if (string.equals (strings [index])) return;
strings [index] = string;
}
if ((parent.style & SWT.VIRTUAL) != 0) cached = true;
if (index == 0) {
/*
* Bug in Windows. Despite the fact that every item in the
* table always has LPSTR_TEXTCALLBACK, Windows caches the
* bounds for the selected items. This means that
* when you change the string to be something else, Windows
* correctly asks you for the new string but when the item
* is selected, the selection draws using the bounds of the
* previous item. The fix is to reset LPSTR_TEXTCALLBACK
* even though it has not changed, causing Windows to flush
* cached bounds.
*/
if ((parent.style & SWT.VIRTUAL) == 0 && cached) {
int itemIndex = parent.indexOf (this);
if (itemIndex != -1) {
int /*long*/ hwnd = parent.handle;
LVITEM lvItem = new LVITEM ();
lvItem.mask = OS.LVIF_TEXT;
lvItem.iItem = itemIndex;
lvItem.pszText = OS.LPSTR_TEXTCALLBACK;
OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
cached = false;
}
}
parent.setScrollWidth (this, false);
}
redraw (index, true, false);
}
Sets the receiver's text at a column |