Back to index

salome-gui  6.5.0
SUIT_MessageBox.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef SUIT_MESSAGEBOX_H
00024 #define SUIT_MESSAGEBOX_H
00025 
00026 #include "SUIT.h"
00027 
00028 #include <QMap>
00029 #include <QList>
00030 #include <QMessageBox>
00031 
00032 class SUIT_EXPORT SUIT_MessageBox : public QMessageBox
00033 {
00034 public:
00035   // construction/destruction
00036   SUIT_MessageBox( QWidget* = 0 );
00037   SUIT_MessageBox( Icon, const QString&, const QString&, StandardButtons buttons = NoButton,
00038                    QWidget* = 0, Qt::WindowFlags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint );
00039   ~SUIT_MessageBox();
00040 
00041   // customize the standard buttons text
00042   QString               buttonText( StandardButton ) const;
00043   void                  setButtonText( StandardButton, const QString& );
00044 
00045   // message box with standard buttons
00046   static StandardButton critical( QWidget* parent, const QString& title, const QString& text,
00047                                   StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
00048   static StandardButton warning( QWidget* parent, const QString& title, const QString& text,
00049                                  StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
00050   static StandardButton information( QWidget* parent, const QString& title, const QString& text,
00051                                      StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
00052   static StandardButton question( QWidget* parent, const QString& title, const QString& text,
00053                                   StandardButtons buttons = Ok, StandardButton defaultButton = NoButton );
00054   
00055   // message boxes with one custom button
00056   static int            critical( QWidget* parent, const QString& title, const QString& text,
00057                                   const QString& button );
00058   static int            warning( QWidget* parent, const QString& title, const QString& text,
00059                                  const QString& button );
00060   static int            information( QWidget* parent, const QString& title, const QString& text,
00061                                      const QString& button );
00062   static int            question( QWidget* parent, const QString& title, const QString& text,
00063                                   const QString& button );
00064 
00065   // message boxes with two custom buttons
00066   static int            critical( QWidget* parent, const QString& title, const QString& text,
00067                                   const QString& button1, const QString& button2, 
00068                                   const int defaultButton = -1, const int escapeButton = -1 );
00069   static int            warning( QWidget* parent, const QString& title, const QString& text,
00070                                  const QString& button1, const QString& button2, 
00071                                  const int defaultButton = -1, const int escapeButton = -1 );
00072   static int            information( QWidget* parent, const QString& title, const QString& text,
00073                                      const QString& button1, const QString& button2, 
00074                                      const int defaultButton = -1, const int escapeButton = -1 );
00075   static int            question( QWidget* parent, const QString& title, const QString& text,
00076                                   const QString& button1, const QString& button2, 
00077                                   const int defaultButton = -1, const int escapeButton = -1 );
00078   
00079   // message boxes with three custom buttons
00080   static int            critical( QWidget* parent, const QString& title, const QString& text,
00081                                   const QString& button1, const QString& button2, const QString& button3,
00082                                   const int defaultButton = -1, const int escapeButton = -1 );
00083   static int            warning( QWidget* parent, const QString& title, const QString& text,
00084                                  const QString& button1, const QString& button2, const QString& button3,
00085                                  const int defaultButton = -1, const int escapeButton = -1 );
00086   static int            information( QWidget* parent, const QString& title, const QString& text,
00087                                      const QString& button1, const QString& button2, const QString& button3,
00088                                      const int defaultButton = -1, const int escapeButton = -1 );
00089   static int            question( QWidget* parent, const QString& title, const QString& text,
00090                                   const QString& button1, const QString& button2, const QString& button3,
00091                                   const int defaultButton = -1, const int escapeButton = -1 );
00092   
00093   // message boxes with four custom buttons
00094   static int            critical( QWidget* parent, const QString& title, const QString& text,
00095                                   const QString& button1, const QString& button2,
00096                                   const QString& button3, const QString& button4,
00097                                   const int defaultButton = -1, const int escapeButton = -1 );
00098   static int            warning( QWidget* parent, const QString& title, const QString& text,
00099                                  const QString& button1, const QString& button2,
00100                                  const QString& button3, const QString& button4,
00101                                  const int defaultButton = -1, const int escapeButton = -1 );
00102   static int            information( QWidget* parent, const QString& title, const QString& text,
00103                                      const QString& button1, const QString& button2,
00104                                      const QString& button3, const QString& button4,
00105                                      const int defaultButton = -1, const int escapeButton = -1 );
00106   static int            question( QWidget* parent, const QString& title, const QString& text,
00107                                   const QString& button1, const QString& button2,
00108                                   const QString& button3, const QString& button4,
00109                                   const int defaultButton = -1, const int escapeButton = -1 );
00110   
00111   // message boxes with arbitrary number of buttons
00112   static int            critical( QWidget* parent, const QString& title, const QString& text, 
00113                                   const int defaultButton, const int escapeButton, 
00114                                   char*, ... );
00115   static int            warning( QWidget* parent, const QString& title, const QString& text,
00116                                  const int defaultButton, const int escapeButton, 
00117                                  char*, ... );
00118   static int            information( QWidget* parent, const QString& title, const QString& text,
00119                                      const int defaultButton, const int escapeButton, 
00120                                      char*, ... );
00121   static int            question( QWidget* parent, const QString& title, const QString& text,
00122                                   const int defaultButton, const int escapeButton, 
00123                                   char*, ... );
00124 
00125 private:
00126   class ButtonInfo
00127   {
00128   public:
00129     ButtonInfo( const int id, 
00130                 const QString& text, 
00131                 const ButtonRole role = ActionRole )
00132       : myId( id ), myText( text ), myRole( role ) {}
00133     int        id()   const { return myId;   }
00134     QString    text() const { return myText; }
00135     ButtonRole role() const { return myRole; }
00136   private:
00137     int        myId;      
00138     QString    myText;    
00139     ButtonRole myRole;    
00140   };
00141 
00142   typedef QList<ButtonInfo> ButtonInfos;
00143 
00144 private:
00145   static int          messageBox( SUIT_MessageBox::Icon icon, QWidget* parent, 
00146                                   const QString& title, const QString& text, 
00147                                   const ButtonInfos& lst, 
00148                                   const int defaultButton = -1, 
00149                                   const int escapeButton  = -1 );
00150   static ButtonInfos  messageList( char*, va_list& );
00151 };
00152 
00153 #endif