libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
button.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 TuiButton : public TuiWidget {
22 PROMEKI_OBJECT(TuiButton, TuiWidget)
23 public:
24 TuiButton(const String &text = String(), ObjectBase *parent = nullptr);
25 ~TuiButton() override;
26
28 void setText(const String &text);
29
31 const String &text() const { return _text; }
32
33 Size2Di32 sizeHint() const override;
34 Size2Di32 minimumSizeHint() const override;
35
37 PROMEKI_SIGNAL(clicked)
38
39 protected:
40 void paintEvent(TuiPaintEvent *e) override;
41 void keyEvent(KeyEvent *e) override;
42 void mouseEvent(MouseEvent *e) override;
43 void focusInEvent(Event *e) override;
44 void focusOutEvent(Event *e) override;
45
46 private:
47 String _text;
48 bool _pressed = false;
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
Event delivered for mouse input.
Definition mouseevent.h:23
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
Clickable button with text label.
Definition button.h:21
void keyEvent(KeyEvent *e) override
Called on keyboard input. Override in subclasses.
Size2Di32 sizeHint() const override
Returns the preferred size. Override in subclasses.
const String & text() const
Returns the button text.
Definition button.h:31
void focusOutEvent(Event *e) override
Called when the widget loses focus.
void mouseEvent(MouseEvent *e) override
Called on mouse input. Override in subclasses.
void setText(const String &text)
Sets the button text.
Size2Di32 minimumSizeHint() const override
Returns the minimum size hint. Override in subclasses.
void paintEvent(TuiPaintEvent *e) override
Emitted when the button is activated.
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
#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