1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 /********************************************************************
20 ** Class: SUIT_MessageBox
21 ** Descr: Message dialog box for SUIT-based application
23 ** Created: UI team, 02.10.00
24 *********************************************************************/
26 #include "SUIT_MessageBox.h"
27 #include "SUIT_OverrideCursor.h"
29 #include <qmessagebox.h>
30 #include <qapplication.h>
33 Shows info message box with one button [ static ]
35 int SUIT_MessageBox::info1( QWidget* parent,
36 const QString& caption,
38 const QString& textButton0 )
40 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
41 int ret = QMessageBox::information( parent, caption, text, textButton0,
42 QString::null, QString::null, 0, 0 );
43 qApp->processEvents();
48 Shows warning message box with one button [ static ]
50 int SUIT_MessageBox::warn1( QWidget* parent,
51 const QString& caption,
53 const QString& textButton0 )
55 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
56 int ret = QMessageBox::warning( parent, caption, text, textButton0,
57 QString::null, QString::null, 0, 0 );
58 qApp->processEvents();
63 Shows error message box with one button [ static ]
65 int SUIT_MessageBox::error1( QWidget* parent,
66 const QString& caption,
68 const QString& textButton0 )
70 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
71 int ret = QMessageBox::critical( parent, caption, text, textButton0,
72 QString::null, QString::null, 0, 0 );
73 qApp->processEvents();
78 Shows question message box with one button [ static ]
80 int SUIT_MessageBox::question1( QWidget* parent,
81 const QString& caption,
83 const QString& textButton0 )
85 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
86 int ret = QMessageBox::question( parent, caption, text, textButton0,
87 QString::null, QString::null, 0, 0 );
88 qApp->processEvents();
93 Shows info message box with two buttons.
94 Returns id of the pressed button or -1 if escaped [ static ]
96 int SUIT_MessageBox::info2( QWidget* parent,
97 const QString& caption,
99 const QString& textButton0,
100 const QString& textButton1,
101 int idButton0, int idButton1, int idDefault )
103 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
104 if ( idDefault == idButton0 )
106 else if ( idDefault == idButton1 )
111 int ret = QMessageBox::information( parent, caption, text, textButton0,
112 textButton1, QString::null, idDefault );
113 qApp->processEvents();
114 return ( ret == 0 ? idButton0 : idButton1 );
118 Shows warning message box with two buttons.
119 Returns id of the pressed button or -1 if escaped [ static ]
121 int SUIT_MessageBox::warn2( QWidget* parent,
122 const QString& caption,
124 const QString& textButton0,
125 const QString& textButton1,
126 int idButton0, int idButton1, int idDefault )
128 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
130 if ( idDefault == idButton0 )
132 else if ( idDefault == idButton1 )
137 int ret = QMessageBox::warning( parent, caption, text, textButton0,
138 textButton1, QString::null, idDefault );
139 qApp->processEvents();
140 return ( ret == 0 ? idButton0 : idButton1 );
144 Shows error message box with two buttons
145 Returns id of the pressed button or -1 if escaped [ static ]
147 int SUIT_MessageBox::error2( QWidget* parent,
148 const QString& caption,
150 const QString& textButton0,
151 const QString& textButton1,
152 int idButton0, int idButton1, int idDefault )
154 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
156 if ( idDefault == idButton0 )
158 else if ( idDefault == idButton1 )
163 int ret = QMessageBox::critical( parent, caption, text, textButton0,
164 textButton1, QString::null, idDefault );
165 qApp->processEvents();
166 return ( ret == 0 ? idButton0 : idButton1 );
170 Shows question message box with two buttons
171 Returns id of the pressed button or -1 if escaped [ static ]
173 int SUIT_MessageBox::question2( QWidget* parent,
174 const QString& caption,
176 const QString& textButton0,
177 const QString& textButton1,
178 int idButton0, int idButton1, int idDefault )
180 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
182 if ( idDefault == idButton0 )
184 else if ( idDefault == idButton1 )
189 int ret = QMessageBox::question( parent, caption, text, textButton0,
190 textButton1, QString::null, idDefault );
191 qApp->processEvents();
192 return ( ret == 0 ? idButton0 : idButton1 );
196 Shows info message box with three buttons.
197 Returns id of the pressed button or -1 if escaped [ static ]
199 int SUIT_MessageBox::info3( QWidget* parent,
200 const QString& caption,
202 const QString& textButton0,
203 const QString& textButton1,
204 const QString& textButton2,
205 int idButton0, int idButton1,
206 int idButton2, int idDefault )
208 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
210 if ( idDefault == idButton0 )
212 else if ( idDefault == idButton1 )
214 else if ( idDefault == idButton2 )
219 int ret = QMessageBox::information( parent, caption, text, textButton0,
220 textButton1, textButton2, idDefault );
221 qApp->processEvents();
235 Shows warning message box with three buttons.
236 Returns id of the pressed button or -1 if escaped [ static ]
238 int SUIT_MessageBox::warn3( QWidget* parent,
239 const QString& caption,
241 const QString& textButton0,
242 const QString& textButton1,
243 const QString& textButton2,
244 int idButton0, int idButton1,
245 int idButton2, int idDefault )
247 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
249 if ( idDefault == idButton0 )
251 else if ( idDefault == idButton1 )
253 else if ( idDefault == idButton2 )
258 int ret = QMessageBox::warning( parent, caption, text, textButton0,
259 textButton1, textButton2, idDefault );
260 qApp->processEvents();
274 Shows error message box with three buttons.
275 Returns id of the pressed button or -1 if escaped [ static ]
277 int SUIT_MessageBox::error3( QWidget* parent,
278 const QString& caption,
280 const QString& textButton0,
281 const QString& textButton1,
282 const QString& textButton2,
283 int idButton0, int idButton1,
284 int idButton2, int idDefault )
286 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
288 if ( idDefault == idButton0 )
290 else if ( idDefault == idButton1 )
292 else if ( idDefault == idButton2 )
297 int ret = QMessageBox::critical( parent, caption, text, textButton0,
298 textButton1, textButton2, idDefault );
299 qApp->processEvents();
313 Shows question message box with three buttons.
314 Returns id of the pressed button or -1 if escaped [ static ]
316 int SUIT_MessageBox::question3( QWidget* parent,
317 const QString& caption,
319 const QString& textButton0,
320 const QString& textButton1,
321 const QString& textButton2,
322 int idButton0, int idButton1,
323 int idButton2, int idDefault )
325 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
327 if ( idDefault == idButton0 )
329 else if ( idDefault == idButton1 )
331 else if ( idDefault == idButton2 )
336 int ret = QMessageBox::question( parent, caption, text, textButton0,
337 textButton1, textButton2, idDefault );
338 qApp->processEvents();