From de39ec30a29f6ea7488b95a176a7772391db46ae Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Wed, 20 Jun 2012 16:35:23 -0400 Subject: drawText does not respect background pattern --- .../cocoa/org/eclipse/swt/graphics/GC.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java index 9c64c31ece..451e4074c3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java @@ -1691,14 +1691,21 @@ public void drawText (String string, int x, int y, int flags) { NSRect rect = data.layoutManager.usedRectForTextContainer(data.textContainer); rect.x = x; rect.y = y; - NSColor bg = data.bg; - if (bg == null) { - float /*double*/ [] color = data.background; - bg = data.bg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); - bg.retain(); + Pattern pattern = data.backgroundPattern; + if (pattern != null) setPatternPhase(pattern); + if (pattern != null && pattern.gradient != null) { + NSBezierPath path = NSBezierPath.bezierPathWithRect(rect); + fillPattern(path, pattern); + } else { + NSColor bg = data.bg; + if (bg == null) { + float /*double*/ [] color = data.background; + bg = data.bg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); + bg.retain(); + } + bg.setFill(); + NSBezierPath.fillRect(rect); } - bg.setFill(); - NSBezierPath.fillRect(rect); } data.layoutManager.drawGlyphsForGlyphRange(range, pt); handle.restoreGraphicsState(); -- cgit