Author: akhaldi Date: Sat Apr 25 09:50:09 2015 New Revision: 67388
URL: http://svn.reactos.org/svn/reactos?rev=67388&view=rev Log: [USER32] Sync DrawTextExW() with Wine Staging 1.7.37. CORE-9246 CORE-9585
Modified: trunk/reactos/win32ss/user/user32/windows/font.c
Modified: trunk/reactos/win32ss/user/user32/windows/font.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/windows... ============================================================================== --- trunk/reactos/win32ss/user/user32/windows/font.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/font.c [iso-8859-1] Sat Apr 25 09:50:09 2015 @@ -1096,7 +1096,7 @@ /* * @implemented * - * Synced with wine 1.1.32 + * Synced with Wine Staging 1.7.37 */ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count, LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp ) @@ -1116,12 +1116,12 @@ int tabwidth /* to keep gcc happy */ = 0; int prefix_offset; ellipsis_data ellip; - int invert_y=0; + BOOL invert_y=FALSE;
TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count, wine_dbgstr_rect(rect), flags);
- if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n", + if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n", dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
if (!str) return 0; @@ -1143,6 +1143,15 @@ if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS)) return 0;
+ 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 = TRUE; + } + if (count == -1) { count = strlenW(str); @@ -1152,21 +1161,12 @@ { rect->right = rect->left; if( flags & DT_SINGLELINE) - rect->bottom = rect->top + lh; + rect->bottom = rect->top + (invert_y ? -lh : lh); else rect->bottom = rect->top; } return lh; } - } - - 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) @@ -1215,9 +1215,10 @@
if (flags & DT_SINGLELINE) { - if (flags & DT_VCENTER) y = rect->top + - (rect->bottom - rect->top) / 2 - size.cy / 2; - else if (flags & DT_BOTTOM) y = rect->bottom - size.cy; + if (flags & DT_VCENTER) + y = rect->top + (rect->bottom - rect->top) / 2 + (invert_y ? (size.cy / 2) : (-size.cy / 2)); + else if (flags & DT_BOTTOM) + y = rect->bottom + (invert_y ? 0 : -size.cy); }
if (!(flags & DT_CALCRECT)) @@ -1234,7 +1235,10 @@ p = str; while (p < str+len && *p != TAB) p++; len_seg = p - str; if (len_seg != len && !GetTextExtentPointW(hdc, str, len_seg, &size)) + { + HeapFree (GetProcessHeap(), 0, retstr); return 0; + } } else len_seg = len; @@ -1242,7 +1246,11 @@ if (!ExtTextOutW( hdc, xseg, y, ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) | ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0), - rect, str, len_seg, NULL )) return 0; + rect, str, len_seg, NULL )) + { + HeapFree (GetProcessHeap(), 0, retstr); + return 0; + } if (prefix_offset != -1 && prefix_offset < len_seg) { TEXT_DrawUnderscore (hdc, xseg, y + tm.tmAscent + 1, str, prefix_offset, (flags & DT_NOCLIP) ? NULL : rect); @@ -1271,14 +1279,11 @@ } } } - } - else if (size.cx > max_width) - max_width = size.cx; - - if (invert_y) - y -= lh; - else - y += lh; + } + else if (size.cx > max_width) + max_width = size.cx; + + y += invert_y ? -lh : lh; if (dtp) dtp->uiLengthDrawn += len; }