-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBox.hpp
More file actions
157 lines (135 loc) · 3.64 KB
/
TextBox.hpp
File metadata and controls
157 lines (135 loc) · 3.64 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
** EPITECH PROJECT, 2018
** arcade
** File description:
** arcade
*/
/*!
* @file TextBox.hpp
* @brief TextBox class, similar to a text rectangle
* @authors https://github.com/EPITECH-Strasbourg-2021/CPP-Arcade-Spec
*
* Class used by games and graphic libraries, similar to a text rectangle.
* All functions must be implemented correctly for libraries to function properly.
*
*/
#pragma once
#include <string>
#include "Color.hpp"
#include "Vect.hpp"
/*!
* @namespace Arcade
* @brief Arcade project namespace
*/
namespace Arcade {
/*!
* @class TextBox
* @brief TextBox class
*
* Class used to represent a rectangle of text
*
*/
class TextBox {
public:
/*!
* @brief TextBox class's constructor
* @param text : characters to be apply on the textBox
* @param pos : Vect<size_t> containing both x and y offsets. Used to place the textBox on the rendering support
* @param fontSize : size of the text
* @param color : color of the text
* @param backgroundColor : background color of the text
*
* Creates a new textBox class instance.
* The first text argument defines the value of the text within the textBox.
* The Vect<size_t> pos argument defines the coordinates
* of the textBox's position on the rendering support.
* It will be the offset applied when rendering it.
* The third fontSize argument defines the size in which the text should be printed.
* The color's argument defines in which color the characters will be printed.
* The backgroundColor's argument defines the background color of the characters.
*/
TextBox(std::string const &text, Vect<size_t> pos,
size_t fontSize = 30,
Color color = Color(255, 255, 255, 255),
Color backgroundColor = Color(0, 0, 0, 255));
/*!
* @brief PixelBox class's destructor
*/
~TextBox() = default;
/*!
* @brief TextBox text's value's getter
* @return the value of the text within textBox
*/
const std::string &getValue() const;
/*!
* @brief Sets the textBox text's value
* @param text : new value to assign
*/
void setValue(std::string const &text);
/*!
* @brief TextBox positions's getter
* @return a Vect<size_t> containing the offsetX (x) and the offsetY (y) of the textBox.
*/
Vect<size_t> getPos() const;
/*!
* @brief TextBox positions's setter
* @param pos : new positions of the textBox
*
* Takes both new positions as parameter, within a Vect<size_t>
*
*/
void setPos(Vect<size_t> pos);
/*!
* @brief TextBox X offset's getter
*/
size_t getX() const;
/*!
* @brief TextBox Y offset's getter
*/
size_t getY() const;
/*!
* @brief TextBox X offset's setter
*/
void setX(size_t x);
/*!
* @brief TextBox Y offset's setter
*/
void setY(size_t y);
/*!
* @brief TextBox's font size's getter
* @return the font size
*/
size_t getFontSize() const;
/*!
* @brief TextBox's font size's setter
* @param size : new font size to be assigned
*/
void setFontSize(size_t size);
/*!
* @brief TextBox's text color's getter
* @return the textBox's text's color
*/
Color getColor() const;
/*!
* @brief TextBox's text color's setter
* @param color : new color to apply to text
*/
void setColor(Color color);
/*!
* @brief TextBox's text background color's getter
* @return the textBox's text's background color
*/
Color getBackgroundColor() const;
/*!
* @brief TextBox's text background color's setter
* @param color : new background color to apply to text
*/
void setBackgroundColor(Color color);
private:
std::string _value;
Vect<size_t> _pos;
size_t _size;
Color _color;
Color _bgColor;
};
};