]> git.tdb.fi Git - libs/gltk.git/blob - source/dialog.cpp
Use a Camera rather than direct matrix manipulation
[libs/gltk.git] / source / dialog.cpp
1 #include "button.h"
2 #include "dialog.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GLtk {
8
9 Dialog::Dialog():
10         stale(false)
11 { }
12
13 void Dialog::add_button(Button &button, int code)
14 {
15         add(button);
16         button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
17 }
18
19 void Dialog::button_release(int x, int y, unsigned button)
20 {
21         Panel::button_release(x, y, button);
22         if(stale)
23                 delete this;
24 }
25
26 void Dialog::key_release(unsigned key, unsigned mod)
27 {
28         Panel::key_release(key, mod);
29         if(stale)
30                 delete this;
31 }
32
33 void Dialog::response(int code)
34 {
35         on_response(code);
36         signal_response.emit(code);
37         stale = true;
38 }
39
40
41 Dialog::Loader::Loader(Dialog &d, WidgetMap &wm):
42         DerivedObjectLoader<Dialog, Panel::Loader>(d, wm)
43 {
44         add("action_button", &Loader::action_button);
45 }
46
47 void Dialog::Loader::action_button(const string &n, int c)
48 {
49         RefPtr<Button> btn = new Button();
50         load_sub(*btn);
51         obj.add_button(*btn.get(), c);
52         last_widget = wdg_map[n] = btn.release();
53 }
54
55 } // namespace GLtk
56 } // namespace Msp