Release 20000326.
[wine/gsoc-2012-control.git] / graphics / win16drv / text.c
blobd9374cd5ca8c3fb9e5a02b54469f96789b786a91
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 "dc.h"
11 #include "gdi.h"
12 #include "debugtools.h"
13 #include "winbase.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 WORD wCount = count;
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 str = HeapAlloc( GetProcessHeap(), 0, count+1 );
42 lstrcpynWtoA( str, wstr, count+1 );
44 clipRect.left = 0;
45 clipRect.top = 0;
47 clipRect.right = dc->w.devCaps->horzRes;
48 clipRect.bottom = dc->w.devCaps->vertRes;
49 if (lprect) {
50 opaqueRect.left = lprect->left;
51 opaqueRect.top = lprect->top;
52 opaqueRect.right = lprect->right;
53 opaqueRect.bottom = lprect->bottom;
54 lpOpaqueRect = &opaqueRect;
57 TRACE("textalign = %d\n", dc->w.textAlign);
59 if (dc->w.textAlign & TA_UPDATECP) {
60 x = dc->w.CursPosX;
61 y = dc->w.CursPosY;
64 x = XLPTODP( dc, x );
65 y = YLPTODP( dc, y );
67 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
68 NULL, str, -count, physDev->FontInfo,
69 win16drv_SegPtr_DrawMode,
70 win16drv_SegPtr_TextXForm,
71 NULL, NULL, 0);
73 width = LOWORD(dwRet);
75 switch( dc->w.textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
76 case TA_LEFT:
77 if (dc->w.textAlign & TA_UPDATECP)
78 dc->w.CursPosX = XDPTOLP( dc, x + width );
79 break;
80 case TA_RIGHT:
81 x -= width;
82 if (dc->w.textAlign & TA_UPDATECP)
83 dc->w.CursPosX = XDPTOLP( dc, x );
84 break;
85 case TA_CENTER:
86 x -= width / 2;
87 break;
90 switch( dc->w.textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) {
91 case TA_TOP:
92 break;
93 case TA_BOTTOM:
94 y -= physDev->FontInfo->dfPixHeight;
95 break;
96 case TA_BASELINE:
97 y -= physDev->FontInfo->dfAscent;
98 break;
101 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE,
102 x, y, &clipRect, str, wCount,
103 physDev->FontInfo, win16drv_SegPtr_DrawMode,
104 win16drv_SegPtr_TextXForm, NULL, lpOpaqueRect,
105 wOptions);
107 HeapFree( GetProcessHeap(), 0, str );
108 return bRet;