--- /dev/null
+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2010 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "button.h"
+#include "dialog.h"
+
+namespace Msp {
+namespace GLtk {
+
+Dialog::Dialog(const Resources &r):
+ Widget(r),
+ Panel(r),
+ stale(false)
+{ }
+
+void Dialog::add_button(Button &button, int code)
+{
+ add(button);
+ button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code));
+}
+
+void Dialog::button_release(int x, int y, unsigned button)
+{
+ Panel::button_release(x, y, button);
+ if(stale)
+ delete this;
+}
+
+void Dialog::key_release(unsigned key, unsigned mod)
+{
+ Panel::key_release(key, mod);
+ if(stale)
+ delete this;
+}
+
+void Dialog::response(int code)
+{
+ on_response(code);
+ signal_response.emit(code);
+ stale=true;
+}
+
+} // namespace GLtk
+} // namespace Msp
--- /dev/null
+/* $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