libyui  3.1.5
YMultiLineEdit.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: YMultiLineEdit.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YMultiLineEdit_h
26 #define YMultiLineEdit_h
27 
28 #include "YWidget.h"
29 
31 
32 
33 class YMultiLineEdit : public YWidget
34 {
35 protected:
36  /**
37  * Constructor.
38  **/
39  YMultiLineEdit( YWidget * parent, const std::string & label );
40 
41 public:
42  /**
43  * Destructor.
44  **/
45  virtual ~YMultiLineEdit();
46 
47  /**
48  * Returns a descriptive name of this widget class for logging,
49  * debugging etc.
50  **/
51  virtual const char * widgetClass() const { return "YMultiLineEdit"; }
52 
53  /**
54  * Get the current value (the text entered by the user or set from the
55  * outside) of this MultiLineEdit.
56  *
57  * Derived classes are required to implement this.
58  **/
59  virtual std::string value() = 0;
60 
61  /**
62  * Set the current value (the text entered by the user or set from the
63  * outside) of this MultiLineEdit.
64  *
65  * Derived classes are required to implement this.
66  **/
67  virtual void setValue( const std::string & text ) = 0;
68 
69  /**
70  * Get the label (the caption above the MultiLineEdit).
71  **/
72  std::string label() const;
73 
74  /**
75  * Set the label (the caption above the MultiLineEdit).
76  *
77  * Derived classes are free to reimplement this, but they should call this
78  * base class method at the end of the overloaded function.
79  **/
80  virtual void setLabel( const std::string & label );
81 
82  /**
83  * The maximum input length, i.e., the maximum number of characters the
84  * user can enter. -1 means no limit.
85  **/
86  int inputMaxLength() const;
87 
88  /**
89  * Set the maximum input length, i.e., the maximum number of characters the
90  * user can enter. -1 means no limit.
91  *
92  * Derived classes are free to reimplement this, but they should call this
93  * base class method at the end of the overloaded function.
94  **/
95  virtual void setInputMaxLength( int numberOfChars );
96 
97  /**
98  * Return the number of input lines that are visible by default.
99  *
100  * This is what the widget would like to get (which will be reflected by
101  * preferredHeight() ), not what it currently actually has due to layout
102  * constraints.
103  **/
104  int defaultVisibleLines() const;
105 
106  /**
107  * Set the number of input lines that are visible by default.
108  *
109  * This is what the widget would like to get (which will be reflected by
110  * preferredHeight() ), not what it currently actually has due to layout
111  * constraints.
112  *
113  * Notice that since a MultiLineEdit is stretchable in both dimensions, it
114  * might get more or less screen space, depending on the layout. This value
115  * is only meaningful if there are no other layout constraints.
116  *
117  * Changing this value will not trigger a re-layout.
118  *
119  * Derived classes can overwrite this function (but should call this base
120  * class function in the new function implementation), but it will normally
121  * be sufficient to query defaultVisibleLines() in preferredHeight().
122  **/
123  virtual void setDefaultVisibleLines( int newVisibleLines );
124 
125  /**
126  * Set a property.
127  * Reimplemented from YWidget.
128  *
129  * This function may throw YUIPropertyExceptions.
130  *
131  * This function returns 'true' if the value was successfully set and
132  * 'false' if that value requires special handling (not in error cases:
133  * those are covered by exceptions).
134  **/
135  virtual bool setProperty( const std::string & propertyName,
136  const YPropertyValue & val );
137 
138  /**
139  * Get a property.
140  * Reimplemented from YWidget.
141  *
142  * This method may throw YUIPropertyExceptions.
143  **/
144  virtual YPropertyValue getProperty( const std::string & propertyName );
145 
146  /**
147  * Return this class's property set.
148  * This also initializes the property upon the first call.
149  *
150  * Reimplemented from YWidget.
151  **/
152  virtual const YPropertySet & propertySet();
153 
154  /**
155  * Get the string of this widget that holds the keyboard shortcut.
156  *
157  * Reimplemented from YWidget.
158  **/
159  virtual std::string shortcutString() const { return label(); }
160 
161  /**
162  * Set the string of this widget that holds the keyboard shortcut.
163  *
164  * Reimplemented from YWidget.
165  **/
166  virtual void setShortcutString( const std::string & str )
167  { setLabel( str ); }
168 
169  /**
170  * The name of the widget property that will return user input.
171  * Inherited from YWidget.
172  **/
173  const char * userInputProperty() { return YUIProperty_Value; }
174 
175 
176 private:
177 
179 };
180 
181 
182 #endif // YMultiLineEdit_h
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
YWidget * parent() const
Return this widget's parent or 0 if it doesn't have a parent.
Definition: YWidget.cc:269
Transport class for the value of simple properties.
Definition: YProperty.h:104
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 MultiLineEdit...
A set of properties to check names and types against.
Definition: YProperty.h:184
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
int inputMaxLength() const
The maximum input length, i.e., the maximum number of characters the user can enter.
virtual void setShortcutString(const std::string &str)
Set the string of this widget that holds the keyboard shortcut.
virtual void setLabel(const std::string &label)
Set the label (the caption above the MultiLineEdit).
virtual std::string value()=0
Get the current value (the text entered by the user or set from the outside) of this MultiLineEdit...
const char * userInputProperty()
The name of the widget property that will return user input.
virtual std::string shortcutString() const
Get the string of this widget that holds the keyboard shortcut.
int defaultVisibleLines() const
Return the number of input lines that are visible by default.
virtual void setDefaultVisibleLines(int newVisibleLines)
Set the number of input lines that are visible by default.
virtual const YPropertySet & propertySet()
Return this class's property set.
YMultiLineEdit(YWidget *parent, const std::string &label)
Constructor.
Abstract base class of all UI widgets.
Definition: YWidget.h:54
std::string label() const
Get the label (the caption above the MultiLineEdit).
virtual void setInputMaxLength(int numberOfChars)
Set the maximum input length, i.e., the maximum number of characters the user can enter...
virtual ~YMultiLineEdit()
Destructor.
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.