PasswordField.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 PASSWORD_FIELD_H
19 #define PASSWORD_FIELD_H
20 
21 #include <SFML/UI/TextField.hpp>
22 
23 namespace sf
24 {
25 namespace ui
26 {
27 
28 class PasswordField : public TextField
29 {
30 public:
31  //CONSTRUCTORS/DESTRUCTORS -------------------------------------------
38  PasswordField();
39 
49  PasswordField(sf::Texture const &texture, sf::Texture const &textureFocused);
50 
60  PasswordField(sf::Texture const &texture, sf::Texture const &textureFocused, sf::Font const &font);
61 
62  virtual ~PasswordField();
63  //--------------------------------------------------------------------
64 
65  //METHODS ------------------------------------------------------------
66 protected:
78  virtual bool insertText(sf::Uint32 text, unsigned int index);
79 
90  virtual bool deleteText(unsigned int index);
91 
97  void replaceTextDisplayed();
98  //--------------------------------------------------------------------
99 
100  //GETTERS/SETTERS ----------------------------------------------------
101 public:
102 
108  const sf::String& getPassword() const;
109 
118  void setPassword(sf::String const &password);
119 
120  //--------------------------------------------------------------------
121 
122  //FIELDS -------------------------------------------------------------
123 protected:
124  sf::String m_password;
125  //--------------------------------------------------------------------
126 };
127 
128 }
129 }
130 
138 
139 #endif
virtual bool deleteText(unsigned int index)
Delete the char at the given index Trigger a TextDeletedEvent.
PasswordField()
Creates an empty password field without texture, font ...
A text field which stores a text.
Definition: TextField.hpp:30
void replaceTextDisplayed()
Replace the TextField's chars by '•'.
virtual bool insertText(sf::Uint32 text, unsigned int index)
Insert a char at the given index Trigger a TextEnteredEvent.
A text field which stores a password.
const sf::String & getPassword() const
void setPassword(sf::String const &password)
Sets the password of the component Don't forget to set the font.