diff options
| author | Raymond Lam | 2012-01-13 22:48:33 +0000 |
|---|---|---|
| committer | Felipe Heidrich | 2012-01-16 15:49:16 +0000 |
| commit | b747b5e801b78693ad8d6192111f35e244194b77 (patch) | |
| tree | 009370ec1d7ddefe93aa5fbf5e7fa4ebc71474df | |
| parent | 9d4061daafc695514476ce33dd01c3ee3d9c6368 (diff) | |
| download | eclipse.platform.swt-b747b5e801b78693ad8d6192111f35e244194b77.tar.gz eclipse.platform.swt-b747b5e801b78693ad8d6192111f35e244194b77.tar.xz eclipse.platform.swt-b747b5e801b78693ad8d6192111f35e244194b77.zip | |
Draw underlining of Link using logical fonts.
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java | 18 |
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 38486f002a..b755b99124 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); } } |
