]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/entry.cpp
Change mspparser -> mspdatafile
[libs/gltk.git] / source / entry.cpp
index 6daa8ef1b1083c1361522d64bc3e845df228c2ad..65bae7214001e842929aab8618982dfbf11cdc84 100644 (file)
@@ -1,5 +1,6 @@
 #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"
@@ -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<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);
 }