Release 960805
[wine] / objects / text.c
1 /*
2  * text functions
3  *
4  * Copyright 1993, 1994 Alexandre Julliard
5  *
6  */
7
8 #include <stdlib.h>
9 #include <X11/Xatom.h>
10 #include "windows.h"
11 #include "dc.h"
12 #include "gdi.h"
13 #include "callback.h"
14 #include "metafile.h"
15 #include "string32.h"
16 #include "stddebug.h"
17 /* #define DEBUG_TEXT */
18 #include "debug.h"
19 #include "xmalloc.h"
20
21 #define TAB     9
22 #define LF     10
23 #define CR     13
24 #define SPACE  32
25 #define PREFIX 38
26
27 #define SWAP_INT(a,b)  { int t = a; a = b; b = t; }
28
29 static int tabstop = 8;
30 static int tabwidth;
31 static int spacewidth;
32 static int prefix_offset;
33
34
35 static const char *TEXT_NextLine( HDC hdc, const char *str, int *count,
36                                   char *dest, int *len, int width, WORD format)
37 {
38     /* Return next line of text from a string.
39      * 
40      * hdc - handle to DC.
41      * str - string to parse into lines.
42      * count - length of str.
43      * dest - destination in which to return line.
44      * len - length of resultant line in dest in chars.
45      * width - maximum width of line in pixels.
46      * format - format type passed to DrawText.
47      *
48      * Returns pointer to next char in str after end of the line
49      * or NULL if end of str reached.
50      */
51
52     int i = 0, j = 0, k;
53     int plen = 0;
54     int numspaces;
55     SIZE16 size;
56     int lasttab = 0;
57     int wb_i = 0, wb_j = 0, wb_count = 0;
58
59     while (*count)
60     {
61         switch (str[i])
62         {
63         case CR:
64         case LF:
65             if (!(format & DT_SINGLELINE))
66             {
67                 if (str[i] == CR && str[i+1] == LF)
68                     i++;
69                 i++;
70                 *len = j;
71                 (*count)--;
72                 return (&str[i]);
73             }
74             dest[j++] = str[i++];
75             if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
76                 (format & DT_WORDBREAK))
77             {
78                 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
79                     return NULL;
80                 plen += size.cx;
81             }
82             break;
83             
84         case PREFIX:
85             if (!(format & DT_NOPREFIX))
86             {
87                 prefix_offset = j;
88                 i++;
89             }
90             else
91             {
92                 dest[j++] = str[i++];
93                 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
94                 {
95                     if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
96                         return NULL;
97                     plen += size.cx;
98                 }
99             }
100             break;
101             
102         case TAB:
103             if (format & DT_EXPANDTABS)
104             {
105                 wb_i = ++i;
106                 wb_j = j;
107                 wb_count = *count;
108
109                 if (!GetTextExtentPoint16(hdc, &dest[lasttab], j - lasttab,
110                                                                  &size))
111                     return NULL;
112
113                 numspaces = (tabwidth - size.cx) / spacewidth;
114                 for (k = 0; k < numspaces; k++)
115                     dest[j++] = SPACE;
116                 plen += tabwidth - size.cx;
117                 lasttab = wb_j + numspaces;
118             }
119             else
120             {
121                 dest[j++] = str[i++];
122                 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
123                     (format & DT_WORDBREAK))
124                 {
125                     if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
126                         return NULL;
127                     plen += size.cx;
128                 }
129             }
130             break;
131
132         case SPACE:
133             dest[j++] = str[i++];
134             if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
135                 (format & DT_WORDBREAK))
136             {
137                 wb_i = i;
138                 wb_j = j - 1;
139                 wb_count = *count;
140                 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
141                     return NULL;
142                 plen += size.cx;
143             }
144             break;
145
146         default:
147             dest[j++] = str[i++];
148             if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
149                 (format & DT_WORDBREAK))
150             {
151                 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
152                     return NULL;
153                 plen += size.cx;
154             }
155         }
156
157         (*count)--;
158         if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
159         {
160             if (plen > width)
161             {
162                 if (format & DT_WORDBREAK)
163                 {
164                     if (wb_j)
165                     {
166                         *len = wb_j;
167                         *count = wb_count - 1;
168                         return (&str[wb_i]);
169                     }
170                 }
171                 else
172                 {
173                     *len = j;
174                     return (&str[i]);
175                 }
176             }
177         }
178     }
179     
180     *len = j;
181     return NULL;
182 }
183
184
185 /***********************************************************************
186  *           DrawText16    (USER.85)
187  */
188 INT16 DrawText16( HDC16 hdc, LPCSTR str, INT16 i_count,
189                   LPRECT16 rect, UINT16 flags )
190 {
191     SIZE16 size;
192     const char *strPtr;
193     static char line[1024];
194     int len, lh, count=i_count;
195     int prefix_x = 0;
196     int prefix_end = 0;
197     TEXTMETRIC16 tm;
198     int x = rect->left, y = rect->top;
199     int width = rect->right - rect->left;
200     int max_width = 0;
201
202     dprintf_text(stddeb,"DrawText: '%s', %d , [(%d,%d),(%d,%d)]\n", str,
203                  count, rect->left, rect->top, rect->right, rect->bottom);
204     
205     if (count == -1) count = strlen(str);
206     strPtr = str;
207
208     GetTextMetrics16(hdc, &tm);
209     if (flags & DT_EXTERNALLEADING)
210         lh = tm.tmHeight + tm.tmExternalLeading;
211     else
212         lh = tm.tmHeight;
213
214     if (flags & DT_TABSTOP)
215         tabstop = flags >> 8;
216
217     if (flags & DT_EXPANDTABS)
218     {
219         GetTextExtentPoint16(hdc, " ", 1, &size);
220         spacewidth = size.cx;
221         GetTextExtentPoint16(hdc, "o", 1, &size);
222         tabwidth = size.cx * tabstop;
223     }
224
225     do
226     {
227         prefix_offset = -1;
228         strPtr = TEXT_NextLine(hdc, strPtr, &count, line, &len, width, flags);
229
230         if (prefix_offset != -1)
231         {
232             GetTextExtentPoint16(hdc, line, prefix_offset, &size);
233             prefix_x = size.cx;
234             GetTextExtentPoint16(hdc, line, prefix_offset + 1, &size);
235             prefix_end = size.cx - 1;
236         }
237
238         if (!GetTextExtentPoint16(hdc, line, len, &size)) return 0;
239         if (flags & DT_CENTER) x = (rect->left + rect->right -
240                                     size.cx) / 2;
241         else if (flags & DT_RIGHT) x = rect->right - size.cx;
242
243         if (flags & DT_SINGLELINE)
244         {
245             if (flags & DT_VCENTER) y = rect->top + 
246                 (rect->bottom - rect->top) / 2 - size.cy / 2;
247             else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
248         }
249         if (!(flags & DT_CALCRECT))
250         {
251             if (!ExtTextOut16(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
252                               rect, line, len, NULL )) return 0;
253             if (prefix_offset != -1)
254             {
255                 HPEN16 hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
256                 HPEN16 oldPen = SelectObject( hdc, hpen );
257                 MoveTo(hdc, x + prefix_x, y + tm.tmAscent + 1 );
258                 LineTo(hdc, x + prefix_end, y + tm.tmAscent + 1 );
259                 SelectObject( hdc, oldPen );
260                 DeleteObject( hpen );
261             }
262         }
263         else if (size.cx > max_width)
264             max_width = size.cx;
265
266         y += lh;
267         if (strPtr)
268         {
269             if (!(flags & DT_NOCLIP) && !(flags & DT_CALCRECT))
270             {
271                 if (y > rect->bottom - lh)
272                     break;
273             }
274         }
275     }
276     while (strPtr);
277     if (flags & DT_CALCRECT)
278     {
279         rect->right = rect->left + max_width;
280         rect->bottom = y;
281     }
282     return 1;
283 }
284
285
286 /***********************************************************************
287  *           DrawText32A    (USER32.163)
288  */
289 INT32 DrawText32A( HDC32 hdc, LPCSTR str, INT32 count,
290                    LPRECT32 rect, UINT32 flags )
291 {
292     RECT16 rect16;
293     INT16 ret;
294
295     if (!rect)
296         return DrawText16( (HDC16)hdc, str, (INT16)count, NULL, (UINT16)flags);
297     CONV_RECT32TO16( rect, &rect16 );
298     ret = DrawText16( (HDC16)hdc, str, (INT16)count, &rect16, (UINT16)flags );
299     CONV_RECT16TO32( &rect16, rect );
300     return ret;
301 }
302
303
304 /***********************************************************************
305  *           DrawText32W    (USER32.166)
306  */
307 INT32 DrawText32W( HDC32 hdc, LPCWSTR str, INT32 count,
308                    LPRECT32 rect, UINT32 flags )
309 {
310     char *p = STRING32_DupUniToAnsi( str );
311     INT32 ret = DrawText32A( hdc, p, count, rect, flags );
312     free(p);
313     return ret;
314 }
315
316
317 /***********************************************************************
318  *           ExtTextOut16    (GDI.351)
319  */
320 BOOL16 ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
321                      const RECT16 *lprect, LPCSTR str, UINT16 count,
322                      const INT16 *lpDx )
323 {
324     int dir, ascent, descent, i;
325     XCharStruct info;
326     XFontStruct *font;
327     RECT16 rect;
328
329     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
330     if (!dc) 
331     {
332         dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC );
333         if (!dc) return FALSE;
334         MF_ExtTextOut( dc, x, y, flags, lprect, str, count, lpDx );
335         return TRUE;
336     }
337
338     if (!DC_SetupGCForText( dc )) return TRUE;
339     font = dc->u.x.font.fstruct;
340
341     dprintf_text(stddeb,"ExtTextOut: hdc=%04x %d,%d '%*.*s', %d  flags=%d\n",
342             hdc, x, y, count, count, str, count, flags);
343     if (lprect != NULL) dprintf_text(stddeb, "\trect=(%d,%d- %d,%d)\n",
344                                      lprect->left, lprect->top,
345                                      lprect->right, lprect->bottom );
346
347       /* Setup coordinates */
348
349     if (dc->w.textAlign & TA_UPDATECP)
350     {
351         x = dc->w.CursPosX;
352         y = dc->w.CursPosY;
353     }
354
355     if (flags & (ETO_OPAQUE | ETO_CLIPPED))  /* there's a rectangle */
356     {
357         if (!lprect)  /* not always */
358         {
359             SIZE16 sz;
360             if (flags & ETO_CLIPPED)  /* Can't clip with no rectangle */
361               return FALSE;
362             if (!GetTextExtentPoint16( hdc, str, count, &sz ))
363               return FALSE;
364             rect.left   = XLPTODP( dc, x );
365             rect.right  = XLPTODP( dc, x+sz.cx );
366             rect.top    = YLPTODP( dc, y );
367             rect.bottom = YLPTODP( dc, y+sz.cy );
368         }
369         else
370         {
371             rect.left   = XLPTODP( dc, lprect->left );
372             rect.right  = XLPTODP( dc, lprect->right );
373             rect.top    = YLPTODP( dc, lprect->top );
374             rect.bottom = YLPTODP( dc, lprect->bottom );
375         }
376         if (rect.right < rect.left) SWAP_INT( rect.left, rect.right );
377         if (rect.bottom < rect.top) SWAP_INT( rect.top, rect.bottom );
378     }
379
380     x = XLPTODP( dc, x );
381     y = YLPTODP( dc, y );
382
383     dprintf_text(stddeb,"\treal coord: x=%i, y=%i, rect=(%d,%d-%d,%d)\n",
384                           x, y, rect.left, rect.top, rect.right, rect.bottom);
385
386       /* Draw the rectangle */
387
388     if (flags & ETO_OPAQUE)
389     {
390         XSetForeground( display, dc->u.x.gc, dc->w.backgroundPixel );
391         XFillRectangle( display, dc->u.x.drawable, dc->u.x.gc,
392                         dc->w.DCOrgX + rect.left, dc->w.DCOrgY + rect.top,
393                         rect.right-rect.left, rect.bottom-rect.top );
394     }
395     if (!count) return TRUE;  /* Nothing more to do */
396
397       /* Compute text starting position */
398
399     XTextExtents( font, str, count, &dir, &ascent, &descent, &info );
400
401     if (lpDx) /* have explicit character cell x offsets */
402     {
403         /* sum lpDx array and add the width of last character */
404
405         info.width = XTextWidth( font, str + count - 1, 1) + dc->w.charExtra;
406         if (str[count-1] == (char)dc->u.x.font.metrics.tmBreakChar)
407             info.width += dc->w.breakExtra;
408
409         for (i = 0; i < count; i++) info.width += lpDx[i];
410     }
411     else
412        info.width += count*dc->w.charExtra + dc->w.breakExtra*dc->w.breakCount;
413
414     switch( dc->w.textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) )
415     {
416       case TA_LEFT:
417           if (dc->w.textAlign & TA_UPDATECP)
418               dc->w.CursPosX = XDPTOLP( dc, x + info.width );
419           break;
420       case TA_RIGHT:
421           x -= info.width;
422           if (dc->w.textAlign & TA_UPDATECP) dc->w.CursPosX = XDPTOLP( dc, x );
423           break;
424       case TA_CENTER:
425           x -= info.width / 2;
426           break;
427     }
428
429     switch( dc->w.textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) )
430     {
431       case TA_TOP:
432           y += font->ascent;
433           break;
434       case TA_BOTTOM:
435           y -= font->descent;
436           break;
437       case TA_BASELINE:
438           break;
439     }
440
441       /* Set the clip region */
442
443     if (flags & ETO_CLIPPED)
444     {
445         SaveVisRgn( hdc );
446         IntersectVisRect( hdc, rect.left, rect.top, rect.right, rect.bottom );
447     }
448
449       /* Draw the text background if necessary */
450
451     if (dc->w.backgroundMode != TRANSPARENT)
452     {
453           /* If rectangle is opaque and clipped, do nothing */
454         if (!(flags & ETO_CLIPPED) || !(flags & ETO_OPAQUE))
455         {
456               /* Only draw if rectangle is not opaque or if some */
457               /* text is outside the rectangle */
458             if (!(flags & ETO_OPAQUE) ||
459                 (x < rect.left) ||
460                 (x + info.width >= rect.right) ||
461                 (y-font->ascent < rect.top) ||
462                 (y+font->descent >= rect.bottom))
463             {
464                 XSetForeground( display, dc->u.x.gc, dc->w.backgroundPixel );
465                 XFillRectangle( display, dc->u.x.drawable, dc->u.x.gc,
466                                 dc->w.DCOrgX + x,
467                                 dc->w.DCOrgY + y - font->ascent,
468                                 info.width,
469                                 font->ascent + font->descent );
470             }
471         }
472     }
473     
474     /* Draw the text (count > 0 verified) */
475
476     XSetForeground( display, dc->u.x.gc, dc->w.textPixel );
477     if (!dc->w.charExtra && !dc->w.breakExtra && !lpDx)
478     {
479         XDrawString( display, dc->u.x.drawable, dc->u.x.gc, 
480                      dc->w.DCOrgX + x, dc->w.DCOrgY + y, str, count );
481     }
482     else  /* Now the fun begins... */
483     {
484         XTextItem *items, *pitem;
485         int delta;
486
487         /* allocate max items */
488
489         pitem = items = xmalloc( count * sizeof(XTextItem) );
490         delta = i = 0;
491         while (i < count)
492         {
493             /* initialize text item with accumulated delta */
494
495             pitem->chars  = (char *)str + i;
496             pitem->delta  = delta; 
497             pitem->nchars = 0;
498             pitem->font   = None;
499             delta = 0;
500
501             /* stuff characters into the same XTextItem until new delta 
502              * becomes  non-zero */
503
504             do
505             {
506                 if (lpDx) delta += lpDx[i] - XTextWidth( font, str + i, 1);
507                 else
508                 {
509                     delta += dc->w.charExtra;
510                     if (str[i] == (char)dc->u.x.font.metrics.tmBreakChar)
511                         delta += dc->w.breakExtra;
512                 }
513                 pitem->nchars++;
514             } 
515             while ((++i < count) && !delta);
516             pitem++;
517         }
518
519         XDrawText( display, dc->u.x.drawable, dc->u.x.gc,
520                    dc->w.DCOrgX + x, dc->w.DCOrgY + y, items, pitem - items );
521         free( items );
522     }
523
524       /* Draw underline and strike-out if needed */
525
526     if (dc->u.x.font.metrics.tmUnderlined)
527     {
528         long linePos, lineWidth;       
529         if (!XGetFontProperty( font, XA_UNDERLINE_POSITION, &linePos ))
530             linePos = font->descent-1;
531         if (!XGetFontProperty( font, XA_UNDERLINE_THICKNESS, &lineWidth ))
532             lineWidth = 0;
533         else if (lineWidth == 1) lineWidth = 0;
534         XSetLineAttributes( display, dc->u.x.gc, lineWidth,
535                             LineSolid, CapRound, JoinBevel ); 
536         XDrawLine( display, dc->u.x.drawable, dc->u.x.gc,
537                    dc->w.DCOrgX + x, dc->w.DCOrgY + y + linePos,
538                    dc->w.DCOrgX + x + info.width, dc->w.DCOrgY + y + linePos );
539     }
540     if (dc->u.x.font.metrics.tmStruckOut)
541     {
542         long lineAscent, lineDescent;
543         if (!XGetFontProperty( font, XA_STRIKEOUT_ASCENT, &lineAscent ))
544             lineAscent = font->ascent / 3;
545         if (!XGetFontProperty( font, XA_STRIKEOUT_DESCENT, &lineDescent ))
546             lineDescent = -lineAscent;
547         XSetLineAttributes( display, dc->u.x.gc, lineAscent + lineDescent,
548                             LineSolid, CapRound, JoinBevel ); 
549         XDrawLine( display, dc->u.x.drawable, dc->u.x.gc,
550                    dc->w.DCOrgX + x, dc->w.DCOrgY + y - lineAscent,
551                    dc->w.DCOrgX + x + info.width, dc->w.DCOrgY + y - lineAscent );
552     }
553     if (flags & ETO_CLIPPED) RestoreVisRgn( hdc );
554     return TRUE;
555 }
556
557
558 /***********************************************************************
559  *           ExtTextOut32A    (GDI32.98)
560  */
561 BOOL32 ExtTextOut32A( HDC32 hdc, INT32 x, INT32 y, UINT32 flags,
562                       const RECT32 *lprect, LPCSTR str, UINT32 count,
563                       const INT32 *lpDx )
564 {
565     RECT16 rect16;
566
567     if (lpDx) fprintf( stderr, "ExtTextOut32A: lpDx not implemented\n" );
568     if (!lprect)
569         return ExtTextOut16( (HDC16)hdc, (INT16)x, (INT16)y, (UINT16)flags,
570                              NULL, str, (UINT16)count, NULL );
571     CONV_RECT32TO16( lprect, &rect16 );
572     return ExtTextOut16( (HDC16)hdc, (INT16)x, (INT16)y, (UINT16)flags,
573                          &rect16, str, (UINT16)count, NULL );
574 }
575
576
577 /***********************************************************************
578  *           ExtTextOut32W    (GDI32.99)
579  */
580 BOOL32 ExtTextOut32W( HDC32 hdc, INT32 x, INT32 y, UINT32 flags,
581                       const RECT32 *lprect, LPCWSTR str, UINT32 count,
582                       const INT32 *lpDx )
583 {
584     char *p = STRING32_DupUniToAnsi( str );
585     INT32 ret = ExtTextOut32A( hdc, x, y, flags, lprect, p, count, lpDx );
586     free(p);
587     return ret;
588 }
589
590
591 /***********************************************************************
592  *           TextOut16    (GDI.33)
593  */
594 BOOL16 TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
595 {
596     return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
597 }
598
599
600 /***********************************************************************
601  *           TextOut32A    (GDI32.355)
602  */
603 BOOL32 TextOut32A( HDC32 hdc, INT32 x, INT32 y, LPCSTR str, INT32 count )
604 {
605     return ExtTextOut32A( hdc, x, y, 0, NULL, str, count, NULL );
606 }
607
608
609 /***********************************************************************
610  *           TextOut32W    (GDI32.356)
611  */
612 BOOL32 TextOut32W( HDC32 hdc, INT32 x, INT32 y, LPCWSTR str, INT32 count )
613 {
614     return ExtTextOut32W( hdc, x, y, 0, NULL, str, count, NULL );
615 }
616
617
618 /***********************************************************************
619  *           GrayString   (USER.185)
620  */
621 BOOL GrayString(HDC hdc, HBRUSH hbr, GRAYSTRINGPROC16 gsprc, LPARAM lParam, 
622                 INT cch, INT x, INT y, INT cx, INT cy)
623 {
624     BOOL ret;
625     COLORREF current_color;
626
627     if (!cch) cch = lstrlen16( (LPCSTR)PTR_SEG_TO_LIN(lParam) );
628     if (gsprc) return gsprc( hdc, lParam, cch );
629     current_color = GetTextColor( hdc );
630     SetTextColor( hdc, GetSysColor(COLOR_GRAYTEXT) );
631     ret = TextOut16( hdc, x, y, (LPCSTR)PTR_SEG_TO_LIN(lParam), cch );
632     SetTextColor( hdc, current_color );
633     return ret;
634 }
635
636
637 /***********************************************************************
638  *           TEXT_TabbedTextOut
639  *
640  * Helper function for TabbedTextOut() and GetTabbedTextExtent().
641  * Note: this doesn't work too well for text-alignment modes other
642  *       than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
643  */
644 LONG TEXT_TabbedTextOut( HDC hdc, int x, int y, LPSTR lpstr, int count, 
645                          int cTabStops, LPINT16 lpTabPos, int nTabOrg,
646                          BOOL fDisplayText)
647 {
648     WORD defWidth;
649     DWORD extent = 0;
650     int i, tabPos = x;
651     int start = x;
652
653     if (cTabStops == 1)
654     {
655         defWidth = *lpTabPos;
656         cTabStops = 0;
657     }
658     else
659     {
660         TEXTMETRIC16 tm;
661         GetTextMetrics16( hdc, &tm );
662         defWidth = 8 * tm.tmAveCharWidth;
663     }
664     
665     while (count > 0)
666     {
667         for (i = 0; i < count; i++)
668             if (lpstr[i] == '\t') break;
669         extent = GetTextExtent( hdc, lpstr, i );
670         while ((cTabStops > 0) && (nTabOrg + *lpTabPos <= x + LOWORD(extent)))
671         {
672             lpTabPos++;
673             cTabStops--;
674         }
675         if (i == count)
676             tabPos = x + LOWORD(extent);
677         else if (cTabStops > 0)
678             tabPos = nTabOrg + *lpTabPos;
679         else
680             tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
681         if (fDisplayText)
682         {
683             RECT16 r;
684             SetRect16( &r, x, y, tabPos, y+HIWORD(extent) );
685             ExtTextOut16( hdc, x, y,
686                           GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
687                           &r, lpstr, i, NULL );
688         }
689         x = tabPos;
690         count -= i+1;
691         lpstr += i+1;
692     }
693     return MAKELONG(tabPos - start, HIWORD(extent));
694 }
695
696
697 /***********************************************************************
698  *           TabbedTextOut    (USER.196)
699  */
700 LONG TabbedTextOut( HDC hdc, short x, short y, LPSTR lpstr, short count, 
701                     short cTabStops, LPINT16 lpTabPos, short nTabOrg )
702 {
703     dprintf_text( stddeb, "TabbedTextOut: %04x %d,%d '%*.*s' %d\n",
704                   hdc, x, y, count, count, lpstr, count );
705     return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
706                                lpTabPos, nTabOrg, TRUE );
707 }
708
709
710 /***********************************************************************
711  *           GetTabbedTextExtent    (USER.197)
712  */
713 DWORD GetTabbedTextExtent( HDC hdc, LPSTR lpstr, int count, 
714                           int cTabStops, LPINT16 lpTabPos )
715 {
716     dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%*.*s' %d\n",
717                   hdc, count, count, lpstr, count );
718     return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
719                                lpTabPos, 0, FALSE );
720 }