supertux
control_textbox_int.hpp
1 // SuperTux
2 // Copyright (C) 2020 A. Semphris <semphris@protonmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (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, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_INTERFACE_CONTROL_TEXTBOX_INT_HPP
18 #define HEADER_SUPERTUX_INTERFACE_CONTROL_TEXTBOX_INT_HPP
19 
20 #include "interface/control_textbox.hpp"
21 
23 {
24 public:
26 
27  virtual void update(float dt_sec) override;
28 
29  int get_value() const { return *m_value; }
30  void set_value(int value) { *m_value = value; revert_value(); }
36  void bind_value(int* value) { m_value = value; revert_value(); }
37 
38 protected:
39  virtual bool parse_value(bool call_on_change = true) override;
40  virtual void revert_value() override;
41 
42 public:
55 
56 private:
57  int* m_value;
58 
59 private:
60  ControlTextboxInt(const ControlTextboxInt&) = delete;
61  ControlTextboxInt& operator=(const ControlTextboxInt&) = delete;
62 };
63 
64 #endif
65 
66 /* EOF */
void bind_value(int *value)
Binds an int to this textbox.
Definition: control_textbox_int.hpp:36
virtual void revert_value() override
Reverts the contents of the char vector to the value of the member variable.
Definition: control_textbox_int.cpp:81
Definition: control_textbox.hpp:26
virtual bool parse_value(bool call_on_change=true) override
Transfers the string into the binded variable, if any.
Definition: control_textbox_int.cpp:38
bool(* m_validate_int)(ControlTextboxInt *, int)
Optional, a function to validate the integer.
Definition: control_textbox_int.hpp:54
Definition: control_textbox_int.hpp:22