aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_wince/ecore_wince_window.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/ecore/src/lib/ecore_wince/ecore_wince_window.c827
1 files changed, 0 insertions, 827 deletions
diff --git a/libraries/ecore/src/lib/ecore_wince/ecore_wince_window.c b/libraries/ecore/src/lib/ecore_wince/ecore_wince_window.c
deleted file mode 100644
index 72353ce..0000000
--- a/libraries/ecore/src/lib/ecore_wince/ecore_wince_window.c
+++ /dev/null
@@ -1,827 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#define WIN32_LEAN_AND_MEAN
6#include <windows.h>
7#undef WIN32_LEAN_AND_MEAN
8
9#include <Evil.h>
10#include <Eina.h>
11
12#include "Ecore_WinCE.h"
13#include "ecore_wince_private.h"
14
15/*============================================================================*
16 * Local *
17 *============================================================================*/
18
19/**
20 * @cond LOCAL
21 */
22
23
24typedef BOOL (__stdcall *UnregisterFunc1Proc)(UINT, UINT);
25
26static int
27_ecore_wince_hardware_keys_register(HWND window)
28{
29 HINSTANCE core_dll;
30 UnregisterFunc1Proc unregister_fct;
31 int i;
32
33 core_dll = LoadLibrary(L"coredll.dll");
34 if (!core_dll)
35 {
36 ERR("LoadLibrary() failed");
37 return 0;
38 }
39
40 unregister_fct = (UnregisterFunc1Proc)GetProcAddress(core_dll, L"UnregisterFunc1");
41 if (!unregister_fct)
42 {
43 ERR("GetProcAddress() failed");
44 FreeLibrary(core_dll);
45 return 0;
46 }
47
48 for (i = 0xc1; i <= 0xcf; i++)
49 {
50 unregister_fct(MOD_WIN, i);
51 RegisterHotKey(window, i, MOD_WIN, i);
52 }
53
54 FreeLibrary(core_dll);
55
56 return 1;
57}
58
59/**
60 * @endcond
61 */
62
63
64/*============================================================================*
65 * Global *
66 *============================================================================*/
67
68/*============================================================================*
69 * API *
70 *============================================================================*/
71
72/**
73 * @addtogroup Ecore_WinCE_Group Ecore_WinCE library
74 *
75 * @{
76 */
77
78/**
79 * @brief Creates a new window.
80 *
81 * @param parent The parent window.
82 * @param x The x coordinate of the top-left corner of the window.
83 * @param y The y coordinate of the top-left corner of the window.
84 * @param width The width of the window.
85 * @param height The height of hte window.
86 * @return A newly allocated window.
87 *
88 * This function creates a new window which parent is @p parent. @p width and
89 * @p height are the size of the window content (the client part),
90 * without the border and title bar. @p x and @p y are the system
91 * coordinates of the top left cerner of the window (that is, of the
92 * title bar). This function returns a newly created window on
93 * success, and @c NULL on failure.
94 */
95EAPI Ecore_WinCE_Window *
96ecore_wince_window_new(Ecore_WinCE_Window *parent,
97 int x,
98 int y,
99 int width,
100 int height)
101{
102 Ecore_WinCE_Window *w;
103 HWND window;
104 RECT rect;
105
106 INF("creating window");
107
108 w = (Ecore_WinCE_Window *)calloc(1, sizeof(Ecore_WinCE_Window));
109 if (!w)
110 {
111 ERR("malloc() failed");
112 return NULL;
113 }
114
115 rect.left = 0;
116 rect.top = 0;
117 rect.right = width;
118 rect.bottom = height;
119 if (!AdjustWindowRectEx(&rect, WS_CAPTION | WS_SYSMENU | WS_VISIBLE, FALSE, WS_EX_TOPMOST))
120 {
121 ERR("AdjustWindowRectEx() failed");
122 free(w);
123 return NULL;
124 }
125
126 window = CreateWindowEx(WS_EX_TOPMOST,
127 ECORE_WINCE_WINDOW_CLASS,
128 L"",
129 WS_CAPTION | WS_SYSMENU | WS_VISIBLE,
130 x, y,
131 rect.right - rect.left, rect.bottom - rect.top,
132 parent ? ((Ecore_WinCE_Window *)parent)->window : NULL,
133 NULL, _ecore_wince_instance, NULL);
134 if (!window)
135 {
136 ERR("CreateWindowEx() failed");
137 free(w);
138 return NULL;
139 }
140
141 if (!_ecore_wince_hardware_keys_register(window))
142 {
143 ERR("_ecore_wince_hardware_keys_register() failed");
144 DestroyWindow(window);
145 free(w);
146 return NULL;
147 }
148
149 w->window = window;
150
151 SetLastError(0);
152 if (!SetWindowLong(window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0))
153 {
154 ERR("SetWindowLong() failed");
155 DestroyWindow(window);
156 free(w);
157 return NULL;
158 }
159
160 w->pointer_is_in = 0;
161
162 return w;
163}
164
165/**
166 * @brief Free the given window.
167 *
168 * @param window The window to free.
169 *
170 * This function frees @p window. If @p window is @c NULL, this
171 * function does nothing.
172 */
173EAPI void
174ecore_wince_window_free(Ecore_WinCE_Window *window)
175{
176 if (!window) return;
177
178 INF("destroying window");
179
180 DestroyWindow(window->window);
181 free(window);
182}
183
184/**
185 * @brief Return the window HANDLE associated to the given window.
186 *
187 * @param window The window to retrieve the HANDLE from.
188 *
189 * This function returns the window HANDLE associated to @p window. If
190 * @p window is @c NULL, this function returns @c NULL.
191 */
192EAPI void *
193ecore_wince_window_hwnd_get(Ecore_WinCE_Window *window)
194{
195 if (!window)
196 return NULL;
197
198 return window->window;
199}
200
201/**
202 * @brief Move the given window to a given position.
203 *
204 * @param window The window to move.
205 * @param x The x coordinate of the destination position.
206 * @param y The y coordinate of the destination position.
207 *
208 * This function move @p window to the new position of coordinates @p x
209 * and @p y. If @p window is @c NULL, or if it is fullscreen, or on
210 * error, this function does nothing.
211 */
212EAPI void
213ecore_wince_window_move(Ecore_WinCE_Window *window,
214 int x,
215 int y)
216{
217 RECT rect;
218
219 if (!window || window->fullscreen)
220 return;
221
222 INF("moving window (%dx%d)", x, y);
223
224 if (!GetWindowRect(window->window, &rect))
225 {
226 ERR("GetWindowRect() failed");
227 return;
228 }
229
230 if (!MoveWindow(window->window, x, y,
231 rect.right - rect.left,
232 rect.bottom - rect.top,
233 TRUE))
234 {
235 ERR("MoveWindow() failed");
236 }
237}
238
239/**
240 * @brief Resize the given window to a given size.
241 *
242 * @param window The window to resize.
243 * @param width The new width.
244 * @param height The new height.
245 *
246 * This function resize @p window to the new @p width and @p height.
247 * If @p window is @c NULL, or if it is fullscreen, or on error, this
248 * function does nothing.
249 */
250EAPI void
251ecore_wince_window_resize(Ecore_WinCE_Window *window,
252 int width,
253 int height)
254{
255 RECT rect;
256 DWORD style;
257 DWORD exstyle;
258 int x;
259 int y;
260
261 if (!window || window->fullscreen)
262 return;
263
264 INF("resizing window (%dx%d)", width, height);
265
266 if (!GetWindowRect(window->window, &rect))
267 {
268 ERR("GetWindowRect() failed");
269 return;
270 }
271
272 x = rect.left;
273 y = rect.top;
274 rect.left = 0;
275 rect.top = 0;
276 rect.right = width;
277 rect.bottom = height;
278 if (!(style = GetWindowLong(window->window, GWL_STYLE)))
279 {
280 ERR("GetWindowLong() failed");
281 return;
282 }
283 if (!(exstyle = GetWindowLong(window->window, GWL_EXSTYLE)))
284 {
285 ERR("GetWindowLong() failed");
286 return;
287 }
288 if (!AdjustWindowRectEx(&rect, style, FALSE, exstyle))
289 {
290 ERR("AdjustWindowRectEx() failed");
291 return;
292 }
293
294 if (!MoveWindow(window->window, x, y,
295 rect.right - rect.left,
296 rect.bottom - rect.top,
297 FALSE))
298 {
299 ERR("MoveWindow() failed");
300 }
301}
302
303/**
304 * @brief Move and resize the given window to a given position and size.
305 *
306 * @param window The window to move and resize.
307 * @param x The x coordinate of the destination position.
308 * @param y The x coordinate of the destination position.
309 * @param width The new width.
310 * @param height The new height.
311 *
312 * This function resize @p window to the new position of coordinates @p x
313 * and @p y and the new @p width and @p height. If @p window is @c NULL,
314 * or if it is fullscreen, or on error, this function does nothing.
315 */
316EAPI void
317ecore_wince_window_move_resize(Ecore_WinCE_Window *window,
318 int x,
319 int y,
320 int width,
321 int height)
322{
323 RECT rect;
324 DWORD style;
325 DWORD exstyle;
326
327 if (!window || window->fullscreen)
328 return;
329
330 INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height);
331
332 rect.left = 0;
333 rect.top = 0;
334 rect.right = width;
335 rect.bottom = height;
336 if (!(style = GetWindowLong(window->window, GWL_STYLE)))
337 {
338 ERR("GetWindowLong() failed");
339 return;
340 }
341 if (!(exstyle = GetWindowLong(window->window, GWL_EXSTYLE)))
342 {
343 ERR("GetWindowLong() failed");
344 return;
345 }
346 if (!AdjustWindowRectEx(&rect, style, FALSE, exstyle))
347 {
348 ERR("AdjustWindowRectEx() failed");
349 return;
350 }
351
352 if (!MoveWindow(window->window, x, y,
353 rect.right - rect.left,
354 rect.bottom - rect.top,
355 TRUE))
356 {
357 ERR("MoveWindow() failed");
358 }
359}
360
361/**
362 * @brief Show the given window.
363 *
364 * @param window The window to show.
365 *
366 * This function shows @p window. If @p window is @c NULL, or on
367 * error, this function does nothing.
368 */
369EAPI void
370ecore_wince_window_show(Ecore_WinCE_Window *window)
371{
372 if (!window) return;
373
374 INF("showing window");
375
376 if (!ShowWindow(window->window, SW_SHOWNORMAL))
377 {
378 ERR("ShowWindow() failed");
379 return;
380 }
381 if (!UpdateWindow(window->window))
382 {
383 ERR("UpdateWindow() failed");
384 }
385 if (!SendMessage(window->window, WM_SHOWWINDOW, 1, 0))
386 {
387 ERR("SendMessage() failed");
388 }
389}
390
391/**
392 * @brief Hide the given window.
393 *
394 * @param window The window to show.
395 *
396 * This function hides @p window. If @p window is @c NULL, or on
397 * error, this function does nothing.
398 */
399EAPI void
400ecore_wince_window_hide(Ecore_WinCE_Window *window)
401{
402 if (!window) return;
403
404 INF("hiding window");
405
406 if (!ShowWindow(window->window, SW_HIDE))
407 {
408 ERR("ShowWindow() failed");
409 return;
410 }
411 if (!SendMessage(window->window, WM_SHOWWINDOW, 0, 0))
412 {
413 ERR("SendMessage() failed");
414 }
415}
416
417/**
418 * @brief Set the title of the given window.
419 *
420 * @param window The window to set the title.
421 * @param title The new title.
422 *
423 * This function sets the title of @p window to @p title. If @p window
424 * is @c NULL, or if @p title is @c NULL or empty, or on error, this
425 * function does nothing.
426 */
427EAPI void
428ecore_wince_window_title_set(Ecore_WinCE_Window *window,
429 const char *title)
430{
431 wchar_t *wtitle;
432
433 if (!window) return;
434
435 if (!title || !title[0]) return;
436
437 INF("setting window title");
438
439 wtitle = evil_char_to_wchar(title);
440 if (!wtitle) return;
441
442 if (!SetWindowText(window->window, wtitle))
443 {
444 ERR("SetWindowText() failed");
445 }
446 free(wtitle);
447}
448
449/**
450 * @brief Set the focus to the given window.
451 *
452 * @param window The window to give focus to.
453 *
454 * This function gives the focus to @p window. If @p window is
455 * @c NULL, this function does nothing.
456 */
457EAPI void
458ecore_wince_window_focus(Ecore_WinCE_Window *window)
459{
460 if (!window) return;
461
462 INF("focusing window");
463
464 if (!SetFocus(window->window))
465 {
466 ERR("SetFocus() failed");
467 }
468}
469
470/**
471 * @brief Get the current focused window.
472 *
473 * @return The window that has focus.
474 *
475 * This function returns the window that has focus. If the calling
476 * thread's message queue does not have an associated window with the
477 * keyboard focus, the return value is @c NULL.
478 *
479 * @note Even if the returned value is @c NULL, another thread's queue
480 * may be associated with a window that has the keyboard focus.
481 *
482 * @note The returned value is of type HWND.
483 */
484EAPI void *
485ecore_wince_window_focus_get(void)
486{
487 HWND focused;
488
489 INF("getting focused window");
490
491 focused = GetFocus();
492 if (!focused)
493 {
494 ERR("GetFocus() failed");
495 return NULL;
496 }
497
498 return focused;
499}
500
501/**
502 * @brief Set the graphic backend used for the given window.
503 *
504 * @param window The window.
505 * @param backend The backend.
506 *
507 * This function sets the graphic backend to use with @p window to
508 * @p backend. If @p window if @c NULL, this function does nothing.
509 *
510 * The valid values for @p backend are
511 *
512 * @li 0: automatic choice of the backend.
513 * @li 1: the framebuffer (fast but could be not well suported).
514 * @li 2: GAPI (less fast but almost always supported).
515 * @li 3: DirectDraw (less fast than GAPI but almost always
516 * supported).
517 * @li 4: GDI (the slowest but always supported).
518 *
519 * The @p backend is used only in Evas and Ecore_Evas. So this
520 * function should not be called if Ecore_Evas is used.
521 */
522EAPI void
523ecore_wince_window_backend_set(Ecore_WinCE_Window *window,
524 int backend)
525{
526 if (!window)
527 return;
528
529 INF("setting backend");
530
531 window->backend = backend;
532}
533
534/**
535 * @brief Set the suspend callback used for the given window.
536 *
537 * @param window The window.
538 * @param suspend_cb The suspend callback.
539 *
540 * This function sets the suspend callback to use with @p window to
541 * @p suspend_cb. If @p window if @c NULL, this function does nothing.
542 *
543 * The @p suspend_cb is used only in Evas and Ecore_Evas. So this
544 * function should not be called if Ecore_Evas is used.
545 */
546EAPI void
547ecore_wince_window_suspend_cb_set(Ecore_WinCE_Window *window, int (*suspend_cb)(int))
548{
549 if (!window)
550 return;
551
552 INF("setting suspend callback");
553
554 window->suspend_cb = suspend_cb;
555}
556
557/**
558 * @brief Set the resume callback used for the given window.
559 *
560 * @param window The window.
561 * @param resume_cb The resume callback.
562 *
563 * This function sets the resume callback to use with @p window to
564 * @p resume_cb. If @p window if @c NULL, this function does nothing.
565 *
566 * The @p resume_cb is used only in Evas and Ecore_Evas. So this
567 * function should not be called if Ecore_Evas is used.
568 */
569EAPI void
570ecore_wince_window_resume_cb_set(Ecore_WinCE_Window *window, int (*resume_cb)(int))
571{
572 if (!window)
573 return;
574
575 INF("setting resume callback");
576
577 window->resume_cb = resume_cb;
578}
579
580/**
581 * @brief Get the geometry of the given window.
582 *
583 * @param window The window to retrieve the geometry from.
584 * @param x The x coordinate of the position.
585 * @param y The x coordinate of the position.
586 * @param width The width.
587 * @param height The height.
588 *
589 * This function retrieves the position and size of @p window. @p x,
590 * @p y, @p width and @p height can be buffers that will be filled with
591 * the corresponding values. If one of them is @c NULL, nothing will
592 * be done for that parameter. If @p window is @c NULL, and if the
593 * buffers are not @c NULL, they will be filled with respectively 0,
594 * 0, the size of the screen and the height of the screen.
595 */
596EAPI void
597ecore_wince_window_geometry_get(Ecore_WinCE_Window *window,
598 int *x,
599 int *y,
600 int *width,
601 int *height)
602{
603 RECT rect;
604 int w;
605 int h;
606
607 INF("getting window geometry");
608
609 if (!window)
610 {
611 if (x) *x = 0;
612 if (y) *y = 0;
613 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
614 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
615
616 return;
617 }
618
619 if (!GetClientRect(window->window, &rect))
620 {
621 ERR("GetClientRect() failed");
622
623 if (x) *x = 0;
624 if (y) *y = 0;
625 if (width) *width = 0;
626 if (height) *height = 0;
627
628 return;
629 }
630
631 w = rect.right - rect.left;
632 h = rect.bottom - rect.top;
633
634 if (!GetWindowRect(window->window, &rect))
635 {
636 ERR("GetWindowRect() failed");
637
638 if (x) *x = 0;
639 if (y) *y = 0;
640 if (width) *width = 0;
641 if (height) *height = 0;
642
643 return;
644 }
645
646 if (x) *x = rect.left;
647 if (y) *y = rect.top;
648 if (width) *width = w;
649 if (height) *height = h;
650}
651
652/**
653 * @brief Get the size of the given window.
654 *
655 * @param window The window to retrieve the size from.
656 * @param width The width.
657 * @param height The height.
658 *
659 * This function retrieves the size of @p window. @p width and
660 * @p height can be buffers that will be filled with the corresponding
661 * values. If one of them is @c NULL, nothing will be done for that
662 * parameter. If @p window is @c NULL, and if the buffers are not
663 * @c NULL, they will be filled with respectively the size of the screen
664 * and the height of the screen.
665 */
666EAPI void
667ecore_wince_window_size_get(Ecore_WinCE_Window *window,
668 int *width,
669 int *height)
670{
671 RECT rect;
672
673 INF("getting window size");
674
675 if (!window)
676 {
677 if (width) *width = GetSystemMetrics(SM_CXSCREEN);
678 if (height) *height = GetSystemMetrics(SM_CYSCREEN);
679
680 return;
681 }
682
683 if (!GetClientRect(window->window, &rect))
684 {
685 ERR("GetClientRect() failed");
686
687 if (width) *width = 0;
688 if (height) *height = 0;
689 }
690
691 if (width) *width = rect.right - rect.left;
692 if (height) *height = rect.bottom - rect.top;
693}
694
695/**
696 * @brief Set the given window to fullscreen.
697 *
698 * @param window The window.
699 * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode.
700 *
701 * This function set @p window to fullscreen or windowed mode. If @p on
702 * is set to EINA_TRUE, the window will be fullscreen, if it is set to
703 * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the
704 * state does not change (like setting to fullscreen while the window
705 * is already fullscreen), this function does nothing.
706 */
707EAPI void
708ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window,
709 Eina_Bool on)
710{
711 HWND task_bar;
712
713 if (!window) return;
714
715 if (((window->fullscreen) && (on)) ||
716 ((!window->fullscreen) && (!on)))
717 return;
718
719 INF("setting fullscreen: %s", on ? "yes" : "no");
720
721 window->fullscreen = !!on;
722
723 if (on)
724 {
725 /* save the position and size of the window */
726 if (!GetWindowRect(window->window, &window->rect))
727 {
728 ERR("GetWindowRect() failed");
729 return;
730 }
731
732 /* hide task bar */
733 task_bar = FindWindow(L"HHTaskBar", NULL);
734 if (!task_bar)
735 {
736 INF("FindWindow(): can not find task bar");
737 }
738 if (!ShowWindow(task_bar, SW_HIDE))
739 {
740 INF("ShowWindow(): task bar already hidden");
741 }
742 if (!EnableWindow(task_bar, FALSE))
743 {
744 INF("EnableWindow(): input already disabled");
745 }
746
747 /* style: visible + popup */
748 if (!SetWindowLong(window->window, GWL_STYLE, WS_POPUP | WS_VISIBLE))
749 {
750 INF("SetWindowLong() failed");
751 }
752
753 /* resize window to fit the entire screen */
754 if (!SetWindowPos(window->window, HWND_TOPMOST,
755 0, 0,
756 GetSystemMetrics(SM_CXSCREEN),
757 GetSystemMetrics(SM_CYSCREEN),
758 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED))
759 {
760 INF("SetWindowPos() failed");
761 }
762 /*
763 * It seems that SetWindowPos is not sufficient.
764 * Call MoveWindow with the correct size and force painting.
765 * Note that UpdateWindow (forcing repainting) is not sufficient
766 */
767 if (!MoveWindow(window->window,
768 0, 0,
769 GetSystemMetrics(SM_CXSCREEN),
770 GetSystemMetrics(SM_CYSCREEN),
771 TRUE))
772 {
773 INF("MoveWindow() failed");
774 }
775 }
776 else
777 {
778 /* show task bar */
779 task_bar = FindWindow(L"HHTaskBar", NULL);
780 if (!task_bar)
781 {
782 INF("FindWindow(): can not find task bar");
783 }
784 if (!ShowWindow(task_bar, SW_SHOW))
785 {
786 INF("ShowWindow(): task bar already visible");
787 }
788 if (!EnableWindow(task_bar, TRUE))
789 {
790 INF("EnableWindow(): input already enabled");
791 }
792
793 /* style: visible + caption + sysmenu */
794 if (!SetWindowLong(window->window, GWL_STYLE, WS_CAPTION | WS_SYSMENU | WS_VISIBLE))
795 {
796 INF("SetWindowLong() failed");
797 }
798 /* restaure the position and size of the window */
799 if (!SetWindowPos(window->window, HWND_TOPMOST,
800 window->rect.left,
801 window->rect.top,
802 window->rect.right - window->rect.left,
803 window->rect.bottom - window->rect.top,
804 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED))
805 {
806 INF("SetWindowLong() failed");
807 }
808 /*
809 * It seems that SetWindowPos is not sufficient.
810 * Call MoveWindow with the correct size and force painting.
811 * Note that UpdateWindow (forcing repainting) is not sufficient
812 */
813 if (!MoveWindow(window->window,
814 window->rect.left,
815 window->rect.top,
816 window->rect.right - window->rect.left,
817 window->rect.bottom - window->rect.top,
818 TRUE))
819 {
820 INF("MoveWindow() failed");
821 }
822 }
823}
824
825/**
826 * @}
827 */