1 | /* $Id: text.cpp,v 1.6 2000-01-29 14:23:33 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Font and Text Functions
|
---|
5 | *
|
---|
6 | * Copyright 1999 Christoph Bratschi
|
---|
7 | *
|
---|
8 | * Copyright 1997 Bertho A. Stultiens
|
---|
9 | * Copyright 1993, 1994 Alexandre Julliard
|
---|
10 | *
|
---|
11 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "winuser.h"
|
---|
15 | #include "user32.h"
|
---|
16 |
|
---|
17 | //WINE parts: wine-991031
|
---|
18 |
|
---|
19 | static const WORD wPattern55AA[] =
|
---|
20 | {
|
---|
21 | 0x5555, 0xaaaa, 0x5555, 0xaaaa,
|
---|
22 | 0x5555, 0xaaaa, 0x5555, 0xaaaa
|
---|
23 | };
|
---|
24 |
|
---|
25 | static HBRUSH hPattern55AABrush = 0;
|
---|
26 | static HBITMAP hPattern55AABitmap = 0;
|
---|
27 |
|
---|
28 | /*********************************************************************
|
---|
29 | * CACHE_GetPattern55AABitmap
|
---|
30 | */
|
---|
31 | HBITMAP CACHE_GetPattern55AABitmap(void)
|
---|
32 | {
|
---|
33 | if (!hPattern55AABitmap)
|
---|
34 | hPattern55AABitmap = CreateBitmap( 8, 8, 1, 1, wPattern55AA );
|
---|
35 | return hPattern55AABitmap;
|
---|
36 | }
|
---|
37 |
|
---|
38 | /*********************************************************************
|
---|
39 | * CACHE_GetPattern55AABrush
|
---|
40 | */
|
---|
41 | HBRUSH CACHE_GetPattern55AABrush(void)
|
---|
42 | {
|
---|
43 | if (!hPattern55AABrush)
|
---|
44 | hPattern55AABrush = CreatePatternBrush(CACHE_GetPattern55AABitmap());
|
---|
45 | return hPattern55AABrush;
|
---|
46 | }
|
---|
47 |
|
---|
48 | INT WIN32API DrawTextA(HDC hDC,LPCSTR lpString,INT nCount,PRECT lpRect,UINT nFormat)
|
---|
49 | {
|
---|
50 | int bla;
|
---|
51 |
|
---|
52 | dprintf(("USER32: DrawTextA %x %s %d (%d,%d)(%d,%d) %x",hDC, lpString, nCount, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, nFormat));
|
---|
53 |
|
---|
54 | if(nFormat == 0x828) {
|
---|
55 | bla = 1;
|
---|
56 | }
|
---|
57 | return InternalDrawTextExA(hDC,lpString,nCount,lpRect,nFormat,NULL,FALSE);
|
---|
58 | }
|
---|
59 | //******************************************************************************
|
---|
60 | //******************************************************************************
|
---|
61 | INT WIN32API DrawTextW(HDC hDC,LPCWSTR lpString,INT nCount,PRECT lpRect,UINT nFormat)
|
---|
62 | {
|
---|
63 | dprintf(("USER32: DrawTextW %x",hDC));
|
---|
64 |
|
---|
65 | return InternalDrawTextExW(hDC,lpString,nCount,lpRect,nFormat,NULL,FALSE);
|
---|
66 | }
|
---|
67 | //******************************************************************************
|
---|
68 | //******************************************************************************
|
---|
69 | INT WIN32API DrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams)
|
---|
70 | {
|
---|
71 | dprintf(("USER32: DrawTextExA %x %s %d (%d,%d)(%d,%d) %x",hdc, lpchText, cchText, lprc->left, lprc->top, lprc->right, lprc->bottom, dwDTFormat));
|
---|
72 |
|
---|
73 | return InternalDrawTextExA(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE);
|
---|
74 | }
|
---|
75 | //******************************************************************************
|
---|
76 | //******************************************************************************
|
---|
77 | int WIN32API DrawTextExW(HDC hdc,LPWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams)
|
---|
78 | {
|
---|
79 | dprintf(("USER32: DrawTextExW %x",hdc));
|
---|
80 |
|
---|
81 | return InternalDrawTextExW(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE);
|
---|
82 | }
|
---|
83 | //******************************************************************************
|
---|
84 | //******************************************************************************
|
---|
85 | DWORD WIN32API GetTabbedTextExtentA( HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)
|
---|
86 | {
|
---|
87 | dprintf(("USER32: GetTabbedTextExtentA %x",hDC));
|
---|
88 |
|
---|
89 | return InternalGetTabbedTextExtentA(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions);
|
---|
90 | }
|
---|
91 | //******************************************************************************
|
---|
92 | //******************************************************************************
|
---|
93 | DWORD WIN32API GetTabbedTextExtentW(HDC hDC,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions)
|
---|
94 | {
|
---|
95 | dprintf(("USER32: GetTabbedTextExtentW %x",hDC));
|
---|
96 |
|
---|
97 | return InternalGetTabbedTextExtentW(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions);
|
---|
98 | }
|
---|
99 | //******************************************************************************
|
---|
100 | //******************************************************************************
|
---|
101 | LONG WIN32API TabbedTextOutA(HDC hdc,INT x,INT y,LPCSTR lpString,INT nCount,INT nTabPositions, LPINT lpnTabStopPositions,INT nTabOrigin)
|
---|
102 | {
|
---|
103 | dprintf(("USER32: TabbedTextOutA %x",hdc));
|
---|
104 |
|
---|
105 | return InternalTabbedTextOutA(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin);
|
---|
106 | }
|
---|
107 | //******************************************************************************
|
---|
108 | //******************************************************************************
|
---|
109 | LONG WIN32API TabbedTextOutW( HDC hdc, int x, int y, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin)
|
---|
110 | {
|
---|
111 | dprintf(("USER32: TabbedTextOutW %x",hdc));
|
---|
112 |
|
---|
113 | return InternalTabbedTextOutW(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin);
|
---|
114 | }
|
---|
115 | //******************************************************************************
|
---|
116 | // WINE/objects/text.c
|
---|
117 | //******************************************************************************
|
---|
118 | static BOOL InternalGrayString(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,INT nCount,INT x,INT y,INT nWidth,INT nHeight,BOOL isUnicode)
|
---|
119 | {
|
---|
120 | HBITMAP hbm, hbmsave;
|
---|
121 | HBRUSH hbsave;
|
---|
122 | HFONT hfsave;
|
---|
123 | HDC memdc = CreateCompatibleDC(hdc);
|
---|
124 | BOOL retval = TRUE;
|
---|
125 | RECT r;
|
---|
126 | COLORREF fg, bg;
|
---|
127 |
|
---|
128 | if (!hdc) return FALSE;
|
---|
129 |
|
---|
130 | if (nCount == 0)
|
---|
131 | nCount = isUnicode ? lstrlenW((LPCWSTR)lpData):lstrlenA((LPCSTR)lpData);
|
---|
132 |
|
---|
133 | if((nWidth == 0 || nHeight == 0) && nCount != -1)
|
---|
134 | {
|
---|
135 | SIZE s;
|
---|
136 |
|
---|
137 | if (isUnicode)
|
---|
138 | GetTextExtentPoint32W(hdc,(LPCWSTR)lpData,nCount,&s);
|
---|
139 | else
|
---|
140 | GetTextExtentPoint32A(hdc,(LPCSTR)lpData,nCount,&s);
|
---|
141 | if (nWidth == 0) nWidth = s.cx;
|
---|
142 | if (nHeight == 0) nHeight = s.cy;
|
---|
143 | }
|
---|
144 |
|
---|
145 | r.left = r.top = 0;
|
---|
146 | r.right = nWidth;
|
---|
147 | r.bottom = nHeight;
|
---|
148 |
|
---|
149 | hbm = CreateBitmap(nWidth,nHeight,1,1,NULL);
|
---|
150 | hbmsave = (HBITMAP)SelectObject(memdc,hbm);
|
---|
151 | FillRect(memdc,&r,(HBRUSH)GetStockObject(BLACK_BRUSH));
|
---|
152 | SetTextColor(memdc,RGB(255,255,255));
|
---|
153 | SetBkColor(memdc,RGB(0,0,0));
|
---|
154 | hfsave = (HFONT)SelectObject(memdc,GetCurrentObject(hdc,OBJ_FONT));
|
---|
155 |
|
---|
156 | if (lpOutputFunc)
|
---|
157 | retval = lpOutputFunc(memdc,lpData,nCount);
|
---|
158 | else
|
---|
159 | if (isUnicode)
|
---|
160 | TextOutW(memdc,0,0,(LPCWSTR)lpData,nCount);
|
---|
161 | else
|
---|
162 | TextOutA(memdc,0,0,(LPCSTR)lpData,nCount);
|
---|
163 | SelectObject(memdc, hfsave);
|
---|
164 |
|
---|
165 | /*
|
---|
166 | * Windows doc says that the bitmap isn't grayed when len == -1 and
|
---|
167 | * the callback function returns FALSE. However, testing this on
|
---|
168 | * win95 showed otherwise...
|
---|
169 | */
|
---|
170 | #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
|
---|
171 | if(retval || nCount != -1)
|
---|
172 | #endif
|
---|
173 | {
|
---|
174 | hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
|
---|
175 | PatBlt(memdc,0,0,nWidth,nHeight,0x000A0329);
|
---|
176 | SelectObject(memdc, hbsave);
|
---|
177 | }
|
---|
178 |
|
---|
179 | if (hBrush) hbsave = (HBRUSH)SelectObject(hdc,hBrush);
|
---|
180 | fg = SetTextColor(hdc, RGB(0, 0, 0));
|
---|
181 | bg = SetBkColor(hdc, RGB(255, 255, 255));
|
---|
182 | BitBlt(hdc,x,y,nWidth,nHeight,memdc,0,0,0x00E20746);
|
---|
183 | SetTextColor(hdc, fg);
|
---|
184 | SetBkColor(hdc, bg);
|
---|
185 | if (hBrush) SelectObject(hdc,hbsave);
|
---|
186 |
|
---|
187 | SelectObject(memdc, hbmsave);
|
---|
188 | DeleteObject(hbm);
|
---|
189 | DeleteDC(memdc);
|
---|
190 |
|
---|
191 | return retval;
|
---|
192 | }
|
---|
193 | //******************************************************************************
|
---|
194 | //******************************************************************************
|
---|
195 | BOOL WIN32API GrayStringA(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,int nCount,int X,int Y,int nWidth,int nHeight)
|
---|
196 | {
|
---|
197 | dprintf(("USER32: GrayStringA %x",hdc));
|
---|
198 |
|
---|
199 | return InternalGrayString(hdc,hBrush,lpOutputFunc,lpData,nCount,X,Y,nWidth,nHeight,FALSE);
|
---|
200 | }
|
---|
201 | //******************************************************************************
|
---|
202 | //******************************************************************************
|
---|
203 | BOOL WIN32API GrayStringW(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,int nCount,int X,int Y,int nWidth,int nHeight)
|
---|
204 | {
|
---|
205 | dprintf(("USER32: GrayStringW %x",hdc));
|
---|
206 |
|
---|
207 | return InternalGrayString(hdc,hBrush,lpOutputFunc,lpData,nCount,X,Y,nWidth,nHeight,TRUE);
|
---|
208 | }
|
---|
209 |
|
---|