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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
MessageBox::MessageBox(QWidget* parent,
const char* name,
const char* text,
msg_type type,
msg_icon icon)
: QDialog(parent, name, TRUE)
{
setCaption(name);
QFrame *topf = new QFrame(this);
topf->setFrameStyle(QFrame::Box | QFrame::Raised);
topf->setLineWidth(3);
QVBoxLayout *bl = new QVBoxLayout(this);
bl->addWidget(topf);
QLabel *lbl_text = new QLabel(topf);
lbl_text->setText(text);
lbl_text->setFont(QFont("Arial", 18));
QFrame *f = new QFrame(topf);
QVBoxLayout *blayout = new QVBoxLayout(topf, 20, 20);
blayout->addWidget(lbl_text);
blayout->addWidget(f);
pix_icon = new QPixmap();
switch(icon) {
case ICON_NONE:
{
break;
}
case ICON_DEFAULT:
{
switch(type) {
case TYPE_OK:
pix_icon->load( PIXMAP_INFO );
break;
case TYPE_OK_CANCEL:
pix_icon->load( PIXMAP_WARNING );
break;
case TYPE_YES_NO:
pix_icon->load( PIXMAP_QUESTION );
break;
case TYPE_YES_NO_CANCEL:
pix_icon->load( PIXMAP_QUESTION );
break;
}
break;
}
case ICON_INFO:
{
pix_icon->load( PIXMAP_INFO );
break;
}
case ICON_WARNING:
{
pix_icon->load( PIXMAP_WARNING );
break;
}
case ICON_ERROR:
{
pix_icon->load( PIXMAP_ERROR );
break;
}
case ICON_QUESTION:
{
pix_icon->load( PIXMAP_QUESTION );
break;
}
}
switch(type) {
case TYPE_OK:
{
QPushButton *bok = createButton(f, TXT_OK );
QGridLayout *glayout = new QGridLayout(f, 1, 1, 20, 20);
glayout->addWidget(bok, 0, 0);
connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
break;
}
case TYPE_OK_CANCEL:
{
QPushButton *bok = createButton(f, TXT_OK );
QPushButton *bcancel = createButton(f, TXT_CANCEL );
QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(bok, 0, 2);
connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));
break;
}
case TYPE_YES_NO:
{
QPushButton *byes = createButton(f, TXT_YES );
QPushButton *bno = createButton(f, TXT_NO );
QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(byes, 0, 1);
connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));
break;
}
case TYPE_YES_NO_CANCEL:
{
QPushButton *byes = createButton(f, TXT_YES );
QPushButton *bcancel = createButton(f, TXT_CANCEL );
QPushButton *bno = createButton(f, TXT_NO );
QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20);
glayout->addWidget(bno, 0, 0);
glayout->addWidget(bcancel, 0, 1);
glayout->addWidget(byes, 0, 2);
connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked()));
connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));
connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));
break;
}
}
}
MessageBox::~MessageBox()
{
delete pix_icon;
}
QPushButton *MessageBox::createButton(QWidget *parent, const char *text)
{
QPushButton *q = new QPushButton(parent);
q->setText(text);
q->setFont(QFont("Arial", 18));
q->setFixedSize(200, 75);
return q;
}
void MessageBox::bok_clicked()
{
done(MSG_OK);
}
void MessageBox::bcancel_clicked()
{
done(MSG_CANCEL);
}
void MessageBox::byes_clicked()
{
done(MSG_YES);
}
void MessageBox::bno_clicked()
{
done(MSG_NO);
}
|