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

Last change on this file since 2093 was 2093, checked in by cbratschi, 26 years ago

text output changes, desktop WM_GETTEXT fixed, scrollbar DC changes

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