1 #include <SDL/SDL_keysym.h>
2 #include <msp/gl/matrix.h>
3 #include <msp/gl/transform.h>
13 Entry::Entry(const Resources &r, const string &t):
21 void Entry::set_text(const string &t)
24 if(edit_pos>text.size())
28 void Entry::key_press(unsigned key, unsigned, wchar_t ch)
35 else if(key==SDLK_RIGHT)
37 if(edit_pos<text.size())
40 else if(key==SDLK_BACKSPACE)
43 text.erase(--edit_pos, 1);
51 void Entry::focus_in()
56 void Entry::focus_out()
61 void Entry::render_part(const Part &part) const
63 if(part.get_name()=="text")
65 const GL::Font *const font=style->get_font();
67 const float font_size=font->get_default_size();
68 unsigned text_w=static_cast<unsigned>(font->get_string_width(text)*font_size);
72 part.get_alignment().apply(geom, text_w, static_cast<unsigned>(font->get_ascent()*font_size));
73 GL::scale_uniform(font_size);
75 const Color &color=style->get_font_color();
76 glColor3f(color.r, color.g, color.b);
79 font->draw_string(text.substr(0, edit_pos));
84 font->draw_string(text.substr(edit_pos));
87 font->draw_string(text);
91 render_text(part, text);
94 Widget::render_part(part);