libyui-qt  2.44.0
 All Classes Functions Variables
YQMultiLineEdit.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: YQMultiLineEdit.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQMultiLineEdit_h
27 #define YQMultiLineEdit_h
28 
29 #include <QFrame>
30 #include <yui/YMultiLineEdit.h>
31 
32 class YQWidgetCaption;
33 class QTextEdit;
34 
35 
36 /**
37  * MultiLineEdit - an input area for multi-line text.
38  **/
39 class YQMultiLineEdit : public QFrame, public YMultiLineEdit
40 {
41  Q_OBJECT
42 
43 public:
44  /**
45  * Constructor.
46  **/
47  YQMultiLineEdit( YWidget * parent, const std::string & label );
48 
49  /**
50  * Destructor.
51  **/
52  virtual ~YQMultiLineEdit();
53 
54  /**
55  * Get the current value (the text entered by the user or set from the
56  * outside) of this MultiLineEdit.
57  *
58  * Implemented from YMultiLineEdit.
59  **/
60  virtual std::string value();
61 
62  /**
63  * Set the current value (the text entered by the user or set from the
64  * outside) of this MultiLineEdit.
65  *
66  * Implemented from YMultiLineEdit.
67  **/
68  virtual void setValue( const std::string & text );
69 
70  /**
71  * Set the label (the caption above the MultiLineEdit).
72  *
73  * Reimplemented from YMultiLineEdit.
74  **/
75  virtual void setLabel( const std::string & label );
76 
77  /**
78  * Set the maximum input length, i.e., the maximum number of characters the
79  * user can enter. -1 means no limit.
80  *
81  * Reimplemented from YMultiLineEdit.
82  **/
83  virtual void setInputMaxLength( int numberOfChars );
84 
85  /**
86  * Set enabled/disabled state.
87  *
88  * Reimplemented from YWidget.
89  **/
90  virtual void setEnabled( bool enabled );
91 
92  /**
93  * Preferred width of the widget.
94  *
95  * Reimplemented from YWidget.
96  **/
97  virtual int preferredWidth();
98 
99  /**
100  * Preferred height of the widget.
101  *
102  * Reimplemented from YWidget.
103  **/
104  virtual int preferredHeight();
105 
106  /**
107  * Set the new size of the widget.
108  *
109  * Reimplemented from YWidget.
110  **/
111  virtual void setSize( int newWidth, int newHeight );
112 
113  /**
114  * Accept the keyboard focus.
115  **/
116  virtual bool setKeyboardFocus();
117 
118 
119 protected slots:
120 
121  /**
122  * Triggered when the text changes.
123  **/
124  void changed();
125 
126  /**
127  * Enforce the maximum input length: If the text becomes too long, remove
128  * the just-entered character at the current cursor position.
129  *
130  * Note that this is a lot more user friendly than silently truncating at
131  * the end of the text: In the latter case, chances are that the user never
132  * gets to know that text was truncated. Removing the just-typed character
133  * OTOH is something he will notice very quickly.
134  **/
135  void enforceMaxInputLength();
136 
137 
138 protected:
139 
140  YQWidgetCaption * _caption;
141  QTextEdit * _qt_textEdit;
142 };
143 
144 
145 #endif // YQMultiLineEdit_h
virtual std::string value()
virtual void setEnabled(bool enabled)
virtual void setValue(const std::string &text)
virtual int preferredWidth()
virtual ~YQMultiLineEdit()
virtual void setInputMaxLength(int numberOfChars)
virtual bool setKeyboardFocus()
virtual void setSize(int newWidth, int newHeight)
void enforceMaxInputLength()
virtual void setLabel(const std::string &label)
virtual int preferredHeight()
YQMultiLineEdit(YWidget *parent, const std::string &label)