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