]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/dialog.h
Add Dialog class
[libs/gltk.git] / source / dialog.h
diff --git a/source/dialog.h b/source/dialog.h
new file mode 100644 (file)
index 0000000..0a9b0d8
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2010  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GLTK_DIALOG_H_
+#define MSP_GLTK_DIALOG_H_
+
+#include "panel.h"
+
+namespace Msp {
+namespace GLtk {
+
+class Button;
+
+/**
+A Dialog is used for temporary interaction with the user.  When any of the
+Dialog's action buttons are clicked, it will emit a signal and delete itself.
+*/
+class Dialog: public Panel
+{
+private:
+       bool stale;
+
+public:
+       sigc::signal<void, int> signal_response;
+
+       Dialog(const Resources &);
+
+       /** Adds an action button to the dialog.  Pressing the button will invoke
+       response handlers and delete the dialog. */
+       void add_button(Button &, int);
+
+       virtual void button_release(int, int, unsigned);
+       virtual void key_release(unsigned, unsigned);
+protected:
+       void response(int);
+
+       /** Called when an action button is pressed. */
+       virtual void on_response(int) { }
+};
+
+} // namespace GLtk
+} // namespace Msp
+
+#endif