WhitelistTextFieldModel.hpp
1 /*
2  * Copyright © 2013 mathdu07
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef WITHELISTTEXTFIELDMODEL_H_
19 #define WITHELISTTEXTFIELDMODEL_H_
20 
21 #include <SFML/UI/Model/TextFieldModel.hpp>
22 #include <set>
23 #include <vector>
24 
25 namespace sf
26 {
27 namespace ui
28 {
29 
31 {
32  //CONSTRUCTORS/DESTRUCTORS -------------------------------------------
33 public:
41 
42  virtual ~WhitelistTextFieldModel();
43  //--------------------------------------------------------------------
44 
45  //METHODS ------------------------------------------------------------
46 public:
54  virtual bool isCharAllowed(sf::Uint32 c) const;
55 
63  void addCharAllowed(sf::Uint32 c);
64 
72  void rmCharAllowed(sf::Uint32 c);
73  //--------------------------------------------------------------------
74 
75  //GETTERS/SETTERS ----------------------------------------------------
76 public:
82  std::vector<sf::Uint32> getCharsAllowed() const;
83  //--------------------------------------------------------------------
84 
85  //FIELDS -------------------------------------------------------------
86 protected:
87  std::set<sf::Uint32> m_whitelist;
88  //--------------------------------------------------------------------
89 };
90 
91 } /* namespace ui */
92 } /* namespace sf */
93 #endif /* WHITELISTTEXTFIELDMODEL_H_ */
94 
void rmCharAllowed(sf::Uint32 c)
Remove a character to the whitelist.
WhitelistTextFieldModel()
Creates a text field model that allows only character present in the whitelist Notice that the whitel...
A textfield model that allows some chars.
virtual bool isCharAllowed(sf::Uint32 c) const
The abstract class that defines what can be typed into the text field.
void addCharAllowed(sf::Uint32 c)
Add a character to the whitelist.
std::vector< sf::Uint32 > getCharsAllowed() const