Salome HOME
Merge branch 'abn/paravis_rearch'
[modules/gui.git] / src / SUIT / SUIT_MessageBox.cxx
index 2a31070529a592ddd8458bc50370ef7081805e25..77e244fd6a0daf3ea8706737acdf6483b2696d54 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -762,6 +762,150 @@ int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QStr
                      defaultButton, escapeButton );
 }
 
+/*!
+  \brief Show critical message box with arbitrary number of user-specified
+         buttons.
+
+  List of buttons to be shown is specified via \a buttons parameter.
+  
+  The function returns clicked button id. The identifiers for the buttons
+  are assigned automatically. The first button is identified as 0, the
+  second one as 1, etc.
+
+  The \a defaultButton parameter allows to specify the button which is assigned
+  for the \c Return or \c Enter key. Similarly, \a escapeButton parameter
+  allows specifing the button which is assigned for \c Escape key.
+  If these parameters are not specified (-1 by default), the first button
+  is set as default button and the last one is defined as escape button.
+
+  \param parent parent widget
+  \param title message box title
+  \param text message box text
+  \param defaultButton default button
+  \param escapeButton escape button
+  \param buttons list of buttons to be shown
+  \return button used button id
+*/
+int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text,
+                              const QStringList& buttons,
+                              const int defaultButton, const int escapeButton )
+{
+  ButtonInfos lst;
+  int id = 0;
+  Q_FOREACH( QString button, buttons )
+    lst.append( ButtonInfo( id++, button ) );
+  return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst,
+                     defaultButton, escapeButton );
+}
+
+/*!
+  \brief Show warning message box with arbitrary number of user-specified
+         buttons.
+
+  List of buttons to be shown is specified via \a buttons parameter.
+  
+  The function returns clicked button id. The identifiers for the buttons
+  are assigned automatically. The first button is identified as 0, the
+  second one as 1, etc.
+
+  The \a defaultButton parameter allows to specify the button which is assigned
+  for the \c Return or \c Enter key. Similarly, \a escapeButton parameter
+  allows specifing the button which is assigned for \c Escape key.
+  If these parameters are not specified (-1 by default), the first button
+  is set as default button and the last one is defined as escape button.
+
+  \param parent parent widget
+  \param title message box title
+  \param text message box text
+  \param defaultButton default button
+  \param escapeButton escape button
+  \param buttons list of buttons to be shown
+  \return button used button id
+*/
+int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text,
+                             const QStringList& buttons,
+                             const int defaultButton, const int escapeButton )
+{
+  ButtonInfos lst;
+  int id = 0;
+  Q_FOREACH( QString button, buttons )
+    lst.append( ButtonInfo( id++, button ) );
+  return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst,
+                     defaultButton, escapeButton );
+}
+
+/*!
+  \brief Show information message box with arbitrary number of user-specified
+         buttons.
+
+  List of buttons to be shown is specified via \a buttons parameter.
+  
+  The function returns clicked button id. The identifiers for the buttons
+  are assigned automatically. The first button is identified as 0, the
+  second one as 1, etc.
+
+  The \a defaultButton parameter allows to specify the button which is assigned
+  for the \c Return or \c Enter key. Similarly, \a escapeButton parameter
+  allows specifing the button which is assigned for \c Escape key.
+  If these parameters are not specified (-1 by default), the first button
+  is set as default button and the last one is defined as escape button.
+
+  \param parent parent widget
+  \param title message box title
+  \param text message box text
+  \param defaultButton default button
+  \param escapeButton escape button
+  \param buttons list of buttons to be shown
+  \return button used button id
+*/
+int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text,
+                                 const QStringList& buttons,
+                                 const int defaultButton, const int escapeButton )
+{
+  ButtonInfos lst;
+  int id = 0;
+  Q_FOREACH( QString button, buttons )
+    lst.append( ButtonInfo( id++, button ) );
+  return messageBox( SUIT_MessageBox::Information, parent, title, text, lst,
+                     defaultButton, escapeButton );
+}
+
+/*!
+  \brief Show question message box with arbitrary number of user-specified
+         buttons.
+
+  List of buttons to be shown is specified via \a buttons parameter.
+  
+  The function returns clicked button id. The identifiers for the buttons
+  are assigned automatically. The first button is identified as 0, the
+  second one as 1, etc.
+
+  The \a defaultButton parameter allows to specify the button which is assigned
+  for the \c Return or \c Enter key. Similarly, \a escapeButton parameter
+  allows specifing the button which is assigned for \c Escape key.
+  If these parameters are not specified (-1 by default), the first button
+  is set as default button and the last one is defined as escape button.
+
+  \param parent parent widget
+  \param title message box title
+  \param text message box text
+  \param defaultButton default button
+  \param escapeButton escape button
+  \param buttons list of buttons to be shown
+  \return button used button id
+*/
+int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text,
+                              const QStringList& buttons,
+                              const int defaultButton, const int escapeButton )
+{
+  ButtonInfos lst;
+  int id = 0;
+  Q_FOREACH( QString button, buttons )
+    lst.append( ButtonInfo( id++, button ) );
+  return messageBox( SUIT_MessageBox::Question, parent, title, text, lst,
+                     defaultButton, escapeButton );
+}
+
 /*!
   \brief Show critical message box with arbitrary number of user-specified
          buttons.