summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2007-08-31 21:00:32 +0000
committerFelipe Heidrich <fheidric>2007-08-31 21:00:32 +0000
commitb6e1dfbb6c67b65776d109a1647ed8268f4264ac (patch)
treeb872a8e19e49d92b834eb23508a88d1050424a42 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
parentfd48f1038f78b11a089cce1dff82a2e75ba45935 (diff)
downloadeclipse.platform.swt-b6e1dfbb6c67b65776d109a1647ed8268f4264ac.tar.gz
eclipse.platform.swt-b6e1dfbb6c67b65776d109a1647ed8268f4264ac.tar.xz
eclipse.platform.swt-b6e1dfbb6c67b65776d109a1647ed8268f4264ac.zip
Bug 201326 - computeSize on empty Link widget returns 0 for height
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java27
1 files changed, 17 insertions, 10 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 431c44d5ca..52133624b6 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
@@ -134,16 +134,23 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
int /*long*/ hDC = OS.GetDC (handle);
int /*long*/ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
int /*long*/ oldFont = OS.SelectObject (hDC, newFont);
- TCHAR buffer = new TCHAR (getCodePage (), parse (text), false);
- RECT rect = new RECT ();
- int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
- if (wHint != SWT.DEFAULT) {
- flags |= OS.DT_WORDBREAK;
- rect.right = wHint;
- }
- OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
- width = rect.right - rect.left;
- height = rect.bottom;
+ if (text.length () > 0) {
+ TCHAR buffer = new TCHAR (getCodePage (), parse (text), false);
+ RECT rect = new RECT ();
+ int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
+ if (wHint != SWT.DEFAULT) {
+ flags |= OS.DT_WORDBREAK;
+ rect.right = wHint;
+ }
+ OS.DrawText (hDC, buffer, buffer.length (), rect, flags);
+ width = rect.right - rect.left;
+ height = rect.bottom;
+ } else {
+ TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW () : new TEXTMETRICA ();
+ OS.GetTextMetrics (hDC, lptm);
+ width = 0;
+ height = lptm.tmHeight;
+ }
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
} else {