]> git.tdb.fi Git - libs/gltk.git/blob - source/dialog.cpp
5a03102f463dd8b551e5606253c2b0426aa683a4
[libs/gltk.git] / source / dialog.cpp
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "button.h"
9 #include "dialog.h"
10
11 namespace Msp {
12 namespace GLtk {
13
14 Dialog::Dialog():
15         stale(false)
16 { }
17
18 void Dialog::add_button(Button &button, int code)
19 {
20         add(button);
21         button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
22 }
23
24 void Dialog::button_release(int x, int y, unsigned button)
25 {
26         Panel::button_release(x, y, button);
27         if(stale)
28                 delete this;
29 }
30
31 void Dialog::key_release(unsigned key, unsigned mod)
32 {
33         Panel::key_release(key, mod);
34         if(stale)
35                 delete this;
36 }
37
38 void Dialog::response(int code)
39 {
40         on_response(code);
41         signal_response.emit(code);
42         stale = true;
43 }
44
45 } // namespace GLtk
46 } // namespace Msp