028343e2b779c3c657db28f6ccfbb8bd89d12a17
[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 private:
11         char *title;
12         Rect rect;
13         Callbacks callbacks;
14
15         std::vector<Window*> children;
16         Window* parent;
17
18         bool dirty;
19         bool managed; // whether the wm manages (+decorates) this win
20         bool focusable;
21
22 public:
23         Window();
24         ~Window();
25
26         const Rect &get_rect() const;
27         Rect get_absolute_rect() const;
28         bool contains_point(int ptr_x, int ptr_y);
29
30         void move(int x, int y);
31         void resize(int x, int y);
32
33         void set_title(const char *s);
34         const char *get_title() const;
35
36         /* mark this window as dirty, and notify the window manager
37          * to repaint it, and anything it used to cover.
38          */
39         void invalidate();
40
41         void draw(const Rect &dirty_region);
42         void draw_children(const Rect &dirty_region);
43
44         unsigned char *get_win_start_on_fb();
45         int get_scanline_width();
46
47         void set_managed(bool managed);
48         bool get_managed() const;
49
50         void set_focusable(bool focusable);
51         bool get_focusable() const;
52
53         bool get_dirty() const;
54
55         void set_display_callback(DisplayFuncType func);
56         void set_keyboard_callback(KeyboardFuncType func);
57         void set_mouse_button_callback(MouseButtonFuncType func);
58         void set_mouse_motion_callback(MouseMotionFuncType func);
59
60         const DisplayFuncType get_display_callback() const;
61         const KeyboardFuncType get_keyboard_callback() const;
62         const MouseButtonFuncType get_mouse_button_callback() const;
63         const MouseMotionFuncType get_mouse_motion_callback() const;
64
65         // win hierarchy
66         void add_child(Window *win);
67         void remove_child(Window *win);
68
69         Window **get_children();
70         int get_children_count() const;
71
72         const Window *get_parent() const;
73         Window *get_parent();
74
75         // XXX remove if not needed
76         friend class WindowManager;
77 };
78
79 #endif  // WINDOW_H_