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