summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRaymond Lam2012-01-13 17:48:33 (EST)
committer Felipe Heidrich2012-01-16 10:49:16 (EST)
commitb747b5e801b78693ad8d6192111f35e244194b77 (patch)
tree009370ec1d7ddefe93aa5fbf5e7fa4ebc71474df
parent9d4061daafc695514476ce33dd01c3ee3d9c6368 (diff)
downloadeclipse.platform.swt-b747b5e801b78693ad8d6192111f35e244194b77.zip
eclipse.platform.swt-b747b5e801b78693ad8d6192111f35e244194b77.tar.gz
eclipse.platform.swt-b747b5e801b78693ad8d6192111f35e244194b77.tar.bz2
Draw underlining of Link using logical fonts.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index 38486f0..b755b99 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -264,10 +264,19 @@ void drawBufferredTextRun(int /*long*/ targetDC, String parsedText, int runStart
boolean underline = false;
TextStyle style = layout.getStyle(runStart);
if (style != null) {
- color = style.foreground.handle;
+ if (style.foreground != null) {
+ color = style.foreground.handle;
+ }
underline = style.underline;
}
+ if (underline) {
+ LOGFONT logFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW () : new LOGFONTA ();
+ OS.GetObject(hFont, LOGFONT.sizeof, logFont);
+ logFont.lfUnderline = 0x01;
+ hFont = OS.CreateFontIndirect(logFont);
+ }
+
Rectangle bounds = layout.getBounds(runStart, runEnd-1);
String runText = parsedText.substring(runStart, runEnd);
TCHAR runBuffer = new TCHAR (getCodePage (), runText, true);
@@ -280,12 +289,7 @@ void drawBufferredTextRun(int /*long*/ targetDC, String parsedText, int runStart
drawBufferredText(targetDC, runBuffer, drawRect, hFont, color, 0);
if (underline) {
- TEXTMETRIC tm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
- OS.GetTextMetrics(targetDC, tm);
- int underlineY = drawRect.bottom - tm.tmDescent;
-
- OS.MoveToEx(targetDC, drawRect.left, underlineY, 0);
- OS.LineTo(targetDC, drawRect.right, underlineY);
+ OS.DeleteObject(hFont);
}
}