libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
lineedit.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <promeki/core/string.h>
12#include <promeki/tui/widget.h>
13
15
21class TuiLineEdit : public TuiWidget {
22 PROMEKI_OBJECT(TuiLineEdit, TuiWidget)
23 public:
24 TuiLineEdit(const String &text = String(), ObjectBase *parent = nullptr);
25 ~TuiLineEdit() override;
26
27 void setText(const String &text);
28 const String &text() const { return _text; }
29
30 void setPlaceholder(const String &text) { _placeholder = text; update(); }
31 const String &placeholder() const { return _placeholder; }
32
33 Size2Di32 sizeHint() const override;
34
35 PROMEKI_SIGNAL(textChanged, const String &)
36 PROMEKI_SIGNAL(returnPressed)
37
38 protected:
39 void paintEvent(TuiPaintEvent *e) override;
40 void keyEvent(KeyEvent *e) override;
41 void focusInEvent(Event *e) override;
42 void focusOutEvent(Event *e) override;
43
44 private:
45 String _text;
46 String _placeholder;
47 int _cursorPos = 0;
48 int _scrollOffset = 0;
49};
50
Base class for the event system.
Definition event.h:29
Event delivered when a key is pressed or released.
Definition keyevent.h:22
Dynamic array container wrapping std::vector.
Definition list.h:40
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Single-line text input widget.
Definition lineedit.h:21
Size2Di32 sizeHint() const override
Returns the preferred size. Override in subclasses.
void keyEvent(KeyEvent *e) override
Called on keyboard input. Override in subclasses.
void focusOutEvent(Event *e) override
Called when the widget loses focus.
void paintEvent(TuiPaintEvent *e) override
Called to paint the widget. Override in subclasses.
void focusInEvent(Event *e) override
Called when the widget gains focus.
Event delivered when a TUI widget needs to repaint.
Definition widget.h:28
Base class for all TUI widgets.
Definition widget.h:88
void update()
Marks the widget as needing a repaint.
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19