diff options
author | Stijn Buys <ingar@osirion.org> | 2008-10-05 19:03:25 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-10-05 19:03:25 +0000 |
commit | da9beb729c58ca2d91f67ab85a6728b628c27cf2 (patch) | |
tree | 96fd5df00a2431f40f515aa9fdf722377a0b6079 /src/ui/window.cc | |
parent | 381c729e777b50771626703e60b422aafc791513 (diff) |
user interface library
Diffstat (limited to 'src/ui/window.cc')
-rw-r--r-- | src/ui/window.cc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/ui/window.cc b/src/ui/window.cc new file mode 100644 index 0000000..8763b53 --- /dev/null +++ b/src/ui/window.cc @@ -0,0 +1,68 @@ +/* + ui/window.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/window.h" +#include "render/primitives.h" + +namespace ui { + +Window::Window(Window *parent) : Widget(static_cast<Widget *>(parent)) +{ + set_label("window"); + set_border(true); + + if (parent) { + parent->add_window(this); + } +} + +Window::~Window() +{ + if (parent()) { + static_cast<Window *>(parent())->remove_window(this); + } + window_children.clear(); +} + +void Window::draw_border() +{ + if (!border()) + return; + + if (palette()) + render::gl::color(palette()->foreground()); + math::Vector2f v(to_global(location())); + render::primitives::border(v, size()); +} + +Window::Windows::iterator Window::find_window(Window *window) +{ + Windows::iterator it; + for (it = window_children.begin(); it != window_children.end(); it++) { + if ((*it) == window) + return it; + } + + return it; +} + +void Window::add_window(Window *window) +{ + Windows::iterator it = find_window(window); + if (it == window_children.end()) { + window_children.push_back(window); + } +} + +void Window::remove_window(Window *window) +{ + + Windows::iterator it = find_window(window); + if (it != window_children.end()) { + window_children.erase(it); + } +} +} |