1 // Copyright (C) 2007-2024 CEA, EDF, 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"
23 #include <SUIT_ResourceMgr.h>
25 #include <QGridLayout>
27 #include <QRadioButton>
28 #include <QButtonGroup>
29 #include <QStringList>
34 //================================================================================
36 * \brief Creates a QGroupBox with a given title
38 //================================================================================
40 StdMeshersGUI_RadioButtonsGrpWdg::StdMeshersGUI_RadioButtonsGrpWdg( const QString& title )
43 myButtonGrp = new QButtonGroup( this );
46 //================================================================================
48 * \brief Creates a given number of button labels with given labels (QString's)
50 //================================================================================
52 void StdMeshersGUI_RadioButtonsGrpWdg::setButtonLabels( const QStringList& buttonLabels,
53 const QStringList& buttonIcons )
55 QGridLayout* layout = new QGridLayout( this );
56 layout->setSpacing(SPACING);
57 layout->setMargin(MARGIN);
59 for ( int id = 0; id < buttonLabels.size(); ++id )
61 QRadioButton* button = new QRadioButton( buttonLabels.at(id), this );
62 layout->addWidget( button, id, 0 );
63 myButtonGrp->addButton( button, id );
65 if ( id < buttonIcons.count() )
67 QPixmap pmi (SMESHGUI::resourceMgr()->loadPixmap("SMESH", buttonIcons.at(id)));
68 if ( !pmi.isNull() ) {
69 QLabel* pixLabel = new QLabel( this );
70 pixLabel->setPixmap( pmi );
71 layout->addWidget( pixLabel, id, 1 );
77 //================================================================================
79 * \brief Set checked a radio button with a give id.
81 //================================================================================
83 void StdMeshersGUI_RadioButtonsGrpWdg::setChecked(int id)
85 if ( QAbstractButton* but = myButtonGrp->button( id ))
86 but->setChecked( true );
89 //================================================================================
91 * \brief Return id (zero based) of a checked radio button
93 //================================================================================
95 int StdMeshersGUI_RadioButtonsGrpWdg::checkedId () const
97 return myButtonGrp->checkedId();