X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftoggle.cpp;h=789ae37ecfec59fdd5987b9739fa0818dc98f8d9;hb=43a75e4e9be56c58be5e224f19016bb14b56a7ef;hp=41e38cba93d393b8af4d650997ae9c8987b2b483;hpb=b92c878a286036af106e969a29b2689876aa5f65;p=libs%2Fgltk.git diff --git a/source/toggle.cpp b/source/toggle.cpp index 41e38cb..789ae37 100644 --- a/source/toggle.cpp +++ b/source/toggle.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "panel.h" #include "part.h" #include "style.h" @@ -37,12 +30,15 @@ void Toggle::autosize() geom.w = max(geom.w, text.get_width()+margin.left+margin.right); geom.h = max(geom.h, text.get_height()+margin.top+margin.bottom); } + + rebuild(); } void Toggle::set_text(const string &t) { text = t; signal_autosize_changed.emit(); + rebuild(); } void Toggle::set_exclusive(bool e) @@ -66,18 +62,18 @@ void Toggle::set_value(bool v) value = v; if(value) { - state |= ACTIVE; + set_state(ACTIVE); if(exclusive && parent) exclude_siblings(); } else - state &= ~ACTIVE; + clear_state(ACTIVE); } -void Toggle::render_special(const Part &part) const +void Toggle::rebuild_special(const Part &part, CachedPart &cache) { if(part.get_name()=="text") - text.render(part, geom); + text.build(part, geom, cache); } void Toggle::button_press(int, int, unsigned btn) @@ -122,10 +118,7 @@ Toggle &Toggle::Loader::get_object() const void Toggle::Loader::finish() { Toggle &tgl = get_object(); - if(tgl.value) - tgl.state |= ACTIVE; - else - tgl.state &= ~ACTIVE; + tgl.set_state(ACTIVE, (tgl.value ? ACTIVE : NORMAL)); } void Toggle::Loader::text(const string &t)