Mercurial > projects > dwt-win
diff dwt/custom/TableCursor.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | fd9c62a2998e |
line wrap: on
line diff
--- a/dwt/custom/TableCursor.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/custom/TableCursor.d Sat May 17 17:34:28 2008 +0200 @@ -160,6 +160,9 @@ TableColumn column = null; Listener tableListener, resizeListener, disposeItemListener, disposeColumnListener; + Color background = null; + Color foreground = null; + // By default, invert the list selection colors static final int BACKGROUND = DWT.COLOR_LIST_SELECTION_TEXT; static final int FOREGROUND = DWT.COLOR_LIST_SELECTION; @@ -253,6 +256,7 @@ disposeItemListener = new class() Listener { public void handleEvent(Event event) { + unhookRowColumnListeners(); row = null; column = null; _resize(); @@ -260,6 +264,7 @@ }; disposeColumnListener = new class() Listener { public void handleEvent(Event event) { + unhookRowColumnListeners(); row = null; column = null; _resize(); @@ -319,16 +324,7 @@ void dispose(Event event) { table.removeListener(DWT.FocusIn, tableListener); table.removeListener(DWT.MouseDown, tableListener); - if (column !is null) { - column.removeListener(DWT.Dispose, disposeColumnListener); - column.removeListener(DWT.Move, resizeListener); - column.removeListener(DWT.Resize, resizeListener); - column = null; - } - if (row !is null) { - row.removeListener(DWT.Dispose, disposeItemListener); - row = null; - } + unhookRowColumnListeners(); ScrollBar hBar = table.getHorizontalBar(); if (hBar !is null) { hBar.removeListener(DWT.Selection, resizeListener); @@ -492,10 +488,11 @@ } void tableFocusIn(Event event) { - if (isDisposed()) - return; - if (isVisible()) + if (isDisposed()) return; + if (isVisible()) { + if (row is null && column is null) return; setFocus(); + } } void tableMouseDown(Event event) { @@ -522,7 +519,14 @@ } TableColumn newColumn = null; int columnCount = table.getColumnCount(); - if (columnCount > 0) { + if (columnCount is 0) { + if ((table.getStyle() & DWT.FULL_SELECTION) is 0) { + Rectangle rect = item.getBounds(0); + rect.width += lineWidth; + rect.height += lineWidth; + if (!rect.contains(pt)) return; + } + } else { for (int i = 0; i < columnCount; i++) { Rectangle rect = item.getBounds(i); rect.width += lineWidth; @@ -533,6 +537,7 @@ } } if (newColumn is null) { + if ((table.getStyle() & DWT.FULL_SELECTION) is 0) return; newColumn = table.getColumn(0); } } @@ -638,6 +643,30 @@ return column is null ? 0 : table.indexOf(column); } /** + * Returns the background color that the receiver will use to draw. + * + * @return the receiver's background color + */ +public Color getBackground() { + checkWidget(); + if (background is null) { + return getDisplay().getSystemColor(BACKGROUND); + } + return background; +} +/** + * Returns the foreground color that the receiver will use to draw. + * + * @return the receiver's foreground color + */ +public Color getForeground() { + checkWidget(); + if (foreground is null) { + return getDisplay().getSystemColor(FOREGROUND); + } + return foreground; +} +/** * Returns the row over which the TableCursor is positioned. * * @return the item for the current position @@ -651,14 +680,49 @@ checkWidget(); return row; } +/** + * Sets the receiver's background color to the color specified + * by the argument, or to the default system color for the control + * if the argument is null. + * <p> + * Note: This operation is a hint and may be overridden by the platform. + * For example, on Windows the background of a Button cannot be changed. + * </p> + * @param color the new color (or null) + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> + * </ul> + * @exception DWTException <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 override void setBackground (Color color) { - if (color is null) color = getDisplay().getSystemColor(BACKGROUND); - super.setBackground(color); + background = color; + super.setBackground(getBackground()); redraw(); } +/** + * Sets the receiver's foreground color to the color specified + * by the argument, or to the default system color for the control + * if the argument is null. + * <p> + * Note: This operation is a hint and may be overridden by the platform. + * </p> + * @param color the new color (or null) + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> + * </ul> + * @exception DWTException <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 override void setForeground (Color color) { - if (color is null) color = getDisplay().getSystemColor(FOREGROUND); - super.setForeground(color); + foreground = color; + super.setForeground(getForeground()); redraw(); } /** @@ -707,4 +771,16 @@ DWT.error(DWT.ERROR_INVALID_ARGUMENT); setRowColumn(table.indexOf(row), column, false); } +void unhookRowColumnListeners() { + if (column !is null) { + column.removeListener(DWT.Dispose, disposeColumnListener); + column.removeListener(DWT.Move, resizeListener); + column.removeListener(DWT.Resize, resizeListener); + column = null; + } + if (row !is null) { + row.removeListener(DWT.Dispose, disposeItemListener); + row = null; + } } +}