1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.lineedit;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.coreevent;
19 import qt.core.margins;
20 import qt.core.namespace;
21 import qt.core.point;
22 import qt.core.rect;
23 import qt.core.size;
24 import qt.core.string;
25 import qt.core.variant;
26 import qt.gui.event;
27 import qt.gui.icon;
28 import qt.helpers;
29 import qt.widgets.action;
30 import qt.widgets.completer;
31 import qt.widgets.styleoption;
32 import qt.widgets.widget;
33 version(QT_NO_CONTEXTMENU){}else
34     import qt.widgets.menu;
35 version(QT_NO_VALIDATOR){}else
36     import qt.gui.validator;
37 
38 /+ QT_REQUIRE_CONFIG(lineedit);
39 
40 class QMenu; +/
41 extern(C++, class) struct QLineEditPrivate;
42 /+ class QCompleter;
43 class QStyleOptionFrame;
44 class QAbstractSpinBox;
45 class QDateTimeEdit;
46 class QIcon;
47 class QToolButton; +/
48 
49 class /+ Q_WIDGETS_EXPORT +/ QLineEdit : QWidget
50 {
51     mixin(Q_OBJECT);
52 
53     /+ Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
54     Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
55     Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
56     Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
57     Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
58     Q_PROPERTY(QString displayText READ displayText)
59     Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
60     Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
61     Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
62     Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
63     Q_PROPERTY(QString selectedText READ selectedText)
64     Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
65     Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
66     Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
67     Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
68     Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
69     Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
70     Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
71     Q_PROPERTY(bool clearButtonEnabled READ isClearButtonEnabled WRITE setClearButtonEnabled) +/
72 public:
73     enum ActionPosition {
74         LeadingPosition,
75         TrailingPosition
76     }
77     /+ Q_ENUM(ActionPosition) +/
78 
79     /+ explicit +/this(QWidget parent = null);
80     /+ explicit +/this(ref const(QString) , QWidget parent = null);
81     ~this();
82 
83     final QString text() const;
84 
85     final QString displayText() const;
86 
87     final QString placeholderText() const;
88     final void setPlaceholderText(ref const(QString) );
89 
90     final int maxLength() const;
91     final void setMaxLength(int);
92 
93     final void setFrame(bool);
94     final bool hasFrame() const;
95 
96     final void setClearButtonEnabled(bool enable);
97     final bool isClearButtonEnabled() const;
98 
99     enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit }
100     /+ Q_ENUM(EchoMode) +/
101     final EchoMode echoMode() const;
102     final void setEchoMode(EchoMode);
103 
104     final bool isReadOnly() const;
105     final void setReadOnly(bool);
106 
107 /+ #ifndef QT_NO_VALIDATOR +/
108     version(QT_NO_VALIDATOR){}else
109     {
110         final void setValidator(const(QValidator) );
111         final const(QValidator)  validator() const;
112     }
113 /+ #endif
114 
115 #if QT_CONFIG(completer) +/
116     final void setCompleter(QCompleter completer);
117     final QCompleter completer() const;
118 /+ #endif +/
119 
120     override QSize sizeHint() const;
121     override QSize minimumSizeHint() const;
122 
123     final int cursorPosition() const;
124     final void setCursorPosition(int);
125     final int cursorPositionAt(ref const(QPoint) pos);
126 
127     final void setAlignment(/+ Qt:: +/qt.core.namespace.Alignment flag);
128     final /+ Qt:: +/qt.core.namespace.Alignment alignment() const;
129 
130     final void cursorForward(bool mark, int steps = 1);
131     final void cursorBackward(bool mark, int steps = 1);
132     final void cursorWordForward(bool mark);
133     final void cursorWordBackward(bool mark);
134     final void backspace();
135     final void del();
136     final void home(bool mark);
137     final void end(bool mark);
138 
139     final bool isModified() const;
140     final void setModified(bool);
141 
142     final void setSelection(int, int);
143     final bool hasSelectedText() const;
144     final QString selectedText() const;
145     final int selectionStart() const;
146     final int selectionEnd() const;
147     final int selectionLength() const;
148 
149     final bool isUndoAvailable() const;
150     final bool isRedoAvailable() const;
151 
152     final void setDragEnabled(bool b);
153     final bool dragEnabled() const;
154 
155     final void setCursorMoveStyle(/+ Qt:: +/qt.core.namespace.CursorMoveStyle style);
156     final /+ Qt:: +/qt.core.namespace.CursorMoveStyle cursorMoveStyle() const;
157 
158     final QString inputMask() const;
159     final void setInputMask(ref const(QString) inputMask);
160     final bool hasAcceptableInput() const;
161 
162     final void setTextMargins(int left, int top, int right, int bottom);
163     final void setTextMargins(ref const(QMargins) margins);
164 /+ #if QT_DEPRECATED_SINCE(5, 14) +/
165     /+ QT_DEPRECATED_X("use textMargins()") +/
166         final void getTextMargins(int* left, int* top, int* right, int* bottom) const;
167 /+ #endif +/
168     final QMargins textMargins() const;
169 
170 /+ #if QT_CONFIG(action) +/
171     /+ using QWidget::addAction; +/
172     final void addAction(QAction action, ActionPosition position);
173     final QAction addAction(ref const(QIcon) icon, ActionPosition position);
174 /+ #endif +/
175 
176 public /+ Q_SLOTS +/:
177     @QSlot final void setText(ref const(QString) );
178     final void setText(const(QString) text) { setText(text); }
179     @QSlot final void clear();
180     @QSlot final void selectAll();
181     @QSlot final void undo();
182     @QSlot final void redo();
183     version(QT_NO_CLIPBOARD){}else
184     {
185         @QSlot final void cut();
186         /+ void copy() const; +/
187         @QSlot final void paste();
188     }
189 
190 public:
191     final void deselect();
192     final void insert(ref const(QString) );
193     version(QT_NO_CONTEXTMENU){}else
194     {
195         final QMenu createStandardContextMenu();
196     }
197 
198 /+ Q_SIGNALS +/public:
199     @QSignal final void textChanged(ref const(QString) );
200     @QSignal final void textEdited(ref const(QString) );
201     @QSignal final void cursorPositionChanged(int, int);
202     @QSignal final void returnPressed();
203     @QSignal final void editingFinished();
204     @QSignal final void selectionChanged();
205     @QSignal final void inputRejected();
206 
207 protected:
208     override void mousePressEvent(QMouseEvent );
209     override void mouseMoveEvent(QMouseEvent );
210     override void mouseReleaseEvent(QMouseEvent );
211     override void mouseDoubleClickEvent(QMouseEvent );
212     override void keyPressEvent(QKeyEvent );
213     override void focusInEvent(QFocusEvent );
214     override void focusOutEvent(QFocusEvent );
215     override void paintEvent(QPaintEvent );
216 /+ #if QT_CONFIG(draganddrop) +/
217     override void dragEnterEvent(QDragEnterEvent );
218     override void dragMoveEvent(QDragMoveEvent e);
219     override void dragLeaveEvent(QDragLeaveEvent e);
220     override void dropEvent(QDropEvent );
221 /+ #endif +/
222     override void changeEvent(QEvent );
223     version(QT_NO_CONTEXTMENU){}else
224     {
225         override void contextMenuEvent(QContextMenuEvent );
226     }
227 
228     override void inputMethodEvent(QInputMethodEvent );
229     final void initStyleOption(QStyleOptionFrame* option) const;
230 public:
231     override QVariant inputMethodQuery(/+ Qt:: +/qt.core.namespace.InputMethodQuery) const;
232     @QInvokable final QVariant inputMethodQuery(/+ Qt:: +/qt.core.namespace.InputMethodQuery property, QVariant argument) const;
233     override bool event(QEvent );
234 protected:
235     final QRect cursorRect() const;
236 
237 public:
238 
239 private:
240     /+ friend class QAbstractSpinBox; +/
241     /+ friend class QAccessibleLineEdit; +/
242     /+ friend class QComboBox; +/
243     version(QT_KEYPAD_NAVIGATION)
244     {
245         /+ friend class QDateTimeEdit; +/
246     }
247     /+ Q_DISABLE_COPY(QLineEdit) +/
248     /+ Q_DECLARE_PRIVATE(QLineEdit) +/
249     /+ Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate())
250     Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &))
251     Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int))
252 #if QT_CONFIG(completer)
253     Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(const QString &))
254 #endif
255 #ifdef QT_KEYPAD_NAVIGATION
256     Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
257 #endif
258     Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
259     Q_PRIVATE_SLOT(d_func(), void _q_updateNeeded(const QRect &))
260     Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString &))
261     Q_PRIVATE_SLOT(d_func(), void _q_clearButtonClicked()) +/
262 }
263