12 rect.width = rect.height = 128;
13 memset(&callbacks, 0, sizeof callbacks);
20 for(size_t i=0; i<children.size(); i++) {
21 wm->remove_window(children[i]);
28 const Rect &Window::get_rect() const
33 bool Window::contains_point(int ptr_x, int ptr_y)
35 return ptr_x >= rect.x && ptr_x < rect.x + rect.width &&
36 ptr_y >= rect.y && ptr_y < rect.y + rect.height;
39 void Window::move(int x, int y)
41 invalidate(); // moved, should redraw, MUST BE CALLED FIRST
46 void Window::resize(int x, int y)
48 invalidate(); // resized, should redraw, MUST BE CALLED FIRST
53 void Window::set_title(const char *s)
57 title = new char[strlen(s) + 1];
61 const char *Window::get_title() const
66 void Window::invalidate()
69 wm->invalidate_region(rect);
72 void Window::draw(const Rect &dirty_region)
77 Rect intersect = rect_intersection(rect, dirty_region);
78 if(intersect.width && intersect.height) {
79 if(callbacks.display) {
80 callbacks.display(this);
88 void Window::draw_children(const Rect &dirty_region)
90 for(size_t i=0; i<children.size(); i++) {
91 children[i]->draw(dirty_region);
95 unsigned char *Window::get_win_start_on_fb()
97 unsigned char *fb = get_framebuffer();
98 return fb + get_color_depth() * (get_screen_size().x * rect.y + rect.x) / 8;
101 int Window::get_scanline_width()
103 return get_screen_size().x;
106 void Window::set_managed(bool managed)
108 this->managed = managed;
111 bool Window::get_managed() const
116 void Window::set_display_callback(DisplayFuncType func)
118 callbacks.display = func;
121 void Window::set_keyboard_callback(KeyboardFuncType func)
123 callbacks.keyboard = func;
126 void Window::set_mouse_button_callback(MouseButtonFuncType func)
128 callbacks.button = func;
131 void Window::set_mouse_motion_callback(MouseMotionFuncType func)
133 callbacks.motion = func;
136 const DisplayFuncType Window::get_display_callback() const
138 return callbacks.display;
141 const KeyboardFuncType Window::get_keyboard_callback() const
143 return callbacks.keyboard;
146 const MouseButtonFuncType Window::get_mouse_button_callback() const
148 return callbacks.button;
151 const MouseMotionFuncType Window::get_mouse_motion_callback() const
153 return callbacks.motion;
156 void Window::add_child(Window *win)
158 children.push_back(win);
160 win->parent->remove_child(win);
165 void Window::remove_child(Window *win)
167 std::vector<Window*>::iterator it;
168 it = std::find(children.begin(), children.end(), win);
169 if(it != children.end()) {
175 const Window *Window::get_parent() const
180 Window *Window::get_parent()