source: trunk/src/gdi32/text.cpp@ 4012

Last change on this file since 4012 was 4012, checked in by cbratschi, 25 years ago

activated WinDrawText

File size: 22.1 KB
Line 
1/* $Id: text.cpp,v 1.11 2000-08-14 15:51:20 cbratschi Exp $ */
2
3/*
4 * GDI32 text apis
5 *
6 * Based on Wine code (991031) (objects\text.c)
7 *
8 * Copyright 1993, 1994 Alexandre Julliard
9 * Copyright 1999-2000 Christoph Bratschi
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14#include <os2win.h>
15#include <stdlib.h>
16#include <misc.h>
17#include <string.h>
18#include <float.h>
19#include "oslibgpi.h"
20
21#define DBG_LOCALLOG DBG_text
22#include "dbglocal.h"
23
24#define ELLIPSIS "..."
25#define ELLIPSISLEN 3
26
27typedef struct _POLYTEXTA
28{
29 int x;
30 int y;
31 UINT n;
32 LPCSTR lpstr;
33 UINT uiFlags;
34 RECT rcl;
35 int *pdx;
36} POLYTEXTA;
37
38typedef struct _POLYTEXTW
39{
40 int x;
41 int y;
42 UINT n;
43 LPCWSTR lpstr;
44 UINT uiFlags;
45 RECT rcl;
46 int *pdx;
47} POLYTEXTW;
48
49//******************************************************************************
50//******************************************************************************
51UINT WINAPI GetTextCharsetInfo(
52 HDC hdc, /* [in] Handle to device context */
53 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
54 DWORD flags) /* [in] Reserved - must be 0 */
55{
56 HGDIOBJ hFont;
57 UINT charSet = DEFAULT_CHARSET;
58 LOGFONTW lf;
59 CHARSETINFO csinfo;
60
61 dprintf(("GetTextCharsetInfo %x %x %x", hdc, fs, flags));
62
63 hFont = GetCurrentObject(hdc, OBJ_FONT);
64 if (hFont == 0)
65 return(DEFAULT_CHARSET);
66 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
67 charSet = lf.lfCharSet;
68
69 if (fs != NULL) {
70 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
71 return (DEFAULT_CHARSET);
72 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
73 }
74 return charSet;
75}
76/***********************************************************************
77 * GetTextCharset32 [GDI32.226] Gets character set for font in DC
78 *
79 * NOTES
80 * Should it return a UINT32 instead of an INT32?
81 * => YES, as GetTextCharsetInfo returns UINT32
82 *
83 * RETURNS
84 * Success: Character set identifier
85 * Failure: DEFAULT_CHARSET
86 */
87UINT WINAPI GetTextCharset(HDC hdc) /* [in] Handle to device context */
88{
89 /* MSDN docs say this is equivalent */
90 return GetTextCharsetInfo(hdc, NULL, 0);
91}
92//******************************************************************************
93// CB: USER32 function, but here is the better place
94//******************************************************************************
95INT SYSTEM EXPORT InternalDrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams,BOOL isDrawTextEx)
96{
97 INT rc;
98 ULONG flCmd;
99 RECT localRectangle;
100 PRECT rectPtr;
101 LONG lTabs,xLeft,yTop;
102 UINT fpuctrlword;
103
104 //SvL: Open32's DrawText messes up the fpu control word! (@#$@#$@#$)
105 //CB: don't know if this is still the case with WinDrawTabbedText (-> testcase)
106 fpuctrlword = _control87(0, 0);
107
108 if ((!lpchText) || (cchText == 0) || (cchText < -1) || (lprc == NULL))
109 {
110 SetLastError(ERROR_INVALID_PARAMETER);
111 return 0;
112 }
113
114 PVOID pHps = OSLibGpiQueryDCData(hdc);
115
116 if (!pHps)
117 {
118 SetLastError(ERROR_INVALID_HANDLE);
119 return 0;
120 }
121
122 if (cchText == -1)
123 {
124 cchText = strlen(lpchText);
125 if (cchText == 0)
126 return 0; //CB: does Win32 return textheight in this case?
127 }
128
129 if (lpDTParams)
130 {
131 // set margins
132 lprc->left += lpDTParams->iLeftMargin;
133 lprc->right -= lpDTParams->iRightMargin;
134
135 // just assume all the text has been drawn
136 lpDTParams->uiLengthDrawn = cchText;
137 }
138
139 if (!(dwDTFormat & DT_CALCRECT))
140 {
141 BOOL bTopBottomIsOkay;
142
143 if ((getIsTopTop(pHps) && lprc->top > lprc->bottom) ||
144 (!getIsTopTop(pHps) && lprc->top < lprc->bottom))
145 bTopBottomIsOkay = FALSE;
146 else
147 bTopBottomIsOkay = TRUE;
148
149 if ((lprc->left >= lprc->right) || !bTopBottomIsOkay)
150 {
151 TEXTMETRICA txtMetrics;
152 BOOL result;
153
154 result = GetTextMetricsA(hdc,&txtMetrics);
155 if (result)
156 rc = (int)txtMetrics.tmHeight;
157 else
158 rc = 0;
159
160 if (lpDTParams)
161 {
162 lprc->left -= lpDTParams->iLeftMargin;
163 lprc->right += lpDTParams->iRightMargin;
164 }
165
166 return rc;
167 }
168 }
169
170 flCmd = DTOS_INVERT | DTOS_WORLDRECT | DTOS_TEXTATTRS | DTOS_AMPERSAND | DTOS_VERTICALEXTENT;
171
172 LONG lMixMode = OSLibGpiQueryBackMix(pHps);
173 if (lMixMode == BMOS_OVERPAINT) flCmd |= DTOS_OPAQUE;
174
175 if (dwDTFormat & DT_CALCRECT)
176 {
177 rectPtr = lprc;
178 flCmd |= DTOS_QUERYEXTENT;
179
180 xLeft = rectPtr->left;
181 yTop = rectPtr->top;
182
183 if (dwDTFormat & DT_RIGHT)
184 {
185 if (rectPtr->left >= rectPtr->right)
186 rectPtr->left = rectPtr->right-1;
187 } else
188 {
189 if (rectPtr->right <= rectPtr->left)
190 rectPtr->right = rectPtr->left+1;
191 }
192
193 if (dwDTFormat & DT_BOTTOM)
194 {
195 if (rectPtr->top >= rectPtr->bottom)
196 rectPtr->top = rectPtr->bottom-1;
197 } else
198 {
199 if (rectPtr->bottom <= rectPtr->top)
200 rectPtr->bottom = rectPtr->top+1;
201 }
202 } else
203 {
204 rectPtr = &localRectangle;
205
206 if ((getMapMode(pHps) == MMOS_ANISOTROPIC) || (getMapMode(pHps) == MMOS_ISOTROPIC))
207 {
208 if (doesYAxisGrowNorth(pHps))
209 {
210 flCmd &= ~DTOS_INVERT;
211 flCmd |= DTOS_INVERTCHAR;
212 }
213 }
214
215 if (lprc->left > lprc->right)
216 {
217 rectPtr->left = lprc->right;
218 rectPtr->right = lprc->left;
219 } else
220 {
221 rectPtr->left = lprc->left;
222 rectPtr->right = lprc->right;
223 }
224 if (lprc->top > lprc->bottom)
225 {
226 rectPtr->top = lprc->bottom;
227 rectPtr->bottom = lprc->top;
228 } else
229 {
230 rectPtr->top = lprc->top;
231 rectPtr->bottom = lprc->bottom;
232 }
233 }
234
235 if (dwDTFormat & DT_EXPANDTABS)
236 {
237 if (isDrawTextEx)
238 {
239 lTabs = (lpDTParams && (dwDTFormat & DT_TABSTOP)) ? lpDTParams->iTabLength:8;
240 } else
241 {
242 lTabs = 8;
243
244 if (dwDTFormat & DT_TABSTOP)
245 {
246 lTabs = (dwDTFormat >> 8) & 0x000000FF;
247 dwDTFormat &= 0xFFFF00FF;
248 }
249 }
250 } else lTabs = -1;
251
252 if (dwDTFormat & DT_RIGHT)
253 flCmd |= DTOS_RIGHT;
254 else
255 if (dwDTFormat & DT_CENTER) flCmd |= DTOS_CENTER;
256 if (dwDTFormat & DT_BOTTOM) flCmd |= DTOS_BOTTOM;
257 if (dwDTFormat & DT_VCENTER) flCmd |= DTOS_VCENTER;
258 if (dwDTFormat & DT_WORDBREAK) flCmd |= DTOS_WORDBREAK;
259 if (dwDTFormat & DT_EXTERNALLEADING) flCmd |= DTOS_EXTERNALLEADING;
260 if (!(dwDTFormat & DT_NOPREFIX)) flCmd |= DTOS_MNEMONIC;
261 if (dwDTFormat & DT_SINGLELINE)
262 flCmd |= DTOS_SINGLELINE;
263 else
264 flCmd |= DTOS_MULTILINE;
265 if (dwDTFormat & DT_NOCLIP) flCmd |= DTOS_NOCLIP;
266
267 //CB: DT_EDITCONTROL, DT_RTLREADING ignored
268
269 BOOL done = FALSE;
270
271 if ((dwDTFormat & DT_END_ELLIPSIS) && (cchText > 1))
272 {
273 int textWidth,width;
274 RECT rect;
275
276 SetRectEmpty(&rect);
277 OSLibWinDrawTabbedText(pHps,cchText,lTabs,lpchText,&rect,0,0,flCmd | DTOS_QUERYEXTENT);
278 width = rectPtr->right-rectPtr->left;
279 textWidth = rect.right-rect.left;
280 if ((textWidth > width) && (width > 0))
281 {
282 char* newText;
283 int newTextLen = cchText-1+ELLIPSISLEN;
284 int preLen = cchText-1;
285
286 newText = (char*)malloc(newTextLen+1);
287 strncpy(newText,lpchText,cchText-1);
288 do
289 {
290 strcpy(&newText[preLen],ELLIPSIS);
291 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT);
292 textWidth = rect.right-rect.left;
293 if (textWidth <= width || preLen == 1) break;
294 newTextLen--;
295 preLen--;
296 } while (TRUE);
297 rc = OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,rectPtr,0,0,flCmd);
298 if (dwDTFormat & DT_MODIFYSTRING) strcpy((LPSTR)lpchText,newText); //check length?
299 free(newText);
300
301 done = TRUE;
302 }
303 } else if ((dwDTFormat & DT_PATH_ELLIPSIS) && (cchText > 1))
304 {
305 int textWidth,width;
306 RECT rect;
307
308//CB: code not yet checked (-> testcase)
309
310 SetRectEmpty(&rect);
311 OSLibWinDrawTabbedText(pHps,cchText,lTabs,lpchText,&rect,0,0,flCmd | DTOS_QUERYEXTENT);
312 width = rectPtr->right-rectPtr->left;
313 textWidth = rect.right-rect.left;
314 if ((textWidth > width) && (width > 0))
315 {
316 char *newText,*slashPos;
317 int newTextLen = cchText+ELLIPSISLEN;
318
319 newText = (char*)malloc(newTextLen+1);
320 strncpy(newText,lpchText,cchText);
321 slashPos = strrchr(newText,(int)"\\");
322 if (slashPos != NULL)
323 {
324 int preLen = slashPos-newText;
325 char* endPtr = (char*)lpchText+preLen;
326 int endLen = cchText-preLen;
327 BOOL ok = FALSE;
328
329 //delete start
330 do
331 {
332 strcpy(&newText[preLen],ELLIPSIS);
333 strncpy(&newText[preLen+ELLIPSISLEN],endPtr,endLen);
334 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT);
335 textWidth = rect.right-rect.left;
336 if (textWidth <= width)
337 {
338 ok = TRUE;
339 break;
340 }
341 if (preLen == 0) break;
342 newTextLen--;
343 preLen--;
344 } while (TRUE);
345
346 if (!ok)
347 {
348 //delete end
349 do
350 {
351 endPtr++;
352 endLen--;
353 newTextLen--;
354 strncpy(&newText[ELLIPSISLEN],endPtr,endLen);
355 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT);
356 textWidth = rect.right-rect.left;
357 if ((textWidth <= width) || (endLen == 0)) break;
358 } while (TRUE);
359 }
360 } else
361 {
362 int preLen,endLen;
363
364 preLen = cchText/2;
365 endLen = cchText-preLen; //endLen >= preLen
366 char* endPtr = (char*)lpchText+preLen;
367
368 do
369 {
370 strcpy(&newText[preLen],ELLIPSIS);
371 strncpy(&newText[preLen+ELLIPSISLEN],endPtr,endLen);
372 OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,&rect,0,0,flCmd | DTOS_QUERYEXTENT);
373 textWidth = rect.right-rect.left;
374 if ((textWidth <= width) || (preLen+endLen == 0)) break;
375 if (endLen > preLen)
376 {
377 endLen--;
378 endPtr++;
379 } else preLen--;
380 newTextLen--;
381 } while (TRUE);
382 }
383 rc = OSLibWinDrawTabbedText(pHps,newTextLen,lTabs,newText,rectPtr,0,0,flCmd);
384 if (dwDTFormat & DT_MODIFYSTRING) strcpy((LPSTR)lpchText,newText); //check length?
385 free(newText);
386
387 done = TRUE;
388 }
389 }
390
391 if (!done)
392 {
393 rc = OSLibWinDrawTabbedText(pHps,cchText,lTabs,lpchText,rectPtr,0,0,flCmd);
394 }
395
396 if (dwDTFormat & DT_CALCRECT)
397 {
398 if (!(dwDTFormat & DT_RIGHT) && (rectPtr->left < xLeft))
399 {
400 rectPtr->right = xLeft+(rectPtr->right-rectPtr->left);
401 rectPtr->left = xLeft;
402 }
403 if (!(dwDTFormat & DT_BOTTOM) && (rectPtr->top < yTop))
404 {
405 rectPtr->bottom = yTop+(rectPtr->bottom-rectPtr->top);
406 rectPtr->top = yTop;
407 }
408 }
409
410 if (lpDTParams)
411 {
412 // don't forget to restore the margins
413 lprc->left -= lpDTParams->iLeftMargin;
414 lprc->right += lpDTParams->iRightMargin;
415 }
416
417 _control87(fpuctrlword, 0xFFFF);
418
419 return rc;
420}
421//******************************************************************************
422//******************************************************************************
423INT SYSTEM EXPORT InternalDrawTextExW(HDC hdc,LPCWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams,BOOL isDrawTextEx)
424{
425 char *astring = (cchText == -1) ? UnicodeToAsciiString((LPWSTR)lpchText):UnicodeToAsciiStringN((LPWSTR)lpchText,cchText);
426 INT rc;
427
428 rc = InternalDrawTextExA(hdc,astring,cchText,lprc,dwDTFormat,lpDTParams,isDrawTextEx);
429 if (dwDTFormat & DT_MODIFYSTRING && (dwDTFormat & (DT_END_ELLIPSIS | DT_PATH_ELLIPSIS))) AsciiToUnicode(astring,(LPWSTR)lpchText);
430 FreeAsciiString(astring);
431
432 return(rc);
433}
434//******************************************************************************
435// CB: USER32 function, but here is the better place
436//******************************************************************************
437DWORD SYSTEM EXPORT InternalGetTabbedTextExtentA(HDC hDC,LPCSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions)
438{
439 PVOID pHps = OSLibGpiQueryDCData(hDC);
440 BOOL result;
441 POINTLOS2 pts[TXTBOXOS_COUNT];
442 POINTLOS2 widthHeight = {0,0};
443
444 if (!pHps || (nCount == 0) || (nTabPositions < 0))
445 return 0;
446
447 if (nCount < 0)
448 {
449 SetLastError(ERROR_STACK_OVERFLOW);
450 return 0;
451 }
452 if ((lpString == NULL) || (nCount > 512) || ((nTabPositions > 0) && (lpnTabStopPositions == NULL)))
453 {
454 SetLastError(ERROR_INVALID_PARAMETER);
455 return 0;
456 }
457 //CB: Win95 supports negative values for right aligned text
458 for (INT i = 0;i < nTabPositions;i++)
459 {
460 if (lpnTabStopPositions[i] < 0)
461 {
462 SetLastError(ERROR_INVALID_PARAMETER);
463 return 0;
464 }
465 }
466
467 result = OSLibGpiQueryTextBox(pHps,(nCount > 1) ? 1:nCount,lpString,TXTBOXOS_COUNT,pts);
468 if (result == FALSE)
469 return 0;
470 calcDimensions(pts,&widthHeight);
471
472 LONG rv1 = OSLibGpiQueryTabbedTextExtent(pHps,nCount,lpString,nTabPositions,lpnTabStopPositions);
473 if (rv1 == GPIOS_ERROR)
474 return 0;
475
476 return (widthHeight.y <<16)+labs(rv1);
477}
478//******************************************************************************
479//******************************************************************************
480DWORD SYSTEM EXPORT InternalGetTabbedTextExtentW(HDC hDC,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions)
481{
482 char *astring = (nCount == -1) ? UnicodeToAsciiString((LPWSTR)lpString):UnicodeToAsciiStringN((LPWSTR)lpString,nCount);
483 DWORD rc;
484
485 rc = InternalGetTabbedTextExtentA(hDC,astring,nCount,nTabPositions,lpnTabStopPositions);
486 FreeAsciiString(astring);
487
488 return(rc);
489}
490//******************************************************************************
491// CB: USER32 function, but here is the better place
492//******************************************************************************
493LONG SYSTEM EXPORT InternalTabbedTextOutA(HDC hdc,INT x,INT y,LPCSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions,INT nTabOrigin)
494{
495 PVOID pHps = OSLibGpiQueryDCData(hdc);
496 POINTLOS2 ptl;
497 DWORD dimensions;
498
499 if ((pHps == NULL) || (lpString == NULL))
500 {
501 SetLastError(ERROR_INVALID_HANDLE);
502 return 0;
503 }
504 if (nCount == -1)
505 nCount = strlen(lpString);
506 if (nCount < 1)
507 {
508 SetLastError(ERROR_INVALID_HANDLE);
509 return 0;
510 }
511 if (lpnTabStopPositions == NULL)
512 nTabPositions = 0;
513 if (nTabPositions == 0)
514 lpnTabStopPositions = NULL;
515 if (nTabPositions < 0)
516 {
517 SetLastError(ERROR_INVALID_HANDLE);
518 return 0;
519 }
520 if (getAlignUpdateCP(pHps) == TRUE)
521 OSLibGpiQueryCurrentPosition(pHps,&ptl);
522 else
523 {
524 ptl.x = x;
525 ptl.y = y;
526 }
527
528 //CB: nTabOrigin is ignored! -> wrong size (width)!
529 // todo: change low word (width), height is ok
530 dimensions = InternalGetTabbedTextExtentA(hdc,lpString,nCount,nTabPositions,lpnTabStopPositions);
531 if (dimensions != 0)
532 {
533 LONG rcGPI;
534
535 ptl.y += getWorldYDeltaFor1Pixel(pHps);
536
537 rcGPI = OSLibGpiTabbedCharStringAt(pHps,&ptl,NULL,0,nCount,lpString,nTabPositions,lpnTabStopPositions,nTabOrigin);
538 if (rcGPI == GPIOS_ALTERROR)
539 return 0;
540 if (getAlignUpdateCP(pHps))
541 {
542 OSLibGpiQueryCurrentPosition (pHps,&ptl);
543 ptl.y -= getWorldYDeltaFor1Pixel(pHps);
544 OSLibGpiSetCurrentPosition (pHps,&ptl);
545 }
546
547 return dimensions;
548 }
549 return 0;
550}
551//******************************************************************************
552//******************************************************************************
553LONG SYSTEM EXPORT InternalTabbedTextOutW(HDC hdc,INT x,INT y,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions,INT nTabOrigin)
554{
555 char *astring = (nCount == -1) ? UnicodeToAsciiString((LPWSTR)lpString):UnicodeToAsciiStringN((LPWSTR)lpString,nCount);
556 LONG rc;
557
558 rc = InternalTabbedTextOutA(hdc,x,y,astring,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin);
559 FreeAsciiString(astring);
560
561 return(rc);
562}
563//******************************************************************************
564// todo: metafile support
565//******************************************************************************
566BOOL InternalTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
567{
568 PVOID pHps = OSLibGpiQueryDCData(hdc);
569 ULONG flOptions = 0;
570 RECTLOS2 pmRect;
571 POINTLOS2 ptl;
572 LONG hits;
573
574 if (!pHps || (cbCount < 0) || ((lpszString == NULL) && (cbCount != 0)))
575 {
576 dprintf(("InternalTextOutA: invalid parameter"));
577 SetLastError(ERROR_INVALID_HANDLE);
578 return FALSE;
579 }
580
581 if (cbCount > 512)
582 {
583 dprintf(("InternalTextOutA: invalid parameter cbCount"));
584 SetLastError(ERROR_INVALID_PARAMETER);
585 return FALSE;
586 }
587 if (fuOptions & ~((UINT)(ETO_CLIPPED | ETO_OPAQUE)))
588 {
589 dprintf(("InternalTextOutA: invalid fuOptions"));
590 //ETO_GLYPH_INDEX, ETO_RTLLEADING, ETO_NUMERICSLOCAL, ETO_NUMERICSLATIN, ETO_IGNORELANGUAGE, ETO_PDY are ignored
591 return TRUE;
592 }
593
594 //CB: add metafile info
595
596 if (lprc)
597 {
598 if (fuOptions)
599 {
600 MapWin32ToOS2Rect(*lprc,pmRect);
601 if (excludeBottomRightPoint(pHps,(PPOINTLOS2)&pmRect) == 0)
602 {
603 dprintf(("InternalTextOutA: excludeBottomRightPoint returned 0"));
604 return TRUE;
605 }
606
607 if (fuOptions & ETO_CLIPPED) flOptions |= CHSOS_CLIP;
608 if (fuOptions & ETO_OPAQUE) flOptions |= CHSOS_OPAQUE;
609 }
610 }
611 else
612 {
613 if (fuOptions)
614 {
615 dprintf(("InternalTextOutA: ERROR_INVALID_HANDLE"));
616 SetLastError(ERROR_INVALID_HANDLE);
617 return FALSE;
618 }
619 }
620
621 if (cbCount == 0)
622 {
623 if (fuOptions & ETO_OPAQUE)
624 {
625 lpszString = " ";
626 cbCount = 1;
627 flOptions |= CHSOS_CLIP;
628 }
629 else {
630 dprintf(("InternalTextOutA: cbCount == 0"));
631 return TRUE;
632 }
633 }
634 if (lpDx)
635 flOptions |= CHSOS_VECTOR;
636
637 if (!getAlignUpdateCP(pHps))
638 {
639 ptl.x = X;
640 ptl.y = Y;
641
642 flOptions |= CHSOS_LEAVEPOS;
643 }
644 else OSLibGpiQueryCurrentPosition(pHps,&ptl);
645
646 UINT align = GetTextAlign(hdc);
647 LONG pmHAlign,pmVAlign;
648
649 //CB: TA_RIGHT not supported by PM, only TA_CENTER and TA_LEFT
650 if ((align & 0x6) == TA_RIGHT)
651 {
652 PPOINTLOS2 pts = (PPOINTLOS2)malloc((cbCount+1)*sizeof(POINTLOS2));
653
654 OSLibGpiQueryCharStringPosAt(pHps,&ptl,flOptions,cbCount,lpszString,lpDx,pts);
655 ptl.x -= pts[cbCount].x-pts[0].x;
656 free(pts);
657 }
658
659 if (lprc && ((align & 0x18) == TA_BASELINE))
660 {
661 //CB: if TA_BASELINE is set, GPI doesn't fill rect
662 // TA_BOTTOM fills rect
663 OSLibGpiQueryTextAlignment(pHps,&pmHAlign,&pmVAlign);
664 OSLibGpiSetTextAlignment(pHps,pmHAlign,(pmVAlign & ~TAOS_BASE) | TAOS_BOTTOM);
665 }
666
667 ptl.y += getWorldYDeltaFor1Pixel(pHps);
668
669 hits = OSLibGpiCharStringPosAt(pHps,&ptl,&pmRect,flOptions,cbCount,lpszString,lpDx);
670
671 if (lprc && ((align & 0x18) == TA_BASELINE))
672 OSLibGpiSetTextAlignment(pHps,pmHAlign,pmVAlign);
673
674 if(hits == GPIOS_ERROR) {
675 dprintf(("InternalTextOutA: OSLibGpiCharStringPosAt returned GPIOS_ERROR"));
676 return FALSE;
677 }
678
679 if (getAlignUpdateCP(pHps))
680 {
681 OSLibGpiQueryCurrentPosition(pHps,&ptl);
682 ptl.y -= getWorldYDeltaFor1Pixel(pHps);
683 OSLibGpiSetCurrentPosition(pHps,&ptl);
684 }
685
686 return TRUE;
687}
688//******************************************************************************
689//******************************************************************************
690BOOL InternalTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
691{
692 char *astring = (cbCount == -1) ? UnicodeToAsciiString((LPWSTR)lpszString):UnicodeToAsciiStringN((LPWSTR)lpszString,cbCount);
693 BOOL rc;
694
695 rc = InternalTextOutA(hdc,X,Y,fuOptions,lprc,(LPCSTR)astring,cbCount,lpDx,IsExtTextOut);
696 FreeAsciiString(astring);
697
698 return(rc);
699}
700//******************************************************************************
701//******************************************************************************
702BOOL WIN32API ExtTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,UINT cbCount,CONST INT *lpDx)
703{
704 dprintf(("GDI32: ExtTextOutA %x %s", hdc, lpszString));
705
706 return InternalTextOutA(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
707}
708//******************************************************************************
709//******************************************************************************
710BOOL WIN32API ExtTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,UINT cbCount,CONST int *lpDx)
711{
712 dprintf(("GDI32: ExtTextOutW\n"));
713
714 return InternalTextOutW(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
715}
716//******************************************************************************
717//******************************************************************************
718BOOL WIN32API TextOutA(HDC hdc,int nXStart,int nYStart,LPCSTR lpszString,int cbString)
719{
720 dprintf(("GDI32: TextOutA %x %s", hdc, lpszString));
721
722 return InternalTextOutA(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
723}
724//******************************************************************************
725//******************************************************************************
726BOOL WIN32API TextOutW(HDC hdc,int nXStart,int nYStart,LPCWSTR lpszString,int cbString)
727{
728 dprintf(("GDI32: TextOutW"));
729
730 return InternalTextOutW(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
731}
732//******************************************************************************
733//******************************************************************************
734BOOL WIN32API PolyTextOutA(HDC hdc,POLYTEXTA *pptxt,int cStrings)
735{
736 dprintf(("GDI32: PolyTextOutA"));
737
738 for (INT x = 0;x < cStrings;x++)
739 {
740 BOOL rc;
741
742 rc = InternalTextOutA(hdc,pptxt[x].x,pptxt[x].y,pptxt[x].uiFlags,&pptxt[x].rcl,pptxt[x].lpstr,pptxt[x].n,pptxt[x].pdx,TRUE);
743 if (!rc) return FALSE;
744 }
745
746 return TRUE;
747}
748//******************************************************************************
749//******************************************************************************
750BOOL WIN32API PolyTextOutW(HDC hdc,POLYTEXTW *pptxt,int cStrings)
751{
752 dprintf(("GDI32: PolyTextOutW"));
753
754 for (INT x = 0;x < cStrings;x++)
755 {
756 BOOL rc;
757
758 rc = InternalTextOutW(hdc,pptxt[x].x,pptxt[x].y,pptxt[x].uiFlags,&pptxt[x].rcl,pptxt[x].lpstr,pptxt[x].n,pptxt[x].pdx,TRUE);
759 if (!rc) return FALSE;
760 }
761
762 return TRUE;
763}
Note: See TracBrowser for help on using the repository browser.