Changed LoadImage16 to take an LPCSTR instead of a SEGPTR.
[wine.git] / dlls / user / text.c
blobeff3fa42d7fc4356542c07ac5a55c62cc213fdc9
1 /*
2 * USER text functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 */
8 #include <string.h>
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "wine/winuser16.h"
13 #include "wine/unicode.h"
14 #include "winbase.h"
15 #include "winerror.h"
16 #include "winnls.h"
17 #include "cache.h"
18 #include "ldt.h"
19 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(text);
23 #define TAB 9
24 #define LF 10
25 #define CR 13
26 #define SPACE 32
27 #define PREFIX 38
29 #define ELLIPSIS "..."
30 #define FORWARD_SLASH '/'
31 #define BACK_SLASH '\\'
33 static const WCHAR SPACEW[] = {' ', 0};
34 static const WCHAR oW[] = {'o', 0};
35 static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
36 static const WCHAR FORWARD_SLASHW[] = {'/', 0};
37 static const WCHAR BACK_SLASHW[] = {'\\', 0};
39 #define SWAP_INT(a,b) { int t = a; a = b; b = t; }
41 static int tabstop = 8;
42 static int tabwidth;
43 static int spacewidth;
44 static int prefix_offset;
46 /*********************************************************************
47 * Return next line of text from a string.
49 * hdc - handle to DC.
50 * str - string to parse into lines.
51 * count - length of str.
52 * dest - destination in which to return line.
53 * len - length of resultant line in dest in chars.
54 * width - maximum width of line in pixels.
55 * format - format type passed to DrawText.
57 * Returns pointer to next char in str after end of the line
58 * or NULL if end of str reached.
60 * FIXME:
61 * GetTextExtentPoint is used to get the width of each character,
62 * rather than GetCharABCWidth... So the whitespace between
63 * characters is ignored, and the reported len is too great.
65 static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
66 WCHAR *dest, int *len, int width, WORD format)
68 int i = 0, j = 0, k;
69 int plen = 0;
70 int numspaces;
71 SIZE size;
72 int lasttab = 0;
73 int wb_i = 0, wb_j = 0, wb_count = 0;
75 while (*count)
77 switch (str[i])
79 case CR:
80 case LF:
81 if (!(format & DT_SINGLELINE))
83 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
85 (*count)--;
86 i++;
88 i++;
89 *len = j;
90 (*count)--;
91 return (&str[i]);
93 dest[j++] = str[i++];
94 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
95 (format & DT_WORDBREAK))
97 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
98 return NULL;
99 plen += size.cx;
101 break;
103 case PREFIX:
104 if (!(format & DT_NOPREFIX) && *count > 1)
106 if (str[++i] == PREFIX)
107 (*count)--;
108 else {
109 prefix_offset = j;
110 break;
113 dest[j++] = str[i++];
114 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
115 (format & DT_WORDBREAK))
117 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
118 return NULL;
119 plen += size.cx;
121 break;
123 case TAB:
124 if (format & DT_EXPANDTABS)
126 wb_i = ++i;
127 wb_j = j;
128 wb_count = *count;
130 if (!GetTextExtentPointW(hdc, &dest[lasttab], j - lasttab, &size))
131 return NULL;
133 numspaces = (tabwidth - size.cx) / spacewidth;
134 for (k = 0; k < numspaces; k++)
135 dest[j++] = SPACE;
136 plen += tabwidth - size.cx;
137 lasttab = wb_j + numspaces;
139 else
141 dest[j++] = str[i++];
142 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
143 (format & DT_WORDBREAK))
145 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
146 return NULL;
147 plen += size.cx;
150 break;
152 case SPACE:
153 dest[j++] = str[i++];
154 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
155 (format & DT_WORDBREAK))
157 wb_i = i;
158 wb_j = j - 1;
159 wb_count = *count;
160 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
161 return NULL;
162 plen += size.cx;
164 break;
166 default:
167 dest[j++] = str[i++];
168 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
169 (format & DT_WORDBREAK))
171 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
172 return NULL;
173 plen += size.cx;
177 (*count)--;
178 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
180 if (plen > width)
182 if (format & DT_WORDBREAK)
184 if (wb_j)
186 *len = wb_j;
187 *count = wb_count - 1;
188 return (&str[wb_i]);
191 else
193 *len = j;
194 return (&str[i]);
200 *len = j;
201 return NULL;
205 /***********************************************************************
206 * DrawText16 (USER.85)
208 INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
210 INT16 ret;
212 if (rect)
214 RECT rect32;
215 CONV_RECT16TO32( rect, &rect32 );
216 ret = DrawTextA( hdc, str, count, &rect32, flags );
217 CONV_RECT32TO16( &rect32, rect );
219 else ret = DrawTextA( hdc, str, count, NULL, flags);
220 return ret;
224 /***********************************************************************
225 * DrawTextExW (USER32.166)
227 INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
228 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
230 SIZE size;
231 const WCHAR *strPtr;
232 static WCHAR line[1024];
233 int len, lh, count=i_count;
234 int prefix_x = 0;
235 int prefix_end = 0;
236 TEXTMETRICW tm;
237 int x = rect->left, y = rect->top;
238 int width = rect->right - rect->left;
239 int max_width = 0;
241 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str, count), count,
242 rect->left, rect->top, rect->right, rect->bottom);
244 if(dtp) {
245 FIXME("Ignores params:%d,%d,%d,%d\n", dtp->cbSize,
246 dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
249 if (!str) return 0;
250 if (count == -1) count = strlenW(str);
251 if (count == 0) return 0;
252 strPtr = str;
254 GetTextMetricsW(hdc, &tm);
255 if (flags & DT_EXTERNALLEADING)
256 lh = tm.tmHeight + tm.tmExternalLeading;
257 else
258 lh = tm.tmHeight;
260 if (flags & DT_TABSTOP)
261 tabstop = flags >> 8;
263 if (flags & DT_EXPANDTABS)
265 GetTextExtentPointW(hdc, SPACEW, 1, &size);
266 spacewidth = size.cx;
267 GetTextExtentPointW(hdc, oW, 1, &size);
268 tabwidth = size.cx * tabstop;
271 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
275 prefix_offset = -1;
276 strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags);
278 if (prefix_offset != -1)
280 GetTextExtentPointW(hdc, line, prefix_offset, &size);
281 prefix_x = size.cx;
282 GetTextExtentPointW(hdc, line, prefix_offset + 1, &size);
283 prefix_end = size.cx - 1;
286 if (!GetTextExtentPointW(hdc, line, len, &size)) return 0;
287 if (flags & DT_CENTER) x = (rect->left + rect->right -
288 size.cx) / 2;
289 else if (flags & DT_RIGHT) x = rect->right - size.cx;
291 if (flags & DT_SINGLELINE)
293 if (flags & DT_VCENTER) y = rect->top +
294 (rect->bottom - rect->top) / 2 - size.cy / 2;
295 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
297 if (flags & (DT_PATH_ELLIPSIS | DT_END_ELLIPSIS | DT_WORD_ELLIPSIS))
299 WCHAR swapStr[sizeof(line)];
300 WCHAR* fnameDelim = NULL;
301 int totalLen = i_count >= 0 ? i_count : strlenW(str);
303 if (size.cx > width)
305 int fnameLen = totalLen;
307 /* allow room for '...' */
308 count = min(totalLen+3, sizeof(line)-3);
310 if (flags & DT_WORD_ELLIPSIS)
311 flags |= DT_WORDBREAK;
313 if (flags & DT_PATH_ELLIPSIS)
315 WCHAR* lastBkSlash = NULL;
316 WCHAR* lastFwdSlash = NULL;
317 strncpyW(line, str, totalLen);
318 line[totalLen] = '\0';
319 lastBkSlash = strrchrW(line, BACK_SLASHW[0]);
320 lastFwdSlash = strrchrW(line, FORWARD_SLASHW[0]);
321 fnameDelim = lastFwdSlash ? lastFwdSlash : lastBkSlash;
322 if (lastBkSlash && lastFwdSlash) /* which is last? */
323 if (lastBkSlash > lastFwdSlash)
324 fnameDelim = lastBkSlash;
326 if (fnameDelim)
327 fnameLen = &line[totalLen] - fnameDelim;
328 else
329 fnameDelim = (WCHAR*)str;
331 strcpyW(swapStr, ELLIPSISW);
332 strncpyW(swapStr+strlenW(swapStr), fnameDelim, fnameLen);
333 swapStr[fnameLen+3] = '\0';
334 strncpyW(swapStr+strlenW(swapStr), str, totalLen - fnameLen);
335 swapStr[totalLen+3] = '\0';
337 else /* DT_END_ELLIPSIS | DT_WORD_ELLIPSIS */
339 strcpyW(swapStr, ELLIPSISW);
340 strncpyW(swapStr+strlenW(swapStr), str, totalLen);
343 TEXT_NextLineW(hdc, swapStr, &count, line, &len, width, flags);
345 /* if only the ELLIPSIS will fit, just let it be clipped */
346 len = max(3, len);
347 GetTextExtentPointW(hdc, line, len, &size);
349 /* FIXME:
350 * NextLine uses GetTextExtentPoint for each character,
351 * rather than GetCharABCWidth... So the whitespace between
352 * characters is ignored in the width measurement, and the
353 * reported len is too great. To compensate, we must get
354 * the width of the entire line and adjust len accordingly.
356 while ((size.cx > width) && (len > 3))
358 line[--len] = '\0';
359 GetTextExtentPointW(hdc, line, len, &size);
362 if (fnameLen < len-3) /* some of the path will fit */
364 /* put the ELLIPSIS between the path and filename */
365 strncpyW(swapStr, &line[fnameLen+3], len-3-fnameLen);
366 swapStr[len-3-fnameLen] = '\0';
367 strcatW(swapStr, ELLIPSISW);
368 strncpyW(swapStr+strlenW(swapStr), &line[3], fnameLen);
370 else
372 /* move the ELLIPSIS to the end */
373 strncpyW(swapStr, &line[3], len-3);
374 swapStr[len-3] = '\0';
375 strcpyW(swapStr+strlenW(swapStr), ELLIPSISW);
378 strncpyW(line, swapStr, len);
379 line[len] = '\0';
380 strPtr = NULL;
384 if (!(flags & DT_CALCRECT))
386 if (!ExtTextOutW(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
387 rect, line, len, NULL )) return 0;
388 if (prefix_offset != -1)
390 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
391 HPEN oldPen = SelectObject( hdc, hpen );
392 MoveToEx(hdc, x + prefix_x, y + tm.tmAscent + 1, NULL );
393 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
394 SelectObject( hdc, oldPen );
395 DeleteObject( hpen );
398 else if (size.cx > max_width)
399 max_width = size.cx;
401 y += lh;
402 if (strPtr)
404 if (!(flags & DT_NOCLIP))
406 if (y > rect->bottom - lh)
407 break;
411 while (strPtr);
412 if (flags & DT_CALCRECT)
414 rect->right = rect->left + max_width;
415 rect->bottom = y;
417 return y - rect->top;
420 /***********************************************************************
421 * DrawTextA (USER32.164)
423 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
425 WCHAR *wstr;
426 INT ret = 0;
427 DWORD wcount;
429 if (count == -1) count = strlen(str);
430 if (!count) return 0;
431 wcount = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 );
432 wstr = HeapAlloc(GetProcessHeap(), 0, wcount * sizeof(WCHAR));
433 if (wstr)
435 MultiByteToWideChar( CP_ACP, 0, str, count, wstr, wcount );
436 ret = DrawTextExW( hdc, wstr, wcount, rect, flags, NULL );
437 HeapFree(GetProcessHeap(), 0, wstr);
439 return ret;
442 /***********************************************************************
443 * DrawTextW (USER32.167)
445 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count,
446 LPRECT rect, UINT flags )
448 return DrawTextExW(hdc, str, count, rect, flags, NULL);
451 /***********************************************************************
452 * DrawTextExA (USER32.165)
454 INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count,
455 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
457 TRACE("(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
458 if(dtp) {
459 FIXME("Ignores params:%d,%d,%d,%d\n",dtp->cbSize,
460 dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin);
462 return DrawTextA(hdc,str,count,rect,flags);
465 /***********************************************************************
466 * TEXT_GrayString
468 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
469 * heap and we can guarantee that the handles fit in an INT16. We have to
470 * rethink the strategy once the migration to NT handles is complete.
471 * We are going to get a lot of code-duplication once this migration is
472 * completed...
475 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, GRAYSTRINGPROC fn, LPARAM lp, INT len,
476 INT x, INT y, INT cx, INT cy, BOOL unicode, BOOL _32bit)
478 HBITMAP hbm, hbmsave;
479 HBRUSH hbsave;
480 HFONT hfsave;
481 HDC memdc = CreateCompatibleDC(hdc);
482 int slen = len;
483 BOOL retval = TRUE;
484 COLORREF fg, bg;
486 if(!hdc) return FALSE;
488 if(len == 0)
490 if(unicode)
491 slen = lstrlenW((LPCWSTR)lp);
492 else if(_32bit)
493 slen = strlen((LPCSTR)lp);
494 else
495 slen = strlen((LPCSTR)PTR_SEG_TO_LIN(lp));
498 if((cx == 0 || cy == 0) && slen != -1)
500 SIZE s;
501 if(unicode)
502 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
503 else if(_32bit)
504 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
505 else
506 GetTextExtentPoint32A(hdc, (LPCSTR)PTR_SEG_TO_LIN(lp), slen, &s);
507 if(cx == 0) cx = s.cx;
508 if(cy == 0) cy = s.cy;
511 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
512 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
513 hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) );
514 PatBlt( memdc, 0, 0, cx, cy, PATCOPY );
515 SelectObject( memdc, hbsave );
516 SetTextColor(memdc, RGB(255, 255, 255));
517 SetBkColor(memdc, RGB(0, 0, 0));
518 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
520 if(fn)
522 if(_32bit)
523 retval = fn(memdc, lp, slen);
524 else
525 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
527 else
529 if(unicode)
530 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
531 else if(_32bit)
532 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
533 else
534 TextOutA(memdc, 0, 0, (LPCSTR)PTR_SEG_TO_LIN(lp), slen);
537 SelectObject(memdc, hfsave);
540 * Windows doc says that the bitmap isn't grayed when len == -1 and
541 * the callback function returns FALSE. However, testing this on
542 * win95 showed otherwise...
544 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
545 if(retval || len != -1)
546 #endif
548 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
549 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
550 SelectObject(memdc, hbsave);
553 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
554 fg = SetTextColor(hdc, RGB(0, 0, 0));
555 bg = SetBkColor(hdc, RGB(255, 255, 255));
556 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
557 SetTextColor(hdc, fg);
558 SetBkColor(hdc, bg);
559 if(hb) SelectObject(hdc, hbsave);
561 SelectObject(memdc, hbmsave);
562 DeleteObject(hbm);
563 DeleteDC(memdc);
564 return retval;
568 /***********************************************************************
569 * GrayString16 (USER.185)
571 BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
572 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
573 INT16 cx, INT16 cy )
575 return TEXT_GrayString(hdc, hbr, (GRAYSTRINGPROC)gsprc, lParam, cch,
576 x, y, cx, cy, FALSE, FALSE);
580 /***********************************************************************
581 * GrayStringA (USER32.315)
583 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
584 LPARAM lParam, INT cch, INT x, INT y,
585 INT cx, INT cy )
587 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
588 FALSE, TRUE);
592 /***********************************************************************
593 * GrayStringW (USER32.316)
595 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
596 LPARAM lParam, INT cch, INT x, INT y,
597 INT cx, INT cy )
599 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
600 TRUE, TRUE);
603 /***********************************************************************
604 * TEXT_TabbedTextOut
606 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
607 * Note: this doesn't work too well for text-alignment modes other
608 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
610 static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
611 INT count, INT cTabStops, const INT16 *lpTabPos16,
612 const INT *lpTabPos32, INT nTabOrg,
613 BOOL fDisplayText )
615 INT defWidth;
616 SIZE extent;
617 int i, tabPos = x;
618 int start = x;
620 extent.cx = 0;
621 extent.cy = 0;
623 if (cTabStops == 1)
625 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
626 cTabStops = 0;
628 else
630 TEXTMETRICA tm;
631 GetTextMetricsA( hdc, &tm );
632 defWidth = 8 * tm.tmAveCharWidth;
635 while (count > 0)
637 for (i = 0; i < count; i++)
638 if (lpstr[i] == '\t') break;
639 GetTextExtentPointA( hdc, lpstr, i, &extent );
640 if (lpTabPos32)
642 while ((cTabStops > 0) &&
643 (nTabOrg + *lpTabPos32 <= x + extent.cx))
645 lpTabPos32++;
646 cTabStops--;
649 else
651 while ((cTabStops > 0) &&
652 (nTabOrg + *lpTabPos16 <= x + extent.cx))
654 lpTabPos16++;
655 cTabStops--;
658 if (i == count)
659 tabPos = x + extent.cx;
660 else if (cTabStops > 0)
661 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
662 else
663 tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
664 if (fDisplayText)
666 RECT r;
667 r.left = x;
668 r.top = y;
669 r.right = tabPos;
670 r.bottom = y + extent.cy;
671 ExtTextOutA( hdc, x, y,
672 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
673 &r, lpstr, i, NULL );
675 x = tabPos;
676 count -= i+1;
677 lpstr += i+1;
679 return MAKELONG(tabPos - start, extent.cy);
683 /***********************************************************************
684 * TabbedTextOut16 (USER.196)
686 LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
687 INT16 count, INT16 cTabStops,
688 const INT16 *lpTabPos, INT16 nTabOrg )
690 TRACE("%04x %d,%d '%.*s' %d\n", hdc, x, y, count, lpstr, count );
691 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
692 lpTabPos, NULL, nTabOrg, TRUE );
696 /***********************************************************************
697 * TabbedTextOutA (USER32.542)
699 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr, INT count,
700 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
702 TRACE("%04x %d,%d '%.*s' %d\n", hdc, x, y, count, lpstr, count );
703 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
704 NULL, lpTabPos, nTabOrg, TRUE );
708 /***********************************************************************
709 * TabbedTextOutW (USER32.543)
711 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str, INT count,
712 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
714 LONG ret;
715 LPSTR p;
716 INT acount;
717 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
719 acount = WideCharToMultiByte(codepage,0,str,count,NULL,0,NULL,NULL);
720 p = HeapAlloc( GetProcessHeap(), 0, acount );
721 if(p == NULL) return 0; /* FIXME: is this the correct return on failure */
722 acount = WideCharToMultiByte(codepage,0,str,count,p,acount,NULL,NULL);
723 ret = TabbedTextOutA( hdc, x, y, p, acount, cTabStops, lpTabPos, nTabOrg );
724 HeapFree( GetProcessHeap(), 0, p );
725 return ret;
729 /***********************************************************************
730 * GetTabbedTextExtent16 (USER.197)
732 DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
733 INT16 cTabStops, const INT16 *lpTabPos )
735 TRACE("%04x '%.*s' %d\n", hdc, count, lpstr, count );
736 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
737 lpTabPos, NULL, 0, FALSE );
741 /***********************************************************************
742 * GetTabbedTextExtentA (USER32.293)
744 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
745 INT cTabStops, const INT *lpTabPos )
747 TRACE("%04x '%.*s' %d\n", hdc, count, lpstr, count );
748 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
749 NULL, lpTabPos, 0, FALSE );
753 /***********************************************************************
754 * GetTabbedTextExtentW (USER32.294)
756 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
757 INT cTabStops, const INT *lpTabPos )
759 LONG ret;
760 LPSTR p;
761 INT acount;
762 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
764 acount = WideCharToMultiByte(codepage,0,lpstr,count,NULL,0,NULL,NULL);
765 p = HeapAlloc( GetProcessHeap(), 0, acount );
766 if(p == NULL) return 0; /* FIXME: is this the correct failure value? */
767 acount = WideCharToMultiByte(codepage,0,lpstr,count,p,acount,NULL,NULL);
768 ret = GetTabbedTextExtentA( hdc, p, acount, cTabStops, lpTabPos );
769 HeapFree( GetProcessHeap(), 0, p );
770 return ret;