1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
| | #include <string>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Button.H>
using namespace std;
class rxFlTextDialog : public Fl_Window
{
protected:
Fl_Window *m_pParent; Fl_Input *m_pInputText;
public:
string m_strText;
public:
rxFlTextDialog(int w_, int h_, const char* title, const char* label, const char* text_label, void *parent)
: Fl_Window(w_, h_, title), m_pInputText(0)
{
m_pParent = (Fl_Window*)parent;
m_strText = "";
int margin = 12;
int xs, ys;
int ws, hs;
{
Fl_Scroll *g = new Fl_Scroll(0, 0, w(), h()-40, 0);
g->box(FL_FLAT_BOX);
xs = margin;
ys = margin;
ws = w()-2.5*margin;
hs = h()-(margin+50);
Fl_Group* sg = new Fl_Group(xs, ys, ws, hs, label);
{
sg->box(FL_DOWN_BOX);
sg->labelsize(12);
sg->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE);
int dx = strlen(text_label)*10;
ys += 25;
m_pInputText = new Fl_Input(xs+dx, ys, ws-(dx+margin*2), 25, text_label);
sg->resizable(NULL);
sg->end();
}
g->end();
Fl_Group::current()->resizable(g);
}
{
ws = 80;
hs = 25;
xs = w()-2*(ws+margin);
ys = h()-(margin+hs);
Fl_Button *button;
button = new Fl_Button(xs, ys, ws, hs, "OK");
button->callback(OnButtonOK_s, this);
button->down_box(FL_UP_BOX);
button = new Fl_Button(xs+(ws+margin), ys, ws, hs, "Cancel");
button->callback(OnButtonCancel_s, this);
button->down_box(FL_UP_BOX);
}
resizable(this);
end();
}
~rxFlTextDialog()
{
if(m_pInputText) delete m_pInputText;
}
public:
static void OnButtonOK_s(Fl_Widget *widget, void* x)
{
((rxFlTextDialog*)x)->OnButtonOK();
}
inline void OnButtonOK(void)
{
m_strText = m_pInputText->value();
hide();
}
static void OnButtonCancel_s(Fl_Widget *widget, void* x)
{
((rxFlTextDialog*)x)->OnButtonCancel();
}
inline void OnButtonCancel(void)
{
hide();
}
};
|