4 * Copyright 1993, 1994 Alexandre Julliard
7 * 1. DrawText functions
8 * 2. GrayString functions
9 * 3. TabbedText functions
16 #include "wine/winuser16.h"
17 #include "wine/unicode.h"
22 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(text
);
26 /*********************************************************************
37 #define ELLIPSIS "..."
38 #define FORWARD_SLASH '/'
39 #define BACK_SLASH '\\'
41 static const WCHAR SPACEW
[] = {' ', 0};
42 static const WCHAR oW
[] = {'o', 0};
43 static const WCHAR ELLIPSISW
[] = {'.','.','.', 0};
44 static const WCHAR FORWARD_SLASHW
[] = {'/', 0};
45 static const WCHAR BACK_SLASHW
[] = {'\\', 0};
49 static int spacewidth
;
50 static int prefix_offset
;
53 /*********************************************************************
54 * Return next line of text from a string.
57 * str - string to parse into lines.
58 * count - length of str.
59 * dest - destination in which to return line.
60 * len - dest buffer size in chars on input, copied length into dest on output.
61 * width - maximum width of line in pixels.
62 * format - format type passed to DrawText.
64 * Returns pointer to next char in str after end of the line
65 * or NULL if end of str reached.
68 * GetTextExtentPoint is used to get the width of each character,
69 * rather than GetCharABCWidth... So the whitespace between
70 * characters is ignored, and the reported len is too great.
72 static const WCHAR
*TEXT_NextLineW( HDC hdc
, const WCHAR
*str
, int *count
,
73 WCHAR
*dest
, int *len
, int width
, WORD format
)
80 int wb_i
= 0, wb_j
= 0, wb_count
= 0;
83 while (*count
&& j
< maxl
)
89 if (!(format
& DT_SINGLELINE
))
91 if ((*count
> 1) && (str
[i
] == CR
) && (str
[i
+1] == LF
))
101 dest
[j
++] = str
[i
++];
102 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
103 (format
& DT_WORDBREAK
))
105 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
112 if (!(format
& DT_NOPREFIX
) && *count
> 1)
114 if (str
[++i
] == PREFIX
)
121 dest
[j
++] = str
[i
++];
122 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
123 (format
& DT_WORDBREAK
))
125 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
132 if (format
& DT_EXPANDTABS
)
138 if (!GetTextExtentPointW(hdc
, &dest
[lasttab
], j
- lasttab
, &size
))
141 numspaces
= (tabwidth
- size
.cx
) / spacewidth
;
142 for (k
= 0; k
< numspaces
; k
++)
144 plen
+= tabwidth
- size
.cx
;
145 lasttab
= wb_j
+ numspaces
;
149 dest
[j
++] = str
[i
++];
150 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
151 (format
& DT_WORDBREAK
))
153 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
161 dest
[j
++] = str
[i
++];
162 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
163 (format
& DT_WORDBREAK
))
168 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
175 dest
[j
++] = str
[i
++];
176 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
177 (format
& DT_WORDBREAK
))
179 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
186 if (!(format
& DT_NOCLIP
) || (format
& DT_WORDBREAK
))
190 if (format
& DT_WORDBREAK
)
195 *count
= wb_count
- 1;
213 /***********************************************************************
214 * DrawTextExW (USER32.@)
216 #define MAX_STATIC_BUFFER 1024
217 INT WINAPI
DrawTextExW( HDC hdc
, LPWSTR str
, INT i_count
,
218 LPRECT rect
, UINT flags
, LPDRAWTEXTPARAMS dtp
)
222 static WCHAR line
[MAX_STATIC_BUFFER
];
223 int len
, lh
, count
=i_count
;
227 int lmargin
= 0, rmargin
= 0;
228 int x
= rect
->left
, y
= rect
->top
;
229 int width
= rect
->right
- rect
->left
;
232 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str
, count
), count
,
233 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
235 if (dtp
) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
236 dtp
->iTabLength
, dtp
->iLeftMargin
, dtp
->iRightMargin
);
239 if (count
== -1) count
= strlenW(str
);
240 if (count
== 0) return 0;
243 GetTextMetricsW(hdc
, &tm
);
244 if (flags
& DT_EXTERNALLEADING
)
245 lh
= tm
.tmHeight
+ tm
.tmExternalLeading
;
251 lmargin
= dtp
->iLeftMargin
* tm
.tmAveCharWidth
;
252 rmargin
= dtp
->iRightMargin
* tm
.tmAveCharWidth
;
253 if (!(flags
& (DT_CENTER
| DT_RIGHT
)))
255 dtp
->uiLengthDrawn
= 0; /* This param RECEIVES number of chars processed */
258 tabstop
= ((flags
& DT_TABSTOP
) && dtp
) ? dtp
->iTabLength
: 8;
260 if (flags
& DT_EXPANDTABS
)
262 GetTextExtentPointW(hdc
, SPACEW
, 1, &size
);
263 spacewidth
= size
.cx
;
264 GetTextExtentPointW(hdc
, oW
, 1, &size
);
265 tabwidth
= size
.cx
* tabstop
;
268 if (flags
& DT_CALCRECT
) flags
|= DT_NOCLIP
;
273 len
= MAX_STATIC_BUFFER
;
274 strPtr
= TEXT_NextLineW(hdc
, strPtr
, &count
, line
, &len
, width
, flags
);
276 if (prefix_offset
!= -1)
278 GetTextExtentPointW(hdc
, line
, prefix_offset
, &size
);
280 GetTextExtentPointW(hdc
, line
, prefix_offset
+ 1, &size
);
281 prefix_end
= size
.cx
- 1;
284 if (!GetTextExtentPointW(hdc
, line
, len
, &size
)) return 0;
285 if (flags
& DT_CENTER
) x
= (rect
->left
+ rect
->right
-
287 else if (flags
& DT_RIGHT
) x
= rect
->right
- size
.cx
;
289 if (flags
& DT_SINGLELINE
)
291 if (flags
& DT_VCENTER
) y
= rect
->top
+
292 (rect
->bottom
- rect
->top
) / 2 - size
.cy
/ 2;
293 else if (flags
& DT_BOTTOM
) y
= rect
->bottom
- size
.cy
;
295 if (flags
& (DT_PATH_ELLIPSIS
| DT_END_ELLIPSIS
| DT_WORD_ELLIPSIS
))
297 WCHAR swapStr
[sizeof(line
)];
298 WCHAR
* fnameDelim
= NULL
;
299 int totalLen
= i_count
>= 0 ? i_count
: strlenW(str
);
303 int fnameLen
= totalLen
;
305 /* allow room for '...' */
306 count
= min(totalLen
+3, sizeof(line
)-3);
308 if (flags
& DT_WORD_ELLIPSIS
)
309 flags
|= DT_WORDBREAK
;
311 if (flags
& DT_PATH_ELLIPSIS
)
313 WCHAR
* lastBkSlash
= NULL
;
314 WCHAR
* lastFwdSlash
= NULL
;
315 strncpyW(line
, str
, totalLen
);
316 line
[totalLen
] = '\0';
317 lastBkSlash
= strrchrW(line
, BACK_SLASHW
[0]);
318 lastFwdSlash
= strrchrW(line
, FORWARD_SLASHW
[0]);
319 fnameDelim
= lastBkSlash
> lastFwdSlash
? lastBkSlash
: lastFwdSlash
;
322 fnameLen
= &line
[totalLen
] - fnameDelim
;
324 fnameDelim
= (WCHAR
*)str
;
326 strcpyW(swapStr
, ELLIPSISW
);
327 strncpyW(swapStr
+strlenW(swapStr
), fnameDelim
, fnameLen
);
328 swapStr
[fnameLen
+3] = '\0';
329 strncpyW(swapStr
+strlenW(swapStr
), str
, totalLen
- fnameLen
);
330 swapStr
[totalLen
+3] = '\0';
332 else /* DT_END_ELLIPSIS | DT_WORD_ELLIPSIS */
334 strcpyW(swapStr
, ELLIPSISW
);
335 strncpyW(swapStr
+strlenW(swapStr
), str
, totalLen
);
338 len
= MAX_STATIC_BUFFER
;
339 TEXT_NextLineW(hdc
, swapStr
, &count
, line
, &len
, width
, flags
);
341 /* if only the ELLIPSIS will fit, just let it be clipped */
343 GetTextExtentPointW(hdc
, line
, len
, &size
);
346 * NextLine uses GetTextExtentPoint for each character,
347 * rather than GetCharABCWidth... So the whitespace between
348 * characters is ignored in the width measurement, and the
349 * reported len is too great. To compensate, we must get
350 * the width of the entire line and adjust len accordingly.
352 while ((size
.cx
> width
) && (len
> 3))
355 GetTextExtentPointW(hdc
, line
, len
, &size
);
358 if (fnameLen
< len
-3) /* some of the path will fit */
360 /* put the ELLIPSIS between the path and filename */
361 strncpyW(swapStr
, &line
[fnameLen
+3], len
-3-fnameLen
);
362 swapStr
[len
-3-fnameLen
] = '\0';
363 strcatW(swapStr
, ELLIPSISW
);
364 strncpyW(swapStr
+strlenW(swapStr
), &line
[3], fnameLen
);
368 /* move the ELLIPSIS to the end */
369 strncpyW(swapStr
, &line
[3], len
-3);
370 swapStr
[len
-3] = '\0';
371 strcpyW(swapStr
+strlenW(swapStr
), ELLIPSISW
);
374 strncpyW(line
, swapStr
, len
);
378 if (flags
& DT_MODIFYSTRING
)
379 strcpyW(str
, swapStr
);
382 if (!(flags
& DT_CALCRECT
))
384 if (!ExtTextOutW( hdc
, x
, y
,
385 ((flags
& DT_NOCLIP
) ? 0 : ETO_CLIPPED
) |
386 ((flags
& DT_RTLREADING
) ? ETO_RTLREADING
: 0),
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
)
404 if (!(flags
& DT_NOCLIP
))
406 if (y
> rect
->bottom
- lh
)
411 dtp
->uiLengthDrawn
+= len
;
415 if (flags
& DT_CALCRECT
)
417 rect
->right
= rect
->left
+ max_width
;
420 rect
->right
+= lmargin
+ rmargin
;
422 return y
- rect
->top
;
425 /***********************************************************************
426 * DrawTextExA (USER32.@)
428 INT WINAPI
DrawTextExA( HDC hdc
, LPSTR str
, INT count
,
429 LPRECT rect
, UINT flags
, LPDRAWTEXTPARAMS dtp
)
435 if (count
== -1) count
= strlen(str
);
436 if (!count
) return 0;
437 wcount
= MultiByteToWideChar( CP_ACP
, 0, str
, count
, NULL
, 0 );
438 wstr
= HeapAlloc(GetProcessHeap(), 0, wcount
* sizeof(WCHAR
));
441 MultiByteToWideChar( CP_ACP
, 0, str
, count
, wstr
, wcount
);
442 ret
= DrawTextExW( hdc
, wstr
, wcount
, rect
, flags
, NULL
);
443 if (flags
& DT_MODIFYSTRING
)
444 WideCharToMultiByte( CP_ACP
, 0, wstr
, -1, str
, count
, NULL
, NULL
);
445 HeapFree(GetProcessHeap(), 0, wstr
);
450 /***********************************************************************
451 * DrawTextW (USER32.@)
453 INT WINAPI
DrawTextW( HDC hdc
, LPCWSTR str
, INT count
, LPRECT rect
, UINT flags
)
457 memset (&dtp
, 0, sizeof(dtp
));
458 if (flags
& DT_TABSTOP
)
460 dtp
.iTabLength
= (flags
>> 8) && 0xff;
463 return DrawTextExW(hdc
, (LPWSTR
)str
, count
, rect
, flags
, &dtp
);
466 /***********************************************************************
467 * DrawTextA (USER32.@)
469 INT WINAPI
DrawTextA( HDC hdc
, LPCSTR str
, INT count
, LPRECT rect
, UINT flags
)
473 memset (&dtp
, 0, sizeof(dtp
));
474 if (flags
& DT_TABSTOP
)
476 dtp
.iTabLength
= (flags
>> 8) && 0xff;
479 return DrawTextExA( hdc
, (LPSTR
)str
, count
, rect
, flags
, &dtp
);
482 /***********************************************************************
485 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
492 CONV_RECT16TO32( rect
, &rect32
);
493 ret
= DrawTextA( hdc
, str
, count
, &rect32
, flags
);
494 CONV_RECT32TO16( &rect32
, rect
);
496 else ret
= DrawTextA( hdc
, str
, count
, NULL
, flags
);
501 /***********************************************************************
503 * GrayString functions
506 /* ### start build ### */
507 extern WORD CALLBACK
TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16
,WORD
,LONG
,WORD
);
508 /* ### stop build ### */
510 struct gray_string_info
512 GRAYSTRINGPROC16 proc
;
516 /* callback for 16-bit gray string proc */
517 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
519 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
520 return TEXT_CallTo16_word_wlw( info
->proc
, hdc
, info
->param
, len
);
523 /***********************************************************************
526 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
527 * heap and we can guarantee that the handles fit in an INT16. We have to
528 * rethink the strategy once the migration to NT handles is complete.
529 * We are going to get a lot of code-duplication once this migration is
533 static BOOL
TEXT_GrayString(HDC hdc
, HBRUSH hb
, GRAYSTRINGPROC fn
, LPARAM lp
, INT len
,
534 INT x
, INT y
, INT cx
, INT cy
, BOOL unicode
, BOOL _32bit
)
536 HBITMAP hbm
, hbmsave
;
544 if(!hdc
) return FALSE
;
545 if (!(memdc
= CreateCompatibleDC(hdc
))) return FALSE
;
550 slen
= lstrlenW((LPCWSTR
)lp
);
552 slen
= strlen((LPCSTR
)lp
);
554 slen
= strlen(MapSL(lp
));
557 if((cx
== 0 || cy
== 0) && slen
!= -1)
561 GetTextExtentPoint32W(hdc
, (LPCWSTR
)lp
, slen
, &s
);
563 GetTextExtentPoint32A(hdc
, (LPCSTR
)lp
, slen
, &s
);
565 GetTextExtentPoint32A(hdc
, MapSL(lp
), slen
, &s
);
566 if(cx
== 0) cx
= s
.cx
;
567 if(cy
== 0) cy
= s
.cy
;
570 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
571 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
572 hbsave
= SelectObject( memdc
, GetStockObject(BLACK_BRUSH
) );
573 PatBlt( memdc
, 0, 0, cx
, cy
, PATCOPY
);
574 SelectObject( memdc
, hbsave
);
575 SetTextColor(memdc
, RGB(255, 255, 255));
576 SetBkColor(memdc
, RGB(0, 0, 0));
577 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
582 retval
= fn(memdc
, lp
, slen
);
584 retval
= (BOOL
)((BOOL16
)((GRAYSTRINGPROC16
)fn
)((HDC16
)memdc
, lp
, (INT16
)slen
));
589 TextOutW(memdc
, 0, 0, (LPCWSTR
)lp
, slen
);
591 TextOutA(memdc
, 0, 0, (LPCSTR
)lp
, slen
);
593 TextOutA(memdc
, 0, 0, MapSL(lp
), slen
);
596 SelectObject(memdc
, hfsave
);
599 * Windows doc says that the bitmap isn't grayed when len == -1 and
600 * the callback function returns FALSE. However, testing this on
601 * win95 showed otherwise...
603 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
604 if(retval
|| len
!= -1)
607 hbsave
= (HBRUSH
)SelectObject(memdc
, CACHE_GetPattern55AABrush());
608 PatBlt(memdc
, 0, 0, cx
, cy
, 0x000A0329);
609 SelectObject(memdc
, hbsave
);
612 if(hb
) hbsave
= (HBRUSH
)SelectObject(hdc
, hb
);
613 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
614 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
615 BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00E20746);
616 SetTextColor(hdc
, fg
);
618 if(hb
) SelectObject(hdc
, hbsave
);
620 SelectObject(memdc
, hbmsave
);
627 /***********************************************************************
628 * GrayString (USER.185)
630 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
631 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
634 struct gray_string_info info
;
636 if (!gsprc
) return TEXT_GrayString(hdc
, hbr
, NULL
, lParam
, cch
, x
, y
, cx
, cy
, FALSE
, FALSE
);
639 return TEXT_GrayString( hdc
, hbr
, gray_string_callback
, (LPARAM
)&info
,
640 cch
, x
, y
, cx
, cy
, FALSE
, FALSE
);
644 /***********************************************************************
645 * GrayStringA (USER32.@)
647 BOOL WINAPI
GrayStringA( HDC hdc
, HBRUSH hbr
, GRAYSTRINGPROC gsprc
,
648 LPARAM lParam
, INT cch
, INT x
, INT y
,
651 return TEXT_GrayString(hdc
, hbr
, gsprc
, lParam
, cch
, x
, y
, cx
, cy
,
656 /***********************************************************************
657 * GrayStringW (USER32.@)
659 BOOL WINAPI
GrayStringW( HDC hdc
, HBRUSH hbr
, GRAYSTRINGPROC gsprc
,
660 LPARAM lParam
, INT cch
, INT x
, INT y
,
663 return TEXT_GrayString(hdc
, hbr
, gsprc
, lParam
, cch
, x
, y
, cx
, cy
,
667 /***********************************************************************
669 * TabbedText functions
672 /***********************************************************************
675 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
676 * Note: this doesn't work too well for text-alignment modes other
677 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
679 static LONG
TEXT_TabbedTextOut( HDC hdc
, INT x
, INT y
, LPCSTR lpstr
,
680 INT count
, INT cTabStops
, const INT16
*lpTabPos16
,
681 const INT
*lpTabPos32
, INT nTabOrg
,
694 defWidth
= lpTabPos32
? *lpTabPos32
: *lpTabPos16
;
700 GetTextMetricsA( hdc
, &tm
);
701 defWidth
= 8 * tm
.tmAveCharWidth
;
706 for (i
= 0; i
< count
; i
++)
707 if (lpstr
[i
] == '\t') break;
708 GetTextExtentPointA( hdc
, lpstr
, i
, &extent
);
711 while ((cTabStops
> 0) &&
712 (nTabOrg
+ *lpTabPos32
<= x
+ extent
.cx
))
720 while ((cTabStops
> 0) &&
721 (nTabOrg
+ *lpTabPos16
<= x
+ extent
.cx
))
728 tabPos
= x
+ extent
.cx
;
729 else if (cTabStops
> 0)
730 tabPos
= nTabOrg
+ (lpTabPos32
? *lpTabPos32
: *lpTabPos16
);
732 tabPos
= nTabOrg
+ ((x
+ extent
.cx
- nTabOrg
) / defWidth
+ 1) * defWidth
;
739 r
.bottom
= y
+ extent
.cy
;
740 ExtTextOutA( hdc
, x
, y
,
741 GetBkMode(hdc
) == OPAQUE
? ETO_OPAQUE
: 0,
742 &r
, lpstr
, i
, NULL
);
748 return MAKELONG(tabPos
- start
, extent
.cy
);
752 /***********************************************************************
753 * TabbedTextOut (USER.196)
755 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
756 INT16 count
, INT16 cTabStops
,
757 const INT16
*lpTabPos
, INT16 nTabOrg
)
759 TRACE("%04x %d,%d %s %d\n", hdc
, x
, y
, debugstr_an(lpstr
,count
), count
);
760 return TEXT_TabbedTextOut( hdc
, x
, y
, lpstr
, count
, cTabStops
,
761 lpTabPos
, NULL
, nTabOrg
, TRUE
);
765 /***********************************************************************
766 * TabbedTextOutA (USER32.@)
768 LONG WINAPI
TabbedTextOutA( HDC hdc
, INT x
, INT y
, LPCSTR lpstr
, INT count
,
769 INT cTabStops
, const INT
*lpTabPos
, INT nTabOrg
)
771 TRACE("%04x %d,%d %s %d\n", hdc
, x
, y
, debugstr_an(lpstr
,count
), count
);
772 return TEXT_TabbedTextOut( hdc
, x
, y
, lpstr
, count
, cTabStops
,
773 NULL
, lpTabPos
, nTabOrg
, TRUE
);
777 /***********************************************************************
778 * TabbedTextOutW (USER32.@)
780 LONG WINAPI
TabbedTextOutW( HDC hdc
, INT x
, INT y
, LPCWSTR str
, INT count
,
781 INT cTabStops
, const INT
*lpTabPos
, INT nTabOrg
)
786 UINT codepage
= CP_ACP
; /* FIXME: get codepage of font charset */
788 acount
= WideCharToMultiByte(codepage
,0,str
,count
,NULL
,0,NULL
,NULL
);
789 p
= HeapAlloc( GetProcessHeap(), 0, acount
);
790 if(p
== NULL
) return 0; /* FIXME: is this the correct return on failure */
791 acount
= WideCharToMultiByte(codepage
,0,str
,count
,p
,acount
,NULL
,NULL
);
792 ret
= TabbedTextOutA( hdc
, x
, y
, p
, acount
, cTabStops
, lpTabPos
, nTabOrg
);
793 HeapFree( GetProcessHeap(), 0, p
);
798 /***********************************************************************
799 * GetTabbedTextExtent (USER.197)
801 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
802 INT16 cTabStops
, const INT16
*lpTabPos
)
804 TRACE("%04x %s %d\n", hdc
, debugstr_an(lpstr
,count
), count
);
805 return TEXT_TabbedTextOut( hdc
, 0, 0, lpstr
, count
, cTabStops
,
806 lpTabPos
, NULL
, 0, FALSE
);
810 /***********************************************************************
811 * GetTabbedTextExtentA (USER32.@)
813 DWORD WINAPI
GetTabbedTextExtentA( HDC hdc
, LPCSTR lpstr
, INT count
,
814 INT cTabStops
, const INT
*lpTabPos
)
816 TRACE("%04x %s %d\n", hdc
, debugstr_an(lpstr
,count
), count
);
817 return TEXT_TabbedTextOut( hdc
, 0, 0, lpstr
, count
, cTabStops
,
818 NULL
, lpTabPos
, 0, FALSE
);
822 /***********************************************************************
823 * GetTabbedTextExtentW (USER32.@)
825 DWORD WINAPI
GetTabbedTextExtentW( HDC hdc
, LPCWSTR lpstr
, INT count
,
826 INT cTabStops
, const INT
*lpTabPos
)
831 UINT codepage
= CP_ACP
; /* FIXME: get codepage of font charset */
833 acount
= WideCharToMultiByte(codepage
,0,lpstr
,count
,NULL
,0,NULL
,NULL
);
834 p
= HeapAlloc( GetProcessHeap(), 0, acount
);
835 if(p
== NULL
) return 0; /* FIXME: is this the correct failure value? */
836 acount
= WideCharToMultiByte(codepage
,0,lpstr
,count
,p
,acount
,NULL
,NULL
);
837 ret
= GetTabbedTextExtentA( hdc
, p
, acount
, cTabStops
, lpTabPos
);
838 HeapFree( GetProcessHeap(), 0, p
);