12 rect.width = rect.height = 128;
13 memset(&callbacks, 0, sizeof callbacks);
21 for(size_t i=0; i<children.size(); i++) {
22 wm->remove_window(children[i]);
29 const Rect &Window::get_rect() const
34 bool Window::contains_point(int ptr_x, int ptr_y)
36 return ptr_x >= rect.x && ptr_x < rect.x + rect.width &&
37 ptr_y >= rect.y && ptr_y < rect.y + rect.height;
40 void Window::move(int x, int y)
42 invalidate(); // moved, should redraw, MUST BE CALLED FIRST
47 void Window::resize(int x, int y)
49 invalidate(); // resized, should redraw, MUST BE CALLED FIRST
54 void Window::set_title(const char *s)
58 title = new char[strlen(s) + 1];
62 const char *Window::get_title() const
67 void Window::invalidate()
70 wm->invalidate_region(rect);
73 void Window::draw(const Rect &dirty_region)
78 Rect intersect = rect_intersection(rect, dirty_region);
79 if(intersect.width && intersect.height) {
80 if(callbacks.display) {
81 callbacks.display(this);
89 void Window::draw_children(const Rect &dirty_region)
91 for(size_t i=0; i<children.size(); i++) {
92 children[i]->draw(dirty_region);
96 unsigned char *Window::get_win_start_on_fb()
98 unsigned char *fb = get_framebuffer();
99 return fb + get_color_depth() * (get_screen_size().x * rect.y + rect.x) / 8;
102 int Window::get_scanline_width()
104 return get_screen_size().x;
107 void Window::set_managed(bool managed)
109 this->managed = managed;
112 bool Window::get_managed() const
117 void Window::set_focusable(bool focusable)
119 this->focusable = focusable;
122 bool Window::get_focusable() const
127 void Window::set_display_callback(DisplayFuncType func)
129 callbacks.display = func;
132 void Window::set_keyboard_callback(KeyboardFuncType func)
134 callbacks.keyboard = func;
137 void Window::set_mouse_button_callback(MouseButtonFuncType func)
139 callbacks.button = func;
142 void Window::set_mouse_motion_callback(MouseMotionFuncType func)
144 callbacks.motion = func;
147 const DisplayFuncType Window::get_display_callback() const
149 return callbacks.display;
152 const KeyboardFuncType Window::get_keyboard_callback() const
154 return callbacks.keyboard;
157 const MouseButtonFuncType Window::get_mouse_button_callback() const
159 return callbacks.button;
162 const MouseMotionFuncType Window::get_mouse_motion_callback() const
164 return callbacks.motion;
167 void Window::add_child(Window *win)
169 children.push_back(win);
171 win->parent->remove_child(win);
176 void Window::remove_child(Window *win)
178 std::vector<Window*>::iterator it;
179 it = std::find(children.begin(), children.end(), win);
180 if(it != children.end()) {
186 Window **Window::get_children()
188 if(children.empty()) {
194 int Window::get_children_count() const
196 return (int)children.size();
199 const Window *Window::get_parent() const
204 Window *Window::get_parent()