5 #define WIN32_LEAN_AND_MEAN
7 #undef WIN32_LEAN_AND_MEAN
11 #include "Ecore_Win32.h"
12 #include "ecore_win32_private.h"
14 /*============================================================================*
16 *============================================================================*/
19 /*============================================================================*
21 *============================================================================*/
24 /*============================================================================*
26 *============================================================================*/
29 * @addtogroup Ecore_Win32_Group Ecore_Win32 library
35 * @brief Create a new cursor.
37 * @param pixels_and The array of bytes containing the bit values for
38 * the AND mask of the cursor.
39 * @param pixels_xor The array of bytes containing the bit values for
40 * the XOR mask of the cursor.
41 * @param width The width of the cursor.
42 * @param height The height of the cursor.
43 * @param hot_x The horizontal position of the cursor's hot spot.
44 * @param hot_y The vertical position of the cursor's hot spot.
45 * @return A newly user-defined cursor.
47 * This function creates a new cursor of size @p width and @p
48 * height. They must be valid size. To determine the valid size of a
49 * cursor, use ecore_win32_cursor_size_get(). @p pixels_and is an array
50 * of bytes (unsigned char) containing the bits of the cursor that
51 * will be visible. @p pixels_xor is similar but will allow the cursor
52 * to have a shape. Here is the truth table for the masks:
55 * <tr><td>AND mask</td><td>XOR mask</td><td>Display</td></tr>
56 * <tr><td>0</td> <td>0</td> <td>Black</td></tr>
57 * <tr><td>0</td> <td>1</td> <td>White</td></tr>
58 * <tr><td>1</td> <td>0</td> <td>Screen</td></tr>
59 * <tr><td>1</td> <td>1</td> <td>Reverse screen</td></tr>
62 * @p hot_x and @p hot_y are the position of the hot spot of the
63 * cursor. If @p pixels_and or @p pixels_xor are @c NULL, the function
64 * returns NULL. If @p width or @p height does not match the valid
65 * size of a cursor, the function returns @c NULL. On success, the
66 * function creates a user-defined cursor, otherwise it returns
69 * Once the cursor is not used anymore, use ecore_win32_cursor_free()
70 * to free the ressources.
75 * unsigned char pixels_and[] ={
76 * 0xFF, 0xFC, 0x3F, 0xFF, // line 1
77 * 0xFF, 0xC0, 0x1F, 0xFF, // line 2
78 * 0xFF, 0x00, 0x3F, 0xFF, // line 3
79 * 0xFE, 0x00, 0xFF, 0xFF, // line 4
81 * 0xF7, 0x01, 0xFF, 0xFF, // line 5
82 * 0xF0, 0x03, 0xFF, 0xFF, // line 6
83 * 0xF0, 0x03, 0xFF, 0xFF, // line 7
84 * 0xE0, 0x07, 0xFF, 0xFF, // line 8
86 * 0xC0, 0x07, 0xFF, 0xFF, // line 9
87 * 0xC0, 0x0F, 0xFF, 0xFF, // line 10
88 * 0x80, 0x0F, 0xFF, 0xFF, // line 11
89 * 0x80, 0x0F, 0xFF, 0xFF, // line 12
91 * 0x80, 0x07, 0xFF, 0xFF, // line 13
92 * 0x00, 0x07, 0xFF, 0xFF, // line 14
93 * 0x00, 0x03, 0xFF, 0xFF, // line 15
94 * 0x00, 0x00, 0xFF, 0xFF, // line 16
96 * 0x00, 0x00, 0x7F, 0xFF, // line 17
97 * 0x00, 0x00, 0x1F, 0xFF, // line 18
98 * 0x00, 0x00, 0x0F, 0xFF, // line 19
99 * 0x80, 0x00, 0x0F, 0xFF, // line 20
101 * 0x80, 0x00, 0x07, 0xFF, // line 21
102 * 0x80, 0x00, 0x07, 0xFF, // line 22
103 * 0xC0, 0x00, 0x07, 0xFF, // line 23
104 * 0xC0, 0x00, 0x0F, 0xFF, // line 24
106 * 0xE0, 0x00, 0x0F, 0xFF, // line 25
107 * 0xF0, 0x00, 0x1F, 0xFF, // line 26
108 * 0xF0, 0x00, 0x1F, 0xFF, // line 27
109 * 0xF8, 0x00, 0x3F, 0xFF, // line 28
111 * 0xFE, 0x00, 0x7F, 0xFF, // line 29
112 * 0xFF, 0x00, 0xFF, 0xFF, // line 30
113 * 0xFF, 0xC3, 0xFF, 0xFF, // line 31
114 * 0xFF, 0xFF, 0xFF, 0xFF // line 32
117 * unsigned char pixels_xor[] = {
118 * 0x00, 0x00, 0x00, 0x00, // line 1
119 * 0x00, 0x03, 0xC0, 0x00, // line 2
120 * 0x00, 0x3F, 0x00, 0x00, // line 3
121 * 0x00, 0xFE, 0x00, 0x00, // line 4
123 * 0x0E, 0xFC, 0x00, 0x00, // line 5
124 * 0x07, 0xF8, 0x00, 0x00, // line 6
125 * 0x07, 0xF8, 0x00, 0x00, // line 7
126 * 0x0F, 0xF0, 0x00, 0x00, // line 8
128 * 0x1F, 0xF0, 0x00, 0x00, // line 9
129 * 0x1F, 0xE0, 0x00, 0x00, // line 10
130 * 0x3F, 0xE0, 0x00, 0x00, // line 11
131 * 0x3F, 0xE0, 0x00, 0x00, // line 12
133 * 0x3F, 0xF0, 0x00, 0x00, // line 13
134 * 0x7F, 0xF0, 0x00, 0x00, // line 14
135 * 0x7F, 0xF8, 0x00, 0x00, // line 15
136 * 0x7F, 0xFC, 0x00, 0x00, // line 16
138 * 0x7F, 0xFF, 0x00, 0x00, // line 17
139 * 0x7F, 0xFF, 0x80, 0x00, // line 18
140 * 0x7F, 0xFF, 0xE0, 0x00, // line 19
141 * 0x3F, 0xFF, 0xE0, 0x00, // line 20
143 * 0x3F, 0xC7, 0xF0, 0x00, // line 21
144 * 0x3F, 0x83, 0xF0, 0x00, // line 22
145 * 0x1F, 0x83, 0xF0, 0x00, // line 23
146 * 0x1F, 0x83, 0xE0, 0x00, // line 24
148 * 0x0F, 0xC7, 0xE0, 0x00, // line 25
149 * 0x07, 0xFF, 0xC0, 0x00, // line 26
150 * 0x07, 0xFF, 0xC0, 0x00, // line 27
151 * 0x01, 0xFF, 0x80, 0x00, // line 28
153 * 0x00, 0xFF, 0x00, 0x00, // line 29
154 * 0x00, 0x3C, 0x00, 0x00, // line 30
155 * 0x00, 0x00, 0x00, 0x00, // line 31
156 * 0x00, 0x00, 0x00, 0x00 // line 32
159 * Ecore_Win32_Cursor *cursor = ecore_win32_cursor_new(pixels_and, pixels_xor, 32, 32, 19, 2);
162 EAPI Ecore_Win32_Cursor *
163 ecore_win32_cursor_new(const void *pixels_and,
164 const void *pixels_xor,
170 Ecore_Win32_Cursor *cursor = NULL;
174 INF("creating cursor");
176 if (!pixels_and || !pixels_xor)
179 cursor_width = GetSystemMetrics(SM_CXCURSOR);
180 cursor_height = GetSystemMetrics(SM_CYCURSOR);
182 if ((cursor_width != width) ||
183 (cursor_height != height))
186 if (!(cursor = CreateCursor(_ecore_win32_instance,
197 * @brief Free the given cursor.
199 * @param cursor The cursor to free.
201 * This function free @p cursor. @p cursor must have been obtained
202 * with ecore_win32_cursor_new().
205 ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
207 INF("destroying cursor");
209 DestroyCursor(cursor);
213 * @brief Create a cursor from a Windows ressource.
215 * @param shape The pre-defined shape of the cursor.
216 * @return The new cursor.
218 * This function returns a pre-defined cursor with a specified
219 * @p shape. This cursor does not need to be freed, as it is loaded
220 * from an existing resource.
222 EAPI Ecore_Win32_Cursor *
223 ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape)
225 Ecore_Win32_Cursor *cursor = NULL;
226 const char *cursor_name;
228 INF("geting shape cursor");
232 case ECORE_WIN32_CURSOR_SHAPE_APP_STARTING:
233 cursor_name = IDC_APPSTARTING;
235 case ECORE_WIN32_CURSOR_SHAPE_ARROW:
236 cursor_name = IDC_ARROW;
238 case ECORE_WIN32_CURSOR_SHAPE_CROSS:
239 cursor_name = IDC_CROSS;
241 case ECORE_WIN32_CURSOR_SHAPE_HAND:
242 cursor_name = IDC_HAND;
244 case ECORE_WIN32_CURSOR_SHAPE_HELP:
245 cursor_name = IDC_HELP;
247 case ECORE_WIN32_CURSOR_SHAPE_I_BEAM:
248 cursor_name = IDC_IBEAM;
250 case ECORE_WIN32_CURSOR_SHAPE_NO:
251 cursor_name = IDC_NO;
253 case ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL:
254 cursor_name = IDC_SIZEALL;
256 case ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW:
257 cursor_name = IDC_SIZENESW;
259 case ECORE_WIN32_CURSOR_SHAPE_SIZE_NS:
260 cursor_name = IDC_SIZENS;
262 case ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE:
263 cursor_name = IDC_SIZENWSE;
265 case ECORE_WIN32_CURSOR_SHAPE_SIZE_WE:
266 cursor_name = IDC_SIZEWE;
268 case ECORE_WIN32_CURSOR_SHAPE_UP_ARROW:
269 cursor_name = IDC_UPARROW;
271 case ECORE_WIN32_CURSOR_SHAPE_WAIT:
272 cursor_name = IDC_WAIT;
278 if (!(cursor = LoadCursor(NULL, cursor_name)))
285 * @brief Retrieve the size of a valid cursor.
287 * @param width The width of a valid cursor.
288 * @param height The height of a valid cursor.
290 * This function returns the size of a cursor that must be passed to
291 * ecore_win32_cursor_new(). @p width and @p height are buffers that
292 * will be filled with the correct size. They can be @c NULL.
295 ecore_win32_cursor_size_get(int *width, int *height)
297 INF("geting size cursor");
299 if (*width) *width = GetSystemMetrics(SM_CXCURSOR);
300 if (*height) *height = GetSystemMetrics(SM_CYCURSOR);