-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextBox.hpp
110 lines (72 loc) · 2.64 KB
/
TextBox.hpp
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
#ifndef TEXTBOX_H
#define TEXTBOX_H
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <string.h>
class TextBox{
public:
/* Initialize the private variables */
TextBox();
TextBox(std::string myText, std::string texturePath, std::string fontPath, float sizeX, float sizeY);
/* Return the size of the TextBox*/
sf::Vector2f getSize();
/* The return indicates if the TextBox is
clicked or not*/
bool isClicked();
/* Return true if the TextBox has been clicked */
bool hasBeenClicked();
/* Return the time since the last time the TextBox
has been clicked (returned in a float as seconds)*/
float timeSinceLastClick();
/* Return the position of the TextBox*/
sf::Vector2f getPosition();
/* Set the position of the TextBox */
void setPosition(float x, float y);
void setPosition(sf::Vector2f position);
/*set the Origin of the TextBox*/
void setOrigin(sf::Vector2f origin);
/* Returns the string setted on the text*/
std::string getText();
/* Set the text on the TextBox */
void setTextBestFit(std::string s, float charSize);
/* Returns the characterSize*/
int getCharacterSize();
/* Set the size of the characters of the TextBox text*/
void setCharacterSize(int);
/* Returns the color of the TextBox's text*/
sf::Color getTextColor();
/* Set the color of the TextBox's text*/
void setTextColor(sf::Color c);
/*Set the Font passed as a parameter as the one used by the TextBox*/
void setFont(sf::Font f);
/* Set the Texture that will be used as default TextBox image.
This function takes as parameter the path of the image*/
void setTexture(std::string name);
/*different version taking the reference of texture*/
void setTexture(sf::Texture tex);
/* Draw the TextBox on the window passed as parameter */
void draw(sf::RenderTarget &w);
/* Update the private variables if needed acordingly to the event*/
void handleEvent(sf::Event e);
bool getTextFinished();
/* Set the size passed as parameter */
void setSize(float x, float y);
void setSize(sf::Vector2f size);
private:
bool clicked;
bool is_clicked;
bool textFinished;
sf::Font font;
sf::Text text;
sf::Clock clock;
sf::Sprite sprite;
sf::Texture texture;
float lecturePointer;
std::string totalText;
float time_since_last_click;
std::vector < std::string > boxTexts;
std::string getFractionText(std::string text, int ini, int end);
void setText(float charSize);
};
#endif // TEXTBOX_H