libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQMultiLineEdit.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:       YQMultiLineEdit.h
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #ifndef YQMultiLineEdit_h
00027 #define YQMultiLineEdit_h
00028 
00029 #include <QFrame>
00030 #include <yui/YMultiLineEdit.h>
00031 
00032 class YQWidgetCaption;
00033 class QTextEdit;
00034 
00035 
00036 /**
00037  * MultiLineEdit - an input area for multi-line text.
00038  **/
00039 class YQMultiLineEdit : public QFrame, public YMultiLineEdit
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     /**
00045      * Constructor.
00046      **/
00047     YQMultiLineEdit( YWidget * parent, const std::string & label );
00048 
00049     /**
00050      * Destructor.
00051      **/
00052     virtual ~YQMultiLineEdit();
00053 
00054     /**
00055      * Get the current value (the text entered by the user or set from the
00056      * outside) of this MultiLineEdit.
00057      *
00058      * Implemented from YMultiLineEdit.
00059      **/
00060     virtual std::string value();
00061 
00062     /**
00063      * Set the current value (the text entered by the user or set from the
00064      * outside) of this MultiLineEdit.
00065      *
00066      * Implemented from YMultiLineEdit.
00067      **/
00068     virtual void setValue( const std::string & text );
00069 
00070     /**
00071      * Set the label (the caption above the MultiLineEdit).
00072      *
00073      * Reimplemented from YMultiLineEdit.
00074      **/
00075     virtual void setLabel( const std::string & label );
00076 
00077     /**
00078      * Set the maximum input length, i.e., the maximum number of characters the
00079      * user can enter. -1 means no limit.
00080      *
00081      * Reimplemented from YMultiLineEdit.
00082      **/
00083     virtual void setInputMaxLength( int numberOfChars );
00084 
00085     /**
00086      * Set enabled/disabled state.
00087      *
00088      * Reimplemented from YWidget.
00089      **/
00090     virtual void setEnabled( bool enabled );
00091 
00092     /**
00093      * Preferred width of the widget.
00094      *
00095      * Reimplemented from YWidget.
00096      **/
00097     virtual int preferredWidth();
00098 
00099     /**
00100      * Preferred height of the widget.
00101      *
00102      * Reimplemented from YWidget.
00103      **/
00104     virtual int preferredHeight();
00105 
00106     /**
00107      * Set the new size of the widget.
00108      *
00109      * Reimplemented from YWidget.
00110      **/
00111     virtual void setSize( int newWidth, int newHeight );
00112 
00113     /**
00114      * Accept the keyboard focus.
00115      **/
00116     virtual bool setKeyboardFocus();
00117 
00118 
00119 protected slots:
00120 
00121     /**
00122      * Triggered when the text changes.
00123      **/
00124     void changed();
00125 
00126     /**
00127      * Enforce the maximum input length: If the text becomes too long, remove
00128      * the just-entered character at the current cursor position.
00129      *
00130      * Note that this is a lot more user friendly than silently truncating at
00131      * the end of the text: In the latter case, chances are that the user never
00132      * gets to know that text was truncated. Removing the just-typed character
00133      * OTOH is something he will notice very quickly.
00134      **/
00135     void enforceMaxInputLength();
00136 
00137 
00138 protected:
00139 
00140     YQWidgetCaption *   _caption;
00141     QTextEdit *         _qt_textEdit;
00142 };
00143 
00144 
00145 #endif // YQMultiLineEdit_h
 All Classes Functions Variables