Vincent Povirk : gdiplus: Implement horizontal alignment in GdipDrawString.

Alexandre Julliard julliard at winehq.org
Tue Jun 30 08:33:28 CDT 2009


Module: wine
Branch: master
Commit: aa9602db10f337f39ab93bf17a9da3203d14376e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=aa9602db10f337f39ab93bf17a9da3203d14376e

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Jun 29 16:36:11 2009 -0500

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;




More information about the wine-cvs mailing list