]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/text.cpp
Make the Text class interface more obvious by not using a reference to pointer
[libs/gltk.git] / source / text.cpp
index d48c33f0a3ba1f7ca8350ff2a908c3d76204082c..31db228071943fc55f0f3942b16a32a50dcb3c90 100644 (file)
@@ -8,16 +8,25 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-Text::Text(const Style *const &s):
-       style(s)
+Text::Text():
+       style(0)
 { }
 
-Text::Text(const Style *const &s, const string &t):
-       style(s)
+Text::Text(const Style &s, const string &t):
+       style(&s)
 {
        set(t);
 }
 
+void Text::set_style(const Style *s)
+{
+       style = s;
+
+       float font_size=style->get_font()->get_default_size();
+       for(vector<Line>::iterator i=lines.begin(); i!=lines.end(); ++i)
+               i->width=static_cast<unsigned>(style->get_font()->get_string_width(text.substr(i->start, i->length))*font_size);
+}
+
 unsigned Text::get_width() const
 {
        unsigned width=0;
@@ -77,13 +86,6 @@ void Text::insert(unsigned pos, const string &s)
        }
 }
 
-void Text::update_style()
-{
-       float font_size=style->get_font()->get_default_size();
-       for(vector<Line>::iterator i=lines.begin(); i!=lines.end(); ++i)
-               i->width=static_cast<unsigned>(style->get_font()->get_string_width(text.substr(i->start, i->length))*font_size);
-}
-
 void Text::render(const Part &part, const Geometry &geom) const
 {
        if(lines.empty())