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, const QString& caption, const QString& text,
36 const QString& textButton0 )
38 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
39 int ret = QMessageBox::information( parent, caption, text, textButton0,
40 QString::null, QString::null, 0, 0 );
41 qApp->processEvents();
46 Shows warning message box with one button [ static ]
48 int SUIT_MessageBox::warn1( QWidget* parent, const QString& caption, const QString& text,
49 const QString& textButton0 )
51 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
52 int ret = QMessageBox::warning( parent, caption, text, textButton0,
53 QString::null, QString::null, 0, 0 );
54 qApp->processEvents();
59 Shows error message box with one button [ static ]
61 int SUIT_MessageBox::error1( QWidget* parent, const QString& caption,
62 const QString& text, const QString& textButton0 )
64 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
65 int ret = QMessageBox::critical( parent, caption, text, textButton0,
66 QString::null, QString::null, 0, 0 );
67 qApp->processEvents();
72 Shows info message box with two buttons.
73 Returns id of the pressed button or -1 if escaped [ static ]
75 int SUIT_MessageBox::info2( QWidget* parent, const QString& caption,
76 const QString& text, const QString& textButton0,
77 const QString& textButton1, int idButton0, int idButton1, int idDefault )
79 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
80 if ( idDefault == idButton0 )
82 else if ( idDefault == idButton1 )
87 int ret = QMessageBox::information( parent, caption, text, textButton0,
88 textButton1, QString::null, idDefault );
89 qApp->processEvents();
90 return ( ret == 0 ? idButton0 : idButton1 );
94 Shows warning message box with two buttons.
95 Returns id of the pressed button or -1 if escaped [ static ]
97 int SUIT_MessageBox::warn2( QWidget* parent, const QString& caption, const QString& text,
98 const QString& textButton0, const QString& textButton1,
99 int idButton0, int idButton1, int idDefault )
101 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
103 if ( idDefault == idButton0 )
105 else if ( idDefault == idButton1 )
110 int ret = QMessageBox::warning( parent, caption, text, textButton0,
111 textButton1, QString::null, idDefault );
112 qApp->processEvents();
113 return ( ret == 0 ? idButton0 : idButton1 );
117 Shows error message box with two buttons
118 Returns id of the pressed button or -1 if escaped [ static ]
120 int SUIT_MessageBox::error2( QWidget* parent, const QString& caption, const QString& text,
121 const QString& textButton0, const QString& textButton1,
122 int idButton0, int idButton1, int idDefault )
124 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
126 if ( idDefault == idButton0 )
128 else if ( idDefault == idButton1 )
133 int ret = QMessageBox::critical( parent, caption, text, textButton0,
134 textButton1, QString::null, idDefault );
135 qApp->processEvents();
136 return ( ret == 0 ? idButton0 : idButton1 );
140 Shows info message box with three buttons.
141 Returns id of the pressed button or -1 if escaped [ static ]
143 int SUIT_MessageBox::info3( QWidget* parent, const QString& caption, const QString& text,
144 const QString& textButton0, const QString& textButton1,
145 const QString& textButton2, int idButton0, int idButton1,
146 int idButton2, int idDefault )
148 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
150 if ( idDefault == idButton0 )
152 else if ( idDefault == idButton1 )
154 else if ( idDefault == idButton2 )
159 int ret = QMessageBox::information( parent, caption, text, textButton0,
160 textButton1, textButton2, idDefault );
161 qApp->processEvents();
175 Shows warning message box with three buttons.
176 Returns id of the pressed button or -1 if escaped [ static ]
178 int SUIT_MessageBox::warn3( QWidget* parent, const QString& caption, const QString& text,
179 const QString& textButton0, const QString& textButton1,
180 const QString& textButton2, int idButton0, int idButton1,
181 int idButton2, int idDefault )
183 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
185 if ( idDefault == idButton0 )
187 else if ( idDefault == idButton1 )
189 else if ( idDefault == idButton2 )
194 int ret = QMessageBox::warning( parent, caption, text, textButton0,
195 textButton1, textButton2, idDefault );
196 qApp->processEvents();
210 Shows error message box with three buttons.
211 Returns id of the pressed button or -1 if escaped [ static ]
213 int SUIT_MessageBox::error3( QWidget* parent, const QString& caption, const QString& text,
214 const QString& textButton0, const QString& textButton1,
215 const QString& textButton2, int idButton0, int idButton1,
216 int idButton2, int idDefault )
218 SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor );
220 if ( idDefault == idButton0 )
222 else if ( idDefault == idButton1 )
224 else if ( idDefault == idButton2 )
229 int ret = QMessageBox::critical( parent, caption, text, textButton0,
230 textButton1, textButton2, idDefault );
231 qApp->processEvents();