![]() |
![]() |
org.eclipse.swt.win32.win32.x86_3.7.2.v3740fbackground = OS.GetBkColor(hdc); font = Font.win32_new(display, hFont); GC gc = GC.win32_new(hdc, data); int x = left; if (iSubItem != 0) { x -= gridWidth; } Image image = item.getImage(iSubItem); if (image != null) { Rectangle rect = image.getBounds(); RECT imageRect = item.getBounds(iItem, iSubItem, false, true, false, false, hDC); Point size = imageList == null ? new Point(width, height) : imageList.getImageSize(); int y = top; if ((!OS.IsWinCE) && (OS.WIN32_VERSION >= OS.VERSION(6, 0))) { y += Math.max(0, (bottom - top - y) / 2); } gc.drawImage(image, x, y, width, height, x, y, x, y); x += x + 4 + (iSubItem == 0 ? -2 : 4); } else { x += 6; } String string = item.getText(iSubItem); if (string != null) { int flags = 2084; TableColumn column = columns != null ? columns[iSubItem] : null; if (column != null) { if ((style & 0x1000000) != 0) { flags |= 0x1; } if ((style & 0x20000) != 0) { flags |= 0x2; } } TCHAR buffer = new TCHAR(getCodePage(), string, false); RECT textRect = new RECT(); OS.SetRect(textRect, x, top, right, bottom); OS.DrawText(hdc, buffer, buffer.length(), textRect, flags); } gc.dispose(); OS.RestoreDC(hdc, nSavedDC); } if (hooks(42)) { RECT itemRect = item.getBounds(iItem, iSubItem, true, true, false, false, hDC); sendPaintItemEvent(item, nmcd, iSubItem, itemRect); } OS.SelectObject(hDC, oldFont); OS.ReleaseDC(handle, hDC); } break; } return null; } } /* Location: * Qualified Name: org.eclipse.swt.widgets.Table * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.swt.widgets; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.internal.win32.HDITEM; import org.eclipse.swt.internal.win32.LVCOLUMN; import org.eclipse.swt.internal.win32.OS; import org.eclipse.swt.internal.win32.RECT; import org.eclipse.swt.internal.win32.TCHAR; import org.eclipse.swt.internal.win32.TOOLINFO; public class TableColumn extends Item { Table parent; boolean resizable; boolean moveable; String toolTipText; int id; public TableColumn(Table parent, int style) { super(parent, checkStyle(style)); resizable = true; this.parent = parent; parent.createItem(this, parent.getColumnCount()); } public TableColumn(Table parent, int style, int index) { super(parent, checkStyle(style)); resizable = true; this.parent = parent; parent.createItem(this, index); } public void addControlListener(ControlListener listener) { checkWidget(); if (listener == null) { error(4); } TypedListener typedListener = new TypedListener(listener); addListener(11, typedListener); addListener(10, typedListener); } public void addSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) { error(4); } TypedListener typedListener = new TypedListener(listener); addListener(13, typedListener); addListener(14, typedListener); } static int checkStyle(int style) { return checkBits(style, 16384, 16777216, 131072, 0, 0, 0); } protected void checkSubclass() { if (!isValidSubclass()) { error(43); } } void destroyWidget() { parent.destroyItem(this); releaseHandle(); } public int getAlignment() { checkWidget(); if ((style & 0x4000) != 0) { return 16384; } if ((style & 0x1000000) != 0) { return 16777216; } if ((style & 0x20000) != 0) { return 131072; } return 16384; } String getNameText() { return getText(); } public Table getParent() { checkWidget(); return parent; } public boolean getMoveable() { checkWidget(); return moveable; } public boolean getResizable() { checkWidget(); return resizable; } public String getToolTipText() { checkWidget(); return toolTipText; } public int getWidth() { checkWidget(); int index = parent.indexOf(this); if (index == -1) { return 0; } int hwnd = parent.handle; return OS.SendMessage(hwnd, 4125, index, 0); } public void pack() { checkWidget(); int index = parent.indexOf(this); if (index == -1) { return; } int hwnd = parent.handle; int oldWidth = OS.SendMessage(hwnd, 4125, index, 0); TCHAR buffer = new TCHAR(parent.getCodePage(), text, true); int headerWidth = OS.SendMessage(hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + 12; if ((OS.COMCTL32_MAJOR >= 6) && (OS.IsAppThemed())) { headerWidth += 3; } boolean hasHeaderImage = false; if ((image != null) || (parent.sortColumn == this)) { hasHeaderImage = true; Image headerImage = null; if ((parent.sortColumn == this) && (parent.sortDirection != 0)) { if (OS.COMCTL32_MAJOR < 6) { headerImage = display.getSortImage(parent.sortDirection); } else { headerWidth += 10; } } else { headerImage = image; } if (headerImage != null) { Rectangle bounds = headerImage.getBounds(); headerWidth += width; } int margin = 0; if (OS.COMCTL32_VERSION >= OS.VERSION(5, 80)) { int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); margin = OS.SendMessage(hwndHeader, 4629, 0, 0); } else { margin = OS.GetSystemMetrics(45) * 3; } headerWidth += margin * 4; } parent.ignoreColumnResize = true; int columnWidth = 0; if (parent.hooks(41)) { RECT headerRect = new RECT(); int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); OS.SendMessage(hwndHeader, 4615, index, headerRect); OS.MapWindowPoints(hwndHeader, hwnd, headerRect, 2); int hDC = OS.GetDC(hwnd); int oldFont = 0;int newFont = OS.SendMessage(hwnd, 49, 0, 0); if (newFont != 0) { oldFont = OS.SelectObject(hDC, newFont); } int count = OS.SendMessage(hwnd, 4100, 0, 0); for (int i = 0; i < count; i++) { TableItem item = parent._getItem(i, false); if (item != null) { int hFont = item.fontHandle(index); if (hFont != -1) { hFont = OS.SelectObject(hDC, hFont); } Event event = parent.sendMeasureItemEvent(item, i, index, hDC); if (hFont != -1) { hFont = OS.SelectObject(hDC, hFont); } if ((isDisposed()) || (parent.isDisposed())) { break; } columnWidth = Math.max(columnWidth, x + width - left); } } if (newFont != 0) { OS.SelectObject(hDC, oldFont); } OS.ReleaseDC(hwnd, hDC); OS.SendMessage(hwnd, 4126, index, columnWidth); } else { OS.SendMessage(hwnd, 4126, index, -1); columnWidth = OS.SendMessage(hwnd, 4125, index, 0); if (index == 0) { if (parent.imageList == null) { columnWidth += 2; } if ((!OS.IsWinCE) && (OS.WIN32_VERSION < OS.VERSION(6, 0)) && (!parent.firstColumnImage)) { int hImageList = OS.SendMessage(hwnd, 4098, 1, 0); if (hImageList != 0) { int[] cx = new int[1];int[] cy = new int[1]; OS.ImageList_GetIconSize(hImageList, cx, cy); columnWidth += cx[0]; } } if ((parent.style & 0x20) != 0) { int hStateList = OS.SendMessage(hwnd, 4098, 2, 0); if (hStateList != 0) { int[] cx = new int[1];int[] cy = new int[1]; OS.ImageList_GetIconSize(hStateList, cx, cy); columnWidth += cx[0]; } } } } if (headerWidth > columnWidth) { if (!hasHeaderImage) { RECT rect = null; boolean fixWidth = index == parent.getColumnCount() - 1; if (fixWidth) { rect = new RECT(); OS.GetWindowRect(hwnd, rect); OS.UpdateWindow(hwnd); int flags = 30; SetWindowPos(hwnd, 0, 0, 0, 0, bottom - top, flags); } OS.SendMessage(hwnd, 4126, index, -2); if (fixWidth) { int flags = 22; SetWindowPos(hwnd, 0, 0, 0, right - left, bottom - top, flags); } } else { OS.SendMessage(hwnd, 4126, index, headerWidth); } } else if (index == 0) { OS.SendMessage(hwnd, 4126, index, columnWidth); } parent.ignoreColumnResize = false; int newWidth = OS.SendMessage(hwnd, 4125, index, 0); if (oldWidth != newWidth) { updateToolTip(index); sendEvent(11); if (isDisposed()) { return; } boolean moved = false; int[] order = parent.getColumnOrder(); TableColumn[] columns = parent.getColumns(); for (int i = 0; i < order.length; i++) { TableColumn column = columns[order[i]]; if ((moved) && (!column.isDisposed())) { column.updateToolTip(order[i]); column.sendEvent(10); } if (column == this) { moved = true; } } } } void releaseHandle() { super.releaseHandle(); parent = null; } void releaseParent() { super.releaseParent(); if (parent.sortColumn == this) { parent.sortColumn = null; } } public void removeControlListener(ControlListener listener) { checkWidget(); if (listener == null) { error(4); } if (eventTable == null) { return; } eventTable.unhook(10, listener); eventTable.unhook(11, listener); } public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) { error(4); } if (eventTable == null) { return; } eventTable.unhook(13, listener); eventTable.unhook(14, listener); } public void setAlignment(int alignment) { checkWidget(); if ((alignment & 0x1024000) == 0) { return; } int index = parent.indexOf(this); if ((index == -1) || (index == 0)) { return; } style &= 0xFEFDBFFF; style |= alignment & 0x1024000; int hwnd = parent.handle; LVCOLUMN lvColumn = new LVCOLUMN(); mask = 1; OS.SendMessage(hwnd, OS.LVM_GETCOLUMN, index, lvColumn); fmt &= 0xFFFFFFFC; int fmt = 0; if ((style & 0x4000) == 16384) { fmt = 0; } if ((style & 0x1000000) == 16777216) { fmt = 2; } if ((style & 0x20000) == 131072) { fmt = 1; } fmt |= fmt; OS.SendMessage(hwnd, OS.LVM_SETCOLUMN, index, lvColumn); if (index != 0) { parent.forceResize(); RECT rect = new RECT();RECT headerRect = new RECT(); OS.GetClientRect(hwnd, rect); int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); OS.SendMessage(hwndHeader, 4615, index, headerRect); OS.MapWindowPoints(hwndHeader, hwnd, headerRect, 2); left = left; right = right; OS.InvalidateRect(hwnd, rect, true); } } public void setImage(Image image) { checkWidget(); if ((image != null) && (image.isDisposed())) { error(5); } super.setImage(image); if ((parent.sortColumn != this) || (parent.sortDirection != 0)) { setImage(image, false, false); } } void setImage(Image image, boolean sort, boolean right) { int index = parent.indexOf(this); if (index == -1) { return; } int hwnd = parent.handle; if (OS.COMCTL32_MAJOR < 6) { int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); HDITEM hdItem = new HDITEM(); mask = 52; OS.SendMessage(hwndHeader, OS.HDM_GETITEM, index, hdItem); fmt &= 0xEFFF; if (image != null) { if (sort) { mask &= 0xFFFFFFDF; fmt &= 0xF7FF; fmt |= 0x2000; hbm = handle; } else { mask &= 0xFFFFFFEF; fmt &= 0xDFFF; fmt |= 0x800; iImage = parent.imageIndexHeader(image); } if (right) { fmt |= 0x1000; } } else { fmt &= 0xD7FF; } OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem); } else { LVCOLUMN lvColumn = new LVCOLUMN(); mask = 17; OS.SendMessage(hwnd, OS.LVM_GETCOLUMN, index, lvColumn); if (image != null) { fmt |= 0x800; iImage = parent.imageIndexHeader(image); if (right) { fmt |= 0x1000; } } else { mask &= 0xFFFFFFEF; fmt &= 0xE7FF; } OS.SendMessage(hwnd, OS.LVM_SETCOLUMN, index, lvColumn); } } public void setMoveable(boolean moveable) { checkWidget(); this.moveable = moveable; parent.updateMoveable(); } public void setResizable(boolean resizable) { checkWidget(); this.resizable = resizable; } void setSortDirection(int direction) { if (OS.COMCTL32_MAJOR >= 6) { int index = parent.indexOf(this); if (index == -1) { return; } int hwnd = parent.handle; int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); HDITEM hdItem = new HDITEM(); mask = 36; OS.SendMessage(hwndHeader, OS.HDM_GETITEM, index, hdItem); switch (direction) { case 128: fmt &= 0xF5FF; fmt |= 0x400; if (image == null) { mask &= 0xFFFFFFDF; } break; case 1024: fmt &= 0xF3FF; fmt |= 0x200; if (image == null) { mask &= 0xFFFFFFDF; } break; case 0: fmt &= 0xF9FF; if (image != null) { fmt |= 0x800; iImage = parent.imageIndexHeader(image); } else { fmt &= 0xF7FF; mask &= 0xFFFFFFDF; } break; } OS.SendMessage(hwndHeader, OS.HDM_SETITEM, index, hdItem); parent.forceResize(); RECT rect = new RECT(); OS.GetClientRect(hwnd, rect); if (OS.SendMessage(hwnd, 4096, 0, 0) != -1) { int oldColumn = OS.SendMessage(hwnd, 4270, 0, 0); int newColumn = direction == 0 ? -1 : index; OS.SendMessage(hwnd, 4236, newColumn, 0); RECT headerRect = new RECT(); if ((oldColumn != -1) && (OS.SendMessage(hwndHeader, 4615, oldColumn, headerRect) != 0)) { OS.MapWindowPoints(hwndHeader, hwnd, headerRect, 2); left = left; right = right; OS.InvalidateRect(hwnd, rect, true); } } RECT headerRect = new RECT(); if (OS.SendMessage(hwndHeader, 4615, index, headerRect) != 0) { OS.MapWindowPoints(hwndHeader, hwnd, headerRect, 2); left = left; right = right; OS.InvalidateRect(hwnd, rect, true); } } else { switch (direction) { case 128: case 1024: setImage(display.getSortImage(direction), true, true); break; case 0: setImage(image, false, false); } } } public void setText(String string) { checkWidget(); if (string == null) { error(4); } if (string.equals(text)) { return; } int index = parent.indexOf(this); if (index == -1) { return; } super.setText(string); int hwnd = parent.handle; LVCOLUMN lvColumn = new LVCOLUMN(); mask = 1; OS.SendMessage(hwnd, OS.LVM_GETCOLUMN, index, lvColumn); boolean replace = (!OS.IsWinCE) && (OS.WIN32_VERSION <= OS.VERSION(4, 10)); int hHeap = OS.GetProcessHeap(); TCHAR buffer = new TCHAR(parent.getCodePage(), fixMnemonic(string, replace), true); int byteCount = buffer.length() * TCHAR.sizeof; int pszText = OS.HeapAlloc(hHeap, 8, byteCount); OS.MoveMemory(pszText, buffer, byteCount); mask |= 0x4; pszText = pszText; int result = OS.SendMessage(hwnd, OS.LVM_SETCOLUMN, index, lvColumn); if (pszText != 0) { OS.HeapFree(hHeap, 0, pszText); } if (result == 0) { error(13); } } public void setToolTipText(String string) { checkWidget(); toolTipText = string; int hwndHeaderToolTip = parent.headerToolTipHandle; if (hwndHeaderToolTip == 0) { parent.createHeaderToolTips(); parent.updateHeaderToolTips(); } } public void setWidth(int width) { checkWidget(); if (width < 0) { return; } int index = parent.indexOf(this); if (index == -1) { return; } int hwnd = parent.handle; if (width != OS.SendMessage(hwnd, 4125, index, 0)) { OS.SendMessage(hwnd, 4126, index, width); } } void updateToolTip(int index) { int hwndHeaderToolTip = parent.headerToolTipHandle; if (hwndHeaderToolTip != 0) { int hwnd = parent.handle; int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); RECT rect = new RECT(); if (OS.SendMessage(hwndHeader, 4615, index, rect) != 0) { TOOLINFO lpti = new TOOLINFO(); cbSize = TOOLINFO.sizeof; hwnd = hwndHeader; uId = id; left = left; top = top; right = right; bottom = bottom; OS.SendMessage(hwndHeaderToolTip, OS.TTM_NEWTOOLRECT, 0, lpti); } } } } /* Location: * Qualified Name: org.eclipse.swt.widgets.TableColumn * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.swt.widgets; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.internal.win32.LVITEM; import org.eclipse.swt.internal.win32.OS; import org.eclipse.swt.internal.win32.RECT; import org.eclipse.swt.internal.win32.TCHAR; public class TableItem extends Item { int[] cellForeground; int[] cellBackground; int foreground = -1; int background = -1; int imageIndent; boolean cached; boolean grayed; boolean checked; Font[] cellFont; Font font; Image[] images; String[] strings; Table parent; public TableItem(Table parent, int style) { this(parent, style, checkNull(parent).getItemCount(), true); } public TableItem(Table parent, int style, int index) { this(parent, style, index, true); } TableItem(Table parent, int style, int index, boolean create) { super(parent, style); this.parent = parent; if (create) { parent.createItem(this, index); } } static Table checkNull(Table control) { if (control == null) { SWT.error(4); } return control; } protected void checkSubclass() { if (!isValidSubclass()) { error(43); } } void clear() { text = ""; image = null; strings = null; images = null; imageIndent = 0; checked = (grayed = 0); font = null; background = (foreground = -1); cellFont = null; cellBackground = (cellForeground = null); if ((parent.style & 0x10000000) != 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(24); } if (background == -1) { return parent.getBackground(); } return Color.win32_new(display, background); } public Color getBackground(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (index > count - 1)) { return getBackground(); } int pixel = cellBackground != null ? cellBackground[index] : -1; return pixel == -1 ? getBackground() : Color.win32_new(display, pixel); } public Rectangle getBounds() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } 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 = right - left;int height = bottom - top; return new Rectangle(left, top, width, height); } public Rectangle getBounds(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } 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 = right - left;int height = bottom - top; return new Rectangle(left, top, width, height); } 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 ((column < 0) || (column >= Math.max(1, columnCount))) { return new RECT(); } if (parent.fixScrollWidth) { parent.setScrollWidth(null, true); } RECT rect = new RECT(); int hwnd = parent.handle; int bits = OS.SendMessage(hwnd, 4151, 0, 0); if ((column == 0) && ((bits & 0x20) == 0)) { if (parent.explorerTheme) { left = 1; parent.ignoreCustomDraw = true; int code = OS.SendMessage(hwnd, 4110, row, rect); parent.ignoreCustomDraw = false; if (code == 0) { return new RECT(); } if (getText) { int width = 0; int hFont = fontHandle(column); if ((hFont == -1) && (hDC == 0)) { TCHAR buffer = new TCHAR(parent.getCodePage(), text, true); width = OS.SendMessage(hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer); } else { TCHAR buffer = new TCHAR(parent.getCodePage(), text, false); int textDC = hDC != 0 ? hDC : OS.GetDC(hwnd);int oldFont = -1; if (hDC == 0) { if (hFont == -1) { hFont = OS.SendMessage(hwnd, 49, 0, 0); } oldFont = OS.SelectObject(textDC, hFont); } RECT textRect = new RECT(); int flags = 3104; OS.DrawText(textDC, buffer, buffer.length(), textRect, flags); width = right - left; if (hDC == 0) { if (oldFont != -1) { OS.SelectObject(textDC, oldFont); } OS.ReleaseDC(hwnd, textDC); } } if (!getImage) { left = right; } right += width + 8; } } else if (getText) { left = 3; parent.ignoreCustomDraw = true; int code = OS.SendMessage(hwnd, 4110, row, rect); parent.ignoreCustomDraw = false; if (code == 0) { return new RECT(); } if (!getImage) { RECT iconRect = new RECT(); left = 1; parent.ignoreCustomDraw = true; code = OS.SendMessage(hwnd, 4110, row, iconRect); parent.ignoreCustomDraw = false; if (code != 0) { left = right; } } } else { left = 1; parent.ignoreCustomDraw = true; int code = OS.SendMessage(hwnd, 4110, row, rect); parent.ignoreCustomDraw = false; if (code == 0) { return new RECT(); } } if ((fullText) || (fullImage)) { RECT headerRect = new RECT(); int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); OS.SendMessage(hwndHeader, 4615, 0, headerRect); OS.MapWindowPoints(hwndHeader, hwnd, headerRect, 2); if ((getText) && (fullText)) { right = right; } if ((getImage) && (fullImage)) { left = left; } } } else { boolean hasImage = ((column == 0) && (image != null)) || ((images != null) && (images[column] != null)); top = column; if ((fullText) || (fullImage) || (hDC == 0)) { left = (getText ? 2 : 1); parent.ignoreCustomDraw = true; int code = OS.SendMessage(hwnd, 4152, row, rect); parent.ignoreCustomDraw = false; if (code == 0) { return new RECT(); } if ((column == 0) && (getText) && (getImage)) { RECT iconRect = new RECT(); left = 1; parent.ignoreCustomDraw = true; code = OS.SendMessage(hwnd, 4152, row, iconRect); parent.ignoreCustomDraw = false; if (code != 0) { left = left; } } if (hasImage) { if ((column != 0) && (getText) && (!getImage)) { RECT iconRect = new RECT(); top = column; left = 1; if (OS.SendMessage(hwnd, 4152, row, iconRect) != 0) { left = (right + 2); } } } else if ((getImage) && (!getText)) { right = left; } if ((column == 0) && (fullImage)) { RECT headerRect = new RECT(); int hwndHeader = OS.SendMessage(hwnd, 4127, 0, 0); OS.SendMessage(hwndHeader, 4615, 0, headerRect); OS.MapWindowPoints(hwndHeader, hwnd, headerRect, 2); left = left; } } else { left = 1; parent.ignoreCustomDraw = true; int code = OS.SendMessage(hwnd, 4152, row, rect); parent.ignoreCustomDraw = false; if (code == 0) { return new RECT(); } if (!hasImage) { right = left; } if (getText) { String string = strings != null ? strings[column] : column == 0 ? text : null; if (string != null) { RECT textRect = new RECT(); TCHAR buffer = new TCHAR(parent.getCodePage(), string, false); int flags = 3104; OS.DrawText(hDC, buffer, buffer.length(), textRect, flags); right += right - left + 12 + 2; } } } } int gridWidth = parent.getLinesVisible() ? 1 : 0; if (OS.COMCTL32_VERSION >= OS.VERSION(5, 80)) { top -= gridWidth; } if (column != 0) { left += gridWidth; } right = Math.max(right, left); top += gridWidth; bottom = Math.max(bottom - gridWidth, top); return rect; } public boolean getChecked() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } if ((parent.style & 0x20) == 0) { return false; } return checked; } public Font getFont() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } return font != null ? font : parent.getFont(); } public Font getFont(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (index > count - 1)) { return getFont(); } if ((cellFont == null) || (cellFont[index] == null)) { return getFont(); } return cellFont[index]; } public Color getForeground() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } if (foreground == -1) { return parent.getForeground(); } return Color.win32_new(display, foreground); } public Color getForeground(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (index > count - 1)) { return getForeground(); } int pixel = cellForeground != null ? cellForeground[index] : -1; return pixel == -1 ? getForeground() : Color.win32_new(display, pixel); } public boolean getGrayed() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } if ((parent.style & 0x20) == 0) { return false; } return grayed; } public Image getImage() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } return super.getImage(); } public Image getImage(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } if (index == 0) { return getImage(); } if ((images != null) && (index >= 0) && (index < images.length)) { return images[index]; } return null; } public Rectangle getImageBounds(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } 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 = right - left;int height = bottom - top; return new Rectangle(left, top, width, height); } public int getImageIndent() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } return imageIndent; } String getNameText() { if (((parent.style & 0x10000000) != 0) && (!cached)) { return "*virtual*"; } return super.getNameText(); } public Table getParent() { checkWidget(); return parent; } public String getText() { checkWidget(); if (!parent.checkData(this, true)) { error(24); } return super.getText(); } public String getText(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } if (index == 0) { return getText(); } if ((strings != null) && (index >= 0) && (index < strings.length)) { String string = strings[index]; return string != null ? string : ""; } return ""; } public Rectangle getTextBounds(int index) { checkWidget(); if (!parent.checkData(this, true)) { error(24); } int itemIndex = parent.indexOf(this); if (itemIndex == -1) { return new Rectangle(0, 0, 0, 0); } RECT rect = getBounds(itemIndex, index, true, false, true); left += 2; if (index != 0) { left += 4; } left = Math.min(left, right); right -= 4; int width = Math.max(0, right - left); int height = Math.max(0, bottom - top); return new Rectangle(left, top, width, height); } void redraw() { if ((parent.currentItem == this) || (!parent.getDrawing())) { return; } int hwnd = parent.handle; if (!OS.IsWindowVisible(hwnd)) { return; } int index = parent.indexOf(this); if (index == -1) { return; } OS.SendMessage(hwnd, 4117, index, index); } void redraw(int column, boolean drawText, boolean drawImage) { if ((parent.currentItem == this) || (!parent.getDrawing())) { return; } int 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(5); } int pixel = -1; if (color != null) { parent.setCustomDraw(true); pixel = handle; } if (background == pixel) { return; } background = pixel; if ((parent.style & 0x10000000) != 0) { cached = true; } redraw(); } public void setBackground(int index, Color color) { checkWidget(); if ((color != null) && (color.isDisposed())) { SWT.error(5); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (index > count - 1)) { return; } int pixel = -1; if (color != null) { parent.setCustomDraw(true); pixel = 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 & 0x10000000) != 0) { cached = true; } redraw(index, true, true); } public void setChecked(boolean checked) { checkWidget(); if ((parent.style & 0x20) == 0) { return; } if (this.checked == checked) { return; } setChecked(checked, false); } void setChecked(boolean checked, boolean notify) { this.checked = checked; if ((parent.style & 0x10000000) != 0) { cached = true; } if (notify) { Event event = new Event(); item = this; detail = 32; parent.sendSelectionEvent(13, event, false); } redraw(); } public void setFont(Font font) { checkWidget(); if ((font != null) && (font.isDisposed())) { SWT.error(5); } 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 & 0x10000000) != 0) { cached = true; } if (((parent.style & 0x10000000) == 0) && (cached)) { int itemIndex = parent.indexOf(this); if (itemIndex != -1) { int hwnd = parent.handle; LVITEM lvItem = new LVITEM(); mask = 1; iItem = itemIndex; pszText = -1; OS.SendMessage(hwnd, OS.LVM_SETITEM, 0, lvItem); cached = false; } } parent.setScrollWidth(this, false); redraw(); } public void setFont(int index, Font font) { checkWidget(); if ((font != null) && (font.isDisposed())) { SWT.error(5); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (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 & 0x10000000) != 0) { cached = true; } if (index == 0) { if (((parent.style & 0x10000000) == 0) && (cached)) { int itemIndex = parent.indexOf(this); if (itemIndex != -1) { int hwnd = parent.handle; LVITEM lvItem = new LVITEM(); mask = 1; iItem = itemIndex; pszText = -1; OS.SendMessage(hwnd, OS.LVM_SETITEM, 0, lvItem); cached = false; } } parent.setScrollWidth(this, false); } redraw(index, true, false); } public void setForeground(Color color) { checkWidget(); if ((color != null) && (color.isDisposed())) { SWT.error(5); } int pixel = -1; if (color != null) { parent.setCustomDraw(true); pixel = handle; } if (foreground == pixel) { return; } foreground = pixel; if ((parent.style & 0x10000000) != 0) { cached = true; } redraw(); } public void setForeground(int index, Color color) { checkWidget(); if ((color != null) && (color.isDisposed())) { SWT.error(5); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (index > count - 1)) { return; } int pixel = -1; if (color != null) { parent.setCustomDraw(true); pixel = 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 & 0x10000000) != 0) { cached = true; } redraw(index, true, false); } public void setGrayed(boolean grayed) { checkWidget(); if ((parent.style & 0x20) == 0) { return; } if (this.grayed == grayed) { return; } this.grayed = grayed; if ((parent.style & 0x10000000) != 0) { cached = true; } redraw(); } public void setImage(Image[] images) { checkWidget(); if (images == null) { error(4); } for (int i = 0; i < images.length; i++) { setImage(i, images[i]); } } public void setImage(int index, Image image) { checkWidget(); if ((image != null) && (image.isDisposed())) { error(5); } Image oldImage = null; if (index == 0) { if ((image != null) && (type == 1) && (image.equals(this.image))) { return; } oldImage = this.image; super.setImage(image); } int count = Math.max(1, parent.getColumnCount()); if ((index < 0) || (index > count - 1)) { return; } if ((images == null) && (index != 0)) { images = new Image[count]; images[0] = image; } if (images != null) { if ((image != null) && (type == 1) && (image.equals(images[index]))) { return; } oldImage = images[index]; images[index] = image; } if ((parent.style & 0x10000000) != 0) { cached = true; } 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); } public void setImage(Image image) { checkWidget(); setImage(0, image); } /** * @deprecated */ public void setImageIndent(int indent) { checkWidget(); if (indent < 0) { return; } if (imageIndent == indent) { return; } imageIndent = indent; if ((parent.style & 0x10000000) != 0) { cached = true; } else { int index = parent.indexOf(this); if (index != -1) { int hwnd = parent.handle; LVITEM lvItem = new LVITEM(); mask = 16; iItem = index; iIndent = indent; OS Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|