branch update for HEAD-2003091401
[reactos.git] / lib / user32 / windows / paint.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * PROJECT:         ReactOS user32.dll
22  * FILE:            lib/user32/windows/input.c
23  * PURPOSE:         Input
24  * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
25  * UPDATE HISTORY:
26  *      09-05-2001  CSH  Created
27  */
28
29 /* INCLUDES ******************************************************************/
30
31 #include <windows.h>
32 #include <resource.h>
33 #include <user32.h>
34 #define NDEBUG
35 #include <debug.h>
36
37 static HBRUSH FrameBrushes[13];
38 static HBITMAP hHatch;
39
40 /* FUNCTIONS *****************************************************************/
41
42 static VOID 
43 CreateFrameBrushes()
44 {
45   FrameBrushes[0] = CreateSolidBrush(RGB(0,0,0));
46   FrameBrushes[1] = CreateSolidBrush(RGB(0,0,128));
47   FrameBrushes[2] = CreateSolidBrush(RGB(10,36,106));
48   FrameBrushes[3] = CreateSolidBrush(RGB(128,128,128));
49   FrameBrushes[4] = CreateSolidBrush(RGB(181,181,181));
50   FrameBrushes[5] = CreateSolidBrush(RGB(212,208,200));
51   FrameBrushes[6] = CreateSolidBrush(RGB(236,233,216));
52   FrameBrushes[7] = CreateSolidBrush(RGB(255,255,255));
53   FrameBrushes[8] = CreateSolidBrush(RGB(49,106,197));
54   FrameBrushes[9] = CreateSolidBrush(RGB(58,110,165));
55   FrameBrushes[10] = CreateSolidBrush(RGB(64,64,64));
56   FrameBrushes[11] = CreateSolidBrush(RGB(255,255,225));
57   hHatch = LoadBitmapW(NULL,MAKEINTRESOURCEW(DF_HATCH));
58   FrameBrushes[12] = CreatePatternBrush(hHatch);
59 }
60
61 VOID 
62 DeleteFrameBrushes(VOID)
63 {
64   unsigned Brush;
65
66   for (Brush = 0; Brush < sizeof(FrameBrushes) / sizeof(HBRUSH); Brush++)
67     {
68       if (NULL != FrameBrushes[Brush])
69         {
70           DeleteObject(FrameBrushes[Brush]);
71           FrameBrushes[Brush] = NULL;
72         }
73     }
74   if (NULL != hHatch)
75     {
76       DeleteObject(hHatch);
77       hHatch = NULL;
78     }
79 }
80
81 /*
82  * @implemented
83  */
84 HDC
85 STDCALL
86 BeginPaint(
87   HWND hwnd,
88   LPPAINTSTRUCT lpPaint)
89 {
90   return NtUserBeginPaint(hwnd, lpPaint);
91 }
92
93
94 /*
95  * @implemented
96  */
97 WINBOOL
98 STDCALL
99 EndPaint(
100   HWND hWnd,
101   CONST PAINTSTRUCT *lpPaint)
102 {
103   return NtUserEndPaint(hWnd, lpPaint);
104 }
105
106
107 /*
108  * @unimplemented
109  */
110 int
111 STDCALL
112 ExcludeUpdateRgn(
113   HDC hDC,
114   HWND hWnd)
115 {
116   UNIMPLEMENTED;
117   return 0;
118 }
119
120
121 /*
122  * @unimplemented
123  */
124 WINBOOL
125 STDCALL
126 GetUpdateRect(
127   HWND hWnd,
128   LPRECT lpRect,
129   WINBOOL bErase)
130 {
131   UNIMPLEMENTED;
132   return FALSE;
133 }
134
135
136 /*
137  * @implemented
138  */
139 int
140 STDCALL
141 GetUpdateRgn(
142   HWND hWnd,
143   HRGN hRgn,
144   WINBOOL bErase)
145 {
146   return NtUserGetUpdateRgn(hWnd, hRgn, bErase);
147 }
148
149
150 /*
151  * @implemented
152  */
153 WINBOOL
154 STDCALL
155 InvalidateRect(
156   HWND hWnd,
157   CONST RECT *lpRect,
158   WINBOOL bErase)
159 {
160   return NtUserInvalidateRect( hWnd, lpRect, bErase );
161 }
162
163
164 /*
165  * @implemented
166  */
167 WINBOOL
168 STDCALL
169 InvalidateRgn(
170   HWND hWnd,
171   HRGN hRgn,
172   WINBOOL bErase)
173 {
174   return NtUserInvalidateRgn( hWnd, hRgn, bErase );
175 }
176
177
178 /*
179  * @implemented
180  */
181 WINBOOL
182 STDCALL
183 RedrawWindow(
184   HWND hWnd,
185   CONST RECT *lprcUpdate,
186   HRGN hrgnUpdate,
187   UINT flags)
188 {
189  return NtUserRedrawWindow(hWnd, lprcUpdate, hrgnUpdate, flags);
190 }
191
192
193 /*
194  * @unimplemented
195  */
196 WINBOOL
197 STDCALL
198 ScrollDC(
199   HDC hDC,
200   int dx,
201   int dy,
202   CONST RECT *lprcScroll,
203   CONST RECT *lprcClip,
204   HRGN hrgnUpdate,
205   LPRECT lprcUpdate)
206 {
207   UNIMPLEMENTED;
208   return FALSE;
209 }
210
211
212 /*
213  * @unimplemented
214  */
215 int
216 STDCALL
217 SetWindowRgn(
218   HWND hWnd,
219   HRGN hRgn,
220   WINBOOL bRedraw)
221 {
222   UNIMPLEMENTED;
223   return 0;
224 }
225
226
227 /*
228  * @unimplemented
229  */
230 WINBOOL
231 STDCALL
232 UpdateWindow(
233   HWND hWnd)
234 {
235   return NtUserUpdateWindow( hWnd );
236 }
237
238
239 /*
240  * @unimplemented
241  */
242 WINBOOL
243 STDCALL
244 ValidateRect(
245   HWND hWnd,
246   CONST RECT *lpRect)
247 {
248   UNIMPLEMENTED;
249   return FALSE;
250 }
251
252
253 /*
254  * @implemented
255  */
256 WINBOOL
257 STDCALL
258 ValidateRgn(
259   HWND hWnd,
260   HRGN hRgn)
261 {
262   return (WINBOOL) NtUserCallTwoParam((DWORD) hWnd,
263                                       (DWORD) hRgn,
264                                       TWOPARAM_ROUTINE_VALIDATERGN);
265 }
266
267
268 /*
269  * @unimplemented
270  */
271 int
272 STDCALL
273 GetWindowRgn(
274   HWND hWnd,
275   HRGN hRgn)
276 {
277   UNIMPLEMENTED;
278   return 0;
279 }
280
281 const BYTE MappingTable[33] = {5,9,2,3,5,7,0,0,0,7,5,5,3,2,7,5,3,3,0,5,7,10,5,0,11,4,1,1,3,8,6,12,7};
282 /*
283  * @implemented
284  */
285 WINBOOL
286 STDCALL
287 DrawFrame(
288           HDC    hDc,
289           RECT  *r,
290           DWORD  width,
291           DWORD  type
292           )
293 {
294         DWORD rop;
295         DWORD brush;
296         HBRUSH hbrFrame;
297         PATRECT p[4];
298         if (NULL == FrameBrushes[0])
299         {
300                 CreateFrameBrushes();
301         }
302         if (type & 4)
303         {
304                 rop = PATINVERT;
305         }
306         else
307         {
308                 rop = PATCOPY;
309         }
310         brush = type / 8;
311         if (brush >= 33)
312         {
313                 brush = 32;
314         }
315         brush = MappingTable[brush];
316         hbrFrame = FrameBrushes[brush];
317         p[0].hBrush = hbrFrame;
318         p[1].hBrush = hbrFrame;
319         p[2].hBrush = hbrFrame;
320         p[3].hBrush = hbrFrame;
321         p[0].r.left = r->left;
322         p[0].r.top = r->top;
323         p[0].r.right = r->right - r->left;
324         p[0].r.bottom = width;
325         p[1].r.left = r->left;
326         p[1].r.top = r->bottom - width;
327         p[1].r.right = r->right - r->left;
328         p[1].r.bottom = width;
329         p[2].r.left = r->left;
330         p[2].r.top = r->top + width;
331         p[2].r.right = width;
332         p[2].r.bottom = r->bottom - r->top - (width * 2);
333         p[3].r.left = r->right - width;
334         p[3].r.top = r->top + width;
335         p[3].r.right = width;
336         p[3].r.bottom = r->bottom - r->top - (width * 2);
337         return PolyPatBlt(hDc,rop,p,4,0);
338 }