1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
21 #include <QVBoxLayout>
22 #include <QRadioButton>
23 #include <QButtonGroup>
24 #include <QStringList>
29 //================================================================================
31 * \brief Creates a QGroupBox with a given title
33 //================================================================================
35 StdMeshersGUI_RadioButtonsGrpWdg::StdMeshersGUI_RadioButtonsGrpWdg( const QString& title )
38 myButtonGrp = new QButtonGroup( this );
41 //================================================================================
43 * \brief Creates a given nubmer of button labels with given labels (QString's)
45 //================================================================================
47 void StdMeshersGUI_RadioButtonsGrpWdg::setButtonLabels( const QStringList& buttonLabels )
49 QVBoxLayout* layout = new QVBoxLayout( this );
50 layout->setSpacing(SPACING);
51 layout->setMargin(MARGIN);
53 for ( int id = 0; id < buttonLabels.size(); ++id )
55 QRadioButton* button = new QRadioButton( buttonLabels.at(id), this );
56 layout->addWidget( button );
57 myButtonGrp->addButton( button, id );
61 //================================================================================
63 * \brief Set checked a radio button with a give id.
65 //================================================================================
67 void StdMeshersGUI_RadioButtonsGrpWdg::setChecked(int id)
69 if ( QAbstractButton* but = myButtonGrp->button( id ))
70 but->setChecked( true );
73 //================================================================================
75 * \brief Return id (zero based) of a checked radio button
77 //================================================================================
79 int StdMeshersGUI_RadioButtonsGrpWdg::checkedId () const
81 return myButtonGrp->checkedId();