supertux
item_intfield.hpp
1 // SuperTux
2 // Copyright (C) 2015 Hume2 <teratux.mail@gmail.com>
3 // 2022 Vankata453
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (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, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef HEADER_SUPERTUX_GUI_ITEM_INTFIELD_HPP
19 #define HEADER_SUPERTUX_GUI_ITEM_INTFIELD_HPP
20 
21 #include "gui/item_textfield.hpp"
22 
23 class ItemIntField final : public ItemTextField
24 {
25 public:
26  ItemIntField(const std::string& text_, int* input_, int id_ = -1, bool positive = false);
27  ~ItemIntField() override;
28 
29  int* number;
30 
32  virtual void on_input_update() override;
33 
34  // Text manipulation and navigation functions
35 
36  virtual void insert_text(const std::string& text, const int left_offset_pos) override;
37 
38 private:
39  std::string m_input;
40  const bool m_positive;
41 
42  void add_char(char c, const int left_offset_pos);
43 
44 private:
45  ItemIntField(const ItemIntField&) = delete;
46  ItemIntField& operator=(const ItemIntField&) = delete;
47 };
48 
49 #endif
50 
51 /* EOF */
Definition: item_textfield.hpp:23
virtual void on_input_update() override
Calls when the input gets updated.
Definition: item_intfield.cpp:73
Definition: item_intfield.hpp:23