From 2ef1ba106bcaeb047325283ddddc50ae62343a39 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 29 Jun 2009 16:36:11 -0500 Subject: [PATCH] gdiplus: implement horizontal alignment in GdipDrawString --- dlls/gdiplus/graphics.c | 30 +++++++++++++++++++++++++----- 1 files changed, 25 insertions(+), 5 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index c052bc3..152d590 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2098,6 +2098,8 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string INT sum = 0, height = 0, offsety = 0, fit, fitcpy, save_state, i, j, lret, nwidth, nheight; SIZE size; + POINT drawbase; + UINT drawflags; RECT drawcoord; TRACE("(%p, %s, %i, %p, %s, %p, %p)\n", graphics, debugstr_wn(string, length), @@ -2207,17 +2209,35 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string length = j; + if (format->align == StringAlignmentNear) + { + drawbase.x = corners[0].x; + drawbase.y = corners[0].y; + drawflags = DT_NOCLIP | DT_EXPANDTABS; + } + else if (format->align == StringAlignmentCenter) + { + drawbase.x = (corners[0].x + corners[1].x)/2; + drawbase.y = (corners[0].y + corners[1].y)/2; + drawflags = DT_NOCLIP | DT_EXPANDTABS | DT_CENTER; + } + else /* (format->align == StringAlignmentFar) */ + { + drawbase.x = corners[1].x; + drawbase.y = corners[1].y; + drawflags = DT_NOCLIP | DT_EXPANDTABS | DT_RIGHT; + } + while(sum < length){ - drawcoord.left = corners[0].x + roundr(ang_sin * (REAL) height); - drawcoord.top = corners[0].y + roundr(ang_cos * (REAL) height); + drawcoord.left = drawcoord.right = drawbase.x + roundr(ang_sin * (REAL) height); + drawcoord.top = drawcoord.bottom = drawbase.y + roundr(ang_cos * (REAL) height); GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum, nwidth, &fit, NULL, &size); fitcpy = fit; if(fit == 0){ - DrawTextW(graphics->hdc, stringdup + sum, 1, &drawcoord, DT_NOCLIP | - DT_EXPANDTABS); + DrawTextW(graphics->hdc, stringdup + sum, 1, &drawcoord, drawflags); break; } @@ -2246,7 +2266,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string } } DrawTextW(graphics->hdc, stringdup + sum, min(length - sum, fit), - &drawcoord, DT_NOCLIP | DT_EXPANDTABS); + &drawcoord, drawflags); sum += fit + (lret < fitcpy ? 1 : 0); height += size.cy; -- 1.5.4.3