X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flabel.cpp;h=263b2a4229d23c7c80747e37f3a66f880f2f5140;hb=4b52d16bc895f9d969383d7a7d6a3558c1972cc5;hp=18bef1a066bb529274644a78cddfd92ec64a1c10;hpb=a87d05583cb7dffaf0e0f5eb9f9b2fc0bcf656e1;p=libs%2Fgltk.git diff --git a/source/label.cpp b/source/label.cpp index 18bef1a..263b2a4 100644 --- a/source/label.cpp +++ b/source/label.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "label.h" #include "part.h" #include "style.h" @@ -14,59 +7,45 @@ using namespace std; namespace Msp { namespace GLtk { -Label::Label(const Resources &r, const string &t): - Widget(r), - text(style) +Label::Label(const string &t) { - focusable=false; - update_style(); set_text(t); } -void Label::autosize() +void Label::set_text(const string &t) { - const list &parts=style->get_parts(); - const Part *text_part=0; - for(list::const_iterator i=parts.begin(); (!text_part && i!=parts.end()); ++i) - if(i->get_name()=="text") - text_part=&*i; - - geom.h=text.get_height(); - geom.w=text.get_width(); - if(text_part) - { - const Sides &margin=text_part->get_margin(); - geom.w+=margin.left+margin.right; - geom.h+=margin.top+margin.bottom; - } + text = t; + signal_autosize_changed.emit(); + rebuild(); } -void Label::set_text(const string &t) +void Label::autosize_special(const Part &part, Geometry &ageom) const { - text=t; + if(part.get_name()=="text") + text.autosize(part, ageom); } -void Label::render_special(const Part &part) const +void Label::rebuild_special(const Part &part) { if(part.get_name()=="text") - text.render(part, geom); + text.build(part, state, geom, part_cache); } void Label::on_style_change() { - text.update_style(); + text.set_style(style); } Label::Loader::Loader(Label &l): - Widget::Loader(l) + DataFile::DerivedObjectLoader(l) { add("text", &Loader::text); } void Label::Loader::text(const string &t) { - static_cast