ScrollableLineEdit.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef SCROLLABLE_LINEEDIT_H
00048 #define SCROLLABLE_LINEEDIT_H
00049
00050 struct ScrollableLineEditPrivate;
00051
00052 class QComboBox;
00053 class QValidator;
00054
00055
00056 #ifndef QT_H
00057 #include "qwidget.h"
00058 #include "qstring.h"
00059 #include <iostream.h>
00060 #endif // QT_H
00061
00062 #ifndef QT_NO_LINEEDIT
00063
00064 class Q_EXPORT ScrollableLineEdit : public QWidget
00065 {
00066 Q_OBJECT
00067 Q_ENUMS( EchoMode )
00068 Q_PROPERTY( QString text READ text WRITE setText )
00069 Q_PROPERTY( int maxLength READ maxLength WRITE setMaxLength )
00070 Q_PROPERTY( bool frame READ frame WRITE setFrame )
00071 Q_PROPERTY( EchoMode echoMode READ echoMode WRITE setEchoMode )
00072 Q_PROPERTY( QString displayText READ displayText )
00073 Q_PROPERTY( int cursorPosition READ cursorPosition WRITE setCursorPosition )
00074 Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
00075 Q_PROPERTY( bool edited READ edited WRITE setEdited )
00076 Q_PROPERTY( bool hasMarkedText READ hasMarkedText )
00077 Q_PROPERTY( QString markedText READ markedText )
00078
00079 public:
00080 ScrollableLineEdit( QWidget *parent, const char *name=0 );
00081 ScrollableLineEdit( const QString &, QWidget *parent, const char *name=0 );
00082 ~ScrollableLineEdit();
00083
00084 QString text() const;
00085
00086 QString displayText() const;
00087
00088 int maxLength() const;
00089 virtual void setMaxLength( int );
00090
00091 virtual void setFrame( bool );
00092 bool frame() const;
00093
00094 enum EchoMode { Normal, NoEcho, Password };
00095 virtual void setEchoMode( EchoMode );
00096 EchoMode echoMode() const;
00097 #if QT_VERSION >= 300
00098 #error "Make setReadOnly virtual"
00099 #endif
00100 void setReadOnly( bool );
00101 bool isReadOnly() const;
00102
00103 virtual void setValidator( const QValidator * );
00104 const QValidator * validator() const;
00105
00106 QSize sizeHint() const;
00107 QSize minimumSizeHint() const;
00108 QSizePolicy sizePolicy() const;
00109
00110 virtual void setEnabled( bool );
00111 virtual void setFont( const QFont & );
00112 virtual void setPalette( const QPalette & );
00113 virtual void setSelection( int, int );
00114
00115 virtual void setCursorPosition( int );
00116 int cursorPosition() const;
00117
00118 bool validateAndSet( const QString &, int, int, int );
00119
00120 #ifndef QT_NO_CLIPBOARD
00121 void cut();
00122 void copy() const;
00123 void paste();
00124 #endif
00125
00126 void setAlignment( int flag );
00127 int alignment() const;
00128
00129 void cursorLeft( bool mark, int steps = 1 );
00130 void cursorRight( bool mark, int steps = 1 );
00131 void cursorWordForward( bool mark );
00132 void cursorWordBackward( bool mark );
00133 void backspace();
00134 void del();
00135 void home( bool mark );
00136 void end( bool mark );
00137
00138 void setEdited( bool );
00139 bool edited() const;
00140
00141 bool hasMarkedText() const;
00142 QString markedText() const;
00143 #if defined(Q_INCOMPATIBLE_3_0_ADDONS)
00144 bool getSelection( int *start, int *end );
00145 void setPasswordChar( QChar c );
00146 QChar passwordChar() const;
00147 #endif
00148
00149 public slots:
00150 virtual void setText( const QString &);
00151
00152 void selectAll();
00153 void deselect();
00154
00155 void clearValidator();
00156
00157 void insert( const QString &);
00158
00159 void clear();
00160
00161 void scrollLeft();
00162 void scrollRight();
00163
00164 signals:
00165 void textChanged( const QString &);
00166 void returnPressed();
00167
00168 protected:
00169 bool event( QEvent * );
00170 void mousePressEvent( QMouseEvent * );
00171 void mouseMoveEvent( QMouseEvent * );
00172 void mouseReleaseEvent( QMouseEvent * );
00173 void mouseDoubleClickEvent( QMouseEvent * );
00174 void keyPressEvent( QKeyEvent * );
00175 void focusInEvent( QFocusEvent * );
00176 void focusOutEvent( QFocusEvent * );
00177 void paintEvent( QPaintEvent * );
00178 void resizeEvent( QResizeEvent * );
00179 void leaveEvent( QEvent * );
00180 #ifndef QT_NO_DRAGANDDROP
00181 void dragEnterEvent( QDragEnterEvent * );
00182 void dropEvent( QDropEvent * );
00183 #endif
00184
00185 void repaintArea( int, int );
00186
00187 void keyReleaseEvent( QKeyEvent * );
00188
00189 private slots:
00190 void clipboardChanged();
00191 void blinkSlot();
00192 void dragScrollSlot();
00193
00194
00195
00196
00197
00198 private:
00199
00200 void newMark( int pos, bool copy=TRUE );
00201 void markWord( int pos );
00202 int lastCharVisible() const;
00203 int minMark() const;
00204 int maxMark() const;
00205 int frameW() const;
00206
00207 void init();
00208
00209 QString tbuf;
00210 ScrollableLineEditPrivate * d;
00211 int cursorPos;
00212 int offset;
00213 int maxLen;
00214 int markAnchor;
00215 int markDrag;
00216 bool cursorOn;
00217 bool dragScrolling;
00218 bool scrollingLeft;
00219 int alignmentFlag;
00220 bool ed;
00221
00222 void updateOffset();
00223 int xPosToCursorPos( int ) const;
00224 void blinkOn();
00225 void makePixmap() const;
00226 void undoInternal();
00227 void redoInternal();
00228
00229 private:
00230 #if defined(Q_DISABLE_COPY)
00231 ScrollableLineEdit( const ScrollableLineEdit & );
00232 ScrollableLineEdit &operator=( const ScrollableLineEdit & );
00233 #endif
00234 };
00235
00236 #endif // QT_NO_LINEEDIT
00237
00238 #endif // QLINEEDIT_H