3 This file is part of the MSP Märklin suite
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):
19 GLtk::Widget(d.get_ui_resources()),
20 GLtk::Dialog(d.get_ui_resources()),
26 add(*(lbl=new GLtk::Label(res, title)));
27 lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20));
29 add(*(entry=new GLtk::Entry(res, text)));
30 entry->set_geometry(GLtk::Geometry(10, geom.h-60, geom.w-20, 20));
34 add_button(*(btn=new GLtk::Button(res, "Cncl")), 0);
35 btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24));
36 btn->set_style("red");
38 add_button(*(btn=new GLtk::Button(res, "OK")), 1);
39 btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24));
40 btn->set_style("green");
42 designer.get_root().add(*this);
43 const GLtk::Geometry &rgeom=designer.get_root().get_geometry();
44 set_position((rgeom.w-geom.w)/2, (rgeom.h-geom.h)/2);
48 void InputDialog::key_press(unsigned key, unsigned mod, wchar_t ch)
50 if(key==Msp::Input::KEY_ENTER)
52 else if(key==Msp::Input::KEY_ESC)
55 Dialog::key_press(key, mod, ch);
58 void InputDialog::on_response(int code)
61 signal_accept.emit(entry->get_text());