1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef SUIT_MESSAGEBOX_H
24 #define SUIT_MESSAGEBOX_H
30 #include <QMessageBox>
32 class SUIT_EXPORT SUIT_MessageBox : public QMessageBox
36 // construction/destruction
37 SUIT_MessageBox( QWidget* = 0 );
38 SUIT_MessageBox( Icon, const QString&, const QString&, StandardButtons buttons = NoButton,
39 QWidget* = 0, Qt::WindowFlags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint );
42 // customize the standard buttons text
43 QString buttonText( StandardButton ) const;
44 void setButtonText( StandardButton, const QString& );
46 // message box with standard buttons
47 static StandardButton critical( QWidget* parent, const QString& title, const QString& text,
48 StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
49 static StandardButton warning( QWidget* parent, const QString& title, const QString& text,
50 StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
51 static StandardButton information( QWidget* parent, const QString& title, const QString& text,
52 StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
53 static StandardButton question( QWidget* parent, const QString& title, const QString& text,
54 StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
56 // message boxes with one custom button
57 static int critical( QWidget* parent, const QString& title, const QString& text,
58 const QString& button );
59 static int warning( QWidget* parent, const QString& title, const QString& text,
60 const QString& button );
61 static int information( QWidget* parent, const QString& title, const QString& text,
62 const QString& button );
63 static int question( QWidget* parent, const QString& title, const QString& text,
64 const QString& button );
66 // message boxes with two custom buttons
67 static int critical( QWidget* parent, const QString& title, const QString& text,
68 const QString& button1, const QString& button2,
69 const int defaultButton = -1, const int escapeButton = -1 );
70 static int warning( QWidget* parent, const QString& title, const QString& text,
71 const QString& button1, const QString& button2,
72 const int defaultButton = -1, const int escapeButton = -1 );
73 static int information( QWidget* parent, const QString& title, const QString& text,
74 const QString& button1, const QString& button2,
75 const int defaultButton = -1, const int escapeButton = -1 );
76 static int question( QWidget* parent, const QString& title, const QString& text,
77 const QString& button1, const QString& button2,
78 const int defaultButton = -1, const int escapeButton = -1 );
80 // message boxes with three custom buttons
81 static int critical( QWidget* parent, const QString& title, const QString& text,
82 const QString& button1, const QString& button2, const QString& button3,
83 const int defaultButton = -1, const int escapeButton = -1 );
84 static int warning( QWidget* parent, const QString& title, const QString& text,
85 const QString& button1, const QString& button2, const QString& button3,
86 const int defaultButton = -1, const int escapeButton = -1 );
87 static int information( QWidget* parent, const QString& title, const QString& text,
88 const QString& button1, const QString& button2, const QString& button3,
89 const int defaultButton = -1, const int escapeButton = -1 );
90 static int question( QWidget* parent, const QString& title, const QString& text,
91 const QString& button1, const QString& button2, const QString& button3,
92 const int defaultButton = -1, const int escapeButton = -1 );
94 // message boxes with four custom buttons
95 static int critical( QWidget* parent, const QString& title, const QString& text,
96 const QString& button1, const QString& button2,
97 const QString& button3, const QString& button4,
98 const int defaultButton = -1, const int escapeButton = -1 );
99 static int warning( QWidget* parent, const QString& title, const QString& text,
100 const QString& button1, const QString& button2,
101 const QString& button3, const QString& button4,
102 const int defaultButton = -1, const int escapeButton = -1 );
103 static int information( QWidget* parent, const QString& title, const QString& text,
104 const QString& button1, const QString& button2,
105 const QString& button3, const QString& button4,
106 const int defaultButton = -1, const int escapeButton = -1 );
107 static int question( QWidget* parent, const QString& title, const QString& text,
108 const QString& button1, const QString& button2,
109 const QString& button3, const QString& button4,
110 const int defaultButton = -1, const int escapeButton = -1 );
112 // message boxes with arbitrary number of buttons
113 static int critical( QWidget* parent, const QString& title, const QString& text,
114 const QStringList& buttons,
115 const int defaultButton = -1, const int escapeButton = -1 );
116 static int warning( QWidget* parent, const QString& title, const QString& text,
117 const QStringList& buttons,
118 const int defaultButton = -1, const int escapeButton = -1 );
119 static int information( QWidget* parent, const QString& title, const QString& text,
120 const QStringList& buttons,
121 const int defaultButton = -1, const int escapeButton = -1 );
122 static int question( QWidget* parent, const QString& title, const QString& text,
123 const QStringList& buttons,
124 const int defaultButton = -1, const int escapeButton = -1 );
126 static int critical( QWidget* parent, const QString& title, const QString& text,
127 const int defaultButton, const int escapeButton,
129 static int warning( QWidget* parent, const QString& title, const QString& text,
130 const int defaultButton, const int escapeButton,
132 static int information( QWidget* parent, const QString& title, const QString& text,
133 const int defaultButton, const int escapeButton,
135 static int question( QWidget* parent, const QString& title, const QString& text,
136 const int defaultButton, const int escapeButton,
143 ButtonInfo( const int id,
145 const ButtonRole role = ActionRole )
146 : myId( id ), myText( text ), myRole( role ) {}
147 int id() const { return myId; }
148 QString text() const { return myText; }
149 ButtonRole role() const { return myRole; }
151 int myId; //!< button id
152 QString myText; //!< button text
153 ButtonRole myRole; //!< button role
156 typedef QList<ButtonInfo> ButtonInfos;
159 static int messageBox( SUIT_MessageBox::Icon icon, QWidget* parent,
160 const QString& title, const QString& text,
161 const ButtonInfos& lst,
162 const int defaultButton = -1,
163 const int escapeButton = -1 );
164 static ButtonInfos messageList( char*, va_list& );