13 rect.width = rect.height = 128;
14 memset(&callbacks, 0, sizeof callbacks);
22 for(size_t i=0; i<children.size(); i++) {
23 wm->remove_window(children[i]);
30 const Rect &Window::get_rect() const
35 const Rect &Window::get_absolute_rect() const
37 return rect; // TODO implement absolute rectangle thingy
40 bool Window::contains_point(int ptr_x, int ptr_y)
42 return ptr_x >= rect.x && ptr_x < rect.x + rect.width &&
43 ptr_y >= rect.y && ptr_y < rect.y + rect.height;
46 void Window::move(int x, int y)
48 invalidate(); // moved, should redraw, MUST BE CALLED FIRST
53 void Window::resize(int x, int y)
55 invalidate(); // resized, should redraw, MUST BE CALLED FIRST
60 void Window::set_title(const char *s)
64 title = new char[strlen(s) + 1];
68 const char *Window::get_title() const
73 void Window::invalidate()
76 wm->invalidate_region(rect);
79 void Window::draw(const Rect &dirty_region)
84 Rect intersect = rect_intersection(rect, dirty_region);
85 if(intersect.width && intersect.height) {
86 if(callbacks.display) {
87 callbacks.display(this);
95 void Window::draw_children(const Rect &dirty_region)
97 for(size_t i=0; i<children.size(); i++) {
98 children[i]->draw(dirty_region);
102 unsigned char *Window::get_win_start_on_fb()
104 unsigned char *fb = get_framebuffer();
105 return fb + get_color_depth() * (get_screen_size().x * rect.y + rect.x) / 8;
108 int Window::get_scanline_width()
110 return get_screen_size().x;
113 void Window::set_managed(bool managed)
115 this->managed = managed;
118 bool Window::get_managed() const
123 void Window::set_focusable(bool focusable)
125 this->focusable = focusable;
128 bool Window::get_focusable() const
133 void Window::set_display_callback(DisplayFuncType func)
135 callbacks.display = func;
138 void Window::set_keyboard_callback(KeyboardFuncType func)
140 callbacks.keyboard = func;
143 void Window::set_mouse_button_callback(MouseButtonFuncType func)
145 callbacks.button = func;
148 void Window::set_mouse_motion_callback(MouseMotionFuncType func)
150 callbacks.motion = func;
153 const DisplayFuncType Window::get_display_callback() const
155 return callbacks.display;
158 const KeyboardFuncType Window::get_keyboard_callback() const
160 return callbacks.keyboard;
163 const MouseButtonFuncType Window::get_mouse_button_callback() const
165 return callbacks.button;
168 const MouseMotionFuncType Window::get_mouse_motion_callback() const
170 return callbacks.motion;
173 void Window::add_child(Window *win)
175 children.push_back(win);
177 win->parent->remove_child(win);
182 void Window::remove_child(Window *win)
184 std::vector<Window*>::iterator it;
185 it = std::find(children.begin(), children.end(), win);
186 if(it != children.end()) {
192 Window **Window::get_children()
194 if(children.empty()) {
200 int Window::get_children_count() const
202 return (int)children.size();
205 const Window *Window::get_parent() const
210 Window *Window::get_parent()