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 #define countof(a) (sizeof(a)/sizeof(a[0]))
28 /*********************************************************************
39 #define ELLIPSIS "..."
40 #define FORWARD_SLASH '/'
41 #define BACK_SLASH '\\'
43 static const WCHAR SPACEW
[] = {' ', 0};
44 static const WCHAR oW
[] = {'o', 0};
45 static const WCHAR ELLIPSISW
[] = {'.','.','.', 0};
46 static const WCHAR FORWARD_SLASHW
[] = {'/', 0};
47 static const WCHAR BACK_SLASHW
[] = {'\\', 0};
51 static int spacewidth
;
52 static int prefix_offset
;
55 /*********************************************************************
56 * Return next line of text from a string.
59 * str - string to parse into lines.
60 * count - length of str.
61 * dest - destination in which to return line.
62 * len - dest buffer size in chars on input, copied length into dest on output.
63 * width - maximum width of line in pixels.
64 * format - format type passed to DrawText.
66 * Returns pointer to next char in str after end of the line
67 * or NULL if end of str reached.
70 * GetTextExtentPoint is used to get the width of each character,
71 * rather than GetCharABCWidth... So the whitespace between
72 * characters is ignored, and the reported len is too great.
74 static const WCHAR
*TEXT_NextLineW( HDC hdc
, const WCHAR
*str
, int *count
,
75 WCHAR
*dest
, int *len
, int width
, WORD format
)
82 int wb_i
= 0, wb_j
= 0, wb_count
= 0;
85 while (*count
&& j
< maxl
)
91 if (!(format
& DT_SINGLELINE
))
93 if ((*count
> 1) && (str
[i
] == CR
) && (str
[i
+1] == LF
))
103 dest
[j
++] = str
[i
++];
104 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
105 (format
& DT_WORDBREAK
))
107 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
114 if (!(format
& DT_NOPREFIX
) && *count
> 1)
116 if (str
[++i
] == PREFIX
)
123 dest
[j
++] = str
[i
++];
124 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
125 (format
& DT_WORDBREAK
))
127 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
134 if (format
& DT_EXPANDTABS
)
140 if (!GetTextExtentPointW(hdc
, &dest
[lasttab
], j
- lasttab
, &size
))
143 numspaces
= (tabwidth
- size
.cx
) / spacewidth
;
144 for (k
= 0; k
< numspaces
; k
++)
146 plen
+= tabwidth
- size
.cx
;
147 lasttab
= wb_j
+ numspaces
;
151 dest
[j
++] = str
[i
++];
152 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
153 (format
& DT_WORDBREAK
))
155 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
163 dest
[j
++] = str
[i
++];
164 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
165 (format
& DT_WORDBREAK
))
170 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
177 dest
[j
++] = str
[i
++];
178 if (!(format
& DT_NOCLIP
) || !(format
& DT_NOPREFIX
) ||
179 (format
& DT_WORDBREAK
))
181 if (!GetTextExtentPointW(hdc
, &dest
[j
-1], 1, &size
))
188 if (!(format
& DT_NOCLIP
) || (format
& DT_WORDBREAK
))
192 if (format
& DT_WORDBREAK
)
197 *count
= wb_count
- 1;
215 /***********************************************************************
216 * DrawTextExW (USER32.@)
218 #define MAX_STATIC_BUFFER 1024
219 INT WINAPI
DrawTextExW( HDC hdc
, LPWSTR str
, INT i_count
,
220 LPRECT rect
, UINT flags
, LPDRAWTEXTPARAMS dtp
)
224 static WCHAR line
[MAX_STATIC_BUFFER
];
225 int len
, lh
, count
=i_count
;
229 int lmargin
= 0, rmargin
= 0;
230 int x
= rect
->left
, y
= rect
->top
;
231 int width
= rect
->right
- rect
->left
;
234 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str
, count
), count
,
235 rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
237 if (dtp
) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
238 dtp
->iTabLength
, dtp
->iLeftMargin
, dtp
->iRightMargin
);
241 if (count
== -1) count
= strlenW(str
);
242 if (count
== 0) return 0;
245 GetTextMetricsW(hdc
, &tm
);
246 if (flags
& DT_EXTERNALLEADING
)
247 lh
= tm
.tmHeight
+ tm
.tmExternalLeading
;
253 lmargin
= dtp
->iLeftMargin
* tm
.tmAveCharWidth
;
254 rmargin
= dtp
->iRightMargin
* tm
.tmAveCharWidth
;
255 if (!(flags
& (DT_CENTER
| DT_RIGHT
)))
257 dtp
->uiLengthDrawn
= 0; /* This param RECEIVES number of chars processed */
260 tabstop
= ((flags
& DT_TABSTOP
) && dtp
) ? dtp
->iTabLength
: 8;
262 if (flags
& DT_EXPANDTABS
)
264 GetTextExtentPointW(hdc
, SPACEW
, 1, &size
);
265 spacewidth
= size
.cx
;
266 GetTextExtentPointW(hdc
, oW
, 1, &size
);
267 tabwidth
= size
.cx
* tabstop
;
270 if (flags
& DT_CALCRECT
) flags
|= DT_NOCLIP
;
275 len
= MAX_STATIC_BUFFER
;
276 strPtr
= TEXT_NextLineW(hdc
, strPtr
, &count
, line
, &len
, width
, flags
);
278 if (prefix_offset
!= -1)
280 GetTextExtentPointW(hdc
, line
, prefix_offset
, &size
);
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
-
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
;
298 if ((flags
& DT_SINGLELINE
) && size
.cx
> width
&&
299 (flags
& (DT_PATH_ELLIPSIS
| DT_END_ELLIPSIS
| DT_WORD_ELLIPSIS
)))
301 WCHAR swapStr
[countof(line
)];
302 WCHAR
* fnameDelim
= NULL
;
303 int totalLen
= i_count
>= 0 ? i_count
: strlenW(str
);
304 int fnameLen
= totalLen
;
306 /* allow room for '...' */
307 count
= min(totalLen
+3, countof(line
)-3);
309 if (flags
& DT_WORD_ELLIPSIS
)
310 flags
|= DT_WORDBREAK
;
312 if (flags
& DT_PATH_ELLIPSIS
)
314 WCHAR
* lastBkSlash
= NULL
;
315 WCHAR
* lastFwdSlash
= NULL
;
316 strncpyW(line
, str
, totalLen
);
317 line
[totalLen
] = '\0';
318 lastBkSlash
= strrchrW(line
, BACK_SLASHW
[0]);
319 lastFwdSlash
= strrchrW(line
, FORWARD_SLASHW
[0]);
320 fnameDelim
= lastBkSlash
> lastFwdSlash
? lastBkSlash
: lastFwdSlash
;
323 fnameLen
= &line
[totalLen
] - fnameDelim
;
325 fnameDelim
= (WCHAR
*)str
;
327 strcpyW(swapStr
, ELLIPSISW
);
328 strncpyW(swapStr
+strlenW(swapStr
), fnameDelim
, fnameLen
);
329 swapStr
[fnameLen
+3] = '\0';
330 strncpyW(swapStr
+strlenW(swapStr
), str
, totalLen
- fnameLen
);
331 swapStr
[totalLen
+3] = '\0';
333 else /* DT_END_ELLIPSIS | DT_WORD_ELLIPSIS */
335 strcpyW(swapStr
, ELLIPSISW
);
336 strncpyW(swapStr
+strlenW(swapStr
), str
, totalLen
);
339 len
= MAX_STATIC_BUFFER
;
340 TEXT_NextLineW(hdc
, swapStr
, &count
, line
, &len
, width
, flags
);
342 /* if only the ELLIPSIS will fit, just let it be clipped */
344 GetTextExtentPointW(hdc
, line
, len
, &size
);
347 * NextLine uses GetTextExtentPoint for each character,
348 * rather than GetCharABCWidth... So the whitespace between
349 * characters is ignored in the width measurement, and the
350 * reported len is too great. To compensate, we must get
351 * the width of the entire line and adjust len accordingly.
353 while ((size
.cx
> width
) && (len
> 3))
356 GetTextExtentPointW(hdc
, line
, len
, &size
);
359 if (fnameLen
< len
-3) /* some of the path will fit */
361 /* put the ELLIPSIS between the path and filename */
362 strncpyW(swapStr
, &line
[fnameLen
+3], len
-3-fnameLen
);
363 swapStr
[len
-3-fnameLen
] = '\0';
364 strcatW(swapStr
, ELLIPSISW
);
365 strncpyW(swapStr
+strlenW(swapStr
), &line
[3], fnameLen
);
369 /* move the ELLIPSIS to the end */
370 strncpyW(swapStr
, &line
[3], len
-3);
371 swapStr
[len
-3] = '\0';
372 strcpyW(swapStr
+strlenW(swapStr
), ELLIPSISW
);
375 strncpyW(line
, swapStr
, len
);
379 if (flags
& DT_MODIFYSTRING
)
380 strcpyW(str
, swapStr
);
382 /* Note that really we ought to refigure the location of
383 * the underline for the prefix; it might be currently set for
384 * something we have just ellipsified out.
387 if (!(flags
& DT_CALCRECT
))
389 if (!ExtTextOutW( hdc
, x
, y
,
390 ((flags
& DT_NOCLIP
) ? 0 : ETO_CLIPPED
) |
391 ((flags
& DT_RTLREADING
) ? ETO_RTLREADING
: 0),
392 rect
, line
, len
, NULL
)) return 0;
393 if (prefix_offset
!= -1)
395 HPEN hpen
= CreatePen( PS_SOLID
, 1, GetTextColor(hdc
) );
396 HPEN oldPen
= SelectObject( hdc
, hpen
);
397 MoveToEx(hdc
, x
+ prefix_x
, y
+ tm
.tmAscent
+ 1, NULL
);
398 LineTo(hdc
, x
+ prefix_end
+ 1, y
+ tm
.tmAscent
+ 1 );
399 SelectObject( hdc
, oldPen
);
400 DeleteObject( hpen
);
403 else if (size
.cx
> max_width
)
409 if (!(flags
& DT_NOCLIP
))
411 if (y
> rect
->bottom
- lh
)
416 dtp
->uiLengthDrawn
+= len
;
420 if (flags
& DT_CALCRECT
)
422 rect
->right
= rect
->left
+ max_width
;
425 rect
->right
+= lmargin
+ rmargin
;
427 return y
- rect
->top
;
430 /***********************************************************************
431 * DrawTextExA (USER32.@)
433 INT WINAPI
DrawTextExA( HDC hdc
, LPSTR str
, INT count
,
434 LPRECT rect
, UINT flags
, LPDRAWTEXTPARAMS dtp
)
440 if (count
== -1) count
= strlen(str
);
441 if (!count
) return 0;
442 wcount
= MultiByteToWideChar( CP_ACP
, 0, str
, count
, NULL
, 0 );
443 wstr
= HeapAlloc(GetProcessHeap(), 0, wcount
* sizeof(WCHAR
));
446 MultiByteToWideChar( CP_ACP
, 0, str
, count
, wstr
, wcount
);
447 ret
= DrawTextExW( hdc
, wstr
, wcount
, rect
, flags
, NULL
);
448 if (flags
& DT_MODIFYSTRING
)
449 WideCharToMultiByte( CP_ACP
, 0, wstr
, -1, str
, count
, NULL
, NULL
);
450 HeapFree(GetProcessHeap(), 0, wstr
);
455 /***********************************************************************
456 * DrawTextW (USER32.@)
458 INT WINAPI
DrawTextW( HDC hdc
, LPCWSTR str
, INT count
, LPRECT rect
, UINT flags
)
462 memset (&dtp
, 0, sizeof(dtp
));
463 if (flags
& DT_TABSTOP
)
465 dtp
.iTabLength
= (flags
>> 8) && 0xff;
468 return DrawTextExW(hdc
, (LPWSTR
)str
, count
, rect
, flags
, &dtp
);
471 /***********************************************************************
472 * DrawTextA (USER32.@)
474 INT WINAPI
DrawTextA( HDC hdc
, LPCSTR str
, INT count
, LPRECT rect
, UINT flags
)
478 memset (&dtp
, 0, sizeof(dtp
));
479 if (flags
& DT_TABSTOP
)
481 dtp
.iTabLength
= (flags
>> 8) && 0xff;
484 return DrawTextExA( hdc
, (LPSTR
)str
, count
, rect
, flags
, &dtp
);
487 /***********************************************************************
490 INT16 WINAPI
DrawText16( HDC16 hdc
, LPCSTR str
, INT16 count
, LPRECT16 rect
, UINT16 flags
)
497 CONV_RECT16TO32( rect
, &rect32
);
498 ret
= DrawTextA( hdc
, str
, count
, &rect32
, flags
);
499 CONV_RECT32TO16( &rect32
, rect
);
501 else ret
= DrawTextA( hdc
, str
, count
, NULL
, flags
);
506 /***********************************************************************
508 * GrayString functions
511 /* ### start build ### */
512 extern WORD CALLBACK
TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16
,WORD
,LONG
,WORD
);
513 /* ### stop build ### */
515 struct gray_string_info
517 GRAYSTRINGPROC16 proc
;
521 /* callback for 16-bit gray string proc */
522 static BOOL CALLBACK
gray_string_callback( HDC hdc
, LPARAM param
, INT len
)
524 const struct gray_string_info
*info
= (struct gray_string_info
*)param
;
525 return TEXT_CallTo16_word_wlw( info
->proc
, hdc
, info
->param
, len
);
528 /***********************************************************************
531 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
532 * heap and we can guarantee that the handles fit in an INT16. We have to
533 * rethink the strategy once the migration to NT handles is complete.
534 * We are going to get a lot of code-duplication once this migration is
538 static BOOL
TEXT_GrayString(HDC hdc
, HBRUSH hb
, GRAYSTRINGPROC fn
, LPARAM lp
, INT len
,
539 INT x
, INT y
, INT cx
, INT cy
, BOOL unicode
, BOOL _32bit
)
541 HBITMAP hbm
, hbmsave
;
549 if(!hdc
) return FALSE
;
550 if (!(memdc
= CreateCompatibleDC(hdc
))) return FALSE
;
555 slen
= lstrlenW((LPCWSTR
)lp
);
557 slen
= strlen((LPCSTR
)lp
);
559 slen
= strlen(MapSL(lp
));
562 if((cx
== 0 || cy
== 0) && slen
!= -1)
566 GetTextExtentPoint32W(hdc
, (LPCWSTR
)lp
, slen
, &s
);
568 GetTextExtentPoint32A(hdc
, (LPCSTR
)lp
, slen
, &s
);
570 GetTextExtentPoint32A(hdc
, MapSL(lp
), slen
, &s
);
571 if(cx
== 0) cx
= s
.cx
;
572 if(cy
== 0) cy
= s
.cy
;
575 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
576 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
577 hbsave
= SelectObject( memdc
, GetStockObject(BLACK_BRUSH
) );
578 PatBlt( memdc
, 0, 0, cx
, cy
, PATCOPY
);
579 SelectObject( memdc
, hbsave
);
580 SetTextColor(memdc
, RGB(255, 255, 255));
581 SetBkColor(memdc
, RGB(0, 0, 0));
582 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
587 retval
= fn(memdc
, lp
, slen
);
589 retval
= (BOOL
)((BOOL16
)((GRAYSTRINGPROC16
)fn
)((HDC16
)memdc
, lp
, (INT16
)slen
));
594 TextOutW(memdc
, 0, 0, (LPCWSTR
)lp
, slen
);
596 TextOutA(memdc
, 0, 0, (LPCSTR
)lp
, slen
);
598 TextOutA(memdc
, 0, 0, MapSL(lp
), slen
);
601 SelectObject(memdc
, hfsave
);
604 * Windows doc says that the bitmap isn't grayed when len == -1 and
605 * the callback function returns FALSE. However, testing this on
606 * win95 showed otherwise...
608 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
609 if(retval
|| len
!= -1)
612 hbsave
= (HBRUSH
)SelectObject(memdc
, CACHE_GetPattern55AABrush());
613 PatBlt(memdc
, 0, 0, cx
, cy
, 0x000A0329);
614 SelectObject(memdc
, hbsave
);
617 if(hb
) hbsave
= (HBRUSH
)SelectObject(hdc
, hb
);
618 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
619 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
620 BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00E20746);
621 SetTextColor(hdc
, fg
);
623 if(hb
) SelectObject(hdc
, hbsave
);
625 SelectObject(memdc
, hbmsave
);
632 /***********************************************************************
633 * GrayString (USER.185)
635 BOOL16 WINAPI
GrayString16( HDC16 hdc
, HBRUSH16 hbr
, GRAYSTRINGPROC16 gsprc
,
636 LPARAM lParam
, INT16 cch
, INT16 x
, INT16 y
,
639 struct gray_string_info info
;
641 if (!gsprc
) return TEXT_GrayString(hdc
, hbr
, NULL
, lParam
, cch
, x
, y
, cx
, cy
, FALSE
, FALSE
);
644 return TEXT_GrayString( hdc
, hbr
, gray_string_callback
, (LPARAM
)&info
,
645 cch
, x
, y
, cx
, cy
, FALSE
, FALSE
);
649 /***********************************************************************
650 * GrayStringA (USER32.@)
652 BOOL WINAPI
GrayStringA( HDC hdc
, HBRUSH hbr
, GRAYSTRINGPROC gsprc
,
653 LPARAM lParam
, INT cch
, INT x
, INT y
,
656 return TEXT_GrayString(hdc
, hbr
, gsprc
, lParam
, cch
, x
, y
, cx
, cy
,
661 /***********************************************************************
662 * GrayStringW (USER32.@)
664 BOOL WINAPI
GrayStringW( HDC hdc
, HBRUSH hbr
, GRAYSTRINGPROC gsprc
,
665 LPARAM lParam
, INT cch
, INT x
, INT y
,
668 return TEXT_GrayString(hdc
, hbr
, gsprc
, lParam
, cch
, x
, y
, cx
, cy
,
672 /***********************************************************************
674 * TabbedText functions
677 /***********************************************************************
680 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
681 * Note: this doesn't work too well for text-alignment modes other
682 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
684 static LONG
TEXT_TabbedTextOut( HDC hdc
, INT x
, INT y
, LPCSTR lpstr
,
685 INT count
, INT cTabStops
, const INT16
*lpTabPos16
,
686 const INT
*lpTabPos32
, INT nTabOrg
,
699 defWidth
= lpTabPos32
? *lpTabPos32
: *lpTabPos16
;
705 GetTextMetricsA( hdc
, &tm
);
706 defWidth
= 8 * tm
.tmAveCharWidth
;
711 for (i
= 0; i
< count
; i
++)
712 if (lpstr
[i
] == '\t') break;
713 GetTextExtentPointA( hdc
, lpstr
, i
, &extent
);
716 while ((cTabStops
> 0) &&
717 (nTabOrg
+ *lpTabPos32
<= x
+ extent
.cx
))
725 while ((cTabStops
> 0) &&
726 (nTabOrg
+ *lpTabPos16
<= x
+ extent
.cx
))
733 tabPos
= x
+ extent
.cx
;
734 else if (cTabStops
> 0)
735 tabPos
= nTabOrg
+ (lpTabPos32
? *lpTabPos32
: *lpTabPos16
);
737 tabPos
= nTabOrg
+ ((x
+ extent
.cx
- nTabOrg
) / defWidth
+ 1) * defWidth
;
744 r
.bottom
= y
+ extent
.cy
;
745 ExtTextOutA( hdc
, x
, y
,
746 GetBkMode(hdc
) == OPAQUE
? ETO_OPAQUE
: 0,
747 &r
, lpstr
, i
, NULL
);
753 return MAKELONG(tabPos
- start
, extent
.cy
);
757 /***********************************************************************
758 * TabbedTextOut (USER.196)
760 LONG WINAPI
TabbedTextOut16( HDC16 hdc
, INT16 x
, INT16 y
, LPCSTR lpstr
,
761 INT16 count
, INT16 cTabStops
,
762 const INT16
*lpTabPos
, INT16 nTabOrg
)
764 TRACE("%04x %d,%d %s %d\n", hdc
, x
, y
, debugstr_an(lpstr
,count
), count
);
765 return TEXT_TabbedTextOut( hdc
, x
, y
, lpstr
, count
, cTabStops
,
766 lpTabPos
, NULL
, nTabOrg
, TRUE
);
770 /***********************************************************************
771 * TabbedTextOutA (USER32.@)
773 LONG WINAPI
TabbedTextOutA( HDC hdc
, INT x
, INT y
, LPCSTR lpstr
, INT count
,
774 INT cTabStops
, const INT
*lpTabPos
, INT nTabOrg
)
776 TRACE("%04x %d,%d %s %d\n", hdc
, x
, y
, debugstr_an(lpstr
,count
), count
);
777 return TEXT_TabbedTextOut( hdc
, x
, y
, lpstr
, count
, cTabStops
,
778 NULL
, lpTabPos
, nTabOrg
, TRUE
);
782 /***********************************************************************
783 * TabbedTextOutW (USER32.@)
785 LONG WINAPI
TabbedTextOutW( HDC hdc
, INT x
, INT y
, LPCWSTR str
, INT count
,
786 INT cTabStops
, const INT
*lpTabPos
, INT nTabOrg
)
791 UINT codepage
= CP_ACP
; /* FIXME: get codepage of font charset */
793 acount
= WideCharToMultiByte(codepage
,0,str
,count
,NULL
,0,NULL
,NULL
);
794 p
= HeapAlloc( GetProcessHeap(), 0, acount
);
795 if(p
== NULL
) return 0; /* FIXME: is this the correct return on failure */
796 acount
= WideCharToMultiByte(codepage
,0,str
,count
,p
,acount
,NULL
,NULL
);
797 ret
= TabbedTextOutA( hdc
, x
, y
, p
, acount
, cTabStops
, lpTabPos
, nTabOrg
);
798 HeapFree( GetProcessHeap(), 0, p
);
803 /***********************************************************************
804 * GetTabbedTextExtent (USER.197)
806 DWORD WINAPI
GetTabbedTextExtent16( HDC16 hdc
, LPCSTR lpstr
, INT16 count
,
807 INT16 cTabStops
, const INT16
*lpTabPos
)
809 TRACE("%04x %s %d\n", hdc
, debugstr_an(lpstr
,count
), count
);
810 return TEXT_TabbedTextOut( hdc
, 0, 0, lpstr
, count
, cTabStops
,
811 lpTabPos
, NULL
, 0, FALSE
);
815 /***********************************************************************
816 * GetTabbedTextExtentA (USER32.@)
818 DWORD WINAPI
GetTabbedTextExtentA( HDC hdc
, LPCSTR lpstr
, INT count
,
819 INT cTabStops
, const INT
*lpTabPos
)
821 TRACE("%04x %s %d\n", hdc
, debugstr_an(lpstr
,count
), count
);
822 return TEXT_TabbedTextOut( hdc
, 0, 0, lpstr
, count
, cTabStops
,
823 NULL
, lpTabPos
, 0, FALSE
);
827 /***********************************************************************
828 * GetTabbedTextExtentW (USER32.@)
830 DWORD WINAPI
GetTabbedTextExtentW( HDC hdc
, LPCWSTR lpstr
, INT count
,
831 INT cTabStops
, const INT
*lpTabPos
)
836 UINT codepage
= CP_ACP
; /* FIXME: get codepage of font charset */
838 acount
= WideCharToMultiByte(codepage
,0,lpstr
,count
,NULL
,0,NULL
,NULL
);
839 p
= HeapAlloc( GetProcessHeap(), 0, acount
);
840 if(p
== NULL
) return 0; /* FIXME: is this the correct failure value? */
841 acount
= WideCharToMultiByte(codepage
,0,lpstr
,count
,p
,acount
,NULL
,NULL
);
842 ret
= GetTabbedTextExtentA( hdc
, p
, acount
, cTabStops
, lpTabPos
);
843 HeapFree( GetProcessHeap(), 0, p
);