6 #include <stdio.h> /* for printf */
8 #define WIN32_LEAN_AND_MEAN
10 #undef WIN32_LEAN_AND_MEAN
14 #include <Ecore_Input.h>
16 #include "Ecore_WinCE.h"
17 #include "ecore_wince_private.h"
19 /*============================================================================*
21 *============================================================================*/
27 static int _ecore_wince_init_count = 0;
30 _ecore_wince_window_procedure(HWND window,
35 Ecore_WinCE_Callback_Data *data;
39 data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data));
40 if (!data) return DefWindowProc(window, message, window_param, data_param);
42 data->window = window;
43 data->message = message;
44 data->window_param = window_param;
45 data->data_param = data_param;
46 data->time = GetTickCount();
47 coord = GetMessagePos();
48 pt = MAKEPOINTS(coord);
52 switch (data->message)
54 /* Keyboard input notifications */
56 _ecore_wince_event_handle_key_press(data, 0);
59 _ecore_wince_event_handle_key_press(data, 1);
63 _ecore_wince_event_handle_key_press(data, 1);
67 _ecore_wince_event_handle_key_release(data, 1);
70 _ecore_wince_event_handle_focus_in(data);
73 _ecore_wince_event_handle_focus_out(data);
75 /* Mouse input notifications */
77 _ecore_wince_event_handle_button_press(data, 1);
80 _ecore_wince_event_handle_button_release(data, 1);
85 Ecore_WinCE_Window *w = NULL;
87 w = (Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA);
89 if (GetClientRect(window, &rect))
93 INF("mouse in window");
95 pt.x = LOWORD(data_param);
96 pt.y = HIWORD(data_param);
97 if (!PtInRect(&rect, pt))
101 w->pointer_is_in = 0;
102 _ecore_wince_event_handle_leave_notify(data);
107 if (!w->pointer_is_in)
109 w->pointer_is_in = 1;
110 _ecore_wince_event_handle_enter_notify(data);
116 ERR("GetClientRect() failed");
118 _ecore_wince_event_handle_motion_notify(data);
122 /* Window notifications */
124 _ecore_wince_event_handle_create_notify(data);
127 _ecore_wince_event_handle_destroy_notify(data);
130 if ((data->data_param == SW_OTHERUNZOOM) ||
131 (data->data_param == SW_OTHERZOOM))
134 if (data->window_param)
135 _ecore_wince_event_handle_map_notify(data);
137 _ecore_wince_event_handle_unmap_notify(data);
141 _ecore_wince_event_handle_delete_request(data);
143 /* GDI notifications */
150 if (BeginPaint(window, &paint))
152 data->update = paint.rcPaint;
153 _ecore_wince_event_handle_expose(data);
154 EndPaint(window, &paint);
159 return DefWindowProc(window, message, window_param, data_param);
166 _ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__,
167 Eina_Log_Level level __UNUSED__,
168 const char *file __UNUSED__,
172 void *data __UNUSED__,
175 fprintf(stderr, "[%s:%d] ", fnc, line);
176 vfprintf(stderr, fmt, args);
184 /*============================================================================*
186 *============================================================================*/
189 double _ecore_wince_double_click_time = 0.25;
190 long _ecore_wince_event_last_time = 0;
191 Ecore_WinCE_Window *_ecore_wince_event_last_window = NULL;
192 HINSTANCE _ecore_wince_instance = NULL;
193 int _ecore_wince_log_dom_global = -1;
195 int ECORE_WINCE_EVENT_MOUSE_IN = 0;
196 int ECORE_WINCE_EVENT_MOUSE_OUT = 0;
197 int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = 0;
198 int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = 0;
199 int ECORE_WINCE_EVENT_WINDOW_DAMAGE = 0;
200 int ECORE_WINCE_EVENT_WINDOW_CREATE = 0;
201 int ECORE_WINCE_EVENT_WINDOW_DESTROY = 0;
202 int ECORE_WINCE_EVENT_WINDOW_SHOW = 0;
203 int ECORE_WINCE_EVENT_WINDOW_HIDE = 0;
204 int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = 0;
206 /*============================================================================*
208 *============================================================================*/
211 * @addtogroup Ecore_WinCE_Group Ecore_WinCE library
213 * Ecore_WinCE is a library that wraps Windows CE graphic functions
214 * and integrate them nicely into the Ecore main loop.
220 * @brief Initialize the Ecore_WinCE library.
222 * @return 1 or greater on success, 0 on error.
224 * This function sets up the Windows CE graphic system. It returns 0 on
225 * failure, otherwise it returns the number of times it has already been
228 * When Ecore_WinCE is not used anymore, call ecore_wince_shutdown()
229 * to shut down the Ecore_WinCE library.
236 if (++_ecore_wince_init_count != 1)
237 return _ecore_wince_init_count;
240 return --_ecore_wince_init_count;
242 eina_log_print_cb_set(_ecore_wince_error_print_cb, NULL);
243 _ecore_wince_log_dom_global = eina_log_domain_register
244 ("ecore_wince", ECORE_WINCE_DEFAULT_LOG_COLOR);
245 if (_ecore_wince_log_dom_global < 0)
247 EINA_LOG_ERR("Ecore_WinCE: Could not register log domain");
251 if (!ecore_event_init())
253 ERR("Ecore_WinCE: Could not init ecore_event");
254 goto unregister_log_domain;
257 _ecore_wince_instance = GetModuleHandle(NULL);
258 if (!_ecore_wince_instance)
260 ERR("GetModuleHandle() failed");
261 goto shutdown_ecore_event;
264 memset (&wc, 0, sizeof (wc));
265 wc.style = CS_HREDRAW | CS_VREDRAW;
266 wc.lpfnWndProc = _ecore_wince_window_procedure;
269 wc.hInstance = _ecore_wince_instance;
271 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
272 wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
273 wc.lpszMenuName = NULL;
274 wc.lpszClassName = ECORE_WINCE_WINDOW_CLASS;
276 if(!RegisterClass(&wc))
278 ERR("RegisterClass() failed");
282 if (!ECORE_WINCE_EVENT_MOUSE_IN)
284 ECORE_WINCE_EVENT_MOUSE_IN = ecore_event_type_new();
285 ECORE_WINCE_EVENT_MOUSE_OUT = ecore_event_type_new();
286 ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
287 ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
288 ECORE_WINCE_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
289 ECORE_WINCE_EVENT_WINDOW_CREATE = ecore_event_type_new();
290 ECORE_WINCE_EVENT_WINDOW_DESTROY = ecore_event_type_new();
291 ECORE_WINCE_EVENT_WINDOW_SHOW = ecore_event_type_new();
292 ECORE_WINCE_EVENT_WINDOW_HIDE = ecore_event_type_new();
293 ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
296 return _ecore_wince_init_count;
299 FreeLibrary(_ecore_wince_instance);
300 shutdown_ecore_event:
301 ecore_event_shutdown();
302 unregister_log_domain:
303 eina_log_domain_unregister(_ecore_wince_log_dom_global);
307 return --_ecore_wince_init_count;
311 * @brief Shut down the Ecore_WinCE library.
313 * @return 0 when the library is completely shut down, 1 or
316 * This function shuts down the Ecore_WinCE library. It returns 0 when it has
317 * been called the same number of times than ecore_wince_init(). In that case
318 * it shuts down all the Windows CE graphic system.
321 ecore_wince_shutdown()
325 if (--_ecore_wince_init_count != 0)
326 return _ecore_wince_init_count;
328 /* force task bar to be shown (in case the application exits */
329 /* while being fullscreen) */
330 task_bar = FindWindow(L"HHTaskBar", NULL);
333 ShowWindow(task_bar, SW_SHOW);
334 EnableWindow(task_bar, TRUE);
337 if (!UnregisterClass(ECORE_WINCE_WINDOW_CLASS, _ecore_wince_instance))
338 ERR("UnregisterClass() failed");
340 if (!FreeLibrary(_ecore_wince_instance))
341 ERR("FreeLibrary() failed");
343 _ecore_wince_instance = NULL;
345 ecore_event_shutdown();
346 eina_log_domain_unregister(_ecore_wince_log_dom_global);
347 _ecore_wince_log_dom_global = -1;
350 return _ecore_wince_init_count;
354 * @brief Set the timeout for a double and triple clicks to be flagged.
356 * @param t The time in seconds.
358 * This function sets the time @p t between clicks before the
359 * double_click flag is set in a button down event. If 3 clicks occur
360 * within double this time, the triple_click flag is also set.
363 ecore_wince_double_click_time_set(double t)
365 if (t < 0.0) t = 0.0;
366 _ecore_wince_double_click_time = t;
370 * @brief Retrieve the double and triple click flag timeout.
372 * @return The timeout for double clicks in seconds.
374 * This function returns the double clicks in seconds. If
375 * ecore_wince_double_click_time_set() has not been called, the
376 * default value is returned. See ecore_wince_double_click_time_set()
377 * for more informations.
380 ecore_wince_double_click_time_get(void)
382 return _ecore_wince_double_click_time;
386 * @brief Return the last event time.
388 * @return The last envent time.
390 * This function returns the last event time.
393 ecore_wince_current_time_get(void)
395 return _ecore_wince_event_last_time;