-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathkeyboard.h
executable file
·78 lines (55 loc) · 1.62 KB
/
keyboard.h
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
#ifndef _KEYBOARD_H_
#define _KEYBOARD_H_
#include <string>
#include "SDL/SDL.h"
#include "SDL/SDL_ttf.h"
#include "window.h"
#define NB_KEY_SETS 5
class CKeyboard : public CWindow
{
public:
// Constructor
CKeyboard(const std::string &p_inputText);
// Destructor
virtual ~CKeyboard(void);
// Get input text
const std::string &getInputText(void) const;
private:
// Forbidden
CKeyboard(void);
CKeyboard(const CKeyboard &p_source);
const CKeyboard &operator =(const CKeyboard &p_source);
// Key press management
virtual const bool keyPress(const SDL_Event &p_event);
// Key hold management
virtual const bool keyHold(void);
// Draw
virtual void render(const bool p_focus) const;
// Move cursor
const bool moveCursorUp(const bool p_loop);
const bool moveCursorDown(const bool p_loop);
const bool moveCursorLeft(const bool p_loop);
const bool moveCursorRight(const bool p_loop);
// Type a letter
const bool type(const std::string &p_text = "");
// Remove last letter
const bool backspace(void);
// UTF8 character or not
const bool utf8Code(const unsigned char p_c) const;
// The image representing the keyboard
SDL_Surface *m_imageKeyboard;
// The image representing the input text field
SDL_Surface *m_textField;
// The input text
std::string m_inputText;
// The cursor index
unsigned char m_selected;
// The footer
SDL_Surface *m_footer;
// Key sets
std::string m_keySets[NB_KEY_SETS];
unsigned char m_keySet;
// Pointers to resources
TTF_Font *m_font;
};
#endif