]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/cocoa/window.cpp
Update .gitignore to include build products on Windows
[libs/gui.git] / source / graphics / cocoa / window.cpp
1 #include "window.h"
2 #include "window_private.h"
3 #include "cocoadisplay.h"
4 #include "cocoawindow.h"
5 #include "display.h"
6 #include "display_private.h"
7
8 namespace Msp {
9 namespace Graphics {
10
11 void Window::platform_init()
12 {
13         CocoaDisplay *dpy = display.get_private().display;
14         priv->window = create_window(dpy, options.width, options.height, options.fullscreen, options.resizable);
15 }
16
17 void Window::platform_cleanup()
18 {
19         destroy_window(priv->window);
20 }
21
22 void Window::set_title(const std::string &title)
23 {
24         set_window_title(priv->window, title.c_str());
25 }
26
27 void Window::platform_reconfigure(bool /*fullscreen_changed*/)
28 {
29         set_window_size(priv->window, options.width, options.height);
30 }
31
32 void Window::show_cursor(bool)
33 {
34 }
35
36 void Window::warp_pointer(int, int)
37 {
38 }
39
40 void Window::platform_set_touch_input()
41 {
42 }
43
44 void Window::platform_show()
45 {
46         show_window(priv->window);
47 }
48
49 void Window::platform_hide()
50 {
51         hide_window(priv->window);
52 }
53
54 bool Window::event(const Event &ev)
55 {
56         switch(ev.cevent.type)
57         {
58         case LEFT_MOUSE_DOWN:
59         case LEFT_MOUSE_UP:
60         case RIGHT_MOUSE_DOWN:
61         case RIGHT_MOUSE_UP:
62         case KEY_DOWN:
63         case KEY_UP:
64         case OTHER_MOUSE_DOWN:
65         case OTHER_MOUSE_UP:
66                 signal_got_focus.emit();
67                 signal_input_event.emit(ev);
68                 break;
69         case MOUSE_MOVED:
70                 if(ev.cevent.motion.x>=0 && ev.cevent.motion.x<options.width && ev.cevent.motion.y>=0 && ev.cevent.motion.y<options.height)
71                         signal_input_event.emit(ev);
72                 break;
73         case WINDOW_CLOSED:
74                 signal_close.emit();
75                 break;
76         default:
77                 return false;
78         }
79
80         return true;
81 }
82
83 } // namespace Graphics
84 } // namespace Msp