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, useecore_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[] =
119 * 0x00, 0x00, 0x00, 0x00, // line 1
120 * 0x00, 0x03, 0xC0, 0x00, // line 2
121 * 0x00, 0x3F, 0x00, 0x00, // line 3
122 * 0x00, 0xFE, 0x00, 0x00, // line 4
124 * 0x0E, 0xFC, 0x00, 0x00, // line 5
125 * 0x07, 0xF8, 0x00, 0x00, // line 6
126 * 0x07, 0xF8, 0x00, 0x00, // line 7
127 * 0x0F, 0xF0, 0x00, 0x00, // line 8
129 * 0x1F, 0xF0, 0x00, 0x00, // line 9
130 * 0x1F, 0xE0, 0x00, 0x00, // line 10
131 * 0x3F, 0xE0, 0x00, 0x00, // line 11
132 * 0x3F, 0xE0, 0x00, 0x00, // line 12
134 * 0x3F, 0xF0, 0x00, 0x00, // line 13
135 * 0x7F, 0xF0, 0x00, 0x00, // line 14
136 * 0x7F, 0xF8, 0x00, 0x00, // line 15
137 * 0x7F, 0xFC, 0x00, 0x00, // line 16
139 * 0x7F, 0xFF, 0x00, 0x00, // line 17
140 * 0x7F, 0xFF, 0x80, 0x00, // line 18
141 * 0x7F, 0xFF, 0xE0, 0x00, // line 19
142 * 0x3F, 0xFF, 0xE0, 0x00, // line 20
144 * 0x3F, 0xC7, 0xF0, 0x00, // line 21
145 * 0x3F, 0x83, 0xF0, 0x00, // line 22
146 * 0x1F, 0x83, 0xF0, 0x00, // line 23
147 * 0x1F, 0x83, 0xE0, 0x00, // line 24
149 * 0x0F, 0xC7, 0xE0, 0x00, // line 25
150 * 0x07, 0xFF, 0xC0, 0x00, // line 26
151 * 0x07, 0xFF, 0xC0, 0x00, // line 27
152 * 0x01, 0xFF, 0x80, 0x00, // line 28
154 * 0x00, 0xFF, 0x00, 0x00, // line 29
155 * 0x00, 0x3C, 0x00, 0x00, // line 30
156 * 0x00, 0x00, 0x00, 0x00, // line 31
157 * 0x00, 0x00, 0x00, 0x00 // line 32
160 * Ecore_Win32_Cursor cursor = ecore_win32_cursor_new(pixels_and, pixels_xor, 32, 32, 19, 2);
163 EAPI Ecore_Win32_Cursor *
164 ecore_win32_cursor_new(const void *pixels_and,
165 const void *pixels_xor,
171 Ecore_Win32_Cursor *cursor = NULL;
175 INF("creating cursor");
177 if (!pixels_and || !pixels_xor)
180 cursor_width = GetSystemMetrics(SM_CXCURSOR);
181 cursor_height = GetSystemMetrics(SM_CYCURSOR);
183 if ((cursor_width != width) ||
184 (cursor_height != height))
187 if (!(cursor = CreateCursor(_ecore_win32_instance,
198 * @brief Free the given cursor.
200 * @param cursor The cursor to free.
202 * This function free @p cursor. @p cursor must have been obtained
203 * with ecore_win32_cursor_new().
206 ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
208 INF("destroying cursor");
210 DestroyCursor(cursor);
214 * @brief Create a cursor from a Windows ressource.
216 * @param shape The pre-defined shape of the cursor.
217 * @return The new cursor.
219 * This function returns a pre-defined cursor with a specified
220 * @p shape. This cursor does not need to be freed, as it is loaded
221 * from an existing resource.
223 EAPI Ecore_Win32_Cursor *
224 ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape)
226 Ecore_Win32_Cursor *cursor = NULL;
227 const char *cursor_name;
229 INF("geting shape cursor");
233 case ECORE_WIN32_CURSOR_SHAPE_APP_STARTING:
234 cursor_name = IDC_APPSTARTING;
236 case ECORE_WIN32_CURSOR_SHAPE_ARROW:
237 cursor_name = IDC_ARROW;
239 case ECORE_WIN32_CURSOR_SHAPE_CROSS:
240 cursor_name = IDC_CROSS;
242 case ECORE_WIN32_CURSOR_SHAPE_HAND:
243 cursor_name = IDC_HAND;
245 case ECORE_WIN32_CURSOR_SHAPE_HELP:
246 cursor_name = IDC_HELP;
248 case ECORE_WIN32_CURSOR_SHAPE_I_BEAM:
249 cursor_name = IDC_IBEAM;
251 case ECORE_WIN32_CURSOR_SHAPE_NO:
252 cursor_name = IDC_NO;
254 case ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL:
255 cursor_name = IDC_SIZEALL;
257 case ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW:
258 cursor_name = IDC_SIZENESW;
260 case ECORE_WIN32_CURSOR_SHAPE_SIZE_NS:
261 cursor_name = IDC_SIZENS;
263 case ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE:
264 cursor_name = IDC_SIZENWSE;
266 case ECORE_WIN32_CURSOR_SHAPE_SIZE_WE:
267 cursor_name = IDC_SIZEWE;
269 case ECORE_WIN32_CURSOR_SHAPE_UP_ARROW:
270 cursor_name = IDC_UPARROW;
272 case ECORE_WIN32_CURSOR_SHAPE_WAIT:
273 cursor_name = IDC_WAIT;
279 if (!(cursor = LoadCursor(NULL, cursor_name)))
286 * @brief Retrieve the size of a valid cursor.
288 * @param width The width of a valid cursor.
289 * @param height The height of a valid cursor.
291 * This function returns the size of a cursor that must be passed to
292 * ecore_win32_cursor_new(). @p width and @p height are buffers that
293 * will be filled with the correct size. They can be @c NULL.
296 ecore_win32_cursor_size_get(int *width, int *height)
298 INF("geting size cursor");
300 if (*width) *width = GetSystemMetrics(SM_CXCURSOR);
301 if (*height) *height = GetSystemMetrics(SM_CYCURSOR);