/
lineeditwidget.h
100 lines (83 loc) · 2.91 KB
/
lineeditwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @file widgets/lineeditwidget.h
*
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBAPPFW_LINEEDITWIDGET_H
#define LIBAPPFW_LINEEDITWIDGET_H
#include "../GuiWidget"
#include <de/shell/AbstractLineEditor>
#include <de/KeyEvent>
namespace de {
/**
* Widget showing a lineedit text and/or image.
*
* As a graphical widget, widget placement and line wrapping is handled in
* terms of pixels rather than characters.
*
* @ingroup guiWidgets
*/
class LIBAPPFW_PUBLIC LineEditWidget : public GuiWidget, public shell::AbstractLineEditor
{
Q_OBJECT
public:
LineEditWidget(String const &name = "");
void setText(String const &lineText) override;
/**
* Sets the text that will be shown in the editor when it is empty.
*
* @param hintText Hint text.
*/
void setEmptyContentHint(String const &hintText);
/**
* Enables or disables the signal emitted when the edit widget receives an
* Enter key. By default, no a signal is emitted (and the key is thus not
* eaten).
*
* @param enterSignal @c true to enable signal and eat event, @c false to
* disable.
*/
void setSignalOnEnter(bool enterSignal);
/**
* Determines where the cursor is currently in view coordinates.
*/
Rectanglei cursorRect() const;
// Events.
void viewResized() override;
void focusGained() override;
void focusLost() override;
void update() override;
void drawContent() override;
bool handleEvent(Event const &event) override;
public:
static KeyModifiers modifiersFromKeyEvent(KeyEvent::Modifiers const &keyMods);
signals:
void enterPressed(QString text);
void editorContentChanged();
protected:
void glInit() override;
void glDeinit() override;
void glMakeGeometry(DefaultVertexBuf::Builder &verts) override;
void updateStyle() override;
int maximumWidth() const override;
void numberOfLinesChanged(int lineCount) override;
void cursorMoved() override;
void contentChanged() override;
void autoCompletionEnded(bool accepted) override;
private:
DENG2_PRIVATE(d)
};
} // namespace de
#endif // LIBAPPFW_LINEEDITWIDGET_H