db64b8b3162f15888be4ffefab7dca151d8e9c23
[reactos.git] / lib / user32 / windows / cursor.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/cursor.c
23  * PURPOSE:         Cursor
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 <user32.h>
33 #include <string.h>
34 #include <debug.h>
35
36 /* INTERNAL ******************************************************************/
37
38 /* This callback routine is called directly after switching to gui mode */
39 NTSTATUS STDCALL
40 User32SetupDefaultCursors(PVOID Arguments, ULONG ArgumentLength)
41 {
42   LRESULT Result = TRUE;
43   /* FIXME load system cursor scheme */
44   
45   return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS));
46 }
47
48 /* FUNCTIONS *****************************************************************/
49
50
51 /*
52  * @unimplemented
53  */
54 HCURSOR STDCALL
55 CopyCursor(HCURSOR pcur)
56 {
57   UNIMPLEMENTED;
58   return (HCURSOR)0;
59 }
60
61
62 /*
63  * @unimplemented
64  */
65 HCURSOR STDCALL
66 CreateCursor(HINSTANCE hInst,
67              int xHotSpot,
68              int yHotSpot,
69              int nWidth,
70              int nHeight,
71              CONST VOID *pvANDPlane,
72              CONST VOID *pvXORPlane)
73 {
74
75   UNIMPLEMENTED;
76   return (HCURSOR)0;
77 }
78
79
80 /*
81  * @unimplemented
82  */
83 WINBOOL STDCALL
84 DestroyCursor(HCURSOR hCursor)
85 {
86   UNIMPLEMENTED;
87   return FALSE;
88 }
89
90
91 /*
92  * @implemented
93  */
94 WINBOOL STDCALL
95 GetClipCursor(LPRECT lpRect)
96 {
97   RECT rc;
98   WINBOOL res;
99   
100   if(!lpRect)
101   {
102     SetLastError(ERROR_NOACCESS);
103     return FALSE;
104   }
105   
106   RtlCopyMemory(&rc, lpRect, sizeof(RECT));
107   res = NtUserGetClipCursor(&rc);
108   RtlCopyMemory(lpRect, &rc, sizeof(RECT));
109   
110   return res;
111 }
112
113
114 /*
115  * @unimplemented
116  */
117 HCURSOR STDCALL
118 GetCursor(VOID)
119 {
120   UNIMPLEMENTED;
121   return (HCURSOR)0;
122 }
123
124
125 /*
126  * @unimplemented
127  */
128 WINBOOL STDCALL
129 GetCursorInfo(PCURSORINFO pci)
130 {
131   UNIMPLEMENTED;
132   return FALSE;
133 }
134
135
136 /*
137  * @implemented
138  */
139 WINBOOL STDCALL
140 GetCursorPos(LPPOINT lpPoint)
141 {
142   POINT pos;
143   WINBOOL res;
144   /* Windows doesn't check if lpPoint == NULL, we do */
145   if(!lpPoint)
146   {
147     SetLastError(ERROR_INVALID_PARAMETER);
148     return FALSE;
149   }
150   
151   res = (WINBOOL)NtUserCallTwoParam((DWORD)&pos, (DWORD)FALSE, 
152                                     TWOPARAM_ROUTINE_CURSORPOSITION);
153   if(res)
154   {
155     lpPoint->x = pos.x;
156     lpPoint->y = pos.y;
157   }
158   return res;
159 }
160
161
162 /*
163  * @implemented
164  */
165 HCURSOR STDCALL
166 LoadCursorA(HINSTANCE hInstance,
167             LPCSTR lpCursorName)
168 {
169   return(LoadImageA(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0,
170                     LR_DEFAULTSIZE));
171 }
172
173
174 /*
175  * @implemented
176  */
177 HCURSOR STDCALL
178 LoadCursorFromFileA(LPCSTR lpFileName)
179 {
180   UNICODE_STRING FileName;
181   HCURSOR Result;
182   RtlCreateUnicodeStringFromAsciiz(&FileName, (LPSTR)lpFileName);
183   Result = LoadImageW(0, FileName.Buffer, IMAGE_CURSOR, 0, 0, 
184                       LR_LOADFROMFILE | LR_DEFAULTSIZE);
185   RtlFreeUnicodeString(&FileName);
186   return(Result);
187 }
188
189
190 /*
191  * @implemented
192  */
193 HCURSOR STDCALL
194 LoadCursorFromFileW(LPCWSTR lpFileName)
195 {
196   return(LoadImageW(0, lpFileName, IMAGE_CURSOR, 0, 0, 
197                     LR_LOADFROMFILE | LR_DEFAULTSIZE));
198 }
199
200
201 /*
202  * @implemented
203  */
204 HCURSOR STDCALL
205 LoadCursorW(HINSTANCE hInstance,
206             LPCWSTR lpCursorName)
207 {
208   return(LoadImageW(hInstance, lpCursorName, IMAGE_CURSOR, 0, 0,
209                     LR_DEFAULTSIZE));
210 }
211
212
213 /*
214  * @implemented
215  */
216 WINBOOL
217 STDCALL
218 ClipCursor(
219   CONST RECT *lpRect)
220 {
221   RECT rc;
222   if(lpRect)
223   {
224     RtlCopyMemory(&rc, lpRect, sizeof(RECT));
225     return NtUserClipCursor(&rc);
226   }
227   else
228     return NtUserClipCursor(NULL);
229 }
230
231
232 /*
233  * @unimplemented
234  */
235 HCURSOR STDCALL
236 SetCursor(HCURSOR hCursor)
237 {
238   UNIMPLEMENTED;
239   return (HCURSOR)0;
240 }
241
242
243 /*
244  * @implemented
245  */
246 WINBOOL STDCALL
247 SetCursorPos(int X,
248              int Y)
249 {
250   POINT pos;
251   pos.x = (LONG)X;
252   pos.y = (LONG)Y;
253   return (WINBOOL)NtUserCallTwoParam((DWORD)&pos, (DWORD)TRUE, 
254                                      TWOPARAM_ROUTINE_CURSORPOSITION);
255 }
256
257
258 /*
259  * @unimplemented
260  */
261 WINBOOL STDCALL
262 SetSystemCursor(HCURSOR hcur,
263                 DWORD id)
264 {
265   UNIMPLEMENTED;
266   return FALSE;
267 }
268
269
270 /*
271  * @unimplemented
272  */
273 int STDCALL
274 ShowCursor(WINBOOL bShow)
275 {
276   UNIMPLEMENTED;
277   return 0;
278 }
279
280 HCURSOR
281 CursorIconToCursor(HICON hIcon, BOOL SemiTransparent)
282 {
283   UNIMPLEMENTED;
284   return 0;
285 }