ecbee9e2edcf0077656219ff0a83125460bc456f
[winnie] / src / window.h
1 #ifndef WINDOW_H_
2 #define WINDOW_H_
3
4 #include <vector>
5
6 #include "geom.h"
7 #include "event.h"
8
9 class Window {
10 public:
11         enum State {STATE_NORMAL, STATE_MINIMIZED, STATE_MAXIMIZED, STATE_SHADED};
12
13 private:
14         char *title;
15         State state;
16
17         Rect rect;
18         Rect normal_rect; // normal state rectangle managed by the wm
19
20         Callbacks callbacks;
21
22         std::vector<Window*> children;
23         Window* parent;
24
25         bool dirty;
26         bool managed; // whether the wm manages (+decorates) this win
27         bool focusable;
28
29 public:
30         Window();
31         ~Window();
32
33         const Rect &get_rect() const;
34         Rect get_absolute_rect() const;
35         bool contains_point(int ptr_x, int ptr_y);
36
37         void move(int x, int y);
38         void resize(int x, int y);
39
40         void set_title(const char *s);
41         const char *get_title() const;
42
43         /* mark this window as dirty, and notify the window manager
44          * to repaint it, and anything it used to cover.
45          */
46         void invalidate();
47
48         void draw(Rect *dirty_region);
49         void draw_children(const Rect &dirty_region);
50
51         unsigned char *get_win_start_on_fb();
52         int get_scanline_width();
53
54         void set_managed(bool managed);
55         bool get_managed() const;
56
57         void set_focusable(bool focusable);
58         bool get_focusable() const;
59
60         bool get_dirty() const;
61
62         void set_display_callback(DisplayFuncType func);
63         void set_keyboard_callback(KeyboardFuncType func);
64         void set_mouse_button_callback(MouseButtonFuncType func);
65         void set_mouse_motion_callback(MouseMotionFuncType func);
66
67         const DisplayFuncType get_display_callback() const;
68         const KeyboardFuncType get_keyboard_callback() const;
69         const MouseButtonFuncType get_mouse_button_callback() const;
70         const MouseMotionFuncType get_mouse_motion_callback() const;
71
72         // win hierarchy
73         void add_child(Window *win);
74         void remove_child(Window *win);
75
76         Window **get_children();
77         int get_children_count() const;
78
79         const Window *get_parent() const;
80         Window *get_parent();
81
82         void set_state(State state);
83         State get_state() const;
84
85         // XXX remove if not needed
86         friend class WindowManager;
87 };
88
89 #endif  // WINDOW_H_