Fixed copying of the MDI 'Windows' menu items if the items are not of
[wine/multimedia.git] / objects / text.c
blob1aa4428db96a6b0addd966232281d03c089e0433
1 /*
2 * 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 "winbase.h"
14 #include "winuser.h"
15 #include "winerror.h"
16 #include "dc.h"
17 #include "gdi.h"
18 #include "heap.h"
19 #include "debugtools.h"
20 #include "cache.h"
22 DEFAULT_DEBUG_CHANNEL(text);
24 #define TAB 9
25 #define LF 10
26 #define CR 13
27 #define SPACE 32
28 #define PREFIX 38
30 #define SWAP_INT(a,b) { int t = a; a = b; b = t; }
32 static int tabstop = 8;
33 static int tabwidth;
34 static int spacewidth;
35 static int prefix_offset;
37 static const char *TEXT_NextLine( HDC16 hdc, const char *str, int *count,
38 char *dest, int *len, int width, WORD format)
40 /* Return next line of text from a string.
42 * hdc - handle to DC.
43 * str - string to parse into lines.
44 * count - length of str.
45 * dest - destination in which to return line.
46 * len - length of resultant line in dest in chars.
47 * width - maximum width of line in pixels.
48 * format - format type passed to DrawText.
50 * Returns pointer to next char in str after end of the line
51 * or NULL if end of str reached.
54 int i = 0, j = 0, k;
55 int plen = 0;
56 int numspaces;
57 SIZE16 size;
58 int lasttab = 0;
59 int wb_i = 0, wb_j = 0, wb_count = 0;
61 while (*count)
63 switch (str[i])
65 case CR:
66 case LF:
67 if (!(format & DT_SINGLELINE))
69 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
71 (*count)--;
72 i++;
74 i++;
75 *len = j;
76 (*count)--;
77 return (&str[i]);
79 dest[j++] = str[i++];
80 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
81 (format & DT_WORDBREAK))
83 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
84 return NULL;
85 plen += size.cx;
87 break;
89 case PREFIX:
90 if (!(format & DT_NOPREFIX) && *count > 1)
92 if (str[++i] == PREFIX)
93 (*count)--;
94 else {
95 prefix_offset = j;
96 break;
99 dest[j++] = str[i++];
100 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
101 (format & DT_WORDBREAK))
103 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
104 return NULL;
105 plen += size.cx;
107 break;
109 case TAB:
110 if (format & DT_EXPANDTABS)
112 wb_i = ++i;
113 wb_j = j;
114 wb_count = *count;
116 if (!GetTextExtentPoint16(hdc, &dest[lasttab], j - lasttab,
117 &size))
118 return NULL;
120 numspaces = (tabwidth - size.cx) / spacewidth;
121 for (k = 0; k < numspaces; k++)
122 dest[j++] = SPACE;
123 plen += tabwidth - size.cx;
124 lasttab = wb_j + numspaces;
126 else
128 dest[j++] = str[i++];
129 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
130 (format & DT_WORDBREAK))
132 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
133 return NULL;
134 plen += size.cx;
137 break;
139 case SPACE:
140 dest[j++] = str[i++];
141 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
142 (format & DT_WORDBREAK))
144 wb_i = i;
145 wb_j = j - 1;
146 wb_count = *count;
147 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
148 return NULL;
149 plen += size.cx;
151 break;
153 default:
154 dest[j++] = str[i++];
155 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
156 (format & DT_WORDBREAK))
158 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
159 return NULL;
160 plen += size.cx;
164 (*count)--;
165 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
167 if (plen > width)
169 if (format & DT_WORDBREAK)
171 if (wb_j)
173 *len = wb_j;
174 *count = wb_count - 1;
175 return (&str[wb_i]);
178 else
180 *len = j;
181 return (&str[i]);
187 *len = j;
188 return NULL;
192 /***********************************************************************
193 * DrawText16 (USER.85)
195 INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 i_count,
196 LPRECT16 rect, UINT16 flags )
198 SIZE16 size;
199 const char *strPtr;
200 static char line[1024];
201 int len, lh, count=i_count;
202 int prefix_x = 0;
203 int prefix_end = 0;
204 TEXTMETRIC16 tm;
205 int x = rect->left, y = rect->top;
206 int width = rect->right - rect->left;
207 int max_width = 0;
209 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n",
210 debugstr_an (str, count), count,
211 rect->left, rect->top, rect->right, rect->bottom);
213 if (!str) return 0;
214 if (count == -1) count = strlen(str);
215 strPtr = str;
217 GetTextMetrics16(hdc, &tm);
218 if (flags & DT_EXTERNALLEADING)
219 lh = tm.tmHeight + tm.tmExternalLeading;
220 else
221 lh = tm.tmHeight;
223 if (flags & DT_TABSTOP)
224 tabstop = flags >> 8;
226 if (flags & DT_EXPANDTABS)
228 GetTextExtentPoint16(hdc, " ", 1, &size);
229 spacewidth = size.cx;
230 GetTextExtentPoint16(hdc, "o", 1, &size);
231 tabwidth = size.cx * tabstop;
234 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
238 prefix_offset = -1;
239 strPtr = TEXT_NextLine(hdc, strPtr, &count, line, &len, width, flags);
241 if (prefix_offset != -1)
243 GetTextExtentPoint16(hdc, line, prefix_offset, &size);
244 prefix_x = size.cx;
245 GetTextExtentPoint16(hdc, line, prefix_offset + 1, &size);
246 prefix_end = size.cx - 1;
249 if (!GetTextExtentPoint16(hdc, line, len, &size)) return 0;
250 if (flags & DT_CENTER) x = (rect->left + rect->right -
251 size.cx) / 2;
252 else if (flags & DT_RIGHT) x = rect->right - size.cx;
254 if (flags & DT_SINGLELINE)
256 if (flags & DT_VCENTER) y = rect->top +
257 (rect->bottom - rect->top) / 2 - size.cy / 2;
258 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
260 if (!(flags & DT_CALCRECT))
262 if (!ExtTextOut16(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
263 rect, line, len, NULL )) return 0;
264 if (prefix_offset != -1)
266 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
267 HPEN oldPen = SelectObject( hdc, hpen );
268 MoveTo16(hdc, x + prefix_x, y + tm.tmAscent + 1 );
269 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
270 SelectObject( hdc, oldPen );
271 DeleteObject( hpen );
274 else if (size.cx > max_width)
275 max_width = size.cx;
277 y += lh;
278 if (strPtr)
280 if (!(flags & DT_NOCLIP))
282 if (y > rect->bottom - lh)
283 break;
287 while (strPtr);
288 if (flags & DT_CALCRECT)
290 rect->right = rect->left + max_width;
291 rect->bottom = y;
293 return y - rect->top;
297 /***********************************************************************
298 * DrawText32A (USER32.164)
300 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count,
301 LPRECT rect, UINT flags )
303 RECT16 rect16;
304 INT16 ret;
306 if (!rect)
307 return DrawText16( (HDC16)hdc, str, (INT16)count, NULL, (UINT16)flags);
308 CONV_RECT32TO16( rect, &rect16 );
309 ret = DrawText16( (HDC16)hdc, str, (INT16)count, &rect16, (UINT16)flags );
310 CONV_RECT16TO32( &rect16, rect );
311 return ret;
315 /***********************************************************************
316 * DrawText32W (USER32.167)
318 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count,
319 LPRECT rect, UINT flags )
321 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
322 INT ret = DrawTextA( hdc, p, count, rect, flags );
323 HeapFree( GetProcessHeap(), 0, p );
324 return ret;
327 /***********************************************************************
328 * DrawTextEx32A (USER32.165)
330 INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count,
331 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
333 TRACE("(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
334 if(dtp) {
335 FIXME("Ignores params:%d,%d,%d,%d,%d\n",dtp->cbSize,
336 dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin,
337 dtp->uiLengthDrawn);
339 return DrawTextA(hdc,str,count,rect,flags);
342 /***********************************************************************
343 * DrawTextEx32W (USER32.166)
345 INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT count,
346 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
348 TRACE("(%d,%p,%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
349 FIXME("ignores extended functionality\n");
350 return DrawTextW(hdc,str,count,rect,flags);
353 /***********************************************************************
354 * ExtTextOut16 (GDI.351)
356 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
357 const RECT16 *lprect, LPCSTR str, UINT16 count,
358 const INT16 *lpDx )
360 BOOL ret;
361 int i;
362 RECT rect32;
363 LPINT lpdx32 = NULL;
365 if (lpDx) lpdx32 = (LPINT)HEAP_xalloc( GetProcessHeap(), 0,
366 sizeof(INT)*count );
367 if (lprect) CONV_RECT16TO32(lprect,&rect32);
368 if (lpdx32) for (i=count;i--;) lpdx32[i]=lpDx[i];
369 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
370 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
371 return ret;
377 /***********************************************************************
378 * ExtTextOutA (GDI32.98)
380 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
381 const RECT *lprect, LPCSTR str, UINT count,
382 const INT *lpDx )
384 /* str need not be \0 terminated but lstrcpynAtoW adds \0 so we allocate one
385 more byte */
386 LPWSTR p = HeapAlloc( GetProcessHeap(), 0, (count+1) * sizeof(WCHAR) );
387 INT ret;
388 lstrcpynAtoW( p, str, count+1 );
389 ret = ExtTextOutW( hdc, x, y, flags, lprect, p, count, lpDx );
390 HeapFree( GetProcessHeap(), 0, p );
391 return ret;
395 /***********************************************************************
396 * ExtTextOutW (GDI32.99)
398 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
399 const RECT *lprect, LPCWSTR str, UINT count,
400 const INT *lpDx )
402 DC * dc = DC_GetDCPtr( hdc );
403 return dc && dc->funcs->pExtTextOut &&
404 dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
408 /***********************************************************************
409 * TextOut16 (GDI.33)
411 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
413 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
417 /***********************************************************************
418 * TextOut32A (GDI32.355)
420 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
422 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
426 /***********************************************************************
427 * TextOut32W (GDI32.356)
429 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
431 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
435 /***********************************************************************
436 * TEXT_GrayString
438 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
439 * heap and we can guarantee that the handles fit in an INT16. We have to
440 * rethink the strategy once the migration to NT handles is complete.
441 * We are going to get a lot of code-duplication once this migration is
442 * completed...
445 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb,
446 GRAYSTRINGPROC fn, LPARAM lp, INT len,
447 INT x, INT y, INT cx, INT cy,
448 BOOL unicode, BOOL _32bit)
450 HBITMAP hbm, hbmsave;
451 HBRUSH hbsave;
452 HFONT hfsave;
453 HDC memdc = CreateCompatibleDC(hdc);
454 int slen = len;
455 BOOL retval = TRUE;
456 COLORREF fg, bg;
458 if(!hdc) return FALSE;
460 if(len == 0)
462 if(unicode)
463 slen = lstrlenW((LPCWSTR)lp);
464 else if(_32bit)
465 slen = lstrlenA((LPCSTR)lp);
466 else
467 slen = lstrlenA((LPCSTR)PTR_SEG_TO_LIN(lp));
470 if((cx == 0 || cy == 0) && slen != -1)
472 SIZE s;
473 if(unicode)
474 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
475 else if(_32bit)
476 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
477 else
478 GetTextExtentPoint32A(hdc, (LPCSTR)PTR_SEG_TO_LIN(lp), slen, &s);
479 if(cx == 0) cx = s.cx;
480 if(cy == 0) cy = s.cy;
483 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
484 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
485 hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) );
486 PatBlt( memdc, 0, 0, cx, cy, PATCOPY );
487 SelectObject( memdc, hbsave );
488 SetTextColor(memdc, RGB(255, 255, 255));
489 SetBkColor(memdc, RGB(0, 0, 0));
490 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
492 if(fn)
493 if(_32bit)
494 retval = fn(memdc, lp, slen);
495 else
496 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
497 else
498 if(unicode)
499 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
500 else if(_32bit)
501 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
502 else
503 TextOutA(memdc, 0, 0, (LPCSTR)PTR_SEG_TO_LIN(lp), slen);
505 SelectObject(memdc, hfsave);
508 * Windows doc says that the bitmap isn't grayed when len == -1 and
509 * the callback function returns FALSE. However, testing this on
510 * win95 showed otherwise...
512 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
513 if(retval || len != -1)
514 #endif
516 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
517 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
518 SelectObject(memdc, hbsave);
521 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
522 fg = SetTextColor(hdc, RGB(0, 0, 0));
523 bg = SetBkColor(hdc, RGB(255, 255, 255));
524 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
525 SetTextColor(hdc, fg);
526 SetBkColor(hdc, bg);
527 if(hb) SelectObject(hdc, hbsave);
529 SelectObject(memdc, hbmsave);
530 DeleteObject(hbm);
531 DeleteDC(memdc);
532 return retval;
536 /***********************************************************************
537 * GrayString16 (USER.185)
539 BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
540 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
541 INT16 cx, INT16 cy )
543 return TEXT_GrayString(hdc, hbr, (GRAYSTRINGPROC)gsprc, lParam, cch, x, y, cx, cy, FALSE, FALSE);
547 /***********************************************************************
548 * GrayString32A (USER32.315)
550 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
551 LPARAM lParam, INT cch, INT x, INT y,
552 INT cx, INT cy )
554 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, FALSE, TRUE);
558 /***********************************************************************
559 * GrayString32W (USER32.316)
561 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
562 LPARAM lParam, INT cch, INT x, INT y,
563 INT cx, INT cy )
565 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, TRUE, TRUE);
569 /***********************************************************************
570 * TEXT_TabbedTextOut
572 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
573 * Note: this doesn't work too well for text-alignment modes other
574 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
576 LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
577 INT count, INT cTabStops, const INT16 *lpTabPos16,
578 const INT *lpTabPos32, INT nTabOrg,
579 BOOL fDisplayText )
581 INT defWidth;
582 DWORD extent = 0;
583 int i, tabPos = x;
584 int start = x;
586 if (cTabStops == 1)
588 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
589 cTabStops = 0;
591 else
593 TEXTMETRIC16 tm;
594 GetTextMetrics16( hdc, &tm );
595 defWidth = 8 * tm.tmAveCharWidth;
598 while (count > 0)
600 for (i = 0; i < count; i++)
601 if (lpstr[i] == '\t') break;
602 extent = GetTextExtent16( hdc, lpstr, i );
603 if (lpTabPos32)
605 while ((cTabStops > 0) &&
606 (nTabOrg + *lpTabPos32 <= x + LOWORD(extent)))
608 lpTabPos32++;
609 cTabStops--;
612 else
614 while ((cTabStops > 0) &&
615 (nTabOrg + *lpTabPos16 <= x + LOWORD(extent)))
617 lpTabPos16++;
618 cTabStops--;
621 if (i == count)
622 tabPos = x + LOWORD(extent);
623 else if (cTabStops > 0)
624 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
625 else
626 tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
627 if (fDisplayText)
629 RECT r;
630 r.left = x;
631 r.top = y;
632 r.right = tabPos;
633 r.bottom = y + HIWORD(extent);
634 ExtTextOutA( hdc, x, y,
635 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
636 &r, lpstr, i, NULL );
638 x = tabPos;
639 count -= i+1;
640 lpstr += i+1;
642 return MAKELONG(tabPos - start, HIWORD(extent));
646 /***********************************************************************
647 * TabbedTextOut16 (USER.196)
649 LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
650 INT16 count, INT16 cTabStops,
651 const INT16 *lpTabPos, INT16 nTabOrg )
653 TRACE("%04x %d,%d '%.*s' %d\n",
654 hdc, x, y, count, lpstr, count );
655 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
656 lpTabPos, NULL, nTabOrg, TRUE );
660 /***********************************************************************
661 * TabbedTextOut32A (USER32.542)
663 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr,
664 INT count, INT cTabStops,
665 const INT *lpTabPos, INT nTabOrg )
667 TRACE("%04x %d,%d '%.*s' %d\n",
668 hdc, x, y, count, lpstr, count );
669 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
670 NULL, lpTabPos, nTabOrg, TRUE );
674 /***********************************************************************
675 * TabbedTextOut32W (USER32.543)
677 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str,
678 INT count, INT cTabStops,
679 const INT *lpTabPos, INT nTabOrg )
681 LONG ret;
682 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
683 lstrcpynWtoA( p, str, count + 1 );
684 ret = TabbedTextOutA( hdc, x, y, p, count, cTabStops,
685 lpTabPos, nTabOrg );
686 HeapFree( GetProcessHeap(), 0, p );
687 return ret;
691 /***********************************************************************
692 * GetTabbedTextExtent16 (USER.197)
694 DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
695 INT16 cTabStops, const INT16 *lpTabPos )
697 TRACE("%04x '%.*s' %d\n",
698 hdc, count, lpstr, count );
699 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
700 lpTabPos, NULL, 0, FALSE );
704 /***********************************************************************
705 * GetTabbedTextExtent32A (USER32.293)
707 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
708 INT cTabStops, const INT *lpTabPos )
710 TRACE("%04x '%.*s' %d\n",
711 hdc, count, lpstr, count );
712 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
713 NULL, lpTabPos, 0, FALSE );
717 /***********************************************************************
718 * GetTabbedTextExtent32W (USER32.294)
720 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
721 INT cTabStops, const INT *lpTabPos )
723 LONG ret;
724 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
725 lstrcpynWtoA( p, lpstr, count + 1 );
726 ret = GetTabbedTextExtentA( hdc, p, count, cTabStops, lpTabPos );
727 HeapFree( GetProcessHeap(), 0, p );
728 return ret;
731 /***********************************************************************
732 * GetTextCharset32 [GDI32.226] Gets character set for font in DC
734 * NOTES
735 * Should it return a UINT32 instead of an INT32?
736 * => YES, as GetTextCharsetInfo returns UINT32
738 * RETURNS
739 * Success: Character set identifier
740 * Failure: DEFAULT_CHARSET
742 UINT WINAPI GetTextCharset(
743 HDC hdc) /* [in] Handle to device context */
745 /* MSDN docs say this is equivalent */
746 return GetTextCharsetInfo(hdc, NULL, 0);
749 /***********************************************************************
750 * GetTextCharset16 [GDI.612]
752 UINT16 WINAPI GetTextCharset16(HDC16 hdc)
754 return (UINT16)GetTextCharset(hdc);
757 /***********************************************************************
758 * GetTextCharsetInfo [GDI32.381] Gets character set for font
760 * NOTES
761 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
762 * Should it return a UINT32 instead of an INT32?
763 * => YES and YES, from win32.hlp from Borland
765 * RETURNS
766 * Success: Character set identifier
767 * Failure: DEFAULT_CHARSET
769 UINT WINAPI GetTextCharsetInfo(
770 HDC hdc, /* [in] Handle to device context */
771 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
772 DWORD flags) /* [in] Reserved - must be 0 */
774 HGDIOBJ hFont;
775 UINT charSet = DEFAULT_CHARSET;
776 LOGFONTW lf;
777 CHARSETINFO csinfo;
779 hFont = GetCurrentObject(hdc, OBJ_FONT);
780 if (hFont == 0)
781 return(DEFAULT_CHARSET);
782 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
783 charSet = lf.lfCharSet;
785 if (fs != NULL) {
786 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
787 return (DEFAULT_CHARSET);
788 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
790 return charSet;
793 /***********************************************************************
794 * PolyTextOutA [GDI.402] Draw several Strings
796 BOOL WINAPI PolyTextOutA (
797 HDC hdc, /* Handle to device context */
798 PPOLYTEXTA pptxt, /* array of strings */
799 INT cStrings /* Number of strings in array */
802 FIXME("stub!\n");
803 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
804 return 0;
809 /***********************************************************************
810 * PolyTextOutW [GDI.403] Draw several Strings
812 BOOL WINAPI PolyTextOutW (
813 HDC hdc, /* Handle to device context */
814 PPOLYTEXTW pptxt, /* array of strings */
815 INT cStrings /* Number of strings in array */
818 FIXME("stub!\n");
819 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
820 return 0;