Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-12 17:27:00 +0000
committerStijn Buys <ingar@osirion.org>2008-10-12 17:27:00 +0000
commit574bf11742c40203a4433c0b69264014b10b5a96 (patch)
tree5fdaa40d22c38e5d8cce47d43a1a892008322598 /src/ui/container.cc
parentb417df720584c101f3799874a0c836a543a8d0a8 (diff)
container widget
Diffstat (limited to 'src/ui/container.cc')
-rw-r--r--src/ui/container.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/ui/container.cc b/src/ui/container.cc
new file mode 100644
index 0000000..d544244
--- /dev/null
+++ b/src/ui/container.cc
@@ -0,0 +1,59 @@
+/*
+ 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"
+
+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() + (children().size()+1) * container_margin;
+
+ set_size(w, h);
+
+ const float x = container_childsize.width() * 0.25f;
+ float y = container_margin;
+
+ // 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;
+}
+
+}