diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-12-25 16:33:45 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-05 17:17:50 +0100 |
commit | 2d1c84a16c36869ca292b74348f2ef852f2f8a62 (patch) | |
tree | 6da35292564452e77dabb315507008da7652b0c0 /src/menu/container.cpp | |
parent | 0f42e8231f3af3d518a5c438ec41a3d849d37a29 (diff) | |
download | usdx-2d1c84a16c36869ca292b74348f2ef852f2f8a62.tar.gz usdx-2d1c84a16c36869ca292b74348f2ef852f2f8a62.tar.xz usdx-2d1c84a16c36869ca292b74348f2ef852f2f8a62.zip |
menu: Container could contains and draw DrawableControls
DrawableControls register/unregister itself during
construction/destruction at the Container (supplied as owner) and get
automatically drawn
Diffstat (limited to 'src/menu/container.cpp')
-rw-r--r-- | src/menu/container.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/menu/container.cpp b/src/menu/container.cpp index 3bed894e..d39ac736 100644 --- a/src/menu/container.cpp +++ b/src/menu/container.cpp @@ -28,32 +28,31 @@ namespace usdx { - Container::Container(Control* parent) - : DrawableControl(parent) + Container::Container(Container* owner) + : DrawableControl(owner) { } Container::~Container() { + controls.clear(); + } + + void Container::draw(void) + { for (std::list<DrawableControl*>::iterator it = controls.begin(); it != controls.end(); it++) { - delete *it; + (*it)->repaint(); } - - controls.clear(); } - void Container::repaint(void) + void Container::add(DrawableControl *child) { - if (get_visible()) { - draw(); - - for (std::list<DrawableControl*>::const_iterator it = - controls.begin(); - it != controls.end(); it++) { + controls.push_back(child); + } - (*it)->repaint(); - } - } + void Container::remove(DrawableControl *child) + { + controls.remove(child); } }; |