1 #ifndef YMSGBOX_H
2 #define YMSGBOX_H
3 
4 #include "ydialog.h"
5 #include "yactionbutton.h"
6 #include "yinputline.h"
7 
8 class YMsgBox;
9 class YLabel;
10 class YInputLine;
11 class YInputListener;
12 
13 class YMsgBoxListener {
14 public:
15     virtual void handleMsgBox(YMsgBox *msgbox, int operation) = 0;
16 protected:
~YMsgBoxListener()17     virtual ~YMsgBoxListener() {}
18 };
19 
20 class YMsgBox:
21     public YDialog,
22     private YActionListener,
23     private YInputListener
24 {
25 public:
26     YMsgBox(int buttons,
27             const char* title = nullptr,
28             const char* text = nullptr,
29             YMsgBoxListener* listener = nullptr,
30             const char* iconName = nullptr);
31     virtual ~YMsgBox();
32 
33     void setTitle(const char* title);
34     void setText(const char* text);
35     void setPixmap(ref<YPixmap> pixmap);
36 
setMsgBoxListener(YMsgBoxListener * listener)37     void setMsgBoxListener(YMsgBoxListener *listener) { fListener = listener; }
getMsgBoxListener()38     YMsgBoxListener *getMsgBoxListener() const { return fListener; }
input()39     YInputLine* input() const { return fInput; }
40 
41     virtual void actionPerformed(YAction action, unsigned int modifiers);
42     virtual void paint(Graphics &g, const YRect& r);
43     virtual void handleClose();
44     virtual void handleFocus(const XFocusChangeEvent &focus);
45     virtual void inputReturn(YInputLine* input);
46     virtual void inputEscape(YInputLine* input);
47     virtual void inputLostFocus(YInputLine* input);
48 
49     enum {
50         mbClose  = 0x0,
51         mbOK     = 0x1,
52         mbCancel = 0x2,
53         mbBoth   = 0x3,
54         mbInput  = 0x4,
55         mbAll    = 0x7,
56     };
57 
58     void showFocused();
59     void autoSize();
60     void unmanage();
61 
62 private:
63     YLabel* fLabel;
64     YInputLine* fInput;
65     YActionButton* fButtonOK;
66     YActionButton* fButtonCancel;
67     YMsgBoxListener* fListener;
68     ref<YPixmap> fPixmap;
69 };
70 
71 #endif
72 
73 // vim: set sw=4 ts=4 et:
74