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