00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "winuser.h"
00014 #include "user32.h"
00015 #include "syscolor.h"
00016 #include <winnls.h>
00017
00018 #define DBG_LOCALLOG DBG_text
00019 #include "dbglocal.h"
00020
00021
00022
00023 INT WIN32API DrawTextA(HDC hDC,LPCSTR lpString,INT nCount,PRECT lpRect,UINT nFormat)
00024 {
00025 dprintf(("USER32: DrawTextA %x %s %d (%d,%d)(%d,%d) %x",hDC, lpString, nCount, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, nFormat));
00026
00027 return InternalDrawTextExA(hDC,lpString,nCount,lpRect,nFormat,NULL,FALSE);
00028 }
00029
00030
00031 INT WIN32API DrawTextW(HDC hDC,LPCWSTR lpString,INT nCount,PRECT lpRect,UINT nFormat)
00032 {
00033 dprintf(("USER32: DrawTextA %x %ls %d (%d,%d)(%d,%d) %x",hDC, lpString, nCount, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, nFormat));
00034
00035 return InternalDrawTextExW(hDC,lpString,nCount,lpRect,nFormat,NULL,FALSE);
00036 }
00037
00038
00039 INT WIN32API DrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams)
00040 {
00041 dprintf(("USER32: DrawTextExA %x %s %d (%d,%d)(%d,%d) %x",hdc, lpchText, cchText, lprc->left, lprc->top, lprc->right, lprc->bottom, dwDTFormat));
00042
00043 return InternalDrawTextExA(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE);
00044 }
00045
00046
00047 int WIN32API DrawTextExW(HDC hdc,LPWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams)
00048 {
00049 dprintf(("USER32: DrawTextExA %x %ls %d (%d,%d)(%d,%d) %x",hdc, lpchText, cchText, lprc->left, lprc->top, lprc->right, lprc->bottom, dwDTFormat));
00050
00051 return InternalDrawTextExW(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE);
00052 }
00053 #if 1
00054
00055
00056
00057
00058
00059
00060
00061
00062 static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
00063 INT count, INT cTabStops, const INT16 *lpTabPos16,
00064 const INT *lpTabPos32, INT nTabOrg,
00065 BOOL fDisplayText )
00066 {
00067 INT defWidth;
00068 SIZE extent;
00069 int i, tabPos = x;
00070 int start = x;
00071
00072 extent.cx = 0;
00073 extent.cy = 0;
00074
00075 if (cTabStops == 1)
00076 {
00077 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
00078 cTabStops = 0;
00079 }
00080 else
00081 {
00082 TEXTMETRICA tm;
00083 GetTextMetricsA( hdc, &tm );
00084 defWidth = 8 * tm.tmAveCharWidth;
00085 }
00086
00087 while (count > 0)
00088 {
00089 for (i = 0; i < count; i++)
00090 if (lpstr[i] == '\t') break;
00091 GetTextExtentPointA( hdc, lpstr, i, &extent );
00092 if (lpTabPos32)
00093 {
00094 while ((cTabStops > 0) &&
00095 (nTabOrg + *lpTabPos32 <= x + extent.cx))
00096 {
00097 lpTabPos32++;
00098 cTabStops--;
00099 }
00100 }
00101 else
00102 {
00103 while ((cTabStops > 0) &&
00104 (nTabOrg + *lpTabPos16 <= x + extent.cx))
00105 {
00106 lpTabPos16++;
00107 cTabStops--;
00108 }
00109 }
00110 if (i == count)
00111 tabPos = x + extent.cx;
00112 else if (cTabStops > 0)
00113 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
00114 else
00115 tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
00116 if (fDisplayText)
00117 {
00118 RECT r;
00119 r.left = x;
00120 r.top = y;
00121 r.right = tabPos;
00122 r.bottom = y + extent.cy;
00123 ExtTextOutA( hdc, x, y,
00124 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
00125 &r, lpstr, i, NULL );
00126 }
00127 x = tabPos;
00128 count -= i+1;
00129 lpstr += i+1;
00130 }
00131 return MAKELONG(tabPos - start, extent.cy);
00132 }
00133
00134
00135
00136
00137
00138
00139 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr, INT count,
00140 INT cTabStops, INT *lpTabPos, INT nTabOrg )
00141 {
00142 dprintf(("USER32: TabbedTextOutA %x (%d,%d) %s %d %d %x %d", hdc, x, y, lpstr, count, cTabStops, lpTabPos, nTabOrg));
00143 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
00144 NULL, lpTabPos, nTabOrg, TRUE );
00145 }
00146
00147
00148
00149
00150
00151 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str, INT count,
00152 INT cTabStops, INT *lpTabPos, INT nTabOrg )
00153 {
00154 LONG ret;
00155 LPSTR p;
00156 INT acount;
00157 UINT codepage = CP_ACP;
00158
00159 acount = WideCharToMultiByte(codepage,0,str,count,NULL,0,NULL,NULL);
00160 p = (LPSTR)HeapAlloc( GetProcessHeap(), 0, acount );
00161 if(p == NULL) return 0;
00162 acount = WideCharToMultiByte(codepage,0,str,count,p,acount,NULL,NULL);
00163 ret = TabbedTextOutA( hdc, x, y, p, acount, cTabStops, lpTabPos, nTabOrg );
00164 HeapFree( GetProcessHeap(), 0, p );
00165 return ret;
00166 }
00167
00168
00169
00170
00171
00172
00173 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
00174 INT cTabStops, INT *lpTabPos )
00175 {
00176 dprintf(("USER32: GetTabbedTextExtentA %x %s %d %d %x",hdc, lpstr, count, cTabStops, lpTabPos));
00177
00178 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
00179 NULL, lpTabPos, 0, FALSE );
00180 }
00181
00182
00183
00184
00185
00186 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
00187 INT cTabStops, INT *lpTabPos )
00188 {
00189 LONG ret;
00190 LPSTR p;
00191 INT acount;
00192 UINT codepage = CP_ACP;
00193
00194 acount = WideCharToMultiByte(codepage,0,lpstr,count,NULL,0,NULL,NULL);
00195 p = (LPSTR)HeapAlloc( GetProcessHeap(), 0, acount );
00196 if(p == NULL) return 0;
00197 acount = WideCharToMultiByte(codepage,0,lpstr,count,p,acount,NULL,NULL);
00198 ret = GetTabbedTextExtentA( hdc, p, acount, cTabStops, lpTabPos );
00199 HeapFree( GetProcessHeap(), 0, p );
00200 return ret;
00201 }
00202 #else
00203
00204
00205 DWORD WIN32API GetTabbedTextExtentA( HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)
00206 {
00207 dprintf(("USER32: GetTabbedTextExtentA %x",hDC));
00208
00209 return InternalGetTabbedTextExtentA(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions);
00210 }
00211
00212
00213 DWORD WIN32API GetTabbedTextExtentW(HDC hDC,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions)
00214 {
00215 dprintf(("USER32: GetTabbedTextExtentW %x",hDC));
00216
00217 return InternalGetTabbedTextExtentW(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions);
00218 }
00219
00220
00221 LONG WIN32API TabbedTextOutA(HDC hdc,INT x,INT y,LPCSTR lpString,INT nCount,INT nTabPositions, LPINT lpnTabStopPositions,INT nTabOrigin)
00222 {
00223 dprintf(("USER32: TabbedTextOutA %x",hdc));
00224
00225 return InternalTabbedTextOutA(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin);
00226 }
00227
00228
00229 LONG WIN32API TabbedTextOutW( HDC hdc, int x, int y, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin)
00230 {
00231 dprintf(("USER32: TabbedTextOutW %x",hdc));
00232
00233 return InternalTabbedTextOutW(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin);
00234 }
00235 #endif
00236
00237
00238
00239 static BOOL InternalGrayString(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,INT nCount,INT x,INT y,INT nWidth,INT nHeight,BOOL isUnicode)
00240 {
00241 HBITMAP hbm, hbmsave;
00242 HBRUSH hbsave;
00243 HFONT hfsave;
00244 HDC memdc = CreateCompatibleDC(hdc);
00245 BOOL retval = TRUE;
00246 RECT r;
00247 COLORREF fg, bg;
00248
00249 if (!hdc) return FALSE;
00250
00251 if (nCount == 0)
00252 nCount = isUnicode ? lstrlenW((LPCWSTR)lpData):lstrlenA((LPCSTR)lpData);
00253
00254 if((nWidth == 0 || nHeight == 0) && nCount != -1)
00255 {
00256 SIZE s;
00257
00258 if (isUnicode)
00259 GetTextExtentPoint32W(hdc,(LPCWSTR)lpData,nCount,&s);
00260 else
00261 GetTextExtentPoint32A(hdc,(LPCSTR)lpData,nCount,&s);
00262 if (nWidth == 0) nWidth = s.cx;
00263 if (nHeight == 0) nHeight = s.cy;
00264 }
00265
00266 r.left = r.top = 0;
00267 r.right = nWidth;
00268 r.bottom = nHeight;
00269
00270 hbm = CreateBitmap(nWidth,nHeight,1,1,NULL);
00271 hbmsave = (HBITMAP)SelectObject(memdc,hbm);
00272 FillRect(memdc,&r,(HBRUSH)GetStockObject(BLACK_BRUSH));
00273 SetTextColor(memdc,RGB(255,255,255));
00274 SetBkColor(memdc,RGB(0,0,0));
00275 hfsave = (HFONT)SelectObject(memdc,GetCurrentObject(hdc,OBJ_FONT));
00276
00277 if (lpOutputFunc)
00278 retval = lpOutputFunc(memdc,lpData,nCount);
00279 else
00280 if (isUnicode)
00281 TextOutW(memdc,0,0,(LPCWSTR)lpData,nCount);
00282 else
00283 TextOutA(memdc,0,0,(LPCSTR)lpData,nCount);
00284 SelectObject(memdc, hfsave);
00285
00286
00287
00288
00289
00290
00291 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
00292 if(retval || nCount != -1)
00293 #endif
00294 {
00295 hbsave = (HBRUSH)SelectObject(memdc,GetPattern55AABrush());
00296 PatBlt(memdc,0,0,nWidth,nHeight,0x000A0329);
00297 SelectObject(memdc, hbsave);
00298 }
00299
00300 if (hBrush) hbsave = (HBRUSH)SelectObject(hdc,hBrush);
00301 fg = SetTextColor(hdc, RGB(0, 0, 0));
00302 bg = SetBkColor(hdc, RGB(255, 255, 255));
00303 BitBlt(hdc,x,y,nWidth,nHeight,memdc,0,0,0x00E20746);
00304 SetTextColor(hdc, fg);
00305 SetBkColor(hdc, bg);
00306 if (hBrush) SelectObject(hdc,hbsave);
00307
00308 SelectObject(memdc, hbmsave);
00309 DeleteObject(hbm);
00310 DeleteDC(memdc);
00311
00312 return retval;
00313 }
00314
00315
00316 BOOL WIN32API GrayStringA(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,int nCount,int X,int Y,int nWidth,int nHeight)
00317 {
00318 dprintf(("USER32: GrayStringA %x",hdc));
00319
00320 return InternalGrayString(hdc,hBrush,lpOutputFunc,lpData,nCount,X,Y,nWidth,nHeight,FALSE);
00321 }
00322
00323
00324 BOOL WIN32API GrayStringW(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,int nCount,int X,int Y,int nWidth,int nHeight)
00325 {
00326 dprintf(("USER32: GrayStringW %x",hdc));
00327
00328 return InternalGrayString(hdc,hBrush,lpOutputFunc,lpData,nCount,X,Y,nWidth,nHeight,TRUE);
00329 }
00330