libyui  3.3.1
YSimpleInputField.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: YSimpleInputField.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YSimpleInputField_h
26 #define YSimpleInputField_h
27 
28 #include "YWidget.h"
29 
31 
32 
33 /**
34  * Abstract base class for simple input fields with a label above the field and
35  * a text value.
36  **/
37 class YSimpleInputField : public YWidget
38 {
39 protected:
40  /**
41  * Constructor.
42  **/
43  YSimpleInputField( YWidget * parent, const std::string & label );
44 
45 public:
46  /**
47  * Destructor.
48  **/
49  virtual ~YSimpleInputField();
50 
51  /**
52  * Get the current value (the text entered by the user or set from the
53  * outside) of this input field.
54  *
55  * Derived classes are required to implement this.
56  **/
57  virtual std::string value() = 0;
58 
59  /**
60  * Set the current value (the text entered by the user or set from the
61  * outside) of this input field.
62  *
63  * Derived classes are required to implement this.
64  **/
65  virtual void setValue( const std::string & text ) = 0;
66 
67  /**
68  * Get the label (the caption above the input field).
69  **/
70  std::string label() const;
71 
72  /**
73  * Set the label (the caption above the input field).
74  *
75  * Derived classes are free to reimplement this, but they should call this
76  * base class method at the end of the overloaded function.
77  **/
78  virtual void setLabel( const std::string & label );
79 
80  /**
81  * Set a property.
82  * Reimplemented from YWidget.
83  *
84  * This function may throw YUIPropertyExceptions.
85  *
86  * This function returns 'true' if the value was successfully set and
87  * 'false' if that value requires special handling (not in error cases:
88  * those are covered by exceptions).
89  **/
90  virtual bool setProperty( const std::string & propertyName,
91  const YPropertyValue & val );
92 
93  /**
94  * Get a property.
95  * Reimplemented from YWidget.
96  *
97  * This method may throw YUIPropertyExceptions.
98  **/
99  virtual YPropertyValue getProperty( const std::string & propertyName );
100 
101  /**
102  * Return this class's property set.
103  * This also initializes the property upon the first call.
104  *
105  * Reimplemented from YWidget.
106  **/
107  virtual const YPropertySet & propertySet();
108 
109  /**
110  * Get the string of this widget that holds the keyboard shortcut.
111  *
112  * Reimplemented from YWidget.
113  **/
114  virtual std::string shortcutString() const { return label(); }
115 
116  /**
117  * Set the string of this widget that holds the keyboard shortcut.
118  *
119  * Reimplemented from YWidget.
120  **/
121  virtual void setShortcutString( const std::string & str )
122  { setLabel( str ); }
123 
124  /**
125  * The name of the widget property that will return user input.
126  * Inherited from YWidget.
127  **/
128  const char * userInputProperty() { return YUIProperty_Value; }
129 
130 
131 private:
132 
134 };
135 
136 
137 #endif // YSimpleInputField_h
virtual ~YSimpleInputField()
Destructor.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
Transport class for the value of simple properties.
Definition: YProperty.h:104
virtual std::string shortcutString() const
Get the string of this widget that holds the keyboard shortcut.
A set of properties to check names and types against.
Definition: YProperty.h:197
virtual std::string value()=0
Get the current value (the text entered by the user or set from the outside) of this input field...
virtual const YPropertySet & propertySet()
Return this class&#39;s property set.
const char * userInputProperty()
The name of the widget property that will return user input.
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
virtual void setShortcutString(const std::string &str)
Set the string of this widget that holds the keyboard shortcut.
virtual void setValue(const std::string &text)=0
Set the current value (the text entered by the user or set from the outside) of this input field...
std::string label() const
Get the label (the caption above the input field).
virtual void setLabel(const std::string &label)
Set the label (the caption above the input field).
Abstract base class for simple input fields with a label above the field and a text value...
Abstract base class of all UI widgets.
Definition: YWidget.h:54
YSimpleInputField(YWidget *parent, const std::string &label)
Constructor.