[2/2] gdiplus: Draw hotkey underlines in GdipDrawString. (try 2)

Vincent Povirk madewokherd at gmail.com
Mon Mar 26 11:00:27 CDT 2012


The previous patch had an error in calculating the x position of underlines.
-------------- next part --------------
From cb8836bd85781b20f67c91b3fecadb32f8f930bb Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 21 Mar 2012 14:09:27 -0500
Subject: [PATCH 2/3] gdiplus: Draw hotkey underlines in GdipDrawString.

---
 dlls/gdiplus/graphics.c |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index c5ac9d1..89ed61b 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -5038,16 +5038,43 @@ static GpStatus draw_string_callback(HDC hdc,
 {
     struct draw_string_args *args = user_data;
     PointF position;
-
-    if (underlined_index_count)
-        FIXME("hotkey underlines not drawn yet\n");
+    GpStatus stat;
 
     position.X = args->x + bounds->X / args->rel_width;
     position.Y = args->y + bounds->Y / args->rel_height + args->ascent;
 
-    return GdipDrawDriverString(args->graphics, &string[index], length, font,
+    stat = GdipDrawDriverString(args->graphics, &string[index], length, font,
         args->brush, &position,
         DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance, NULL);
+
+    if (stat == Ok && underlined_index_count)
+    {
+        OUTLINETEXTMETRICW otm;
+        REAL underline_y, underline_height;
+        int i;
+
+        GetOutlineTextMetricsW(hdc, sizeof(otm), &otm);
+
+        underline_height = otm.otmsUnderscoreSize / args->rel_height;
+        underline_y = position.Y - otm.otmsUnderscorePosition / args->rel_height - underline_height / 2;
+
+        for (i=0; i<underlined_index_count; i++)
+        {
+            REAL start_x, end_x;
+            SIZE text_size;
+            INT ofs = underlined_indexes[i] - index;
+
+            GetTextExtentExPointW(hdc, string + index, ofs, INT_MAX, NULL, NULL, &text_size);
+            start_x = text_size.cx / args->rel_width;
+
+            GetTextExtentExPointW(hdc, string + index, ofs+1, INT_MAX, NULL, NULL, &text_size);
+            end_x = text_size.cx / args->rel_width;
+
+            GdipFillRectangle(args->graphics, (GpBrush*)args->brush, position.X+start_x, underline_y, end_x-start_x, underline_height);
+        }
+    }
+
+    return stat;
 }
 
 GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string,
-- 
1.7.9.1


More information about the wine-patches mailing list