user32: Invert y in DrawTextEx in GM_COMPATIBLE mode if y increases up.

This commit is contained in:
Vincent Povirk 2009-09-25 16:55:45 -05:00 committed by Alexandre Julliard
parent 575ee0bb4e
commit d1099eb4d8
2 changed files with 19 additions and 3 deletions

View File

@ -80,7 +80,7 @@ static void test_DrawTextCalcRect(void)
ok( textheight, "DrawTextA error %u\n", GetLastError()); ok( textheight, "DrawTextA error %u\n", GetLastError());
trace("MM_HIENGLISH rect.bottom %d\n", rect.bottom); 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. " "DT_CALCRECT should return a negative rectangle bottom. "
"(bot=%d)\n", rect.bottom); "(bot=%d)\n", rect.bottom);

View File

@ -855,6 +855,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
int tabwidth /* to keep gcc happy */ = 0; int tabwidth /* to keep gcc happy */ = 0;
int prefix_offset; int prefix_offset;
ellipsis_data ellip; ellipsis_data ellip;
int invert_y=0;
TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count, TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count,
wine_dbgstr_rect(rect), flags); 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) if (dtp)
{ {
lmargin = dtp->iLeftMargin; lmargin = dtp->iLeftMargin;
@ -932,7 +942,10 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
do do
{ {
len = sizeof(line)/sizeof(line[0]); 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); 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 - 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) else if (size.cx > max_width)
max_width = size.cx; max_width = size.cx;
y += lh; if (invert_y)
y -= lh;
else
y += lh;
if (dtp) if (dtp)
dtp->uiLengthDrawn += len; dtp->uiLengthDrawn += len;
} }