Added regedit unit test, a couple minor changes to regedit.
[wine] / dlls / gdi / win16drv / text.c
1 /*
2  * win16 driver text functions
3  *
4  * Copyright 1996 John Harvey
5  *           1998 Huw Davies
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <stdlib.h>
23 #include "win16drv/win16drv.h"
24 #include "gdi.h"
25 #include "wine/debug.h"
26 #include "winbase.h"
27 #include "winnls.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(win16drv);
30
31 /***********************************************************************
32  *           WIN16DRV_ExtTextOut
33  */
34 BOOL WIN16DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
35                            const RECT *lprect, LPCWSTR wstr, UINT count,
36                            const INT *lpDx )
37 {
38     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dev;
39     DC *dc = physDev->dc;
40     BOOL bRet = 1;
41     RECT16       clipRect;
42     RECT16       opaqueRect;
43     RECT16      *lpOpaqueRect = NULL;
44     WORD wOptions = 0;
45     DWORD len;
46     INT16 width;
47     char *str;
48     DWORD dwRet;
49
50     if (count == 0)
51         return FALSE;
52
53     TRACE("%04x %d %d %x %p %s %p\n",
54           dc->hSelf, x, y, flags, lprect, debugstr_wn(wstr, count), lpDx);
55
56     len = WideCharToMultiByte( CP_ACP, 0, wstr, count, NULL, 0, NULL, NULL );
57     str = HeapAlloc( GetProcessHeap(), 0, len );
58     WideCharToMultiByte( CP_ACP, 0, wstr, count, str, len, NULL, NULL );
59
60     clipRect.left = 0;
61     clipRect.top = 0;
62
63     clipRect.right = physDev->DevCaps.horzRes;
64     clipRect.bottom = physDev->DevCaps.vertRes;
65     if (lprect) {
66         opaqueRect.left = lprect->left;
67         opaqueRect.top = lprect->top;
68         opaqueRect.right = lprect->right;
69         opaqueRect.bottom = lprect->bottom;
70         lpOpaqueRect = &opaqueRect;
71     }
72
73     TRACE("textalign = %d\n", dc->textAlign);
74
75     if (dc->textAlign & TA_UPDATECP) {
76         x = dc->CursPosX;
77         y = dc->CursPosY;
78     }
79
80     x = XLPTODP( dc, x );
81     y = YLPTODP( dc, y );
82
83     dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
84                               NULL, str, -len,  physDev->FontInfo,
85                               win16drv_SegPtr_DrawMode,
86                               win16drv_SegPtr_TextXForm,
87                               NULL, NULL, 0);
88
89     width = LOWORD(dwRet);
90
91     switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
92     case TA_LEFT:
93         if (dc->textAlign & TA_UPDATECP)
94             dc->CursPosX = XDPTOLP( dc, x + width );
95         break;
96     case TA_RIGHT:
97         x -= width;
98         if (dc->textAlign & TA_UPDATECP)
99             dc->CursPosX = XDPTOLP( dc, x );
100         break;
101     case TA_CENTER:
102         x -= width / 2;
103         break;
104     }
105
106     switch( dc->textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) {
107     case TA_TOP:
108         break;
109     case TA_BOTTOM:
110         y -= physDev->FontInfo->dfPixHeight;
111         break;
112     case TA_BASELINE:
113         y -= physDev->FontInfo->dfAscent;
114         break;
115     }
116
117     dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE,
118                               x, y, &clipRect, str, (WORD)len,
119                               physDev->FontInfo, win16drv_SegPtr_DrawMode,
120                               win16drv_SegPtr_TextXForm, NULL, lpOpaqueRect,
121                               wOptions);
122
123     HeapFree( GetProcessHeap(), 0, str );
124     return bRet;
125 }
126
127
128
129
130
131
132
133
134