/* ui/container.cc This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #include "ui/container.h" #include "ui/paint.h" namespace ui { // TODO Container::direction Container::Container(Widget *parent) : Window(parent) { set_label("container"); set_border(false); set_border(true); set_background(true); container_childsize.assign(256, 48); container_margin = 24; } Container::~Container() { } void Container::resize() { float w = container_childsize.width() * 1.5f; float h = children().size() * (container_childsize.height() + margin()) + container_childsize.height(); set_size(w, h); const float x = container_childsize.width() * 0.25f; float y = container_childsize.height() * 0.5f; // reposition all children within the container for (Children::iterator it = children().begin(); it != children().end(); it++) { Widget *w = (*it); w->set_size(container_childsize); w->set_location(x, y); y += container_childsize.height() + container_margin; } } void Container::set_childsize(const float w, const float h) { container_childsize.assign(w, h); } void Container::set_margin(const float margin) { container_margin = margin; } void Container::draw_border() { if (!border()) return; if(focus()) { paint::color(palette()->foreground()); } else { paint::color(palette()->border()); } paint::border(global_location(), size()); } }