Compile fix for gcc 2.7.2.3.
[wine/multimedia.git] / graphics / win16drv / text.c
blobde289d027dcc6ab5b21e4bb643f758a4f9904039
1 /*
2 * win16 driver text functions
4 * Copyright 1996 John Harvey
5 * 1998 Huw Davies
6 */
8 #include <stdlib.h>
9 #include "win16drv.h"
10 #include "gdi.h"
11 #include "debugtools.h"
12 #include "winbase.h"
13 #include "winnls.h"
15 DEFAULT_DEBUG_CHANNEL(win16drv);
17 /***********************************************************************
18 * WIN16DRV_ExtTextOut
20 BOOL WIN16DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
21 const RECT *lprect, LPCWSTR wstr, UINT count,
22 const INT *lpDx )
24 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
25 BOOL bRet = 1;
26 RECT16 clipRect;
27 RECT16 opaqueRect;
28 RECT16 *lpOpaqueRect = NULL;
29 WORD wOptions = 0;
30 DWORD len;
31 INT16 width;
32 char *str;
33 DWORD dwRet;
35 if (count == 0)
36 return FALSE;
38 TRACE("%04x %d %d %x %p %s %p\n",
39 dc->hSelf, x, y, flags, lprect, debugstr_wn(wstr, count), lpDx);
41 len = WideCharToMultiByte( CP_ACP, 0, wstr, count, NULL, 0, NULL, NULL );
42 str = HeapAlloc( GetProcessHeap(), 0, len );
43 WideCharToMultiByte( CP_ACP, 0, wstr, count, str, len, NULL, NULL );
45 clipRect.left = 0;
46 clipRect.top = 0;
48 clipRect.right = dc->devCaps->horzRes;
49 clipRect.bottom = dc->devCaps->vertRes;
50 if (lprect) {
51 opaqueRect.left = lprect->left;
52 opaqueRect.top = lprect->top;
53 opaqueRect.right = lprect->right;
54 opaqueRect.bottom = lprect->bottom;
55 lpOpaqueRect = &opaqueRect;
58 TRACE("textalign = %d\n", dc->textAlign);
60 if (dc->textAlign & TA_UPDATECP) {
61 x = dc->CursPosX;
62 y = dc->CursPosY;
65 x = XLPTODP( dc, x );
66 y = YLPTODP( dc, y );
68 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
69 NULL, str, -len, physDev->FontInfo,
70 win16drv_SegPtr_DrawMode,
71 win16drv_SegPtr_TextXForm,
72 NULL, NULL, 0);
74 width = LOWORD(dwRet);
76 switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
77 case TA_LEFT:
78 if (dc->textAlign & TA_UPDATECP)
79 dc->CursPosX = XDPTOLP( dc, x + width );
80 break;
81 case TA_RIGHT:
82 x -= width;
83 if (dc->textAlign & TA_UPDATECP)
84 dc->CursPosX = XDPTOLP( dc, x );
85 break;
86 case TA_CENTER:
87 x -= width / 2;
88 break;
91 switch( dc->textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) {
92 case TA_TOP:
93 break;
94 case TA_BOTTOM:
95 y -= physDev->FontInfo->dfPixHeight;
96 break;
97 case TA_BASELINE:
98 y -= physDev->FontInfo->dfAscent;
99 break;
102 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE,
103 x, y, &clipRect, str, (WORD)len,
104 physDev->FontInfo, win16drv_SegPtr_DrawMode,
105 win16drv_SegPtr_TextXForm, NULL, lpOpaqueRect,
106 wOptions);
108 HeapFree( GetProcessHeap(), 0, str );
109 return bRet;