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
; }
27 class MessageDialog
: public Widget
{
29 MessageDialog(int screen
, EventDispatcher
*ed
, ustring title
,
31 MessageDialog(EventDispatcher
*ed
, ustring title
, ustring caption
);
32 MessageDialog(Widget
*parent
, ustring title
, ustring caption
);
33 virtual ~MessageDialog();
35 virtual void addButton(const DialogButton
&b
) { _buttons
.push_back(b
); }
37 virtual const DialogButton
& run();
43 virtual const DialogButton
& result() const { return *_result
; }
44 virtual void setResult(const DialogButton
&result
) { _result
= &result
; }
46 virtual void keyPressHandler(const XKeyEvent
&e
);
47 virtual void clientMessageHandler(const XClientMessageEvent
&e
);
50 static DialogButton _default_result
;
52 void init(const ustring
&title
, const ustring
&caption
);
54 std::vector
<DialogButton
> _buttons
;
55 std::vector
<Button
*> _button_widgets
;
57 Widget
*_button_holder
;
60 const DialogButton
*_result
;
65 #endif // __messagedialog_hh