*in progress*
[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         bool contains_point(int ptr_x, int ptr_y);
28
29         void move(int x, int y);
30         void resize(int x, int y);
31
32         void set_title(const char *s);
33         const char *get_title() const;
34
35         /* mark this window as dirty, and notify the window manager
36          * to repaint it, and anything it used to cover.
37          */
38         void invalidate();
39
40         void draw(const Rect &dirty_region);
41         void draw_children(const Rect &dirty_region);
42
43         unsigned char *get_win_start_on_fb();
44         int get_scanline_width();
45
46         void set_managed(bool managed);
47         bool get_managed() const;
48
49         void set_focusable(bool focusable);
50         bool get_focusable() const;
51
52         void set_display_callback(DisplayFuncType func);
53         void set_keyboard_callback(KeyboardFuncType func);
54         void set_mouse_button_callback(MouseButtonFuncType func);
55         void set_mouse_motion_callback(MouseMotionFuncType func);
56
57         const DisplayFuncType get_display_callback() const;
58         const KeyboardFuncType get_keyboard_callback() const;
59         const MouseButtonFuncType get_mouse_button_callback() const;
60         const MouseMotionFuncType get_mouse_motion_callback() const;
61
62         // win hierarchy
63         void add_child(Window *win);
64         void remove_child(Window *win);
65
66         Window **get_children();
67         int get_children_count() const;
68
69         const Window *get_parent() const;
70         Window *get_parent();
71
72         // XXX remove if not needed
73         friend class WindowManager;
74 };
75
76 #endif  // WINDOW_H_