#include <SDL/SDL_keysym.h>
#include <msp/gl/matrix.h>
+#include <msp/gl/texture.h>
#include <msp/gl/transform.h>
#include "entry.h"
#include "part.h"
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)
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();
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);
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<unsigned>(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);
}