X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftoggle.cpp;h=43acaa3125b021161a489f91ab9603a044a7ec95;hb=73afd124ab87e8bace98db55517a56c797a9b8c7;hp=a950b971307aae231b91783624a234155aee8ae3;hpb=91997dd3189b93a67179822ec2fed5f2a7bddb74;p=libs%2Fgltk.git diff --git a/source/toggle.cpp b/source/toggle.cpp index a950b97..43acaa3 100644 --- a/source/toggle.cpp +++ b/source/toggle.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspgltk -Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -35,6 +35,15 @@ void Toggle::set_exclusive(bool e) exclude_siblings(); } +void Toggle::exclude_siblings() +{ + const list &siblings = parent->get_children(); + for(list::const_iterator i=siblings.begin(); i!=siblings.end(); ++i) + if(Toggle *tgl = dynamic_cast(*i)) + if(tgl!=this && tgl->get_exclusive() && tgl->get_value()) + tgl->set_value(false); +} + void Toggle::set_value(bool v) { value = v; @@ -48,6 +57,12 @@ void Toggle::set_value(bool v) state &= ~ACTIVE; } +void Toggle::render_special(const Part &part) const +{ + if(part.get_name()=="text") + text.render(part, geom); +} + void Toggle::button_press(int, int, unsigned btn) { if(btn==1) @@ -68,21 +83,6 @@ void Toggle::button_release(int x, int y, unsigned btn) } } -void Toggle::render_special(const Part &part) const -{ - if(part.get_name()=="text") - text.render(part, geom); -} - -void Toggle::exclude_siblings() -{ - const list &siblings = parent->get_children(); - for(list::const_iterator i=siblings.begin(); i!=siblings.end(); ++i) - if(Toggle *tgl = dynamic_cast(*i)) - if(tgl!=this && tgl->get_exclusive() && tgl->get_value()) - tgl->set_value(false); -} - void Toggle::on_style_change() { text.set_style(style); @@ -99,12 +99,12 @@ Toggle::Loader::Loader(Toggle &t): Toggle &Toggle::Loader::get_object() const { - return static_cast(wdg); + return static_cast(obj); } void Toggle::Loader::finish() { - Toggle &tgl = static_cast(wdg); + Toggle &tgl = get_object(); if(tgl.value) tgl.state |= ACTIVE; else @@ -113,7 +113,7 @@ void Toggle::Loader::finish() void Toggle::Loader::text(const string &t) { - static_cast(wdg).text = t; + get_object().text = t; } } // namespace GLtk