1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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
20 #ifndef ModuleBase_ChoiceCtrl_H
21 #define ModuleBase_ChoiceCtrl_H
23 #include "ModuleBase.h"
26 #include <QStringList>
36 * A Choice control. It provides a choice in several strings.
37 * It can be represented by several radiobuttons or by combo box.
38 * Radio buttons can be represented as by radiou buttons with text
39 * or by icons in toggle buttons.
41 class MODULEBASE_EXPORT ModuleBase_ChoiceCtrl: public QWidget
52 * \param theParent a parent widget
53 * \param theChoiceList a list of choice strings
54 * \param theIconsList a list of icon names for radiou buttons
55 * \param theType a type of choice representation
56 * \param theButtonsDir direction of radio buttons placement
58 ModuleBase_ChoiceCtrl(QWidget* theParent,
59 const QStringList& theChoiceList,
60 const QStringList& theIconsList,
61 ControlType theType = RadioButtons,
62 Qt::Orientation theButtonsDir = Qt::Horizontal);
64 /// Set label for the controls.
65 /// It is a label for combo box and title for group of radio buttons.
66 /// \param theText a text of the label
67 void setLabel(const QString& theText);
69 /// Set Icon for the label. Used only for combo box.
70 /// \param theIcon a name of icon
71 void setLabelIcon(const QString& theIcon);
73 /// Set value: Id of button or item of combo box.
74 /// \param theVal a value (from 0 to number of items)
75 void setValue(int theVal);
77 /// Set value: text of button or item of combo box.
78 /// \param theVal a value (one of text items)
79 void setValue(const QString& theVal);
81 /// Set tool tip for label. Used only for combo box.
82 void setTooltip(QString theTip);
84 /// Returns currently selected value
87 /// Returns text of currently selected value
88 QString textValue() const;
90 /// Transfer focus on itself
93 /// Returns controls for activation
94 QList<QWidget*> getControls() const;
96 /// Set list of choice
97 /// \param theChoiceList a string list of items
98 void setChoiceList(const QStringList& theChoiceList);
101 /// A signal raised on change of current value
102 void valueChanged(int theVal);
108 /// A label for cmbo box
111 /// A combo box represerntation of control
114 /// A group box for radio buttons
115 QGroupBox* myGroupBox;
117 /// A group of buttons
118 QButtonGroup* myButtons;