1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __messagedialog_hh
3 #define __messagedialog_hh
19 DialogButton(char *label) : _label(label), _default(false)
21 DialogButton(char *label, bool def) : _label(label), _default(def)
23 inline const ustring& label() const { return _label; }
24 inline const bool& isDefault() const { return _default; }
26 bool operator==(const DialogButton &o) { return _label == o._label; }
27 bool operator!=(const DialogButton &o) { return !(_label == o._label); }
30 class MessageDialog : public Widget {
32 MessageDialog(int screen, EventDispatcher *ed, ustring title,
34 MessageDialog(EventDispatcher *ed, ustring title, ustring caption);
35 MessageDialog(Widget *parent, ustring title, ustring caption);
36 virtual ~MessageDialog();
38 virtual void addButton(const DialogButton &b) { _buttons.push_back(b); }
40 virtual const DialogButton& run();
46 virtual const DialogButton& result() const { return *_result; }
47 virtual void setResult(const DialogButton &result) { _result = &result; }
49 virtual void keyPressHandler(const XKeyEvent &e);
50 virtual void clientMessageHandler(const XClientMessageEvent &e);
53 static DialogButton _default_result;
55 void init(const ustring &title, const ustring &caption);
57 std::vector<DialogButton> _buttons;
58 std::vector<Button *> _button_widgets;
60 Widget *_button_holder;
63 const DialogButton *_result;
68 #endif // __messagedialog_hh