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 struct _Ecore_WinCE_Window *w = NULL;
87 w = (struct _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 */
148 if (BeginPaint(window, &paint))
150 data->update = paint.rcPaint;
151 _ecore_wince_event_handle_expose(data);
152 EndPaint(window, &paint);
157 return DefWindowProc(window, message, window_param, data_param);
164 _ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__,
165 Eina_Log_Level level __UNUSED__,
166 const char *file __UNUSED__,
170 void *data __UNUSED__,
173 fprintf(stderr, "[%s:%d] ", fnc, line);
174 vfprintf(stderr, fmt, args);
182 /*============================================================================*
184 *============================================================================*/
187 double _ecore_wince_double_click_time = 0.25;
188 long _ecore_wince_event_last_time = 0;
189 Ecore_WinCE_Window *_ecore_wince_event_last_window = NULL;
190 HINSTANCE _ecore_wince_instance = NULL;
191 int _ecore_wince_log_dom_global = -1;
193 int ECORE_WINCE_EVENT_MOUSE_IN = 0;
194 int ECORE_WINCE_EVENT_MOUSE_OUT = 0;
195 int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = 0;
196 int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = 0;
197 int ECORE_WINCE_EVENT_WINDOW_DAMAGE = 0;
198 int ECORE_WINCE_EVENT_WINDOW_CREATE = 0;
199 int ECORE_WINCE_EVENT_WINDOW_DESTROY = 0;
200 int ECORE_WINCE_EVENT_WINDOW_SHOW = 0;
201 int ECORE_WINCE_EVENT_WINDOW_HIDE = 0;
202 int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = 0;
204 /*============================================================================*
206 *============================================================================*/
209 * @addtogroup Ecore_WinCE_Group Ecore_WinCE library
211 * Ecore_WinCE is a library that wraps Windows CE graphic functions
212 * and integrate them nicely into the Ecore main loop.
218 * @brief Initialize the Ecore_WinCE library.
220 * @return 1 or greater on success, 0 on error.
222 * This function sets up the Windows CE graphic system. It returns 0 on
223 * failure, otherwise it returns the number of times it has already been
226 * When Ecore_WinCE is not used anymore, call ecore_wince_shutdown()
227 * to shut down the Ecore_WinCE library.
234 if (++_ecore_wince_init_count != 1)
235 return _ecore_wince_init_count;
238 return --_ecore_wince_init_count;
240 eina_log_print_cb_set(_ecore_wince_error_print_cb, NULL);
241 _ecore_wince_log_dom_global = eina_log_domain_register
242 ("ecore_wince", ECORE_WINCE_DEFAULT_LOG_COLOR);
243 if (_ecore_wince_log_dom_global < 0)
245 EINA_LOG_ERR("Ecore_WinCE: Could not register log domain");
249 if (!ecore_event_init())
251 ERR("Ecore_WinCE: Could not init ecore_event");
252 goto unregister_log_domain;
255 _ecore_wince_instance = GetModuleHandle(NULL);
256 if (!_ecore_wince_instance)
258 ERR("GetModuleHandle() failed");
259 goto shutdown_ecore_event;
262 memset (&wc, 0, sizeof (wc));
263 wc.style = CS_HREDRAW | CS_VREDRAW;
264 wc.lpfnWndProc = _ecore_wince_window_procedure;
267 wc.hInstance = _ecore_wince_instance;
269 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
270 wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
271 wc.lpszMenuName = NULL;
272 wc.lpszClassName = ECORE_WINCE_WINDOW_CLASS;
274 if(!RegisterClass(&wc))
276 ERR("RegisterClass() failed");
280 if (!ECORE_WINCE_EVENT_MOUSE_IN)
282 ECORE_WINCE_EVENT_MOUSE_IN = ecore_event_type_new();
283 ECORE_WINCE_EVENT_MOUSE_OUT = ecore_event_type_new();
284 ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
285 ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
286 ECORE_WINCE_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
287 ECORE_WINCE_EVENT_WINDOW_CREATE = ecore_event_type_new();
288 ECORE_WINCE_EVENT_WINDOW_DESTROY = ecore_event_type_new();
289 ECORE_WINCE_EVENT_WINDOW_SHOW = ecore_event_type_new();
290 ECORE_WINCE_EVENT_WINDOW_HIDE = ecore_event_type_new();
291 ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
294 return _ecore_wince_init_count;
297 FreeLibrary(_ecore_wince_instance);
298 shutdown_ecore_event:
299 ecore_event_shutdown();
300 unregister_log_domain:
301 eina_log_domain_unregister(_ecore_wince_log_dom_global);
305 return --_ecore_wince_init_count;
309 * @brief Shut down the Ecore_WinCE library.
311 * @return 0 when the library is completely shut down, 1 or
314 * This function shuts down the Ecore_WinCE library. It returns 0 when it has
315 * been called the same number of times than ecore_wince_init(). In that case
316 * it shuts down all the Windows CE graphic system.
319 ecore_wince_shutdown()
323 if (--_ecore_wince_init_count != 0)
324 return _ecore_wince_init_count;
326 /* force task bar to be shown (in case the application exits */
327 /* while being fullscreen) */
328 task_bar = FindWindow(L"HHTaskBar", NULL);
331 ShowWindow(task_bar, SW_SHOW);
332 EnableWindow(task_bar, TRUE);
335 if (!UnregisterClass(ECORE_WINCE_WINDOW_CLASS, _ecore_wince_instance))
336 ERR("UnregisterClass() failed");
338 if (!FreeLibrary(_ecore_wince_instance))
339 ERR("FreeLibrary() failed");
341 _ecore_wince_instance = NULL;
343 ecore_event_shutdown();
344 eina_log_domain_unregister(_ecore_wince_log_dom_global);
345 _ecore_wince_log_dom_global = -1;
348 return _ecore_wince_init_count;
352 * @brief Set the timeout for a double and triple clicks to be flagged.
354 * @param t The time in seconds.
356 * This function sets the time @p t between clicks before the
357 * double_click flag is set in a button down event. If 3 clicks occur
358 * within double this time, the triple_click flag is also set.
361 ecore_wince_double_click_time_set(double t)
363 if (t < 0.0) t = 0.0;
364 _ecore_wince_double_click_time = t;
368 * @brief Retrieve the double and triple click flag timeout.
370 * @return The timeout for double clicks in seconds.
372 * This function returns the double clicks in seconds. If
373 * ecore_wince_double_click_time_set() has not been called, the
374 * default value is returned. See ecore_wince_double_click_time_set()
375 * for more informations.
378 ecore_wince_double_click_time_get(void)
380 return _ecore_wince_double_click_time;
384 * @brief Return the last event time.
386 * @return The last envent time.
388 * This function returns the last event time.
391 ecore_wince_current_time_get(void)
393 return _ecore_wince_event_last_time;