home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qmessagebox.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  6KB  |  188 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qmessagebox.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of QMessageBox class
  5. **
  6. ** Created : 950503
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the dialogs module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QMESSAGEBOX_H
  39. #define QMESSAGEBOX_H
  40.  
  41. #ifndef QT_H
  42. #include "qdialog.h"
  43. #endif // QT_H
  44.  
  45. #ifndef QT_NO_MESSAGEBOX
  46.  
  47. class  QLabel;
  48. class  QPushButton;
  49. struct QMessageBoxData;
  50.  
  51. class Q_EXPORT QMessageBox : public QDialog
  52. {
  53.     Q_OBJECT
  54.     Q_ENUMS( Icon )
  55.     Q_PROPERTY( QString text READ text WRITE setText )
  56.     Q_PROPERTY( Icon icon READ icon WRITE setIcon )
  57.     Q_PROPERTY( QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap )
  58.     Q_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat )
  59.  
  60. public:
  61.     enum Icon { NoIcon = 0, Information = 1, Warning = 2, Critical = 3 };
  62.  
  63.     QMessageBox( QWidget* parent=0, const char* name=0 );
  64.     QMessageBox( const QString& caption, const QString &text, Icon icon,
  65.          int button0, int button1, int button2,
  66.          QWidget* parent=0, const char* name=0, bool modal=TRUE,
  67.          WFlags f=WStyle_DialogBorder  );
  68.     ~QMessageBox();
  69.  
  70.     enum { NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5,
  71.        Retry = 6, Ignore = 7, ButtonMask = 0x07,
  72.        Default = 0x100, Escape = 0x200, FlagMask = 0x300 };
  73.  
  74.     static int information( QWidget *parent, const QString &caption,
  75.                 const QString& text,
  76.                 int button0, int button1=0, int button2=0 );
  77.     static int information( QWidget *parent, const QString &caption,
  78.                 const QString& text,
  79.                 const QString& button0Text = QString::null,
  80.                 const QString& button1Text = QString::null,
  81.                 const QString& button2Text = QString::null,
  82.                 int defaultButtonNumber = 0,
  83.                 int escapeButtonNumber = -1 );
  84.  
  85.     static int warning( QWidget *parent, const QString &caption,
  86.             const QString& text,
  87.             int button0, int button1, int button2=0 );
  88.     static int warning( QWidget *parent, const QString &caption,
  89.             const QString& text,
  90.             const QString& button0Text = QString::null,
  91.             const QString& button1Text = QString::null,
  92.             const QString& button2Text = QString::null,
  93.             int defaultButtonNumber = 0,
  94.             int escapeButtonNumber = -1 );
  95.  
  96.     static int critical( QWidget *parent, const QString &caption,
  97.              const QString& text,
  98.              int button0, int button1, int button2=0 );
  99.     static int critical( QWidget *parent, const QString &caption,
  100.              const QString& text,
  101.              const QString& button0Text = QString::null,
  102.              const QString& button1Text = QString::null,
  103.              const QString& button2Text = QString::null,
  104.              int defaultButtonNumber = 0,
  105.              int escapeButtonNumber = -1 );
  106.  
  107.     static void about( QWidget *parent, const QString &caption,
  108.                const QString& text );
  109.  
  110.     static void aboutQt( QWidget *parent,
  111.              const QString& caption=QString::null );
  112.  
  113. /* OBSOLETE */
  114.     static int message( const QString &caption,
  115.             const QString& text,
  116.             const QString& buttonText=QString::null,
  117.             QWidget *parent=0, const char * =0 ) {
  118.     return QMessageBox::information( parent, caption, text,
  119.                      buttonText.isEmpty()
  120.                      ? tr("OK") : buttonText ) == 0;
  121.     }
  122.  
  123. /* OBSOLETE */
  124.     static bool query( const QString &caption,
  125.                const QString& text,
  126.                const QString& yesButtonText=QString::null,
  127.                const QString& noButtonText=QString::null,
  128.                QWidget *parent=0, const char * = 0 ) {
  129.     return QMessageBox::information( parent, caption, text,
  130.                      yesButtonText.isEmpty()
  131.                      ? tr("OK") : yesButtonText,
  132.                      noButtonText ) == 0;
  133.     }
  134.  
  135.     QString    text() const;
  136.     void    setText( const QString &);
  137.  
  138.     Icon    icon() const;
  139.  
  140.     // ### the next four functions will probably be renamed in 3.0.
  141.     void    setIcon( Icon );
  142.     void    setIcon( const QPixmap & );
  143.  
  144.     const QPixmap *iconPixmap() const;
  145.     void    setIconPixmap( const QPixmap & );
  146.  
  147.     QString    buttonText( int button ) const;
  148.     void    setButtonText( int button, const QString &);
  149.  
  150.     void    adjustSize();
  151.  
  152. /* OBSOLETE */
  153.     static QPixmap standardIcon( Icon icon, GUIStyle );
  154.  
  155.     static QPixmap standardIcon( Icon icon );
  156.  
  157.     TextFormat textFormat() const;
  158.     void     setTextFormat( TextFormat );
  159.  
  160. protected:
  161.     void    resizeEvent( QResizeEvent * );
  162.     void    showEvent( QShowEvent * );
  163.     void    keyPressEvent( QKeyEvent * );
  164.     void    styleChanged( QStyle& );
  165.  
  166. private slots:
  167.     void    buttonClicked();
  168.  
  169. private:
  170.     void    init( int, int, int );
  171.     int        indexOf( int ) const;
  172.     void    resizeButtons();
  173.     QLabel     *label;
  174.     QMessageBoxData *mbd;
  175.     void       *reserved1;
  176.     void       *reserved2;
  177.  
  178. private:    // Disabled copy constructor and operator=
  179. #if defined(Q_DISABLE_COPY)
  180.     QMessageBox( const QMessageBox & );
  181.     QMessageBox &operator=( const QMessageBox & );
  182. #endif
  183. };
  184.  
  185. #endif // QT_NO_MESSAGEBOX
  186.  
  187. #endif // QMESSAGEBOX_H
  188.