libyui  3.1.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Pages
YRadioButtonGroup.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YRadioButtonGroup.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YRadioButtonGroup_h
26 #define YRadioButtonGroup_h
27 
28 #include "YSingleChildContainerWidget.h"
29 
30 class YRadioButton;
32 
33 typedef std::list<YRadioButton *> YRadioButtonList;
34 typedef YRadioButtonList::iterator YRadioButtonListIterator;
35 typedef YRadioButtonList::const_iterator YRadioButtonListConstIterator;
36 
37 
39 {
40 protected:
41  /**
42  * Constructor.
43  **/
45 
46 public:
47  /**
48  * Destructor.
49  **/
50  virtual ~YRadioButtonGroup();
51 
52  /**
53  * Returns a descriptive name of this widget class for logging,
54  * debugging etc.
55  **/
56  virtual const char * widgetClass() const { return "YRadioButtonGroup"; }
57 
58  /**
59  * Find the currently selected button.
60  **/
61  YRadioButton * currentButton() const;
62 
63  /**
64  * The same as currentButton() above for convenience.
65  **/
66  YRadioButton * value() const { return currentButton(); }
67 
68  /**
69  * Add a RadioButton to this button group. RadioButtons are required to
70  * call this in their constructor.
71  *
72  * Derived classes are free to overload this, but they should call this
73  * base class function in the overloaded function.
74  **/
75  virtual void addRadioButton( YRadioButton * radioButton );
76 
77  /**
78  * Remove a RadioButton from this button group. RadioButtons are required
79  * to call this in their destructor, but only if the button group is not
80  * also in the process of being destroyed (otherwise there may be race
81  * conditions with child widgets already destroyed):
82  *
83  * if ( ! buttonGroup()->beingDestroyed )
84  * buttonGroup()->removeRadioButton( this );
85  **/
86  virtual void removeRadioButton( YRadioButton * radioButton );
87 
88  /**
89  * Unchecks all radio buttons except one. This method
90  * can be used by a concrete UI (the Qt UI or the NCurses UI)
91  * in the implementation of YRadioButton::setValue().
92  **/
93  void uncheckOtherButtons( YRadioButton * radioButton );
94 
95  /**
96  * Set a property.
97  * Reimplemented from YWidget.
98  *
99  * This method may throw exceptions, for example
100  * - if there is no property with that name
101  * - if the expected type and the type mismatch
102  * - if the value is out of range
103  *
104  * This function returns 'true' if the value was successfully set and
105  * 'false' if that value requires special handling (not in error cases:
106  * those are covered by exceptions).
107  **/
108  virtual bool setProperty( const std::string & propertyName,
109  const YPropertyValue & val );
110 
111  /**
112  * Get a property.
113  * Reimplemented from YWidget.
114  *
115  * This method may throw exceptions, for example
116  * - if there is no property with that name
117  **/
118  virtual YPropertyValue getProperty( const std::string & propertyName );
119 
120  /**
121  * Return this class's property set.
122  * This also initializes the property set upon the first call.
123  *
124  * Reimplemented from YWidget.
125  **/
126  virtual const YPropertySet & propertySet();
127 
128 protected:
129 
130  /**
131  * Return an iterator that points to the first RadioButton of this button
132  * group.
133  *
134  * Note that RadioButtons in this group may be direct or indirect children
135  * of the group, so don't confuse this with YWidget::widgetsBegin().
136  **/
137  YRadioButtonListConstIterator radioButtonsBegin() const;
138 
139  /**
140  * Return an iterator that points behind the last RadioButton of this
141  * button group.
142  **/
143  YRadioButtonListConstIterator radioButtonsEnd() const;
144 
145  /**
146  * Return the number of RadioButtons in this button group.
147  **/
148  int radioButtonsCount() const;
149 
150 
151 private:
152 
154 };
155 
156 
157 #endif // YRadioButtonGroup_h
RadioButton: Widget for one-out-of-many selection.
Definition: YRadioButton.h:51
YRadioButton * value() const
The same as currentButton() above for convenience.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
YWidget * parent() const
Return this widget's parent or 0 if it doesn't have a parent.
Definition: YWidget.cc:269
Transport class for the value of simple properties.
Definition: YProperty.h:104
YRadioButtonGroup(YWidget *parent)
Constructor.
YRadioButtonListConstIterator radioButtonsBegin() const
Return an iterator that points to the first RadioButton of this button group.
YRadioButton * currentButton() const
Find the currently selected button.
A set of properties to check names and types against.
Definition: YProperty.h:184
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
YRadioButtonListConstIterator radioButtonsEnd() const
Return an iterator that points behind the last RadioButton of this button group.
Container widget class that manages one child.
virtual void addRadioButton(YRadioButton *radioButton)
Add a RadioButton to this button group.
virtual ~YRadioButtonGroup()
Destructor.
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
virtual const YPropertySet & propertySet()
Return this class's property set.
void uncheckOtherButtons(YRadioButton *radioButton)
Unchecks all radio buttons except one.
Abstract base class of all UI widgets.
Definition: YWidget.h:54
int radioButtonsCount() const
Return the number of RadioButtons in this button group.
virtual void removeRadioButton(YRadioButton *radioButton)
Remove a RadioButton from this button group.