X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fentry.cpp;h=f5037215592e1a45143ab8b305cf563007c7dbe0;hb=75a16eae9eb2714f8112d46fa5b8f7908b6d2487;hp=523fea5cc945f8a6bf6b321990c74ff449ee63d1;hpb=aba0416fb73e17d068b30ff163c2fedcb0254da2;p=libs%2Fgltk.git diff --git a/source/entry.cpp b/source/entry.cpp index 523fea5..f503721 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -16,17 +16,16 @@ Distributed under the LGPL using namespace std; -#include - namespace Msp { namespace GLtk { Entry::Entry(const Resources &r, const string &t): Widget(r), - text(t), - edit_pos(text.size()) + text(style), + edit_pos(0) { update_style(); + set_text(t); } void Entry::set_text(const string &t) @@ -64,7 +63,7 @@ void Entry::key_press(unsigned key, unsigned, wchar_t ch) void Entry::render_special(const Part &part) const { if(part.get_name()=="text") - render_text(part, text); + text.render(part, geom); else if(part.get_name()=="cursor") { if(!part.get_graphic(state)) @@ -74,8 +73,8 @@ void Entry::render_special(const Part &part) const const float font_size=font->get_default_size(); Geometry rgeom=part.get_geometry(); - rgeom.x=static_cast(font->get_string_width(text.substr(0, edit_pos))*font_size); - rgeom.w=static_cast(font->get_string_width(text)*font_size); + rgeom.x=static_cast(font->get_string_width(text.get().substr(0, edit_pos))*font_size); + rgeom.w=static_cast(font->get_string_width(text.get())*font_size); part.get_alignment().apply(rgeom, geom, part.get_margin()); GL::push_matrix();