SuperTuxKart
Loading...
Searching...
No Matches
screen_keyboard.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2013-2015 SuperTuxKart-Team
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License: or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_SCREEN_KEYBOARD_HPP
20#define HEADER_SCREEN_KEYBOARD_HPP
21
22#include <IGUIButton.h>
23#include <IGUIWindow.h>
24
25#include "guiengine/abstract_top_level_container.hpp"
26#include "guiengine/skin.hpp"
27#include "input/input_manager.hpp"
28#include "utils/leak_check.hpp"
29
30
31class CGUIEditBox;
32
36namespace GUIEngine
37{
38 class ButtonWidget;
39
49 {
50 protected:
51 typedef std::vector<std::vector<std::string> > KeyboardLayout;
52 typedef std::vector<std::vector<int> > KeyboardLayoutProportions;
53 enum ButtonsType
54 {
55 BUTTONS_NONE,
56 BUTTONS_LOWER,
57 BUTTONS_UPPER,
58 BUTTONS_DIGITS,
59 BUTTONS_DIGITS2,
60 BUTTONS_EMOJI
61 };
62 private:
65
69
73
75 unsigned int m_repeat_time;
76
79
82
85
87 irr::gui::IGUIButton* m_back_button;
88
90 ButtonsType m_buttons_type;
91
93 irr::gui::IGUIWindow* m_irrlicht_window;
94
96 irr::core::rect<irr::s32> m_area;
97
99 std::vector<ButtonWidget*> m_buttons;
100
102 InputManager::InputDriverMode m_previous_mode;
103
104 void createButtons();
105 void assignButtons(ButtonsType buttons_type);
106 core::stringw getKeyName(std::string key_id);
107
108 public:
109 LEAK_CHECK()
110
111 ScreenKeyboard(float percent_width, float percent_height,
112 CGUIEditBox* edit_box);
114
115 void init();
116
117 virtual EventPropagation processEvent(const std::string& eventSource);
118
119 static void dismiss();
120 static bool onEscapePressed();
124
126 static bool isActive() {return m_screen_keyboard != NULL;}
127
128 static bool shouldUseScreenKeyboard();
129 static bool hasSystemScreenKeyboard();
130
132 virtual void onUpdate(float dt);
133
134 bool onEvent(const SEvent &event);
135
137 irr::gui::IGUIWindow* getIrrlichtElement() {return m_irrlicht_window;}
138
143 bool isMyIrrChild(irr::gui::IGUIElement* widget) const
144 {return m_irrlicht_window->isMyChild(widget);}
145
147 int getWidth() {return m_area.getWidth();}
148
150 int getHeight() {return m_area.getHeight();}
151
154
155 virtual KeyboardLayoutProportions getKeyboardLayoutProportions() const;
156
157 virtual KeyboardLayout* getKeyboardLayout(ButtonsType bt) const;
158
159 virtual ButtonsType getDefaultButtonsType() const
160 {
161 return BUTTONS_LOWER;
162 }
163 };
164}
165
166#endif
Definition: CGUIEditBox.hpp:32
Represents a GUI widgets container.
Definition: abstract_top_level_container.hpp:43
Class representing a screen keyboard.
Definition: screen_keyboard.hpp:49
ButtonsType m_buttons_type
Remembers currently selected button type.
Definition: screen_keyboard.hpp:90
static bool isActive()
Returns true if keyboard is created.
Definition: screen_keyboard.hpp:126
virtual void onUpdate(float dt)
Override to be notified of updates.
Definition: screen_keyboard.cpp:338
bool m_back_button_pressed
True if backspace button was pressed.
Definition: screen_keyboard.hpp:78
InputManager::InputDriverMode m_previous_mode
Remembered input mode that was used before keyboard creation.
Definition: screen_keyboard.hpp:102
void createButtons()
Creates all button widgets.
Definition: screen_keyboard.cpp:199
static bool shouldUseScreenKeyboard()
A function that determines if (native) screen keyboard should be activated.
Definition: screen_keyboard.cpp:534
CGUIEditBox * m_edit_box
The edit box that is assigned to the keyboard.
Definition: screen_keyboard.hpp:84
static ScreenKeyboard * getCurrent()
Returns pointer to the created keyboard or NULL if keyboard was not created.
Definition: screen_keyboard.hpp:123
unsigned int m_repeat_time
A time for repeat key feature.
Definition: screen_keyboard.hpp:75
static bool hasSystemScreenKeyboard()
Returns true if system screen keyboard is available.
Definition: screen_keyboard.cpp:542
std::vector< ButtonWidget * > m_buttons
Contans the pointers to all button widgets.
Definition: screen_keyboard.hpp:99
float m_percent_width
A value in range of 0.0 to 1.0 that determines width of the screen that is used by the keyboard.
Definition: screen_keyboard.hpp:68
irr::gui::IGUIButton * m_back_button
A button that is used as backspace key.
Definition: screen_keyboard.hpp:87
static bool onEscapePressed()
A function that handles escape pressed event.
Definition: screen_keyboard.cpp:525
irr::gui::IGUIWindow * m_irrlicht_window
Irrlicht window used by the keyboard widget.
Definition: screen_keyboard.hpp:93
irr::core::rect< irr::s32 > m_area
Contains position and dimensions of the keyboard.
Definition: screen_keyboard.hpp:96
bool isMyIrrChild(irr::gui::IGUIElement *widget) const
Checks if the screen keyboard is a parent of the selected item.
Definition: screen_keyboard.hpp:143
static void dismiss()
A function that closes the keyboard.
Definition: screen_keyboard.cpp:516
irr::gui::IGUIWindow * getIrrlichtElement()
Get irrlicht window used by the keyboard widget.
Definition: screen_keyboard.hpp:137
int getHeight()
Returns height of the screen keyboard.
Definition: screen_keyboard.hpp:150
int getWidth()
Returns width of the screen keyboard.
Definition: screen_keyboard.hpp:147
CGUIEditBox * getEditBox()
Returns assigned edit box.
Definition: screen_keyboard.hpp:153
float m_percent_height
A value in range of 0.0 to 1.0 that determines height of the screen that is used by the keyboard.
Definition: screen_keyboard.hpp:72
virtual EventPropagation processEvent(const std::string &eventSource)
A function that handles buttons events.
Definition: screen_keyboard.cpp:426
bool m_schedule_close
True if screen keyboard is going to be closed.
Definition: screen_keyboard.hpp:81
void assignButtons(ButtonsType buttons_type)
A function that allows to select one of the available buttons layout.
Definition: screen_keyboard.cpp:298
void init()
Screen keyboard initialization, needs to be called after new to take into account for runtime polymor...
Definition: screen_keyboard.cpp:153
static ScreenKeyboard * m_screen_keyboard
Global instance of the current screen keyboard.
Definition: screen_keyboard.hpp:64
bool onEvent(const SEvent &event)
A function that handles irrlicht events.
Definition: screen_keyboard.cpp:379
In order to avoid calculating render information every frame, it's stored in a SkinWidgetContainer fo...
Definition: skin.hpp:142
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33