GameKit
0.0.1a
C++ gamedev tools
include
gk
graphics
TextInput.hpp
Go to the documentation of this file.
1
/*
2
* =====================================================================================
3
*
4
* Filename: TextInput.hpp
5
*
6
* Description:
7
*
8
* Created: 22/01/2018 14:35:10
9
*
10
* Author: Quentin Bazin, <quent42340@gmail.com>
11
*
12
* =====================================================================================
13
*/
14
#ifndef GK_TEXTINPUT_HPP_
15
#define GK_TEXTINPUT_HPP_
16
17
#include "
gk/core/SDLHeaders.hpp
"
18
#include "
gk/graphics/RectangleShape.hpp
"
19
#include "
gk/graphics/Text.hpp
"
20
21
namespace
gk
{
22
23
class
TextInput
:
public
IDrawable
,
public
Transformable
{
24
public
:
25
TextInput
();
26
27
void
onEvent
(
const
SDL_Event &event);
28
29
const
std::string &
content
()
const
{
return
m_content
; }
30
31
Vector2f
getSize
()
const
{
return
m_rectText
.
getSize
(); }
32
33
void
setPosition
(
float
x,
float
y);
34
void
setSize
(
u16
width,
u16
height);
35
void
setCharacterLimit
(
u16
characterLimit) {
m_characterLimit
= characterLimit; }
36
void
setContent
(
const
std::string &
content
) {
m_content
=
content
;
m_text
.
setText
(
m_content
+
m_cursor
); }
37
void
setKeyboardSound
(
const
std::string &keyboardSound) {
m_keyboardSound
= keyboardSound; }
38
void
setCursor
(
const
std::string &cursor) {
m_cursor
= cursor;
m_text
.
setText
(
m_content
+
m_cursor
); }
39
40
private
:
41
void
draw
(
RenderTarget
&target,
RenderStates
states)
const override
;
42
43
RectangleShape
m_rectText
;
44
45
Text
m_text
;
46
std::string
m_content
;
47
48
u16
m_characterLimit
= 0;
49
50
std::string
m_keyboardSound
;
51
52
std::string
m_cursor
=
"|"
;
53
};
54
55
}
// namespace gk
56
57
#endif // GK_TEXTINPUT_HPP_
gk::TextInput::TextInput
TextInput()
Definition:
TextInput.cpp:20
SDLHeaders.hpp
gk::TextInput::m_text
Text m_text
Definition:
TextInput.hpp:45
gk::TextInput::setCharacterLimit
void setCharacterLimit(u16 characterLimit)
Definition:
TextInput.hpp:35
gk::TextInput::m_rectText
RectangleShape m_rectText
Definition:
TextInput.hpp:43
gk::TextInput::m_content
std::string m_content
Definition:
TextInput.hpp:46
gk::Text::setText
void setText(const std::string &text)
Definition:
Text.hpp:40
gk
Definition:
AudioPlayer.hpp:21
gk::Text
Definition:
Text.hpp:27
gk::TextInput::getSize
Vector2f getSize() const
Definition:
TextInput.hpp:31
gk::RenderStates
Definition:
RenderStates.hpp:42
Text.hpp
u16
unsigned short u16
Definition:
IntTypes.hpp:22
RectangleShape.hpp
gk::TextInput::setContent
void setContent(const std::string &content)
Definition:
TextInput.hpp:36
gk::TextInput::setPosition
void setPosition(float x, float y)
Definition:
TextInput.cpp:30
gk::Transformable
Definition:
Transformable.hpp:21
gk::RectangleShape
Definition:
RectangleShape.hpp:26
gk::TextInput
Definition:
TextInput.hpp:23
gk::RectangleShape::getSize
Vector2f getSize() const
Definition:
RectangleShape.hpp:39
gk::TextInput::draw
void draw(RenderTarget &target, RenderStates states) const override
Draw the object to a render target.
Definition:
TextInput.cpp:64
gk::TextInput::content
const std::string & content() const
Definition:
TextInput.hpp:29
gk::TextInput::m_cursor
std::string m_cursor
Definition:
TextInput.hpp:52
gk::TextInput::setCursor
void setCursor(const std::string &cursor)
Definition:
TextInput.hpp:38
gk::TextInput::setKeyboardSound
void setKeyboardSound(const std::string &keyboardSound)
Definition:
TextInput.hpp:37
gk::RenderTarget
Definition:
RenderTarget.hpp:27
gk::TextInput::m_keyboardSound
std::string m_keyboardSound
Definition:
TextInput.hpp:50
gk::IDrawable
Abstract base class for objects that can be drawn to a render target.
Definition:
IDrawable.hpp:25
gk::TextInput::setSize
void setSize(u16 width, u16 height)
Definition:
TextInput.cpp:35
gk::TextInput::m_characterLimit
u16 m_characterLimit
Definition:
TextInput.hpp:48
gk::Vector2< float >
gk::TextInput::onEvent
void onEvent(const SDL_Event &event)
Definition:
TextInput.cpp:39
Generated by
1.8.12