3 This file is part of R²C²
4 Copyright © 2006-2008, 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
9 #include <msp/gl/texture.h>
10 #include <msp/gltk/button.h>
11 #include <msp/input/keys.h>
18 InputDialog::InputDialog(Designer &d, const string &title, const string &text):
24 add(*(lbl=new GLtk::Label(title)));
25 lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20));
27 add(*(entry=new GLtk::Entry(text)));
28 entry->set_geometry(GLtk::Geometry(10, geom.h-60, geom.w-20, 20));
32 add_button(*(btn=new GLtk::Button("Cncl")), 0);
33 btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24));
34 btn->set_style("red");
36 add_button(*(btn=new GLtk::Button("OK")), 1);
37 btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24));
38 btn->set_style("green");
40 designer.get_root().add(*this);
41 const GLtk::Geometry &rgeom=designer.get_root().get_geometry();
42 set_position((rgeom.w-geom.w)/2, (rgeom.h-geom.h)/2);
46 void InputDialog::key_press(unsigned key, unsigned mod, wchar_t ch)
48 if(key==Msp::Input::KEY_ENTER)
50 else if(key==Msp::Input::KEY_ESC)
53 Dialog::key_press(key, mod, ch);
56 void InputDialog::on_response(int code)
59 signal_accept.emit(entry->get_text());