openbox/otk/messagedialog.hh

67 lines
1.7 KiB
C++
Raw Normal View History

2003-02-16 11:59:12 +00:00
// -*- 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:
2003-02-16 19:48:54 +00:00
DialogButton(ustring label) : _label(label), _default(false)
2003-02-16 11:59:12 +00:00
{}
2003-02-16 19:48:54 +00:00
DialogButton(ustring label, bool def) : _label(label), _default(def)
2003-02-16 11:59:12 +00:00
{}
inline const ustring& label() const { return _label; }
inline const bool& isDefault() const { return _default; }
2003-02-16 16:36:07 +00:00
2003-02-16 16:37:02 +00:00
bool operator==(const DialogButton &o) const { return _label == o._label; }
bool operator!=(const DialogButton &o) const { return!(_label == o._label); }
2003-02-16 11:59:12 +00:00
};
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();
2003-02-16 19:48:54 +00:00
virtual void addButton(const DialogButton &b);
2003-02-16 11:59:12 +00:00
virtual const DialogButton& run();
virtual void show();
virtual void hide();
2003-02-16 12:23:35 +00:00
virtual void focus();
2003-02-16 11:59:12 +00:00
2003-02-16 19:48:54 +00:00
virtual const DialogButton& result() const { return _result; }
virtual void setResult(const DialogButton &result) { _result = result; }
2003-02-16 11:59:12 +00:00
virtual void keyPressHandler(const XKeyEvent &e);
virtual void clientMessageHandler(const XClientMessageEvent &e);
private:
void init(const ustring &title, const ustring &caption);
2003-02-16 19:48:54 +00:00
protected:
2003-02-16 11:59:12 +00:00
std::vector<Button *> _button_widgets;
Label *_label;
Widget *_button_holder;
KeyCode _return;
KeyCode _escape;
2003-02-16 19:48:54 +00:00
DialogButton _result;
2003-02-16 11:59:12 +00:00
};
}
#endif // __messagedialog_hh