### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java,v retrieving revision 1.286 diff -u -r1.286 CTabFolder.java --- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java 24 Feb 2009 03:50:26 -0000 1.286 +++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java 31 Mar 2009 19:07:38 -0000 @@ -146,7 +146,11 @@ //a single cache is required. If that happens to not be true, cache simply becomes less effective, //but we don't leak colours. Color[] selectionHighlightGradientColorsCache = null; //null is a legal value, check on access - + /* Colors for anti-aliasing */ + Color selectedOuterColor = null; + Color selectedInnerColor = null; + Color tabAreaColor = null; + /* Unselected item appearance */ Image bgImage; Color[] gradientColors; @@ -309,6 +313,7 @@ selectionForeground = display.getSystemColor(SELECTION_FOREGROUND); selectionBackground = display.getSystemColor(SELECTION_BACKGROUND); borderColor = display.getSystemColor(BORDER1_COLOR); + createAntialiasColors(); updateTabHeight(false); initAccessible(); @@ -498,7 +503,7 @@ addListener(SWT.Selection, typedListener); addListener(SWT.DefaultSelection, typedListener); } -void antialias (int[] shape, RGB lineRGB, RGB innerRGB, RGB outerRGB, GC gc){ +void antialias (int[] shape, Color innerColor, Color outerColor, GC gc){ // Don't perform anti-aliasing on Mac and WPF because the platform // already does it. The simple style also does not require anti-aliasing. if (simple) return; @@ -508,7 +513,7 @@ if ("wpf".equals(platform)) return; //$NON-NLS-1$ // Don't perform anti-aliasing on low resolution displays if (getDisplay().getDepth() < 15) return; - if (outerRGB != null) { + if (outerColor != null) { int index = 0; boolean left = true; int oldY = onBottom ? 0 : getSize().y; @@ -521,17 +526,10 @@ outer[index] = shape[index++] + (left ? -1 : +1); outer[index] = shape[index++]; } - RGB from = lineRGB; - RGB to = outerRGB; - int red = from.red + 2*(to.red - from.red)/3; - int green = from.green + 2*(to.green - from.green)/3; - int blue = from.blue + 2*(to.blue - from.blue)/3; - Color color = new Color(getDisplay(), red, green, blue); - gc.setForeground(color); + gc.setForeground(outerColor); gc.drawPolyline(outer); - color.dispose(); } - if (innerRGB != null) { + if (innerColor != null) { int[] inner = new int[shape.length]; int index = 0; boolean left = true; @@ -544,15 +542,8 @@ inner[index] = shape[index++] + (left ? +1 : -1); inner[index] = shape[index++]; } - RGB from = lineRGB; - RGB to = innerRGB; - int red = from.red + 2*(to.red - from.red)/3; - int green = from.green + 2*(to.green - from.green)/3; - int blue = from.blue + 2*(to.blue - from.blue)/3; - Color color = new Color(getDisplay(), red, green, blue); - gc.setForeground(color); + gc.setForeground(innerColor); gc.drawPolyline(inner); - color.dispose(); } } /* @@ -580,6 +571,47 @@ return new Rectangle (trimX, trimY, trimWidth, trimHeight); } } +void createAntialiasColors() { + disposeAntialiasColors(); + RGB lineRGB = CTabFolder.borderColor.getRGB(); + /* compute the selected color */ + RGB innerRGB = selectionBackground.getRGB(); + if (selectionBgImage != null || + (selectionGradientColors != null && selectionGradientColors.length > 1)) { + innerRGB = null; + } + RGB outerRGB = getBackground().getRGB(); + if (bgImage != null || + (gradientColors != null && gradientColors.length > 1)) { + outerRGB = null; + } + if (outerRGB != null) { + RGB from = lineRGB; + RGB to = outerRGB; + int red = from.red + 2*(to.red - from.red)/3; + int green = from.green + 2*(to.green - from.green)/3; + int blue = from.blue + 2*(to.blue - from.blue)/3; + selectedOuterColor = new Color(getDisplay(), red, green, blue); + } + if (innerRGB != null) { + RGB from = lineRGB; + RGB to = innerRGB; + int red = from.red + 2*(to.red - from.red)/3; + int green = from.green + 2*(to.green - from.green)/3; + int blue = from.blue + 2*(to.blue - from.blue)/3; + selectedInnerColor = new Color(getDisplay(), red, green, blue); + } + /* compute the tabArea color */ + outerRGB = getParent().getBackground().getRGB(); + if (outerRGB != null) { + RGB from = lineRGB; + RGB to = outerRGB; + int red = from.red + 2*(to.red - from.red)/3; + int green = from.green + 2*(to.green - from.green)/3; + int blue = from.blue + 2*(to.blue - from.blue)/3; + tabAreaColor = new Color(getDisplay(), red, green, blue); + } +} void createItem (CTabItem item, int index) { if (0 > index || index > getItemCount ())SWT.error (SWT.ERROR_INVALID_RANGE); item.parent = this; @@ -1163,8 +1195,7 @@ // Draw border line if (borderLeft > 0) { - RGB outside = getParent().getBackground().getRGB(); - antialias(shape, borderColor.getRGB(), null, outside, gc); + antialias(shape, null, tabAreaColor, gc); gc.setForeground(borderColor); gc.drawPolyline(shape); } @@ -1899,7 +1930,8 @@ selectionBackground = null; selectionForeground = null; - disposeSelectionHighlightGradientColors(); + disposeSelectionHighlightGradientColors(); + disposeAntialiasColors(); } void onDragDetect(Event event) { boolean consume = false; @@ -2472,6 +2504,7 @@ } public void setBackground (Color color) { super.setBackground(color); + createAntialiasColors(); redraw(); } /** @@ -2624,6 +2657,11 @@ bgImage = image; redraw(); } +public void setBackgroundImage(Image image) { + super.setBackgroundImage(image); + createAntialiasColors(); + redraw(); +} /** * Toggle the visibility of the border * @@ -3299,6 +3337,7 @@ if (selectionBackground == color) return; if (color == null) color = getDisplay().getSystemColor(SELECTION_BACKGROUND); selectionBackground = color; + createAntialiasColors(); if (selectedIndex > -1) redraw(); } /** @@ -3524,6 +3563,7 @@ disposeSelectionHighlightGradientColors(); } selectionBgImage = image; + createAntialiasColors(); if (selectedIndex > -1) redraw(); } /** @@ -3575,7 +3615,12 @@ selectionHighlightGradientColorsCache[i] = new Color(getDisplay(), red, green, blue); } } - +void disposeAntialiasColors() { + if (tabAreaColor != null) tabAreaColor.dispose(); + if (selectedInnerColor != null) selectedInnerColor.dispose(); + if (selectedOuterColor != null) selectedOuterColor.dispose(); + tabAreaColor = selectedInnerColor = selectedOuterColor = null; +} void disposeSelectionHighlightGradientColors() { if(selectionHighlightGradientColorsCache == null) return; Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java,v retrieving revision 1.112 diff -u -r1.112 CTabItem.java --- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java 24 Feb 2009 03:50:26 -0000 1.112 +++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java 31 Mar 2009 19:07:39 -0000 @@ -357,17 +357,7 @@ for (int i = 0; i < shape.length/2; i++) { if (shape[2*i + 1] == y + height + 1) shape[2*i + 1] -= 1; } - RGB inside = parent.selectionBackground.getRGB(); - if (parent.selectionBgImage != null || - (parent.selectionGradientColors != null && parent.selectionGradientColors.length > 1)) { - inside = null; - } - RGB outside = parent.getBackground().getRGB(); - if (parent.bgImage != null || - (parent.gradientColors != null && parent.gradientColors.length > 1)) { - outside = null; - } - parent.antialias(shape, CTabFolder.borderColor.getRGB(), inside, outside, gc); + parent.antialias(shape, parent.selectedInnerColor, parent.selectedOuterColor, gc); gc.setForeground(CTabFolder.borderColor); gc.drawPolyline(shape);