[2/2] gdiplus: Draw hotkey underlines in GdipDrawString.
Vincent Povirk
madewokherd at gmail.com
Wed Mar 21 14:25:15 CDT 2012
-------------- next part --------------
From 04ebc807e58dc8aeeb47d7fe42bb0bc6b15d2fe1 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/2] 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 f5866b3..1999543 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -5032,16 +5032,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, 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