Commit aa9602db authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Implement horizontal alignment in GdipDrawString.

parent 3ca49a10
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment