?? tableitem.java
字號:
parent.setScrollWidth (this, false); redraw (-1, true, true);}/** * 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.0 */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; int hFont = -1; if (font != null) { parent.customDraw = true; hFont = font.handle; } if (cellFont == null) { cellFont = new int [count]; for (int i = 0; i < count; i++) { cellFont [i] = -1; } } if (cellFont [index] == hFont) return; cellFont [index] = hFont; 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 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, true);}/** * 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) * * @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); } int pixel = -1; if (color != null) { parent.customDraw = true; pixel = color.handle; } if (foreground == pixel) return; foreground = pixel; redraw (-1, true, true);}/** * 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.0 * */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.customDraw = 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; redraw (index, true, true);}/** * 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. * * @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; redraw (-1, true, true);}/** * Sets the image for multiple columns in the Table. * * @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> */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> */public void setImage (int index, Image image) { checkWidget(); if (image != null && image.isDisposed ()) { error(SWT.ERROR_INVALID_ARGUMENT); } if (index == 0) { if (image != null && image.type == SWT.ICON) { if (image.equals (this.image)) return; } 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]; if (images != null) { if (image != null && image.type == SWT.ICON) { if (image.equals (images [index])) return; } images [index] = image; } /* Ensure that the image list is created */ parent.imageIndex (image); if (index == 0) parent.setScrollWidth (this, false); redraw (index, false, true);}public void setImage (Image image) { checkWidget (); setImage (0, image);}/** * Sets the indent of the first column's image, expressed in terms of the image's width. * * @param indent the new indent * * </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> */public void setImageIndent (int indent) { checkWidget(); if (indent < 0) return; if (imageIndent == indent) return; imageIndent = indent; if ((parent.style & SWT.VIRTUAL) == 0) { int index = parent.indexOf (this); if (index != -1) { int 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 (-1, true, true);}/** * Sets the text for multiple columns in the table. * * @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> */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> */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]; if (strings != null) { if (string.equals (strings [index])) return; strings [index] = string; } 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 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);}public void setText (String string) { checkWidget(); setText (0, string);}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -