Changeset 5810 for trunk/src/user32/text.cpp
- Timestamp:
- May 27, 2001, 9:01:35 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/text.cpp
r5796 r5810 1 /* $Id: text.cpp,v 1.1 1 2001-05-24 19:26:59sandervl Exp $ */1 /* $Id: text.cpp,v 1.12 2001-05-27 19:01:35 sandervl Exp $ */ 2 2 3 3 /* … … 14 14 #include "user32.h" 15 15 #include "syscolor.h" 16 #include <winnls.h> 16 17 17 18 #define DBG_LOCALLOG DBG_text … … 50 51 return InternalDrawTextExW(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE); 51 52 } 53 #if 1 54 //Based on Wine version 20010510 55 /*********************************************************************** 56 * TEXT_TabbedTextOut 57 * 58 * Helper function for TabbedTextOut() and GetTabbedTextExtent(). 59 * Note: this doesn't work too well for text-alignment modes other 60 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-) 61 */ 62 static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr, 63 INT count, INT cTabStops, const INT16 *lpTabPos16, 64 const INT *lpTabPos32, INT nTabOrg, 65 BOOL fDisplayText ) 66 { 67 INT defWidth; 68 SIZE extent; 69 int i, tabPos = x; 70 int start = x; 71 72 extent.cx = 0; 73 extent.cy = 0; 74 75 if (cTabStops == 1) 76 { 77 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16; 78 cTabStops = 0; 79 } 80 else 81 { 82 TEXTMETRICA tm; 83 GetTextMetricsA( hdc, &tm ); 84 defWidth = 8 * tm.tmAveCharWidth; 85 } 86 87 while (count > 0) 88 { 89 for (i = 0; i < count; i++) 90 if (lpstr[i] == '\t') break; 91 GetTextExtentPointA( hdc, lpstr, i, &extent ); 92 if (lpTabPos32) 93 { 94 while ((cTabStops > 0) && 95 (nTabOrg + *lpTabPos32 <= x + extent.cx)) 96 { 97 lpTabPos32++; 98 cTabStops--; 99 } 100 } 101 else 102 { 103 while ((cTabStops > 0) && 104 (nTabOrg + *lpTabPos16 <= x + extent.cx)) 105 { 106 lpTabPos16++; 107 cTabStops--; 108 } 109 } 110 if (i == count) 111 tabPos = x + extent.cx; 112 else if (cTabStops > 0) 113 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16); 114 else 115 tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth; 116 if (fDisplayText) 117 { 118 RECT r; 119 r.left = x; 120 r.top = y; 121 r.right = tabPos; 122 r.bottom = y + extent.cy; 123 ExtTextOutA( hdc, x, y, 124 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0, 125 &r, lpstr, i, NULL ); 126 } 127 x = tabPos; 128 count -= i+1; 129 lpstr += i+1; 130 } 131 return MAKELONG(tabPos - start, extent.cy); 132 } 133 134 135 136 /*********************************************************************** 137 * TabbedTextOutA (USER32.@) 138 */ 139 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr, INT count, 140 INT cTabStops, INT *lpTabPos, INT nTabOrg ) 141 { 142 dprintf(("USER32: TabbedTextOutA %x (%d,%d) %s %d %d %x %d", hdc, x, y, lpstr, count, cTabStops, lpTabPos, nTabOrg)); 143 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops, 144 NULL, lpTabPos, nTabOrg, TRUE ); 145 } 146 147 148 /*********************************************************************** 149 * TabbedTextOutW (USER32.@) 150 */ 151 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str, INT count, 152 INT cTabStops, INT *lpTabPos, INT nTabOrg ) 153 { 154 LONG ret; 155 LPSTR p; 156 INT acount; 157 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */ 158 159 acount = WideCharToMultiByte(codepage,0,str,count,NULL,0,NULL,NULL); 160 p = (LPSTR)HeapAlloc( GetProcessHeap(), 0, acount ); 161 if(p == NULL) return 0; /* FIXME: is this the correct return on failure */ 162 acount = WideCharToMultiByte(codepage,0,str,count,p,acount,NULL,NULL); 163 ret = TabbedTextOutA( hdc, x, y, p, acount, cTabStops, lpTabPos, nTabOrg ); 164 HeapFree( GetProcessHeap(), 0, p ); 165 return ret; 166 } 167 168 169 170 /*********************************************************************** 171 * GetTabbedTextExtentA (USER32.@) 172 */ 173 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count, 174 INT cTabStops, INT *lpTabPos ) 175 { 176 dprintf(("USER32: GetTabbedTextExtentA %x %s %d %d %x",hdc, lpstr, count, cTabStops, lpTabPos)); 177 178 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops, 179 NULL, lpTabPos, 0, FALSE ); 180 } 181 182 183 /*********************************************************************** 184 * GetTabbedTextExtentW (USER32.@) 185 */ 186 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count, 187 INT cTabStops, INT *lpTabPos ) 188 { 189 LONG ret; 190 LPSTR p; 191 INT acount; 192 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */ 193 194 acount = WideCharToMultiByte(codepage,0,lpstr,count,NULL,0,NULL,NULL); 195 p = (LPSTR)HeapAlloc( GetProcessHeap(), 0, acount ); 196 if(p == NULL) return 0; /* FIXME: is this the correct failure value? */ 197 acount = WideCharToMultiByte(codepage,0,lpstr,count,p,acount,NULL,NULL); 198 ret = GetTabbedTextExtentA( hdc, p, acount, cTabStops, lpTabPos ); 199 HeapFree( GetProcessHeap(), 0, p ); 200 return ret; 201 } 202 #else 52 203 //****************************************************************************** 53 204 //****************************************************************************** … … 82 233 return InternalTabbedTextOutW(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin); 83 234 } 235 #endif 84 236 //****************************************************************************** 85 237 // WINE/objects/text.c
Note:
See TracChangeset
for help on using the changeset viewer.