source: trunk/src/user32/text.cpp@ 2804

Last change on this file since 2804 was 2804, checked in by sandervl, 26 years ago

Added new logging feature

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