added struct subsys so that we know each
[winnie] / src / window.h
1 /*
2 winnie - an experimental window system
3
4 Copyright (C) 2013 Eleni Maria Stea
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 Author: Eleni Maria Stea <elene.mst@gmail.com>
20 */
21
22 #ifndef WINDOW_H_
23 #define WINDOW_H_
24
25 #include <vector>
26
27 #include "geom.h"
28 #include "event.h"
29
30 class Window {
31 public:
32         enum State {STATE_NORMAL, STATE_MINIMIZED, STATE_MAXIMIZED, STATE_SHADED};
33
34 private:
35         char *title;
36         State state;
37
38         Rect rect;
39         Rect normal_rect; // normal state rectangle managed by the wm
40
41         Callbacks callbacks;
42
43         std::vector<Window*> children;
44         Window* parent;
45
46         bool dirty;
47         bool managed; // whether the wm manages (+decorates) this win
48         bool focusable;
49
50 public:
51         Window();
52         ~Window();
53
54         const Rect &get_rect() const;
55         Rect get_absolute_rect() const;
56         bool contains_point(int ptr_x, int ptr_y);
57
58         void move(int x, int y);
59         void resize(int x, int y);
60
61         void set_title(const char *s);
62         const char *get_title() const;
63
64         /* mark this window as dirty, and notify the window manager
65          * to repaint it, and anything it used to cover.
66          */
67         void invalidate();
68
69         void draw(Rect *dirty_region);
70         void draw_children(const Rect &dirty_region);
71
72         unsigned char *get_win_start_on_fb();
73         int get_scanline_width();
74
75         void set_managed(bool managed);
76         bool get_managed() const;
77
78         void set_focusable(bool focusable);
79         bool get_focusable() const;
80
81         bool get_dirty() const;
82
83         void set_display_callback(DisplayFuncType func);
84         void set_keyboard_callback(KeyboardFuncType func);
85         void set_mouse_button_callback(MouseButtonFuncType func);
86         void set_mouse_motion_callback(MouseMotionFuncType func);
87
88         const DisplayFuncType get_display_callback() const;
89         const KeyboardFuncType get_keyboard_callback() const;
90         const MouseButtonFuncType get_mouse_button_callback() const;
91         const MouseMotionFuncType get_mouse_motion_callback() const;
92
93         // win hierarchy
94         void add_child(Window *win);
95         void remove_child(Window *win);
96
97         Window **get_children();
98         int get_children_count() const;
99
100         const Window *get_parent() const;
101         Window *get_parent();
102
103         void set_state(State state);
104         State get_state() const;
105
106         // XXX remove if not needed
107         friend class WindowManager;
108 };
109
110 #endif  // WINDOW_H_