]> Dogcows Code - chaz/openbox/blob - otk/messagedialog.hh
change the default titlebar layout
[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 bool operator==(const DialogButton &o) const { return _label == o._label; }
27 bool operator!=(const DialogButton &o) const { return!(_label == o._label); }
28 };
29
30 class MessageDialog : public Widget {
31 public:
32 MessageDialog(int screen, EventDispatcher *ed, ustring title,
33 ustring caption);
34 MessageDialog(EventDispatcher *ed, ustring title, ustring caption);
35 MessageDialog(Widget *parent, ustring title, ustring caption);
36 virtual ~MessageDialog();
37
38 virtual void addButton(const DialogButton &b) { _buttons.push_back(b); }
39
40 virtual const DialogButton& run();
41
42 virtual void show();
43 virtual void hide();
44 virtual void focus();
45
46 virtual const DialogButton& result() const { return *_result; }
47 virtual void setResult(const DialogButton &result) { _result = &result; }
48
49 virtual void keyPressHandler(const XKeyEvent &e);
50 virtual void clientMessageHandler(const XClientMessageEvent &e);
51
52 private:
53 static DialogButton _default_result;
54
55 void init(const ustring &title, const ustring &caption);
56
57 std::vector<DialogButton> _buttons;
58 std::vector<Button *> _button_widgets;
59 Label *_label;
60 Widget *_button_holder;
61 KeyCode _return;
62 KeyCode _escape;
63 const DialogButton *_result;
64 };
65
66 }
67
68 #endif // __messagedialog_hh
This page took 0.037467 seconds and 4 git commands to generate.