1 /********************************************************************** 2 ** $Id: qt/qmultilineedit.h 3.3.8 edited Jan 11 14:38 $ 3 ** 4 ** Definition of QMultiLineEdit widget class 5 ** 6 ** Created : 961005 7 ** 8 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 9 ** 10 ** This file is part of the widgets module of the Qt GUI Toolkit. 11 ** 12 ** This file may be distributed under the terms of the Q Public License 13 ** as defined by Trolltech ASA of Norway and appearing in the file 14 ** LICENSE.QPL included in the packaging of this file. 15 ** 16 ** This file may be distributed and/or modified under the terms of the 17 ** GNU General Public License version 2 as published by the Free Software 18 ** Foundation and appearing in the file LICENSE.GPL included in the 19 ** packaging of this file. 20 ** 21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 22 ** licenses may use this file in accordance with the Qt Commercial License 23 ** Agreement provided with the Software. 24 ** 25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 27 ** 28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 29 ** information about Qt Commercial License Agreements. 30 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 31 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 32 ** 33 ** Contact info@trolltech.com if any conditions of this licensing are 34 ** not clear to you. 35 ** 36 **********************************************************************/ 37 38 #ifndef QMULTILINEEDIT_H 39 #define QMULTILINEEDIT_H 40 41 #ifndef QT_H 42 #include "qtextedit.h" 43 #endif // QT_H 44 45 #ifndef QT_NO_MULTILINEEDIT 46 47 class QMultiLineEditCommand; 48 class QValidator; 49 class QMultiLineEditData; 50 51 class Q_EXPORT QMultiLineEdit : public QTextEdit 52 { 53 Q_OBJECT 54 Q_PROPERTY( int numLines READ numLines ) 55 Q_PROPERTY( bool atBeginning READ atBeginning ) 56 Q_PROPERTY( bool atEnd READ atEnd ) 57 Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment ) 58 Q_PROPERTY( bool edited READ edited WRITE setEdited DESIGNABLE false ) 59 60 public: 61 QMultiLineEdit( QWidget* parent=0, const char* name=0 ); 62 ~QMultiLineEdit(); 63 64 QString textLine( int line ) const; 65 int numLines() const; 66 67 virtual void insertLine( const QString &s, int line = -1 ); insertAt(const QString & s,int line,int col)68 virtual void insertAt( const QString &s, int line, int col ) { 69 insertAt( s, line, col, FALSE ); 70 } 71 virtual void insertAt( const QString &s, int line, int col, bool mark ); 72 virtual void removeLine( int line ); setCursorPosition(int line,int col)73 virtual void setCursorPosition( int line, int col ) { 74 setCursorPosition( line, col, FALSE ); 75 } 76 virtual void setCursorPosition( int line, int col, bool mark ); 77 bool atBeginning() const; 78 bool atEnd() const; 79 80 void setAlignment( int flags ); 81 int alignment() const; 82 83 void setEdited( bool ); 84 bool edited() const; 85 86 bool hasMarkedText() const; 87 QString markedText() const; 88 89 void cursorWordForward( bool mark ); 90 void cursorWordBackward( bool mark ); 91 92 // noops autoUpdate()93 bool autoUpdate() const { return TRUE; } setAutoUpdate(bool)94 virtual void setAutoUpdate( bool ) {} 95 totalWidth()96 int totalWidth() const { return contentsWidth(); } totalHeight()97 int totalHeight() const { return contentsHeight(); } 98 maxLines()99 int maxLines() const { return QWIDGETSIZE_MAX; } setMaxLines(int)100 void setMaxLines( int ) {} 101 102 public slots: deselect()103 void deselect() { selectAll( FALSE ); } 104 105 protected: 106 QPoint cursorPoint() const; 107 108 protected: 109 virtual void insertAndMark( const QString&, bool mark ); 110 virtual void newLine(); 111 virtual void killLine(); 112 virtual void pageUp( bool mark=FALSE ); 113 virtual void pageDown( bool mark=FALSE ); 114 virtual void cursorLeft( bool mark=FALSE, bool wrap = TRUE ); 115 virtual void cursorRight( bool mark=FALSE, bool wrap = TRUE ); 116 virtual void cursorUp( bool mark=FALSE ); 117 virtual void cursorDown( bool mark=FALSE ); 118 virtual void backspace(); 119 virtual void home( bool mark=FALSE ); 120 virtual void end( bool mark=FALSE ); 121 122 bool getMarkedRegion( int *line1, int *col1, 123 int *line2, int *col2 ) const; 124 int lineLength( int row ) const; 125 126 private: 127 QMultiLineEditData *d; 128 129 private: // Disabled copy constructor and operator= 130 #if defined(Q_DISABLE_COPY) 131 QMultiLineEdit( const QMultiLineEdit & ); 132 QMultiLineEdit &operator=( const QMultiLineEdit & ); 133 #endif 134 }; 135 136 #endif // QT_NO_MULTILINEEDIT 137 138 #endif // QMULTILINED_H 139