Fully implement DrawTextEx* functions.

This commit is contained in:
Travis Michielsen 2001-07-26 20:10:40 +00:00 committed by Alexandre Julliard
parent 40734af751
commit 188b32b73f
2 changed files with 69 additions and 58 deletions

View File

@ -225,8 +225,8 @@ INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT
* DrawTextExW (USER32.@) * DrawTextExW (USER32.@)
*/ */
#define MAX_STATIC_BUFFER 1024 #define MAX_STATIC_BUFFER 1024
INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count, INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp ) LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
{ {
SIZE size; SIZE size;
const WCHAR *strPtr; const WCHAR *strPtr;
@ -235,6 +235,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
int prefix_x = 0; int prefix_x = 0;
int prefix_end = 0; int prefix_end = 0;
TEXTMETRICW tm; TEXTMETRICW tm;
int lmargin = 0, rmargin = 0;
int x = rect->left, y = rect->top; int x = rect->left, y = rect->top;
int width = rect->right - rect->left; int width = rect->right - rect->left;
int max_width = 0; int max_width = 0;
@ -242,10 +243,8 @@ INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str, count), count, TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str, count), count,
rect->left, rect->top, rect->right, rect->bottom); rect->left, rect->top, rect->right, rect->bottom);
if(dtp) { if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
FIXME("Ignores params:%d,%d,%d,%d\n", dtp->cbSize, dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
}
if (!str) return 0; if (!str) return 0;
if (count == -1) count = strlenW(str); if (count == -1) count = strlenW(str);
@ -258,8 +257,17 @@ INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
else else
lh = tm.tmHeight; lh = tm.tmHeight;
if (dtp)
{
lmargin = dtp->iLeftMargin * tm.tmAveCharWidth;
rmargin = dtp->iRightMargin * tm.tmAveCharWidth;
if (!(flags & (DT_CENTER | DT_RIGHT)))
x += lmargin;
dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */
}
if (flags & DT_TABSTOP) if (flags & DT_TABSTOP)
tabstop = flags >> 8; tabstop = dtp ? dtp->iTabLength : flags >> 8;
if (flags & DT_EXPANDTABS) if (flags & DT_EXPANDTABS)
{ {
@ -320,10 +328,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
line[totalLen] = '\0'; line[totalLen] = '\0';
lastBkSlash = strrchrW(line, BACK_SLASHW[0]); lastBkSlash = strrchrW(line, BACK_SLASHW[0]);
lastFwdSlash = strrchrW(line, FORWARD_SLASHW[0]); lastFwdSlash = strrchrW(line, FORWARD_SLASHW[0]);
fnameDelim = lastFwdSlash ? lastFwdSlash : lastBkSlash; fnameDelim = lastBkSlash > lastFwdSlash ? lastBkSlash : lastFwdSlash;
if (lastBkSlash && lastFwdSlash) /* which is last? */
if (lastBkSlash > lastFwdSlash)
fnameDelim = lastBkSlash;
if (fnameDelim) if (fnameDelim)
fnameLen = &line[totalLen] - fnameDelim; fnameLen = &line[totalLen] - fnameDelim;
@ -382,12 +387,15 @@ INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
line[len] = '\0'; line[len] = '\0';
strPtr = NULL; strPtr = NULL;
} }
if (flags & DT_MODIFYSTRING)
strcpyW(str, swapStr);
} }
} }
if (!(flags & DT_CALCRECT)) if (!(flags & DT_CALCRECT))
{ {
if (!ExtTextOutW(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED, if (!ExtTextOutW( hdc, x, y,
rect, line, len, NULL )) return 0; ( (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED ) | ( (flags & DT_RTLREADING) ? 0 : ETO_RTLREADING ),
rect, line, len, NULL )) return 0;
if (prefix_offset != -1) if (prefix_offset != -1)
{ {
HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) ); HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
@ -410,20 +418,26 @@ INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
break; break;
} }
} }
if (dtp)
dtp->uiLengthDrawn += len;
} }
while (strPtr); while (strPtr);
if (flags & DT_CALCRECT) if (flags & DT_CALCRECT)
{ {
rect->right = rect->left + max_width; rect->right = rect->left + max_width;
rect->bottom = y; rect->bottom = y;
if (dtp)
rect->right += lmargin + rmargin;
} }
return y - rect->top; return y - rect->top;
} }
/*********************************************************************** /***********************************************************************
* DrawTextA (USER32.@) * DrawTextExA (USER32.@)
*/ */
INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags ) INT WINAPI DrawTextExA( HDC hdc, LPSTR str, INT count,
LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
{ {
WCHAR *wstr; WCHAR *wstr;
INT ret = 0; INT ret = 0;
@ -437,6 +451,8 @@ INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
{ {
MultiByteToWideChar( CP_ACP, 0, str, count, wstr, wcount ); MultiByteToWideChar( CP_ACP, 0, str, count, wstr, wcount );
ret = DrawTextExW( hdc, wstr, wcount, rect, flags, NULL ); ret = DrawTextExW( hdc, wstr, wcount, rect, flags, NULL );
if (flags & DT_MODIFYSTRING)
WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, count, NULL, NULL );
HeapFree(GetProcessHeap(), 0, wstr); HeapFree(GetProcessHeap(), 0, wstr);
} }
return ret; return ret;
@ -445,24 +461,17 @@ INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
/*********************************************************************** /***********************************************************************
* DrawTextW (USER32.@) * DrawTextW (USER32.@)
*/ */
INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
LPRECT rect, UINT flags )
{ {
return DrawTextExW(hdc, str, count, rect, flags, NULL); return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, NULL);
} }
/*********************************************************************** /***********************************************************************
* DrawTextExA (USER32.@) * DrawTextA (USER32.@)
*/ */
INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count, INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
{ {
TRACE("(%d,%s,%d,%p,0x%08x,%p)\n",hdc,debugstr_an(str,count),count,rect,flags,dtp); return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, NULL );
if(dtp) {
FIXME("Ignores params:%d,%d,%d,%d\n",dtp->cbSize,
dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin);
}
return DrawTextA(hdc,str,count,rect,flags);
} }
/*********************************************************************** /***********************************************************************

View File

@ -3499,30 +3499,32 @@ BOOL WINAPI DrawCaption(HWND,HDC,const RECT*,UINT);
BOOL WINAPI DrawCaptionTempA(HWND,HDC,const RECT*,HFONT,HICON,LPCSTR,UINT); BOOL WINAPI DrawCaptionTempA(HWND,HDC,const RECT*,HFONT,HICON,LPCSTR,UINT);
BOOL WINAPI DrawCaptionTempW(HWND,HDC,const RECT*,HFONT,HICON,LPCWSTR,UINT); BOOL WINAPI DrawCaptionTempW(HWND,HDC,const RECT*,HFONT,HICON,LPCWSTR,UINT);
#define DrawCaptionTemp WINELIB_NAME_AW(DrawCaptionTemp) #define DrawCaptionTemp WINELIB_NAME_AW(DrawCaptionTemp)
BOOL WINAPI DrawEdge(HDC,LPRECT,UINT,UINT); BOOL WINAPI DrawEdge(HDC,LPRECT,UINT,UINT);
BOOL WINAPI DrawFocusRect(HDC,const RECT*); BOOL WINAPI DrawFocusRect(HDC,const RECT*);
BOOL WINAPI DrawFrameControl(HDC,LPRECT,UINT,UINT); BOOL WINAPI DrawFrameControl(HDC,LPRECT,UINT,UINT);
BOOL WINAPI DrawIcon(HDC,INT,INT,HICON); BOOL WINAPI DrawIcon(HDC,INT,INT,HICON);
BOOL WINAPI DrawIconEx(HDC,INT,INT,HICON,INT,INT, BOOL WINAPI DrawIconEx(HDC,INT,INT,HICON,INT,INT,UINT,HBRUSH,UINT);
UINT,HBRUSH,UINT); BOOL WINAPI DrawMenuBar(HWND);
BOOL WINAPI DrawMenuBar(HWND); BOOL WINAPI DrawStateA(HDC,HBRUSH,DRAWSTATEPROC,LPARAM,WPARAM,INT,INT,INT,INT,UINT);
BOOL WINAPI DrawStateA(HDC,HBRUSH,DRAWSTATEPROC,LPARAM,WPARAM,INT,INT,INT,INT,UINT); BOOL WINAPI DrawStateW(HDC,HBRUSH,DRAWSTATEPROC,LPARAM,WPARAM,INT,INT,INT,INT,UINT);
BOOL WINAPI DrawStateW(HDC,HBRUSH,DRAWSTATEPROC,LPARAM,WPARAM,INT,INT,INT,INT,UINT);
#define DrawState WINELIB_NAME_AW(DrawState) #define DrawState WINELIB_NAME_AW(DrawState)
INT WINAPI DrawTextA(HDC,LPCSTR,INT,LPRECT,UINT); INT WINAPI DrawTextA(HDC,LPCSTR,INT,LPRECT,UINT);
INT WINAPI DrawTextW(HDC,LPCWSTR,INT,LPRECT,UINT); INT WINAPI DrawTextW(HDC,LPCWSTR,INT,LPRECT,UINT);
#define DrawText WINELIB_NAME_AW(DrawText) #define DrawText WINELIB_NAME_AW(DrawText)
BOOL WINAPI EmptyClipboard(void); INT WINAPI DrawTextExA(HDC,LPSTR,INT,LPRECT,UINT,LPDRAWTEXTPARAMS);
UINT WINAPI EnableMenuItem(HMENU,UINT,UINT); INT WINAPI DrawTextExW(HDC,LPWSTR,INT,LPRECT,UINT,LPDRAWTEXTPARAMS);
BOOL WINAPI EnableScrollBar(HWND,INT,UINT); #define DrawTextEx WINELIB_NAME_AW(DrawTextEx)
BOOL WINAPI EnableWindow(HWND,BOOL); BOOL WINAPI EmptyClipboard(void);
BOOL WINAPI EndDeferWindowPos(HDWP); UINT WINAPI EnableMenuItem(HMENU,UINT,UINT);
BOOL WINAPI EndDialog(HWND,INT); BOOL WINAPI EnableScrollBar(HWND,INT,UINT);
BOOL WINAPI EndPaint(HWND,const PAINTSTRUCT*); BOOL WINAPI EnableWindow(HWND,BOOL);
BOOL WINAPI EnumChildWindows(HWND,WNDENUMPROC,LPARAM); BOOL WINAPI EndDeferWindowPos(HDWP);
UINT WINAPI EnumClipboardFormats(UINT); BOOL WINAPI EndDialog(HWND,INT);
INT WINAPI EnumPropsA(HWND,PROPENUMPROCA); BOOL WINAPI EndPaint(HWND,const PAINTSTRUCT*);
INT WINAPI EnumPropsW(HWND,PROPENUMPROCW); BOOL WINAPI EnumChildWindows(HWND,WNDENUMPROC,LPARAM);
UINT WINAPI EnumClipboardFormats(UINT);
INT WINAPI EnumPropsA(HWND,PROPENUMPROCA);
INT WINAPI EnumPropsW(HWND,PROPENUMPROCW);
#define EnumProps WINELIB_NAME_AW(EnumProps) #define EnumProps WINELIB_NAME_AW(EnumProps)
BOOL WINAPI EnumWindows(WNDENUMPROC,LPARAM); BOOL WINAPI EnumWindows(WNDENUMPROC,LPARAM);
BOOL WINAPI EnumWindowStationsA(WINSTAENUMPROCA,LPARAM); BOOL WINAPI EnumWindowStationsA(WINSTAENUMPROCA,LPARAM);