1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the dialog module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
32
#include "QtGui/qdialog.h"
34
#ifndef QT_NO_MESSAGEBOX
37
class QMessageBoxPrivate;
39
class Q_GUI_EXPORT QMessageBox : public QDialog
43
Q_PROPERTY(QString text READ text WRITE setText)
44
Q_PROPERTY(Icon icon READ icon WRITE setIcon)
45
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
46
Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
57
explicit QMessageBox(QWidget *parent = 0);
58
QMessageBox(const QString &caption, const QString &text, Icon icon,
59
int button0, int button1, int button2,
60
QWidget *parent = 0, Qt::WFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
63
enum Button { NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5,
64
Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, ButtonMask = 0xff,
65
Default = 0x100, Escape = 0x200, FlagMask = 0x300 };
68
void setText(const QString &);
73
QPixmap iconPixmap() const;
74
void setIconPixmap(const QPixmap &);
76
QString buttonText(int button) const;
77
void setButtonText(int button, const QString &);
79
Qt::TextFormat textFormat() const;
80
void setTextFormat(Qt::TextFormat);
82
static int information(QWidget *parent, const QString &caption,
84
int button0, int button1=0, int button2=0);
85
static int information(QWidget *parent, const QString &caption,
87
const QString& button0Text = QString(),
88
const QString& button1Text = QString(),
89
const QString& button2Text = QString(),
90
int defaultButtonNumber = 0,
91
int escapeButtonNumber = -1);
93
static int question(QWidget *parent, const QString &caption,
95
int button0, int button1=0, int button2=0);
96
static int question(QWidget *parent, const QString &caption,
98
const QString& button0Text = QString(),
99
const QString& button1Text = QString(),
100
const QString& button2Text = QString(),
101
int defaultButtonNumber = 0,
102
int escapeButtonNumber = -1);
104
static int warning(QWidget *parent, const QString &caption,
106
int button0, int button1, int button2=0);
107
static int warning(QWidget *parent, const QString &caption,
109
const QString& button0Text = QString(),
110
const QString& button1Text = QString(),
111
const QString& button2Text = QString(),
112
int defaultButtonNumber = 0,
113
int escapeButtonNumber = -1);
115
static int critical(QWidget *parent, const QString &caption,
117
int button0, int button1, int button2=0);
118
static int critical(QWidget *parent, const QString &caption,
120
const QString& button0Text = QString(),
121
const QString& button1Text = QString(),
122
const QString& button2Text = QString(),
123
int defaultButtonNumber = 0,
124
int escapeButtonNumber = -1);
126
static void about(QWidget *parent, const QString &caption,
127
const QString& text);
129
static void aboutQt(QWidget *parent,
130
const QString& caption=QString());
132
QSize sizeHint() const;
135
QT3_SUPPORT_CONSTRUCTOR QMessageBox(const QString &caption, const QString &text, Icon icon,
136
int button0, int button1, int button2,
137
QWidget *parent, const char *name, bool modal,
138
Qt::WFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
139
QT3_SUPPORT_CONSTRUCTOR QMessageBox(QWidget *parent, const char *name);
141
static QT3_SUPPORT QPixmap standardIcon(Icon icon, Qt::GUIStyle);
142
static QT3_SUPPORT int message(const QString &caption,
144
const QString& buttonText=QString(),
145
QWidget *parent=0, const char * =0) {
146
return QMessageBox::information(parent, caption, text,
148
? tr("OK") : buttonText) == 0;
150
static QT3_SUPPORT bool query(const QString &caption,
152
const QString& yesButtonText=QString(),
153
const QString& noButtonText=QString(),
154
QWidget *parent=0, const char * = 0) {
155
return QMessageBox::information(parent, caption, text,
156
yesButtonText.isEmpty()
157
? tr("OK") : yesButtonText,
162
static QPixmap standardIcon(Icon icon);
165
void resizeEvent(QResizeEvent *);
166
void showEvent(QShowEvent *);
167
void closeEvent(QCloseEvent *);
168
void keyPressEvent(QKeyEvent *);
169
void changeEvent(QEvent *);
172
Q_PRIVATE_SLOT(d_func(), void buttonClicked())
174
Q_DISABLE_COPY(QMessageBox)
175
Q_DECLARE_PRIVATE(QMessageBox)
178
#define QT_REQUIRE_VERSION(argc, argv, str) { QString s=QString::fromLatin1(str);\
179
QString sq=QString::fromLatin1(qVersion()); if ((sq.section('.',0,0).toInt()<<16)+\
180
(sq.section('.',1,1).toInt()<<8)+sq.section('.',2,2).toInt()<(s.section('.',0,0).toInt()<<16)+\
181
(s.section('.',1,1).toInt()<<8)+s.section('.',2,2).toInt()){if (!qApp){ int c=0; new \
182
QApplication(argc,argv);} QString s = QApplication::tr("Executable '%1' requires Qt "\
183
"%2, found Qt %3.").arg(QString::fromLatin1(qAppName())).arg(QString::fromLatin1(\
184
str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\
185
"Incompatible Qt Library Error"), s, QMessageBox::Abort,0); qFatal(s.ascii()); }}
188
#endif // QT_NO_MESSAGEBOX
190
#endif // QMESSAGEBOX_H