diff options
| author | Markus Keller | 2016-03-10 19:44:25 +0000 |
|---|---|---|
| committer | Markus Keller | 2016-03-10 19:44:25 +0000 |
| commit | 4ff972b78809d2996835d862e322900e0334ebc9 (patch) | |
| tree | 74b8bb02472faab5c055297c31d69c22364422c5 | |
| parent | 7aca04f4ccb049797b37383ffdf0e9ff879d4bfc (diff) | |
| download | eclipse.platform.swt-4ff972b78809d2996835d862e322900e0334ebc9.tar.gz eclipse.platform.swt-4ff972b78809d2996835d862e322900e0334ebc9.tar.xz eclipse.platform.swt-4ff972b78809d2996835d862e322900e0334ebc9.zip | |
Bug 399786: Fixes for overflowing Tree/Table labels with owner draw.
Workarounds/documentation for bad code from bug 446075, see comment 69.
4 files changed, 27 insertions, 10 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 087cf62ad4..c7ae51f567 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 @@ -15,6 +15,7 @@ import org.eclipse.swt.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; +import org.eclipse.swt.widgets.*; /** * Class <code>GC</code> is where all of the drawing capabilities that are @@ -3455,7 +3456,7 @@ void setClipping(long /*int*/ clipRgn) { */ public void setClipping(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setClipping(new Rectangle(x, y, width, height)); + setClippingInPixels(DPIUtil.autoScaleUp(x), DPIUtil.autoScaleUp(y), DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height)); } void setClippingInPixels(int x, int y, int width, int height) { if (width < 0) { @@ -3536,8 +3537,8 @@ public void setClipping(Rectangle rect) { setClippingInPixels(DPIUtil.autoScaleUp(rect)); } void setClippingInPixels(Rectangle rect) { - if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0)) { - return; + if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && (drawable instanceof Tree || drawable instanceof Table)) { + return; //FIXME: This is an atrocious hack for bug 446075 } if (rect == null) { setClipping(0); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index d8a608775b..ed36380842 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -3359,7 +3359,9 @@ long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) { data.cairo = cairo; } GC gc = event.gc = GC.gtk_new (this, data); - gc.setClipping (DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height))); + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping (rect2.x, rect2.y, rect2.width, rect2.height); drawWidget (gc); sendEvent (SWT.Paint, event); gc.dispose (); 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 f3c3a8b170..de152e7918 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 @@ -2793,13 +2793,17 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) { GdkRectangle r = new GdkRectangle(); OS.gdk_cairo_get_clip_rectangle(cr, r); - gc.setClipping(DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height))); + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { rect.width = r.width; } } else { - gc.setClipping(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height))); + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); } Event event = new Event (); @@ -2917,7 +2921,11 @@ 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(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height))); + + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + Event event = new Event (); event.item = item; event.index = columnIndex; 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 ecd1194969..657a074fb4 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 @@ -2818,12 +2818,16 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) { GdkRectangle r = new GdkRectangle(); OS.gdk_cairo_get_clip_rectangle(cr, r); - gc.setClipping(DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height))); + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, r.y, r.width, r.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { rect.width = r.width; } } else { - gc.setClipping(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height))); + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); } Event event = new Event (); event.item = item; @@ -2934,7 +2938,9 @@ void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, lo rect.x = getClientWidth () - rect.width - rect.x; } - gc.setClipping(DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height))); + Rectangle rect2 = DPIUtil.autoScaleDown(new Rectangle(rect.x, rect.y, rect.width, rect.height)); + // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 + gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); Event event = new Event (); event.item = item; |
