X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=blobdiff_plain;f=source%2Fentry.cpp;h=65bae7214001e842929aab8618982dfbf11cdc84;hp=6daa8ef1b1083c1361522d64bc3e845df228c2ad;hb=131ac8ff2c06f94d40f4bf98d4a6ec0d113cdffc;hpb=e9455430a6e765b6184532f160f6fde4a67b4a2f diff --git a/source/entry.cpp b/source/entry.cpp index 6daa8ef..65bae72 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "entry.h" #include "part.h" @@ -13,9 +14,9 @@ namespace GLtk { Entry::Entry(const Resources &r, const string &t): Widget(r), text(t), - edit_pos(0), - active(false) + edit_pos(0) { + update_style(); } void Entry::set_text(const string &t) @@ -50,18 +51,21 @@ void Entry::key_press(unsigned key, unsigned, wchar_t ch) void Entry::focus_in() { - active=true; + if(state!=DISABLED) + state=ACTIVE; } void Entry::focus_out() { - active=false; + if(state==ACTIVE) + state=NORMAL; } void Entry::render_part(const Part &part) const { if(part.get_name()=="text") - { + render_text(part, text); + /*{ const GL::Font *const font=style->get_font(); const float font_size=font->get_default_size(); @@ -74,9 +78,11 @@ void Entry::render_part(const Part &part) const const Color &color=style->get_font_color(); glColor3f(color.r, color.g, color.b); - if(active) + if(state==ACTIVE) { + cout<<"foo\n"; font->draw_string(text.substr(0, edit_pos)); + GL::Texture::unbind(); glBegin(GL_LINES); glVertex2f(0, 0); glVertex2f(0, 1); @@ -89,7 +95,21 @@ void Entry::render_part(const Part &part) const GL::pop_matrix(); render_text(part, text); - } + }*/ + /*else if(part.get_name()=="cursor") + { + unsigned gw=part.get_width(); + unsigned gh=(part.get_fill_y() ? geom.h : part.get_height()); + + const float font_size=font->get_default_size(); + unsigned text_w=static_cast(font->get_string_width(text)*font_size); + + GL::push_matrix(); + GL::translate((geom.w-gw)*(value-min)/(max-min), (geom.h-gh)*(part.get_alignment().y+1)/2, 0); + const Graphic *graphic=part.get_graphic(state); + graphic->render(gw, gh); + GL::pop_matrix(); + }*/ else Widget::render_part(part); }