]> git.tdb.fi Git - libs/gltk.git/blob - source/dialog.cpp
5e5e390e7cadadf91d3e5af4e978d4e3f333dc33
[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 void Dialog::add_button(Button &button, int code)
10 {
11         add(button);
12         button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
13 }
14
15 void Dialog::set_modal(bool m)
16 {
17         if(m)
18         {
19                 set_focus();
20                 if(state&FOCUS)
21                         signal_grab_pointer.emit();
22         }
23         else
24                 signal_ungrab_pointer.emit();
25 }
26
27 void Dialog::response(int code)
28 {
29         on_response(code);
30         signal_response.emit(code);
31         set_visible(false);
32 }
33
34
35 Dialog::Loader::Loader(Dialog &d, WidgetMap &wm):
36         DerivedObjectLoader<Dialog, Panel::Loader>(d, wm)
37 {
38         add("action_button", &Loader::action_button);
39 }
40
41 void Dialog::Loader::action_button(const string &n, int c)
42 {
43         unique_ptr<Button> btn = make_unique<Button>();
44         load_sub(*btn);
45         obj.add_button(*btn.get(), c);
46         last_widget = wdg_map[n] = btn.release();
47 }
48
49 } // namespace GLtk
50 } // namespace Msp