]> Dogcows Code - chaz/openbox/blob - otk/messagedialog.hh
make DialogButtons take char*'s meaning that the label will always be Utf-8
[chaz/openbox] / otk / messagedialog.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __messagedialog_hh
3 #define __messagedialog_hh
4
5 #include "widget.hh"
6 #include "ustring.hh"
7
8 #include <vector>
9
10 namespace otk {
11
12 class Button;
13 class Label;
14
15 class DialogButton {
16 ustring _label;
17 bool _default;
18 public:
19 DialogButton(char *label) : _label(label), _default(false)
20 {}
21 DialogButton(char *label, bool def) : _label(label), _default(def)
22 {}
23 inline const ustring& label() const { return _label; }
24 inline const bool& isDefault() const { return _default; }
25 };
26
27 class MessageDialog : public Widget {
28 public:
29 MessageDialog(int screen, EventDispatcher *ed, ustring title,
30 ustring caption);
31 MessageDialog(EventDispatcher *ed, ustring title, ustring caption);
32 MessageDialog(Widget *parent, ustring title, ustring caption);
33 virtual ~MessageDialog();
34
35 virtual void addButton(const DialogButton &b) { _buttons.push_back(b); }
36
37 virtual const DialogButton& run();
38
39 virtual void show();
40 virtual void hide();
41 virtual void focus();
42
43 virtual const DialogButton& result() const { return *_result; }
44 virtual void setResult(const DialogButton &result) { _result = &result; }
45
46 virtual void keyPressHandler(const XKeyEvent &e);
47 virtual void clientMessageHandler(const XClientMessageEvent &e);
48
49 private:
50 static DialogButton _default_result;
51
52 void init(const ustring &title, const ustring &caption);
53
54 std::vector<DialogButton> _buttons;
55 std::vector<Button *> _button_widgets;
56 Label *_label;
57 Widget *_button_holder;
58 KeyCode _return;
59 KeyCode _escape;
60 const DialogButton *_result;
61 };
62
63 }
64
65 #endif // __messagedialog_hh
This page took 0.04114 seconds and 4 git commands to generate.