diff options
author | Silenio Quarti <silenio> | 2006-03-17 18:53:04 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2006-03-17 18:53:04 +0000 |
commit | 869d0b47847f64e864b376350d43251357ab2f40 (patch) | |
tree | d02051f36f2d03088f165feb739fff5e58ba4ce6 | |
parent | 72a07d06147da38e9c81864638a860396abfd8c4 (diff) | |
download | eclipse.platform.swt-869d0b47847f64e864b376350d43251357ab2f40.tar.gz eclipse.platform.swt-869d0b47847f64e864b376350d43251357ab2f40.tar.xz eclipse.platform.swt-869d0b47847f64e864b376350d43251357ab2f40.zip |
*** empty log message ***
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java index 754ab4b45d..7a3547fa44 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java @@ -992,7 +992,9 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, Color background = item.getBackground (columnIndex); Color foreground = item.getForeground (columnIndex); Image image = item.getImage (columnIndex); - String text = item.getText (columnIndex); + String text = item.getText (columnIndex); + gc.setClipping (region); + gc.setFont (font); Point extent = gc.stringExtent (text); int contentWidth = extent.x; Rectangle imageBounds = null; @@ -1003,8 +1005,6 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, contentWidth += this.imageBounds.width + gap; } int paintWidth = contentWidth; - gc.setClipping (region); - gc.setFont (font); if (hooks (SWT.MeasureItem)) { Event event = new Event (); event.item = item; @@ -1027,7 +1027,8 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, } boolean draw = true; boolean selected = (itemState & (OS.kDataBrowserItemIsSelected | OS.kDataBrowserItemIsDragTarget)) != 0, wasSelected = selected; - if (selected) { + boolean itemBg = item.background != null || (item.cellBackground != null && item.cellBackground [columnIndex] != null); + if (selected && ((style & SWT.FULL_SELECTION) != 0 || columnIndex == 0)) { gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); } else { @@ -1044,12 +1045,13 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, event.width = itemWidth; event.height = itemHeight; if (selected) event.detail |= SWT.SELECTED; + if (itemBg) event.detail |= SWT.BACKGROUND; sendEvent (SWT.EraseItem, event); draw = event.doit; selected = (event.detail & SWT.SELECTED) != 0; gc.setClipping (region); gc.setFont (font); - if (selected) { + if (selected && ((style & SWT.FULL_SELECTION) != 0 || columnIndex == 0)) { gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); } else { @@ -1057,27 +1059,35 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, if (!wasSelected) gc.setForeground (foreground); } } - if (draw) { - if (columnCount != 0) { - TableColumn column = columns [columnIndex]; - if ((column.style & SWT.CENTER) != 0) x += (width - contentWidth) / 2; - if ((column.style & SWT.RIGHT) != 0) x += width - contentWidth; - } - int stringX = x, imageX = x; - if (image != null) stringX += this.imageBounds.width + gap; - if (selected && ((style & SWT.HIDE_SELECTION) == 0 || hasFocus ())) { + if (columnCount != 0) { + TableColumn column = columns [columnIndex]; + if ((column.style & SWT.CENTER) != 0) x += (width - contentWidth) / 2; + if ((column.style & SWT.RIGHT) != 0) x += width - contentWidth; + } + int stringX = x; + boolean drawBackground = itemBg; + if (image != null) stringX += this.imageBounds.width + gap; + if (selected && ((style & SWT.FULL_SELECTION) != 0 || columnIndex == 0)) { + if ((style & SWT.HIDE_SELECTION) == 0 || hasFocus ()) { if ((style & SWT.FULL_SELECTION) != 0) { gc.fillRectangle (itemX, itemY, itemWidth, itemHeight - 1); + drawBackground = false; } else if (columnIndex == 0) { gc.fillRectangle (stringX - 1, y, extent.x + 2, itemHeight - 1); + drawBackground = false; } - } else { - if (item.background != null || (item.cellBackground != null && item.cellBackground [columnIndex] != null)) { - gc.fillRectangle (itemX, itemY, itemWidth, itemHeight); - } + } else { + //TODO - funny thing + if (itemBg) gc.setBackground (background); + } + } + if (draw) { + if (drawBackground) { + gc.fillRectangle (itemX, itemY, itemWidth, itemHeight); } if (image != null) { - gc.drawImage (image, 0, 0, imageBounds.width, imageBounds.height, imageX, y + (height - this.imageBounds.height) / 2, this.imageBounds.width, this.imageBounds.height); + int imageX = x, imageY = y + (height - this.imageBounds.height) / 2; + gc.drawImage (image, 0, 0, imageBounds.width, imageBounds.height, imageX, imageY, this.imageBounds.width, this.imageBounds.height); } gc.drawString (text, stringX, y + (height - extent.y) / 2, true); } @@ -1091,6 +1101,7 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, event.width = paintWidth; event.height = itemHeight; if (selected) event.detail |= SWT.SELECTED; + if (itemBg) event.detail |= SWT.BACKGROUND; sendEvent (SWT.PaintItem, event); } OS.CGContextRestoreGState (gc.handle); |