]> git.tdb.fi Git - libs/gltk.git/blob - source/dialog.h
Make keyboard event handlers indicate whether the event was handled
[libs/gltk.git] / source / dialog.h
1 #ifndef MSP_GLTK_DIALOG_H_
2 #define MSP_GLTK_DIALOG_H_
3
4 #include "panel.h"
5
6 namespace Msp {
7 namespace GLtk {
8
9 class Button;
10
11 /**
12 A Dialog is used for temporary interaction with the user.  When any of the
13 Dialog's action buttons are clicked, it will emit a signal and delete itself.
14 */
15 class Dialog: public Panel
16 {
17 public:
18         class Loader: public DataFile::DerivedObjectLoader<Dialog, Panel::Loader>
19         {
20         public:
21                 Loader(Dialog &, WidgetMap &);
22         private:
23                 void action_button(const std::string &, int);
24         };
25
26         sigc::signal<void, int> signal_response;
27
28 private:
29         bool stale;
30
31 public:
32         Dialog();
33
34         /** Adds an action button to the dialog.  Pressing the button will invoke
35         response handlers and delete the dialog. */
36         void add_button(Button &, int);
37
38         virtual void button_release(int, int, unsigned);
39         virtual bool key_release(unsigned, unsigned);
40 protected:
41         void response(int);
42
43         /** Called when an action button is pressed. */
44         virtual void on_response(int) { }
45 };
46
47 } // namespace GLtk
48 } // namespace Msp
49
50 #endif