| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef QLINEEDIT_H | 
|---|
| 43 | #define QLINEEDIT_H | 
|---|
| 44 |  | 
|---|
| 45 | #include <QtGui/qframe.h> | 
|---|
| 46 | #include <QtCore/qstring.h> | 
|---|
| 47 |  | 
|---|
| 48 | QT_BEGIN_HEADER | 
|---|
| 49 |  | 
|---|
| 50 | QT_BEGIN_NAMESPACE | 
|---|
| 51 |  | 
|---|
| 52 | QT_MODULE(Gui) | 
|---|
| 53 |  | 
|---|
| 54 | #ifndef QT_NO_LINEEDIT | 
|---|
| 55 |  | 
|---|
| 56 | class QValidator; | 
|---|
| 57 | class QMenu; | 
|---|
| 58 | class QLineEditPrivate; | 
|---|
| 59 | class QCompleter; | 
|---|
| 60 | class QStyleOptionFrame; | 
|---|
| 61 | class QAbstractSpinBox; | 
|---|
| 62 | class QDateTimeEdit; | 
|---|
| 63 |  | 
|---|
| 64 | class Q_GUI_EXPORT QLineEdit : public QWidget | 
|---|
| 65 | { | 
|---|
| 66 | Q_OBJECT | 
|---|
| 67 |  | 
|---|
| 68 | Q_ENUMS(EchoMode) | 
|---|
| 69 | Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask) | 
|---|
| 70 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true) | 
|---|
| 71 | Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength) | 
|---|
| 72 | Q_PROPERTY(bool frame READ hasFrame WRITE setFrame) | 
|---|
| 73 | Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode) | 
|---|
| 74 | Q_PROPERTY(QString displayText READ displayText) | 
|---|
| 75 | Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition) | 
|---|
| 76 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) | 
|---|
| 77 | Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false) | 
|---|
| 78 | Q_PROPERTY(bool hasSelectedText READ hasSelectedText) | 
|---|
| 79 | Q_PROPERTY(QString selectedText READ selectedText) | 
|---|
| 80 | Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled) | 
|---|
| 81 | Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) | 
|---|
| 82 | Q_PROPERTY(bool undoAvailable READ isUndoAvailable) | 
|---|
| 83 | Q_PROPERTY(bool redoAvailable READ isRedoAvailable) | 
|---|
| 84 | Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) | 
|---|
| 85 |  | 
|---|
| 86 | public: | 
|---|
| 87 | explicit QLineEdit(QWidget* parent=0); | 
|---|
| 88 | explicit QLineEdit(const QString &, QWidget* parent=0); | 
|---|
| 89 | #ifdef QT3_SUPPORT | 
|---|
| 90 | QT3_SUPPORT_CONSTRUCTOR QLineEdit(QWidget* parent, const char* name); | 
|---|
| 91 | QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, QWidget* parent, const char* name); | 
|---|
| 92 | QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, const QString &, QWidget* parent=0, const char* name=0); | 
|---|
| 93 | #endif | 
|---|
| 94 | ~QLineEdit(); | 
|---|
| 95 |  | 
|---|
| 96 | QString text() const; | 
|---|
| 97 |  | 
|---|
| 98 | QString displayText() const; | 
|---|
| 99 |  | 
|---|
| 100 | int maxLength() const; | 
|---|
| 101 | void setMaxLength(int); | 
|---|
| 102 |  | 
|---|
| 103 | void setFrame(bool); | 
|---|
| 104 | bool hasFrame() const; | 
|---|
| 105 |  | 
|---|
| 106 | enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit }; | 
|---|
| 107 | EchoMode echoMode() const; | 
|---|
| 108 | void setEchoMode(EchoMode); | 
|---|
| 109 |  | 
|---|
| 110 | bool isReadOnly() const; | 
|---|
| 111 | void setReadOnly(bool); | 
|---|
| 112 |  | 
|---|
| 113 | #ifndef QT_NO_VALIDATOR | 
|---|
| 114 | void setValidator(const QValidator *); | 
|---|
| 115 | const QValidator * validator() const; | 
|---|
| 116 | #endif | 
|---|
| 117 |  | 
|---|
| 118 | #ifndef QT_NO_COMPLETER | 
|---|
| 119 | void setCompleter(QCompleter *completer); | 
|---|
| 120 | QCompleter *completer() const; | 
|---|
| 121 | #endif | 
|---|
| 122 |  | 
|---|
| 123 | QSize sizeHint() const; | 
|---|
| 124 | QSize minimumSizeHint() const; | 
|---|
| 125 |  | 
|---|
| 126 | int cursorPosition() const; | 
|---|
| 127 | void setCursorPosition(int); | 
|---|
| 128 | int cursorPositionAt(const QPoint &pos); | 
|---|
| 129 |  | 
|---|
| 130 | void setAlignment(Qt::Alignment flag); | 
|---|
| 131 | Qt::Alignment alignment() const; | 
|---|
| 132 |  | 
|---|
| 133 | void cursorForward(bool mark, int steps = 1); | 
|---|
| 134 | void cursorBackward(bool mark, int steps = 1); | 
|---|
| 135 | void cursorWordForward(bool mark); | 
|---|
| 136 | void cursorWordBackward(bool mark); | 
|---|
| 137 | void backspace(); | 
|---|
| 138 | void del(); | 
|---|
| 139 | void home(bool mark); | 
|---|
| 140 | void end(bool mark); | 
|---|
| 141 |  | 
|---|
| 142 | bool isModified() const; | 
|---|
| 143 | void setModified(bool); | 
|---|
| 144 |  | 
|---|
| 145 | void setSelection(int, int); | 
|---|
| 146 | bool hasSelectedText() const; | 
|---|
| 147 | QString selectedText() const; | 
|---|
| 148 | int selectionStart() const; | 
|---|
| 149 |  | 
|---|
| 150 | bool isUndoAvailable() const; | 
|---|
| 151 | bool isRedoAvailable() const; | 
|---|
| 152 |  | 
|---|
| 153 | void setDragEnabled(bool b); | 
|---|
| 154 | bool dragEnabled() const; | 
|---|
| 155 |  | 
|---|
| 156 | QString inputMask() const; | 
|---|
| 157 | void setInputMask(const QString &inputMask); | 
|---|
| 158 | bool hasAcceptableInput() const; | 
|---|
| 159 |  | 
|---|
| 160 | void setTextMargins(int left, int top, int right, int bottom); | 
|---|
| 161 | void getTextMargins(int *left, int *top, int *right, int *bottom) const; | 
|---|
| 162 |  | 
|---|
| 163 | public Q_SLOTS: | 
|---|
| 164 | void setText(const QString &); | 
|---|
| 165 | void clear(); | 
|---|
| 166 | void selectAll(); | 
|---|
| 167 | void undo(); | 
|---|
| 168 | void redo(); | 
|---|
| 169 | #ifndef QT_NO_CLIPBOARD | 
|---|
| 170 | void cut(); | 
|---|
| 171 | void copy() const; | 
|---|
| 172 | void paste(); | 
|---|
| 173 | #endif | 
|---|
| 174 |  | 
|---|
| 175 | public: | 
|---|
| 176 | void deselect(); | 
|---|
| 177 | void insert(const QString &); | 
|---|
| 178 | #ifndef QT_NO_CONTEXTMENU | 
|---|
| 179 | QMenu *createStandardContextMenu(); | 
|---|
| 180 | #endif | 
|---|
| 181 |  | 
|---|
| 182 | Q_SIGNALS: | 
|---|
| 183 | void textChanged(const QString &); | 
|---|
| 184 | void textEdited(const QString &); | 
|---|
| 185 | void cursorPositionChanged(int, int); | 
|---|
| 186 | void returnPressed(); | 
|---|
| 187 | void editingFinished(); | 
|---|
| 188 | void selectionChanged(); | 
|---|
| 189 |  | 
|---|
| 190 | protected: | 
|---|
| 191 | void mousePressEvent(QMouseEvent *); | 
|---|
| 192 | void mouseMoveEvent(QMouseEvent *); | 
|---|
| 193 | void mouseReleaseEvent(QMouseEvent *); | 
|---|
| 194 | void mouseDoubleClickEvent(QMouseEvent *); | 
|---|
| 195 | void keyPressEvent(QKeyEvent *); | 
|---|
| 196 | void focusInEvent(QFocusEvent *); | 
|---|
| 197 | void focusOutEvent(QFocusEvent *); | 
|---|
| 198 | void paintEvent(QPaintEvent *); | 
|---|
| 199 | #ifndef QT_NO_DRAGANDDROP | 
|---|
| 200 | void dragEnterEvent(QDragEnterEvent *); | 
|---|
| 201 | void dragMoveEvent(QDragMoveEvent *e); | 
|---|
| 202 | void dragLeaveEvent(QDragLeaveEvent *e); | 
|---|
| 203 | void dropEvent(QDropEvent *); | 
|---|
| 204 | #endif | 
|---|
| 205 | void changeEvent(QEvent *); | 
|---|
| 206 | #ifndef QT_NO_CONTEXTMENU | 
|---|
| 207 | void contextMenuEvent(QContextMenuEvent *); | 
|---|
| 208 | #endif | 
|---|
| 209 | #ifdef QT3_SUPPORT | 
|---|
| 210 | inline QT3_SUPPORT void repaintArea(int, int) { update(); } | 
|---|
| 211 | #endif | 
|---|
| 212 |  | 
|---|
| 213 | void inputMethodEvent(QInputMethodEvent *); | 
|---|
| 214 | void initStyleOption(QStyleOptionFrame *option) const; | 
|---|
| 215 | public: | 
|---|
| 216 | QVariant inputMethodQuery(Qt::InputMethodQuery) const; | 
|---|
| 217 | bool event(QEvent *); | 
|---|
| 218 | protected: | 
|---|
| 219 | QRect cursorRect() const; | 
|---|
| 220 |  | 
|---|
| 221 | public: | 
|---|
| 222 | #ifdef QT3_SUPPORT | 
|---|
| 223 | inline QT3_SUPPORT void clearModified() { setModified(false); } | 
|---|
| 224 | inline QT3_SUPPORT void cursorLeft(bool mark, int steps = 1) { cursorForward(mark, -steps); } | 
|---|
| 225 | inline QT3_SUPPORT void cursorRight(bool mark, int steps = 1) { cursorForward(mark, steps); } | 
|---|
| 226 | QT3_SUPPORT bool validateAndSet(const QString &, int, int, int); | 
|---|
| 227 | inline QT3_SUPPORT bool frame() const { return hasFrame(); } | 
|---|
| 228 | #ifndef QT_NO_VALIDATOR | 
|---|
| 229 | inline QT3_SUPPORT void clearValidator() { setValidator(0); } | 
|---|
| 230 | #endif | 
|---|
| 231 | inline QT3_SUPPORT bool hasMarkedText() const { return hasSelectedText(); } | 
|---|
| 232 | inline QT3_SUPPORT QString markedText() const { return selectedText(); } | 
|---|
| 233 | QT3_SUPPORT bool edited() const; | 
|---|
| 234 | QT3_SUPPORT void setEdited(bool); | 
|---|
| 235 | QT3_SUPPORT int characterAt(int, QChar*) const; | 
|---|
| 236 | QT3_SUPPORT bool getSelection(int *, int *); | 
|---|
| 237 |  | 
|---|
| 238 | QT3_SUPPORT void setFrameRect(QRect) {} | 
|---|
| 239 | QT3_SUPPORT QRect frameRect() const { return QRect(); } | 
|---|
| 240 | enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel, | 
|---|
| 241 | HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel, | 
|---|
| 242 | PopupPanel, LineEditPanel, TabWidgetPanel, MShape }; | 
|---|
| 243 | QT3_SUPPORT void setFrameShadow(DummyFrame) {} | 
|---|
| 244 | QT3_SUPPORT DummyFrame frameShadow() const { return Plain; } | 
|---|
| 245 | QT3_SUPPORT void setFrameShape(DummyFrame) {} | 
|---|
| 246 | QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; } | 
|---|
| 247 | QT3_SUPPORT void setFrameStyle(int) {} | 
|---|
| 248 | QT3_SUPPORT int frameStyle() const  { return 0; } | 
|---|
| 249 | QT3_SUPPORT int frameWidth() const { return 0; } | 
|---|
| 250 | QT3_SUPPORT void setLineWidth(int) {} | 
|---|
| 251 | QT3_SUPPORT int lineWidth() const { return 0; } | 
|---|
| 252 | QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); } | 
|---|
| 253 | QT3_SUPPORT int margin() const | 
|---|
| 254 | { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy);  return margin; } | 
|---|
| 255 | QT3_SUPPORT void setMidLineWidth(int) {} | 
|---|
| 256 | QT3_SUPPORT int midLineWidth() const { return 0; } | 
|---|
| 257 |  | 
|---|
| 258 | Q_SIGNALS: | 
|---|
| 259 | QT_MOC_COMPAT void lostFocus(); | 
|---|
| 260 | #endif | 
|---|
| 261 |  | 
|---|
| 262 | private: | 
|---|
| 263 | friend class QAbstractSpinBox; | 
|---|
| 264 | #ifdef QT_KEYPAD_NAVIGATION | 
|---|
| 265 | friend class QDateTimeEdit; | 
|---|
| 266 | #endif | 
|---|
| 267 | Q_DISABLE_COPY(QLineEdit) | 
|---|
| 268 | Q_DECLARE_PRIVATE(QLineEdit) | 
|---|
| 269 | Q_PRIVATE_SLOT(d_func(), void _q_clipboardChanged()) | 
|---|
| 270 | Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate()) | 
|---|
| 271 | Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected()) | 
|---|
| 272 | #ifndef QT_NO_COMPLETER | 
|---|
| 273 | Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString)) | 
|---|
| 274 | #endif | 
|---|
| 275 | }; | 
|---|
| 276 |  | 
|---|
| 277 | #endif // QT_NO_LINEEDIT | 
|---|
| 278 |  | 
|---|
| 279 | QT_END_NAMESPACE | 
|---|
| 280 |  | 
|---|
| 281 | QT_END_HEADER | 
|---|
| 282 |  | 
|---|
| 283 | #endif // QLINEEDIT_H | 
|---|