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