diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-02-16 11:59:12 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-02-16 11:59:12 +0000 |
| commit | 7a41f7730dfa7e5733720f98f89c5a5906f1e786 (patch) | |
| tree | 17c99ac6c1d5cc88109d1013fc638303a3f5450c /otk/messagedialog.hh | |
| parent | f325abe4e454f3c413ad91e6145b8a8c458c8758 (diff) | |
add otk::MessageDialog
Diffstat (limited to 'otk/messagedialog.hh')
| -rw-r--r-- | otk/messagedialog.hh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/otk/messagedialog.hh b/otk/messagedialog.hh new file mode 100644 index 00000000..d68c1726 --- /dev/null +++ b/otk/messagedialog.hh @@ -0,0 +1,66 @@ +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- +#ifndef __messagedialog_hh +#define __messagedialog_hh + +#include "widget.hh" +#include "ustring.hh" + +#include <vector> + +namespace otk { + +class Button; +class Label; + +class DialogButton { + ustring _label; + bool _default; +public: + DialogButton(char *label) : _label(label), _default(false) + {} + DialogButton(ustring label) : _label(label), _default(false) + {} + DialogButton(ustring label, bool def) : _label(label), _default(def) + {} + inline const ustring& label() const { return _label; } + inline const bool& isDefault() const { return _default; } +}; + +class MessageDialog : public Widget { +public: + MessageDialog(int screen, EventDispatcher *ed, ustring title, + ustring caption); + MessageDialog(EventDispatcher *ed, ustring title, ustring caption); + MessageDialog(Widget *parent, ustring title, ustring caption); + virtual ~MessageDialog(); + + virtual void addButton(const DialogButton &b) { _buttons.push_back(b); } + + virtual const DialogButton& run(); + + virtual void show(); + virtual void hide(); + + virtual const DialogButton& result() const { return *_result; } + virtual void setResult(const DialogButton &result) { _result = &result; } + + virtual void keyPressHandler(const XKeyEvent &e); + virtual void clientMessageHandler(const XClientMessageEvent &e); + +private: + static DialogButton _default_result; + + void init(const ustring &title, const ustring &caption); + + std::vector<DialogButton> _buttons; + std::vector<Button *> _button_widgets; + Label *_label; + Widget *_button_holder; + KeyCode _return; + KeyCode _escape; + const DialogButton *_result; +}; + +} + +#endif // __messagedialog_hh |
