diff options
| author | Snjezana Peco | 2015-03-20 21:14:52 +0000 |
|---|---|---|
| committer | Alexander Kurtakov | 2015-03-25 06:40:42 +0000 |
| commit | 01234cea8bf0b04b381a8eb47a28ba41d0fd4c3e (patch) | |
| tree | a354fe496308c72cb01b5ed1290642cfdfd41a9f | |
| parent | 09ffd39885e9fefd9e005f5708df6fb05c84a722 (diff) | |
| download | eclipse.platform.swt-01234cea8bf0b04b381a8eb47a28ba41d0fd4c3e.tar.gz eclipse.platform.swt-01234cea8bf0b04b381a8eb47a28ba41d0fd4c3e.tar.xz eclipse.platform.swt-01234cea8bf0b04b381a8eb47a28ba41d0fd4c3e.zip | |
Bug 446075 - [GTK3] [GTK 3.10] Garbled bold text when used with icons
The patch fixes drawing issues with GTK3 in SWT.
See https://developer.gnome.org/gtk3/stable/ch25s02.html#id-1.6.3.4.11
Change-Id: Ie949c147e640760f011d9ab3f9f280e49ce4bc73
Signed-off-by: Snjezana Peco <snjeza.peco@gmail.com>
3 files changed, 44 insertions, 61 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index 53cfb92198..7e27ee27ee 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -3438,6 +3438,9 @@ public void setClipping(Path path) { */ public void setClipping(Rectangle rect) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0)) { + return; + } if (rect == null) { setClipping(0); } else { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index d56c9b60fc..079812e8c6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -11,28 +11,12 @@ package org.eclipse.swt.widgets; -import org.eclipse.swt.SWT; -import org.eclipse.swt.SWTException; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.internal.Converter; -import org.eclipse.swt.internal.ImageList; -import org.eclipse.swt.internal.cairo.Cairo; -import org.eclipse.swt.internal.gtk.GdkColor; -import org.eclipse.swt.internal.gtk.GdkEventButton; -import org.eclipse.swt.internal.gtk.GdkEventExpose; -import org.eclipse.swt.internal.gtk.GdkRGBA; -import org.eclipse.swt.internal.gtk.GdkRectangle; -import org.eclipse.swt.internal.gtk.GtkAllocation; -import org.eclipse.swt.internal.gtk.GtkCellRendererClass; -import org.eclipse.swt.internal.gtk.GtkRequisition; -import org.eclipse.swt.internal.gtk.OS; +import org.eclipse.swt.*; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.cairo.*; +import org.eclipse.swt.internal.gtk.*; /** * Instances of this class implement a selectable user interface @@ -2679,7 +2663,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo Cairo.cairo_restore (cr); } } - GC gc = new GC (this); + GC gc = getGC(cr); if ((drawState & SWT.SELECTED) != 0) { gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); @@ -2689,7 +2673,9 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } gc.setFont (item.getFont (columnIndex)); if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x; - gc.setClipping (rect.x, rect.y, rect.width, rect.height); + if (!OS.GTK3) { + gc.setClipping (rect.x, rect.y, rect.width, rect.height); + } Event event = new Event (); event.item = item; event.index = columnIndex; @@ -2702,11 +2688,6 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo sendEvent (SWT.EraseItem, event); drawForeground = null; drawState = event.doit ? event.detail : 0; - // A temporary fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=427480 - // Force native painting - if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0)) { - drawState |= SWT.FOREGROUND; - } drawFlags &= ~(OS.GTK_CELL_RENDERER_FOCUSED | OS.GTK_CELL_RENDERER_SELECTED); if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED; if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED; @@ -2735,7 +2716,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } } if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) { - GC gc = new GC (this); + GC gc = getGC(cr); gc.setBackground (item.getBackground (columnIndex)); GdkRectangle rect = new GdkRectangle (); OS.memmove (rect, background_area, GdkRectangle.sizeof); @@ -2775,7 +2756,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } contentX [0] -= imageWidth; contentWidth [0] += imageWidth; - GC gc = new GC (this); + GC gc = getGC(cr); if ((drawState & SWT.SELECTED) != 0) { Color background, foreground; if (OS.gtk_widget_has_focus (handle) || OS.GTK3) { @@ -2816,6 +2797,18 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } } +private GC getGC(long cr) { + GC gc; + if (OS.GTK3){ + GCData gcData = new GCData(); + gcData.cairo = cr; + gc = GC.gtk_new(this, gcData ); + } else { + gc = new GC (this); + } + return gc; +} + void resetCustomDraw () { if ((style & SWT.VIRTUAL) != 0 || ownerDraw) return; int end = Math.max (1, columnCount); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index cba9dfa2ee..9487206d1c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -2687,14 +2687,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } } } - GC gc; - if (OS.GTK3){ - GCData gcData = new GCData(); - gcData.cairo = cr; - gc = GC.gtk_new(this, gcData ); - } else { - gc = new GC (this); - } + GC gc = getGC(cr); if ((drawState & SWT.SELECTED) != 0) { gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); @@ -2720,9 +2713,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo sendEvent (SWT.EraseItem, event); drawForeground = null; drawState = event.doit ? event.detail : 0; - // A temporary fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=427480 - // Force native painting - if (OS.GTK3) { + if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { drawState |= SWT.FOREGROUND; } drawFlags &= ~(OS.GTK_CELL_RENDERER_FOCUSED | OS.GTK_CELL_RENDERER_SELECTED); @@ -2744,14 +2735,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) { - GC gc; - if (OS.GTK3){ - GCData gcData = new GCData(); - gcData.cairo = cr; - gc = GC.gtk_new(this, gcData ); - } else { - gc = new GC (this); - } + GC gc = getGC(cr); gc.setBackground (item.getBackground (columnIndex)); GdkRectangle rect = new GdkRectangle (); OS.memmove (rect, background_area, GdkRectangle.sizeof); @@ -2793,14 +2777,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } contentX [0] -= imageWidth; contentWidth [0] += imageWidth; - GC gc; - if (OS.GTK3){ - GCData gcData = new GCData(); - gcData.cairo = cr; - gc = GC.gtk_new(this, gcData ); - } else { - gc = new GC(this); - } + GC gc = getGC(cr); if ((drawState & SWT.SELECTED) != 0) { Color background, foreground; if (OS.gtk_widget_has_focus (handle) || OS.GTK3) { @@ -2841,9 +2818,7 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo event.width = contentWidth [0]; event.height = rect.height; event.detail = drawState; - // Temporary fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=427480 - // Force native paint - if (!OS.GTK3) { + if (OS.GTK_VERSION > OS.VERSION(3, 14, 8)) { sendEvent (SWT.PaintItem, event); } gc.dispose(); @@ -2852,6 +2827,18 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo } } +private GC getGC(long cr) { + GC gc; + if (OS.GTK3){ + GCData gcData = new GCData(); + gcData.cairo = cr; + gc = GC.gtk_new(this, gcData ); + } else { + gc = new GC (this); + } + return gc; +} + void resetCustomDraw () { if ((style & SWT.VIRTUAL) != 0 || ownerDraw) return; int end = Math.max (1, columnCount); |
