libyui  3.4.2
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 
38 /**
39  * A group of YRadioButton widgets.
40  **/
42 {
43 protected:
44  /**
45  * Constructor.
46  **/
48 
49 public:
50  /**
51  * Destructor.
52  **/
53  virtual ~YRadioButtonGroup();
54 
55  /**
56  * Returns a descriptive name of this widget class for logging,
57  * debugging etc.
58  **/
59  virtual const char * widgetClass() const { return "YRadioButtonGroup"; }
60 
61  /**
62  * Find the currently selected button.
63  **/
64  YRadioButton * currentButton() const;
65 
66  /**
67  * The same as currentButton() above for convenience.
68  **/
69  YRadioButton * value() const { return currentButton(); }
70 
71  /**
72  * Add a RadioButton to this button group. RadioButtons are required to
73  * call this in their constructor.
74  *
75  * Derived classes are free to overload this, but they should call this
76  * base class function in the overloaded function.
77  **/
78  virtual void addRadioButton( YRadioButton * radioButton );
79 
80  /**
81  * Remove a RadioButton from this button group. RadioButtons are required
82  * to call this in their destructor, but only if the button group is not
83  * also in the process of being destroyed (otherwise there may be race
84  * conditions with child widgets already destroyed):
85  *
86  * if ( ! buttonGroup()->beingDestroyed )
87  * buttonGroup()->removeRadioButton( this );
88  **/
89  virtual void removeRadioButton( YRadioButton * radioButton );
90 
91  /**
92  * Unchecks all radio buttons except one. This method
93  * can be used by a concrete UI (the Qt UI or the NCurses UI)
94  * in the implementation of YRadioButton::setValue().
95  **/
96  void uncheckOtherButtons( YRadioButton * radioButton );
97 
98  /**
99  * Set a property.
100  * Reimplemented from YWidget.
101  *
102  * This method may throw exceptions, for example
103  * - if there is no property with that name
104  * - if the expected type and the type mismatch
105  * - if the value is out of range
106  *
107  * This function returns 'true' if the value was successfully set and
108  * 'false' if that value requires special handling (not in error cases:
109  * those are covered by exceptions).
110  **/
111  virtual bool setProperty( const std::string & propertyName,
112  const YPropertyValue & val );
113 
114  /**
115  * Get a property.
116  * Reimplemented from YWidget.
117  *
118  * This method may throw exceptions, for example
119  * - if there is no property with that name
120  **/
121  virtual YPropertyValue getProperty( const std::string & propertyName );
122 
123  /**
124  * Return this class's property set.
125  * This also initializes the property set upon the first call.
126  *
127  * Reimplemented from YWidget.
128  **/
129  virtual const YPropertySet & propertySet();
130 
131 protected:
132 
133  /**
134  * Return an iterator that points to the first RadioButton of this button
135  * group.
136  *
137  * Note that RadioButtons in this group may be direct or indirect children
138  * of the group, so don't confuse this with YWidget::widgetsBegin().
139  **/
140  YRadioButtonListConstIterator radioButtonsBegin() const;
141 
142  /**
143  * Return an iterator that points behind the last RadioButton of this
144  * button group.
145  **/
146  YRadioButtonListConstIterator radioButtonsEnd() const;
147 
148  /**
149  * Return the number of RadioButtons in this button group.
150  **/
151  int radioButtonsCount() const;
152 
153 
154 private:
155 
157 };
158 
159 
160 #endif // YRadioButtonGroup_h
RadioButton: Widget for one-out-of-many selection.
Definition: YRadioButton.h:51
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Transport class for the value of simple properties.
Definition: YProperty.h:104
YRadioButtonGroup(YWidget *parent)
Constructor.
A group of YRadioButton widgets.
A set of properties to check names and types against.
Definition: YProperty.h:197
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
Container widget class that manages one child.
virtual void addRadioButton(YRadioButton *radioButton)
Add a RadioButton to this button group.
YRadioButtonListConstIterator radioButtonsBegin() const
Return an iterator that points to the first RadioButton of this button group.
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
virtual ~YRadioButtonGroup()
Destructor.
YRadioButtonListConstIterator radioButtonsEnd() const
Return an iterator that points behind the last RadioButton of this button group.
YRadioButton * value() const
The same as currentButton() above for convenience.
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
void uncheckOtherButtons(YRadioButton *radioButton)
Unchecks all radio buttons except one.
int radioButtonsCount() const
Return the number of RadioButtons in this button group.
Abstract base class of all UI widgets.
Definition: YWidget.h:54
YRadioButton * currentButton() const
Find the currently selected button.
virtual void removeRadioButton(YRadioButton *radioButton)
Remove a RadioButton from this button group.