SuperTuxKart
Loading...
Searching...
No Matches
general_text_field_dialog.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2016 SuperTuxKart-Team
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#ifndef HEADER_GENERAL_TEXT_FIELD_DIALOG_HPP
19#define HEADER_GENERAL_TEXT_FIELD_DIALOG_HPP
20
21#include "guiengine/modaldialog.hpp"
22#include "utils/cpp2011.hpp"
23
24#include "irrString.h"
25
26#include <functional>
27
28namespace GUIEngine
29{
30 class TextBoxWidget;
31 class ButtonWidget;
32 class LabelWidget;
33}
34
41{
42private:
43 typedef std::function<void(const irr::core::stringw&)> DismissCallback;
44
45 typedef
47 ValidationCallback;
48
50
51 GUIEngine::TextBoxWidget* m_text_field;
52
53 DismissCallback m_dm_cb;
54
55 ValidationCallback m_val_cb;
56
57 bool m_self_destroy;
58
59public:
60 GeneralTextFieldDialog(const core::stringw& title, DismissCallback dm_cb,
61 ValidationCallback val_cb = []
63 {
64 // No validation if not specify, always go to dismiss callback
65 return true;
66 });
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
70 virtual void onEnterPressedInternal() OVERRIDE;
71 // ------------------------------------------------------------------------
72 virtual void onUpdate(float dt) OVERRIDE;
73 // ------------------------------------------------------------------------
74 GUIEngine::EventPropagation processEvent(const std::string& eventSource)
75 OVERRIDE;
76 // ------------------------------------------------------------------------
77 GUIEngine::TextBoxWidget* getTextField() const { return m_text_field; }
78 // ------------------------------------------------------------------------
79 GUIEngine::LabelWidget* getTitle() const { return m_title; }
80
81};
82
83#endif
A simple label widget.
Definition: label_widget.hpp:36
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:56
A text field widget.
Definition: text_box_widget.hpp:53
A general textfield dialog to do anything based on captured text using callbacks.
Definition: general_text_field_dialog.hpp:41
virtual void onUpdate(float dt) OVERRIDE
Override to be notified of updates.
Definition: general_text_field_dialog.cpp:106
GUIEngine::EventPropagation processEvent(const std::string &eventSource) OVERRIDE
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: general_text_field_dialog.cpp:62
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33