Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qmessagebox.h 3.3.8 edited Jan 11 14:37 $ 00003 ** 00004 ** Definition of QMessageBox class 00005 ** 00006 ** Created : 950503 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the dialogs module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QMESSAGEBOX_H 00039 #define QMESSAGEBOX_H 00040 00041 #ifndef QT_H 00042 #include "qdialog.h" 00043 #endif // QT_H 00044 00045 #ifndef QT_NO_MESSAGEBOX 00046 00047 class QLabel; 00048 class QPushButton; 00049 struct QMessageBoxData; 00050 00051 class Q_EXPORT QMessageBox : public QDialog 00052 { 00053 Q_OBJECT 00054 Q_ENUMS( Icon ) 00055 Q_PROPERTY( QString text READ text WRITE setText ) 00056 Q_PROPERTY( Icon icon READ icon WRITE setIcon ) 00057 Q_PROPERTY( QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap ) 00058 Q_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat ) 00059 00060 public: 00061 enum Icon { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, 00062 Question = 4 }; 00063 00064 QMessageBox( QWidget* parent=0, const char* name=0 ); 00065 QMessageBox( const QString& caption, const QString &text, Icon icon, 00066 int button0, int button1, int button2, 00067 QWidget* parent=0, const char* name=0, bool modal=TRUE, 00068 WFlags f=WStyle_DialogBorder ); 00069 ~QMessageBox(); 00070 00071 enum { NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5, 00072 Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, ButtonMask = 0xff, 00073 Default = 0x100, Escape = 0x200, FlagMask = 0x300 }; 00074 00075 static int information( QWidget *parent, const QString &caption, 00076 const QString& text, 00077 int button0, int button1=0, int button2=0 ); 00078 static int information( QWidget *parent, const QString &caption, 00079 const QString& text, 00080 const QString& button0Text = QString::null, 00081 const QString& button1Text = QString::null, 00082 const QString& button2Text = QString::null, 00083 int defaultButtonNumber = 0, 00084 int escapeButtonNumber = -1 ); 00085 00086 static int question( QWidget *parent, const QString &caption, 00087 const QString& text, 00088 int button0, int button1=0, int button2=0 ); 00089 static int question( QWidget *parent, const QString &caption, 00090 const QString& text, 00091 const QString& button0Text = QString::null, 00092 const QString& button1Text = QString::null, 00093 const QString& button2Text = QString::null, 00094 int defaultButtonNumber = 0, 00095 int escapeButtonNumber = -1 ); 00096 00097 static int warning( QWidget *parent, const QString &caption, 00098 const QString& text, 00099 int button0, int button1, int button2=0 ); 00100 static int warning( QWidget *parent, const QString &caption, 00101 const QString& text, 00102 const QString& button0Text = QString::null, 00103 const QString& button1Text = QString::null, 00104 const QString& button2Text = QString::null, 00105 int defaultButtonNumber = 0, 00106 int escapeButtonNumber = -1 ); 00107 00108 static int critical( QWidget *parent, const QString &caption, 00109 const QString& text, 00110 int button0, int button1, int button2=0 ); 00111 static int critical( QWidget *parent, const QString &caption, 00112 const QString& text, 00113 const QString& button0Text = QString::null, 00114 const QString& button1Text = QString::null, 00115 const QString& button2Text = QString::null, 00116 int defaultButtonNumber = 0, 00117 int escapeButtonNumber = -1 ); 00118 00119 static void about( QWidget *parent, const QString &caption, 00120 const QString& text ); 00121 00122 static void aboutQt( QWidget *parent, 00123 const QString& caption=QString::null ); 00124 00125 /* OBSOLETE */ 00126 static int message( const QString &caption, 00127 const QString& text, 00128 const QString& buttonText=QString::null, 00129 QWidget *parent=0, const char * =0 ) { 00130 return QMessageBox::information( parent, caption, text, 00131 buttonText.isEmpty() 00132 ? tr("OK") : buttonText ) == 0; 00133 } 00134 00135 /* OBSOLETE */ 00136 static bool query( const QString &caption, 00137 const QString& text, 00138 const QString& yesButtonText=QString::null, 00139 const QString& noButtonText=QString::null, 00140 QWidget *parent=0, const char * = 0 ) { 00141 return QMessageBox::information( parent, caption, text, 00142 yesButtonText.isEmpty() 00143 ? tr("OK") : yesButtonText, 00144 noButtonText ) == 0; 00145 } 00146 00147 QString text() const; 00148 void setText( const QString &); 00149 00150 Icon icon() const; 00151 00152 void setIcon( Icon ); 00153 void setIcon( const QPixmap & ); 00154 00155 const QPixmap *iconPixmap() const; 00156 void setIconPixmap( const QPixmap & ); 00157 00158 QString buttonText( int button ) const; 00159 void setButtonText( int button, const QString &); 00160 00161 void adjustSize(); 00162 00163 /* OBSOLETE */ 00164 static QPixmap standardIcon( Icon icon, GUIStyle ); 00165 00166 static QPixmap standardIcon( Icon icon ); 00167 00168 TextFormat textFormat() const; 00169 void setTextFormat( TextFormat ); 00170 00171 protected: 00172 void resizeEvent( QResizeEvent * ); 00173 void showEvent( QShowEvent * ); 00174 void closeEvent( QCloseEvent * ); 00175 void keyPressEvent( QKeyEvent * ); 00176 void styleChanged( QStyle& ); 00177 00178 private slots: 00179 void buttonClicked(); 00180 00181 private: 00182 void init( int, int, int ); 00183 int indexOf( int ) const; 00184 void resizeButtons(); 00185 QLabel *label; 00186 QMessageBoxData *mbd; 00187 void *reserved1; 00188 void *reserved2; 00189 00190 private: // Disabled copy constructor and operator= 00191 #if defined(Q_DISABLE_COPY) 00192 QMessageBox( const QMessageBox & ); 00193 QMessageBox &operator=( const QMessageBox & ); 00194 #endif 00195 }; 00196 00197 /* 00198 * Macro to be used at the beginning of main(), e.g. 00199 * 00200 * #include <qapplication.h> 00201 * #include <qmessagebox.h> 00202 * int main( int argc, char**argv ) 00203 * { 00204 * QT_REQUIRE_VERSION( argc, argv, "3.0.5" ) 00205 * ... 00206 * } 00207 */ 00208 #define QT_REQUIRE_VERSION( argc, argv, str ) { QString s=QString::fromLatin1(str);\ 00209 QString sq=QString::fromLatin1(qVersion()); if ( (sq.section('.',0,0).toInt()<<16)+\ 00210 (sq.section('.',1,1).toInt()<<8)+sq.section('.',2,2).toInt()<(s.section('.',0,0).toInt()<<16)+\ 00211 (s.section('.',1,1).toInt()<<8)+s.section('.',2,2).toInt() ){if ( !qApp){ int c=0; new \ 00212 QApplication(argc,argv);} QString s = QApplication::tr("Executable '%1' requires Qt "\ 00213 "%2, found Qt %3.").arg(QString::fromLatin1(qAppName())).arg(QString::fromLatin1(\ 00214 str)).arg(QString::fromLatin1(qVersion()) ); QMessageBox::critical( 0, QApplication::tr(\ 00215 "Incompatible Qt Library Error" ), s, QMessageBox::Abort,0 ); qFatal(s.ascii()); }} 00216 00217 00218 #endif // QT_NO_MESSAGEBOX 00219 00220 #endif // QMESSAGEBOX_H