libyui  3.2.1
YCheckBoxFrame.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: YCheckBoxFrame.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YCheckBoxFrame_h
26 #define YCheckBoxFrame_h
27 
28 #include <string>
29 #include "YSingleChildContainerWidget.h"
30 #include "ImplPtr.h"
31 
33 
34 
36 {
37 public:
38  /**
39  * Constructor.
40  **/
42  const std::string & label,
43  bool checked );
44 
45  /**
46  * Destructor.
47  **/
48  virtual ~YCheckBoxFrame();
49 
50  /**
51  * Returns a descriptive name of this widget class for logging,
52  * debugging etc.
53  **/
54  virtual const char * widgetClass() const { return "YCheckBoxFrame"; }
55 
56  /**
57  * Return the label text on the CheckBoxFrame.
58  **/
59  std::string label() const;
60 
61  /**
62  * Change the label text on the CheckBoxFrame.
63  *
64  * Derived classes should overload this, but call this base class function
65  * in the overloaded function.
66  **/
67  virtual void setLabel( const std::string & label );
68 
69  /**
70  * Check or uncheck the CheckBoxFrame's check box.
71  *
72  * Derived classes are required to implement this.
73  **/
74  virtual void setValue( bool isChecked ) = 0;
75 
76  /**
77  * Get the status of the CheckBoxFrame's check box.
78  *
79  * Derived classes are required to implement this.
80  **/
81  virtual bool value() = 0;
82 
83  /**
84  * Handle children enabling/disabling automatically based on the
85  * CheckBoxFrame's check box?
86  **/
87  bool autoEnable() const;
88 
89  /**
90  * Change autoEnabled flag.
91  *
92  * Derived classes are free to overload this, but they should call this
93  * base class function in the overloaded function.
94  **/
95  virtual void setAutoEnable( bool autoEnable );
96 
97  /**
98  * Invert the meaning of the CheckBoxFrame's check box, i.e., disable child
99  * widgets when checked?
100  **/
101  bool invertAutoEnable() const;
102 
103  /**
104  * Change invertAutonEnable flag.
105  *
106  * Derived classes are free to overload this, but they should call this
107  * base class function in the overloaded function.
108  **/
109  virtual void setInvertAutoEnable( bool invertAutoEnable );
110 
111  /**
112  * Handle enabling/disabling of child widgets based on 'isChecked' (the
113  * current status of the check box) and autoEnable() and
114  * invertAutoEnable().
115  *
116  * Derived classes should call this when the check box status changes
117  * rather than try to handle it on their level.
118  *
119  * This method also needs to be called after new child widgets are added to
120  * establish the initial enabled or disabled state of the child widgets.
121  **/
122  void handleChildrenEnablement( bool isChecked );
123 
124  /**
125  * Get the string of this widget that holds the keyboard shortcut.
126  *
127  * Reimplemented from YWidget.
128  **/
129  virtual std::string shortcutString() const { return label(); }
130 
131  /**
132  * Set the string of this widget that holds the keyboard shortcut.
133  *
134  * Reimplemented from YWidget.
135  **/
136  virtual void setShortcutString( const std::string & str )
137  { setLabel( str ); }
138 
139  /**
140  * The name of the widget property that will return user input.
141  * Inherited from YWidget.
142  **/
143  const char * userInputProperty() { return YUIProperty_Value; }
144 
145  /**
146  * Set a property.
147  * Reimplemented from YWidget.
148  *
149  * This method may throw exceptions, for example
150  * - if there is no property with that name
151  * - if the expected type and the type mismatch
152  * - if the value is out of range
153  *
154  * This function returns 'true' if the value was successfully set and
155  * 'false' if that value requires special handling (not in error cases:
156  * those are covered by exceptions).
157  **/
158  virtual bool setProperty( const std::string & propertyName,
159  const YPropertyValue & val );
160 
161  /**
162  * Get a property.
163  * Reimplemented from YWidget.
164  *
165  * This method may throw exceptions, for example
166  * - if there is no property with that name
167  **/
168  virtual YPropertyValue getProperty( const std::string & propertyName );
169 
170  /**
171  * Return this class's property set.
172  * This also initializes the property set upon the first call.
173  *
174  * Reimplemented from YWidget.
175  **/
176  virtual const YPropertySet & propertySet();
177 
178 private:
179 
181 };
182 
183 
184 #endif // YCheckBoxFrame_h
virtual bool value()=0
Get the status of the CheckBoxFrame's check box.
virtual std::string shortcutString() const
Get the string of this widget that holds the keyboard shortcut.
YWidget * parent() const
Return this widget's parent or 0 if it doesn't have a parent.
Definition: YWidget.cc:269
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
YCheckBoxFrame(YWidget *parent, const std::string &label, bool checked)
Constructor.
Transport class for the value of simple properties.
Definition: YProperty.h:104
A set of properties to check names and types against.
Definition: YProperty.h:184
virtual void setAutoEnable(bool autoEnable)
Change autoEnabled flag.
bool autoEnable() const
Handle children enabling/disabling automatically based on the CheckBoxFrame's check box...
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
const char * userInputProperty()
The name of the widget property that will return user input.
std::string label() const
Return the label text on the CheckBoxFrame.
Container widget class that manages one child.
bool invertAutoEnable() const
Invert the meaning of the CheckBoxFrame's check box, i.e., disable child widgets when checked...
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
void handleChildrenEnablement(bool isChecked)
Handle enabling/disabling of child widgets based on 'isChecked' (the current status of the check box)...
virtual const YPropertySet & propertySet()
Return this class's property set.
virtual void setInvertAutoEnable(bool invertAutoEnable)
Change invertAutonEnable flag.
virtual void setLabel(const std::string &label)
Change the label text on the CheckBoxFrame.
virtual void setShortcutString(const std::string &str)
Set the string of this widget that holds the keyboard shortcut.
Abstract base class of all UI widgets.
Definition: YWidget.h:54
virtual ~YCheckBoxFrame()
Destructor.
virtual void setValue(bool isChecked)=0
Check or uncheck the CheckBoxFrame's check box.