2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
6 #include <stdio.h> /* for printf */
8 #define WIN32_LEAN_AND_MEAN
10 #undef WIN32_LEAN_AND_MEAN
13 #include "Ecore_WinCE.h"
14 #include "ecore_wince_private.h"
17 /***** Global declarations *****/
19 double _ecore_wince_double_click_time = 0.25;
20 double _ecore_wince_event_last_time = 0.0;
21 Ecore_WinCE_Window *_ecore_wince_event_last_window = NULL;
22 HINSTANCE _ecore_wince_instance = NULL;
24 int ECORE_WINCE_EVENT_KEY_DOWN = 0;
25 int ECORE_WINCE_EVENT_KEY_UP = 0;
26 int ECORE_WINCE_EVENT_MOUSE_BUTTON_DOWN = 0;
27 int ECORE_WINCE_EVENT_MOUSE_BUTTON_UP = 0;
28 int ECORE_WINCE_EVENT_MOUSE_MOVE = 0;
29 int ECORE_WINCE_EVENT_MOUSE_IN = 0;
30 int ECORE_WINCE_EVENT_MOUSE_OUT = 0;
31 int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = 0;
32 int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = 0;
33 int ECORE_WINCE_EVENT_WINDOW_DAMAGE = 0;
34 int ECORE_WINCE_EVENT_WINDOW_CREATE = 0;
35 int ECORE_WINCE_EVENT_WINDOW_DESTROY = 0;
36 int ECORE_WINCE_EVENT_WINDOW_SHOW = 0;
37 int ECORE_WINCE_EVENT_WINDOW_HIDE = 0;
38 int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = 0;
41 /***** Private declarations *****/
43 static int _ecore_wince_init_count = 0;
46 LRESULT CALLBACK _ecore_wince_window_procedure(HWND window,
59 if (_ecore_wince_init_count > 0)
61 _ecore_wince_init_count++;
62 return _ecore_wince_init_count;
65 _ecore_wince_instance = GetModuleHandle(NULL);
66 if (!_ecore_wince_instance)
69 memset (&wc, 0, sizeof (wc));
70 wc.style = CS_HREDRAW | CS_VREDRAW;
71 wc.lpfnWndProc = _ecore_wince_window_procedure;
74 wc.hInstance = _ecore_wince_instance;
76 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
77 wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
78 wc.lpszMenuName = NULL;
79 wc.lpszClassName = ECORE_WINCE_WINDOW_CLASS;
81 if(!RegisterClass(&wc))
83 FreeLibrary(_ecore_wince_instance);
87 if (!ECORE_WINCE_EVENT_KEY_DOWN)
89 ECORE_WINCE_EVENT_KEY_DOWN = ecore_event_type_new();
90 ECORE_WINCE_EVENT_KEY_UP = ecore_event_type_new();
91 ECORE_WINCE_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
92 ECORE_WINCE_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
93 ECORE_WINCE_EVENT_MOUSE_MOVE = ecore_event_type_new();
94 ECORE_WINCE_EVENT_MOUSE_IN = ecore_event_type_new();
95 ECORE_WINCE_EVENT_MOUSE_OUT = ecore_event_type_new();
96 ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
97 ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
98 ECORE_WINCE_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
99 ECORE_WINCE_EVENT_WINDOW_CREATE = ecore_event_type_new();
100 ECORE_WINCE_EVENT_WINDOW_DESTROY = ecore_event_type_new();
101 ECORE_WINCE_EVENT_WINDOW_SHOW = ecore_event_type_new();
102 ECORE_WINCE_EVENT_WINDOW_HIDE = ecore_event_type_new();
103 ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
106 _ecore_wince_init_count++;
108 printf ("ecore_wince : instance + class bon\n");
110 return _ecore_wince_init_count;
114 ecore_wince_shutdown()
116 _ecore_wince_init_count++;
117 if (_ecore_wince_init_count > 0) return _ecore_wince_init_count;
118 if (!_ecore_wince_instance) return _ecore_wince_init_count;
120 UnregisterClass(ECORE_WINCE_WINDOW_CLASS, _ecore_wince_instance);
121 FreeLibrary(_ecore_wince_instance);
122 _ecore_wince_instance = NULL;
124 if (_ecore_wince_init_count < 0) _ecore_wince_init_count = 0;
126 return _ecore_wince_init_count;
130 * Sets the timeout for a double and triple clicks to be flagged.
132 * This sets the time between clicks before the double_click flag is
133 * set in a button down event. If 3 clicks occur within double this
134 * time, the triple_click flag is also set.
136 * @param t The time in seconds
139 ecore_wince_double_click_time_set(double t)
141 if (t < 0.0) t = 0.0;
142 _ecore_wince_double_click_time = t;
146 * Retrieves the double and triple click flag timeout.
148 * See @ref ecore_wince_double_click_time_set for more information.
150 * @return The timeout for double clicks in seconds.
153 ecore_wince_double_click_time_get(void)
155 return _ecore_wince_double_click_time;
159 * Return the last event time
162 ecore_wince_current_time_get(void)
164 return _ecore_wince_event_last_time;
168 /***** Private functions definitions *****/
171 _ecore_wince_window_procedure(HWND window,
176 Ecore_WinCE_Callback_Data *data;
180 data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data));
181 if (!data) return DefWindowProc(window, message, window_param, data_param);
183 data->window = window;
184 data->message = message;
185 data->window_param = window_param;
186 data->data_param = data_param;
187 data->time = GetTickCount();
188 coord = GetMessagePos();
189 pt = MAKEPOINTS(coord);
193 switch (data->message)
195 /* Keyboard input notifications */
197 printf (" * ecore message : keystroke down (hotkey)\n");
198 _ecore_wince_event_handle_key_press(data);
201 printf (" * ecore message : keystroke down\n");
202 _ecore_wince_event_handle_key_press(data);
205 printf (" * ecore message : keystroke up\n");
206 _ecore_wince_event_handle_key_release(data);
209 printf (" * ecore message : focus in\n");
210 _ecore_wince_event_handle_focus_in(data);
213 printf (" * ecore message : focus out\n");
214 _ecore_wince_event_handle_focus_out(data);
216 /* Mouse input notifications */
218 printf (" * ecore message : lbuttondown\n");
219 _ecore_wince_event_handle_button_press(data, 1);
222 printf (" * ecore message : lbuttonup\n");
223 _ecore_wince_event_handle_button_release(data, 1);
228 struct _Ecore_WinCE_Window *w = NULL;
230 w = (struct _Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA);
231 printf (" * ecore message : mouse move\n");
233 if (GetClientRect(window, &rect))
237 printf ("GetClientRect !!\n");
238 pt.x = LOWORD(data_param);
239 pt.y = HIWORD(data_param);
240 if (!PtInRect(&rect, pt))
242 printf ("pas dans rect...\n");
243 if (w->pointer_is_in)
245 w->pointer_is_in = 0;
246 _ecore_wince_event_handle_leave_notify(data);
251 printf ("dans rect... %d\n", w->pointer_is_in);
252 if (!w->pointer_is_in)
254 printf ("w->pointer_is_in a 0\n");
255 w->pointer_is_in = 1;
256 _ecore_wince_event_handle_enter_notify(data);
262 printf ("pas de GetClientRect !!\n");
264 _ecore_wince_event_handle_motion_notify(data);
268 /* Window notifications */
272 GetClientRect(window, &rect);
273 printf (" *** ecore message : create %ld %ld\n",
274 rect.right - rect.left, rect.bottom - rect.top);
276 _ecore_wince_event_handle_create_notify(data);
279 printf (" * ecore message : destroy\n");
280 _ecore_wince_event_handle_destroy_notify(data);
285 GetClientRect(window, &rect);
286 printf (" *** ecore message : show %ld %ld\n",
287 rect.right - rect.left, rect.bottom - rect.top);
289 if ((data->data_param == SW_OTHERUNZOOM) ||
290 (data->data_param == SW_OTHERUNZOOM))
293 if (data->window_param)
294 _ecore_wince_event_handle_map_notify(data);
296 _ecore_wince_event_handle_unmap_notify(data);
300 printf (" * ecore message : close\n");
301 _ecore_wince_event_handle_delete_request(data);
303 /* GDI notifications */
309 printf (" * ecore message : paint\n");
310 if (BeginPaint(window, &paint))
312 printf (" * ecore message : painting...\n");
313 data->update = paint.rcPaint;
314 _ecore_wince_event_handle_expose(data);
315 EndPaint(window, &paint);
320 return DefWindowProc(window, message, window_param, data_param);