X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flabel.cpp;h=263b2a4229d23c7c80747e37f3a66f880f2f5140;hb=4b52d16bc895f9d969383d7a7d6a3558c1972cc5;hp=a91f821406292d4672053782b79ce1b3f9b70bae;hpb=6081ed9020ad22214a8e5b3829092f97b12d7c71;p=libs%2Fgltk.git diff --git a/source/label.cpp b/source/label.cpp index a91f821..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,42 +7,28 @@ using namespace std; namespace Msp { namespace GLtk { -Label::Label(const Resources &r, const string &t): - Widget(r), - text() +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() @@ -59,14 +38,14 @@ void Label::on_style_change() Label::Loader::Loader(Label &l): - Widget::Loader(l) + DataFile::DerivedObjectLoader(l) { add("text", &Loader::text); } void Label::Loader::text(const string &t) { - static_cast