libyui
YCheckBox.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: YCheckBox.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef YCheckBox_h
26 #define YCheckBox_h
27 
28 #include <string>
29 
30 #include "YWidget.h"
31 #include "ImplPtr.h"
32 
33 class YCheckBoxPrivate;
34 
35 enum YCheckBoxState
36 {
37  YCheckBox_dont_care = -1, // tristate
38  YCheckBox_off = 0,
39  YCheckBox_on = 1
40 };
41 
46 class YCheckBox : public YWidget
47 {
48 protected:
52  YCheckBox( YWidget * parent, const std::string & label );
53 
54 public:
58  virtual ~YCheckBox();
59 
64  virtual const char * widgetClass() const { return "YCheckBox"; }
65 
66 
89  virtual YCheckBoxState value() = 0;
90 
96  virtual void setValue( YCheckBoxState state ) = 0;
97 
101  bool isChecked() { return value() == YCheckBox_on; }
102 
106  void setChecked( bool checked = true )
107  { setValue( checked ? YCheckBox_on : YCheckBox_off ); }
108 
112  bool dontCare() { return value() == YCheckBox_dont_care; }
113 
117  void setDontCare() { setValue( YCheckBox_dont_care ); }
118 
122  std::string label() const;
123 
130  virtual void setLabel( const std::string & label );
131 
135  bool useBoldFont() const;
136 
143  virtual void setUseBoldFont( bool bold = true );
144 
158  virtual bool setProperty( const std::string & propertyName,
159  const YPropertyValue & val );
160 
168  virtual YPropertyValue getProperty( const std::string & propertyName );
169 
176  virtual const YPropertySet & propertySet();
177 
183  virtual std::string shortcutString() const { return label(); }
184 
190  virtual void setShortcutString( const std::string & str )
191  { setLabel( str ); }
192 
197  const char * userInputProperty() { return YUIProperty_Value; }
198 
199 
200 private:
201 
203 };
204 
205 
206 #endif // YCheckBox_h
const char * userInputProperty()
Definition: YCheckBox.h:197
virtual const YPropertySet & propertySet()
Definition: YCheckBox.cc:86
Definition: YProperty.h:104
Definition: YProperty.h:197
YWidget * parent() const
Definition: YWidget.cc:271
bool isChecked()
Definition: YCheckBox.h:101
YCheckBox(YWidget *parent, const std::string &label)
Definition: YCheckBox.cc:47
Definition: YCheckBox.cc:35
virtual const char * widgetClass() const
Definition: YCheckBox.h:64
virtual void setLabel(const std::string &label)
Definition: YCheckBox.cc:61
bool dontCare()
Definition: YCheckBox.h:112
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Definition: YCheckBox.cc:107
std::string label() const
Definition: YCheckBox.cc:67
virtual std::string shortcutString() const
Definition: YCheckBox.h:183
virtual void setValue(YCheckBoxState state)=0
void setDontCare()
Definition: YCheckBox.h:117
virtual void setUseBoldFont(bool bold=true)
Definition: YCheckBox.cc:79
void setChecked(bool checked=true)
Definition: YCheckBox.h:106
virtual void setShortcutString(const std::string &str)
Definition: YCheckBox.h:190
bool useBoldFont() const
Definition: YCheckBox.cc:73
Definition: YCheckBox.h:46
Definition: YWidget.h:54
virtual ~YCheckBox()
Definition: YCheckBox.cc:55
virtual YCheckBoxState value()=0
virtual YPropertyValue getProperty(const std::string &propertyName)
Definition: YCheckBox.cc:123