Argentum Online - Cliente
text_input.h
1 #ifndef __TEXT_INPUT_H
2 #define __TEXT_INPUT_H
3 
4 #include <string>
5 
6 #include "../SDL/sdl_text.h"
7 #include "../SDL/sdl_timer.h"
8 #include "SDL2/SDL_ttf.h"
9 
14 class TextInput {
15  private:
16  SDL_Rect render_area;
17  SDLText render_text;
18  bool enabled;
19  SDL_Renderer* renderer;
20  bool render_blink;
21  std::string text;
22  SDL_Color background_color;
23  uint64_t max_len;
24  SDLTimer blink_timer;
25  void render_cursor();
26  void render_background();
27 
28  public:
39  TextInput(SDL_Rect render_area, SDL_Renderer* renderer,
40  SDL_Color font_color, SDL_Color background_color, TTF_Font* font,
41  uint64_t max_len = UINT64_MAX);
42  ~TextInput();
43 
49  void add_characters(const char* characters);
50 
55  void erase();
56 
61  void erase_all();
62 
67  void render();
68 
74  std::string get_text();
75 
80  void toggle();
81 };
82 
83 #endif
TextInput::erase_all
void erase_all()
Borra todo el texto escrito.
Definition: text_input.cpp:111
TextInput::render
void render()
Renderiza el textbox y todo su texto.
Definition: text_input.cpp:87
TextInput::erase
void erase()
Borra un caracter del texto.
Definition: text_input.cpp:29
SDLTimer
Timer basado en la cuenta de SDL.
Definition: sdl_timer.h:9
TextInput::add_characters
void add_characters(const char *characters)
Agrega caracteres al texto.
Definition: text_input.cpp:20
TextInput::TextInput
TextInput(SDL_Rect render_area, SDL_Renderer *renderer, SDL_Color font_color, SDL_Color background_color, TTF_Font *font, uint64_t max_len=UINT64_MAX)
Crea un objeto TextInput.
Definition: text_input.cpp:5
TextInput::get_text
std::string get_text()
Devuelve el texto escrito.
Definition: text_input.cpp:107
SDLText
Objeto de texto de SDL.
Definition: sdl_text.h:13
TextInput::toggle
void toggle()
Activa/desactiva el cursor.
Definition: text_input.cpp:38
TextInput
Input de texto.
Definition: text_input.h:14