Vincent Povirk : user32: Invert y in DrawTextEx in GM_COMPATIBLE mode if y increases up.
Alexandre Julliard
julliard at winehq.org
Mon Sep 28 11:54:35 CDT 2009
Module: wine
Branch: master
Commit: d1099eb4d819494e2fcfe0a3d7a1a6cd6a4d766f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d1099eb4d819494e2fcfe0a3d7a1a6cd6a4d766f
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Fri Sep 25 16:55:45 2009 -0500
user32: Invert y in DrawTextEx in GM_COMPATIBLE mode if y increases up.
---
dlls/user32/tests/text.c | 2 +-
dlls/user32/text.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c
index 080e5dd..88ea6b5 100644
--- a/dlls/user32/tests/text.c
+++ b/dlls/user32/tests/text.c
@@ -80,7 +80,7 @@ static void test_DrawTextCalcRect(void)
ok( textheight, "DrawTextA error %u\n", GetLastError());
trace("MM_HIENGLISH rect.bottom %d\n", rect.bottom);
- todo_wine ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
+ ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
"DT_CALCRECT should return a negative rectangle bottom. "
"(bot=%d)\n", rect.bottom);
diff --git a/dlls/user32/text.c b/dlls/user32/text.c
index b8aad0b..e34877f 100644
--- a/dlls/user32/text.c
+++ b/dlls/user32/text.c
@@ -855,6 +855,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
int tabwidth /* to keep gcc happy */ = 0;
int prefix_offset;
ellipsis_data ellip;
+ int invert_y=0;
TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count,
wine_dbgstr_rect(rect), flags);
@@ -898,6 +899,15 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
}
}
+ if (GetGraphicsMode(hdc) == GM_COMPATIBLE)
+ {
+ SIZE window_ext, viewport_ext;
+ GetWindowExtEx(hdc, &window_ext);
+ GetViewportExtEx(hdc, &viewport_ext);
+ if ((window_ext.cy > 0) != (viewport_ext.cy > 0))
+ invert_y = 1;
+ }
+
if (dtp)
{
lmargin = dtp->iLeftMargin;
@@ -932,7 +942,10 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
do
{
len = sizeof(line)/sizeof(line[0]);
- last_line = !(flags & DT_NOCLIP) && y + ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) > rect->bottom;
+ if (invert_y)
+ last_line = !(flags & DT_NOCLIP) && y - ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) < rect->bottom;
+ else
+ last_line = !(flags & DT_NOCLIP) && y + ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) > rect->bottom;
strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags, &size, last_line, &p_retstr, tabwidth, &prefix_offset, &ellip);
if (flags & DT_CENTER) x = (rect->left + rect->right -
@@ -1001,7 +1014,10 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
else if (size.cx > max_width)
max_width = size.cx;
- y += lh;
+ if (invert_y)
+ y -= lh;
+ else
+ y += lh;
if (dtp)
dtp->uiLengthDrawn += len;
}
More information about the wine-cvs
mailing list