SuperTuxKart
Loading...
Searching...
No Matches
text_box_widget.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2009-2015 Marianne Gagnon
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19
20#ifndef HEADER_TEXTBOX_HPP
21#define HEADER_TEXTBOX_HPP
22
23#include <irrString.h>
24
25#include "guiengine/widget.hpp"
26#include "utils/leak_check.hpp"
27#include "utils/ptr_vector.hpp"
28
29namespace GUIEngine
30{
31 // This enum can allow showing different soft keyboard in android
32 enum TextBoxType: int
33 {
34 TBT_TEXT = 0, /* Normal text input (default) */
35 TBT_CAP_SENTENCES = 1, /* Capitalize the first character of each sentence */
36 TBT_PASSWORD = 2, /* Password input */
37 TBT_NUMBER = 3, /* Number only input */
38 TBT_EMAIL = 4, /* Email input */
39 };
40
42 {
43 public:
44 virtual ~ITextBoxWidgetListener() {}
45 virtual void onTextUpdated() = 0;
46 virtual bool onEnterPressed(const irr::core::stringw& text) { return false; }
47 };
48
52 class TextBoxWidget : public Widget
53 {
56 virtual int getWidthNeededAroundLabel() const { return 10; }
57
60 virtual int getHeightNeededAroundLabel() const { return 10; }
61
62 public:
63
64 LEAK_CHECK()
65
68 {
69 setWithinATextBox(false);
70 }
71
72 void add();
73 void addItem(const char* item);
74
75 virtual EventPropagation focused(const int playerID);
76 virtual void unfocused(const int playerID, Widget* new_focus);
77
78 void addListener(ITextBoxWidgetListener* listener);
79 void clearListeners();
80
81 irr::core::stringw getText() const;
82 void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
83 void setTextBoxType(TextBoxType t);
84 virtual void elementRemoved();
85
87 virtual void setActive(bool active=true);
88
89 virtual EventPropagation onActivationInput(const int playerID);
90 virtual EventPropagation rightPressed(const int playerID);
91 virtual EventPropagation leftPressed (const int playerID);
92
93 };
94}
95
96#endif
Definition: text_box_widget.hpp:42
A text field widget.
Definition: text_box_widget.hpp:53
virtual void elementRemoved()
Called when irrLicht widgets cleared.
Definition: text_box_widget.cpp:200
virtual void setActive(bool active=true)
Override method from base class Widget.
Definition: text_box_widget.cpp:214
virtual int getWidthNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: text_box_widget.hpp:56
virtual int getHeightNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: text_box_widget.hpp:60
virtual EventPropagation rightPressed(const int playerID)
called when right key is pressed and focus is on widget.
Definition: text_box_widget.cpp:241
virtual void unfocused(const int playerID, Widget *new_focus)
override in children if you need to know when the widget is unfocused.
Definition: text_box_widget.cpp:189
void add()
Create and add the irrLicht widget(s) associated with this object.
Definition: text_box_widget.cpp:112
virtual EventPropagation leftPressed(const int playerID)
called when left key is pressed and focus is on widget.
Definition: text_box_widget.cpp:251
virtual EventPropagation focused(const int playerID)
override in children if you need to know when the widget is focused.
Definition: text_box_widget.cpp:177
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33