CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UITextField.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "UIControl.hpp"
11
14
15namespace CeresEngine {
16
17 class UITextField : public UIControl {
18 private:
21
24
27
28 public:
31
32 public:
34 explicit UITextField(const String& text) : UITextField(kDefaultFrame, text) {}
35 explicit UITextField(const UIRect& frame) : UITextField(frame, ""){};
36 explicit UITextField(const UIRect& frame, const String& text);
37 ~UITextField() override;
38
39 public:
41 [[nodiscard]] const String& getText() const { return mText; }
42
44 void setText(const String& text);
45
47 [[nodiscard]] const HFont& getFont() const { return mFont; }
48
50 void setFont(HFont font);
51
52 public: // UIView
54 [[nodiscard]] bool needsPanelToBecomeKey() const override { return true; }
55
58
60 void layoutSubviews() override;
61
63 void draw(UIGraphicsContext& context, const UIRect& dirtyRect) override;
64
65 public: // UIResponder
67 void keyDown(const UIKeyEvent& event) override;
68
69 private:
72
73 private:
78 };
79
80} // namespace CeresEngine
An object that represents a graphics context.
Definition GraphicsContext.hpp:45
Base template for the event class.
Definition Event.hpp:27
An object that coordinates the layout and display of text characters.
Definition TextLayoutManager.hpp:74
A definition of the fundamental behavior for controls, which are specialized views that notify your a...
Definition UIControl.hpp:30
Definition UITextField.hpp:17
void setFont(HFont font)
The font to be used when rendering the text field.
String mText
The text currently shown in the text field.
Definition UITextField.hpp:20
static const UIColorAppearanceProperty innerBorderColorProperty
Definition UITextField.hpp:76
TextLayoutManager mLayoutManager
The manager that layouts text on the text field.
Definition UITextField.hpp:26
void setText(const String &text)
The text currently shown in the text field.
UITextField(const UIRect &frame)
Definition UITextField.hpp:35
HFont mFont
The font to be used when rendering the text field.
Definition UITextField.hpp:23
static const UIColorAppearanceProperty backgroundColorProperty
Definition UITextField.hpp:75
bool needsPanelToBecomeKey() const override
The default value of this property is false.
Definition UITextField.hpp:54
static const UIColorAppearanceProperty highlightColorProperty
Definition UITextField.hpp:77
static const UIColorAppearanceProperty borderColorProperty
Definition UITextField.hpp:74
const HFont & getFont() const
The font to be used when rendering the text field.
Definition UITextField.hpp:47
UITextField(const UIRect &frame, const String &text)
void layoutSubviews() override
Lays out subviews.
UITextField(const String &text)
Definition UITextField.hpp:34
void draw(UIGraphicsContext &context, const UIRect &dirtyRect) override
Displays the view and all its subviews if possible.
UISize getIntrinsicContentSize() const override
The natural size for the receiving view, considering only properties of the view itself.
Event< void(const String &)> didChangeValue
A signal dispatched by the button whenever the user clicks it.
Definition UITextField.hpp:30
void updateTextLayout()
Called internally whenever the text layout needs to be updated.
void keyDown(const UIKeyEvent &event) override
Informs the receiver that the user has pressed a key.
UITextField()
Definition UITextField.hpp:33
const String & getText() const
The text currently shown in the text field.
Definition UITextField.hpp:41
static const UIRect kDefaultFrame
A rectangle that represents the default frame set by a view without an explicit frame.
Definition UIView.hpp:296
Definition Application.hpp:19
Size2 UISize
A type that contains width and height values.
Definition UIUtility.hpp:30
Rect2 UIRect
A structure that contains the location and dimensions of a rectangle.
Definition UIUtility.hpp:33
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
A UI appearance property that returns a color.
Definition UIAppearance.hpp:30
Definition UIEvent.hpp:129