]> git.tdb.fi Git - r2c2.git/blob - source/designer/input.cpp
Skip routes that are completely covered by the lead route
[r2c2.git] / source / designer / input.cpp
1 #include <GL/gl.h>
2 #include <msp/gl/texture.h>
3 #include <msp/gltk/button.h>
4 #include <msp/gltk/column.h>
5 #include <msp/gltk/row.h>
6 #include <msp/input/keys.h>
7 #include "designer.h"
8 #include "input.h"
9
10 using namespace std;
11 using namespace Msp;
12
13 InputDialog::InputDialog(Designer &d, const string &title, const string &text):
14         designer(d)
15 {
16         set_layout(new GLtk::Layout);
17         GLtk::Column col(*layout);
18
19         GLtk::Label *lbl;
20         add(*(lbl=new GLtk::Label(title)));
21         lbl->set_style("title");
22
23         add(*(entry=new GLtk::Entry(text)));
24         entry->set_edit_size(60, 1);
25
26         GLtk::Button *btn;
27
28         {
29                 GLtk::Row row(*layout);
30                 row.split();
31                 add_button(*(btn=new GLtk::Button("Cncl")), 0);
32                 btn->set_style("red");
33
34                 add_button(*(btn=new GLtk::Button("OK")), 1);
35                 btn->set_style("green");
36         }
37
38         entry->set_focus();
39 }
40
41 void InputDialog::key_press(unsigned key, unsigned mod)
42 {
43         if(key==Msp::Input::KEY_ENTER)
44                 response(1);
45         else if(key==Msp::Input::KEY_ESC)
46                 response(0);
47         else
48                 Dialog::key_press(key, mod);
49 }
50
51 void InputDialog::on_response(int code)
52 {
53         if(code)
54                 signal_accept.emit(entry->get_text());
55 }