#include <msp/gl/matrix.h>
#include <msp/gl/texture.h>
#include <msp/gl/transform.h>
+#include <msp/input/keys.h>
#include "entry.h"
#include "graphic.h"
#include "part.h"
using namespace std;
+#include <iostream>
+
namespace Msp {
namespace GLtk {
Entry::Entry(const Resources &r, const string &t):
Widget(r),
text(t),
- edit_pos(0)
+ edit_pos(text.size())
{
update_style();
}
void Entry::set_text(const string &t)
{
text=t;
- if(edit_pos>text.size())
- edit_pos=text.size();
+ edit_pos=text.size();
}
void Entry::key_press(unsigned key, unsigned, wchar_t ch)
{
- if(key==100)
+ if(key==Input::KEY_LEFT)
{
if(edit_pos>0)
--edit_pos;
}
- else if(key==102)
+ else if(key==Input::KEY_RIGHT)
{
if(edit_pos<text.size())
++edit_pos;
}
- else if(key==22)
+ else if(key==Input::KEY_BACKSPACE)
{
if(edit_pos>0)
text.erase(--edit_pos, 1);
}
else
{
- text+=ch;
+ text.insert(edit_pos, Codecs::encode<Codecs::Utf8>(Codecs::ustring(1, ch)));
++edit_pos;
}
}
void Graphic::render(unsigned wd, unsigned ht) const
{
- GL::VertexArray varr((GL::TEXCOORD2, GL::VERTEX2));
- RefPtr<GL::VertexArrayBuilder> vab=varr.modify();
-
vector<float> x, y;
create_coords(0.0f-shadow.left, wd+shadow.right, border.left, border.right, slice.w-border.left-border.right, x);
create_coords(0.0f-shadow.bottom, ht+shadow.top, border.bottom, border.top, slice.h-border.bottom-border.top, y);
unsigned ymax=y.size()-(border.top ? 2 : 3);
texture->bind();
- GL::Immediate imm((GL::TEXCOORD2,GL::VERTEX2));
+ GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+ imm.color(1.0f, 1.0f, 1.0f);
imm.begin(GL::QUADS);
for(unsigned i=ymin; i<=ymax; ++i)
{
ChildSeq::iterator i=find(children.begin(), children.end(), &wdg);
if(i!=children.end())
{
+ if(&wdg==pointer_focus)
+ set_pointer_focus(0, 0);
+ if(&wdg==input_focus)
+ set_input_focus(0);
+
set_parent(wdg, 0);
children.erase(i);
}
Distributed under the LGPL
*/
+#include <msp/input/keys.h>
#include "root.h"
namespace Msp {
void Root::key_press_event(unsigned key, unsigned mod, wchar_t ch)
{
if(visible)
- key_press(key, mod, ch);
+ key_press(Input::key_from_sys(key), mod, ch);
}
void Root::key_release_event(unsigned key, unsigned mod)
{
if(visible)
- key_release(key, mod);
+ key_release(Input::key_from_sys(key), mod);
}
void Root::translate_coords(int &x, int &y)
Distributed under the LGPL
*/
+#include <msp/gl/immediate.h>
#include <msp/gl/matrix.h>
#include <msp/gl/transform.h>
#include <msp/strings/formatter.h>
GL::scale_uniform(font_size);
const GL::Color &color=style->get_font_color();
- glColor3f(color.r, color.g, color.b);
- font->draw_string(text);
- glColor3f(1, 1, 1);
+ GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+ imm.color(color.r, color.g, color.b);
+ font->draw_string(text, imm);
GL::pop_matrix();
}