TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Classes | Public Member Functions | Public Attributes | List of all members
tgui::EditBox Struct Reference
Inheritance diagram for tgui::EditBox:
tgui::OBJECT tgui::OBJECT_BORDERS tgui::OBJECT_ANIMATION

Classes

struct  Alignment
 The text alignment. More...
 

Public Member Functions

 EditBox ()
 Default constructor. More...
 
 EditBox (const EditBox &copy)
 Copy constructor. More...
 
virtual ~EditBox ()
 Destructor. More...
 
EditBoxoperator= (const EditBox &right)
 Overload of assignment operator. More...
 
virtual bool load (const std::string &pathname)
 Loads the edit box images and optionally a matching text color. More...
 
virtual void setSize (float width, float height)
 Changes the size of the edit box. More...
 
virtual Vector2u getSize () const
 Returns the size of the edit box, unaffected by scaling. More...
 
virtual Vector2f getScaledSize () const
 Returns the size of the edit box, after the scaling transformation. More...
 
virtual std::string getLoadedPathname () const
 Returns the pathname that was used to load the edit box. More...
 
virtual void setText (const sf::String &text)
 Changes the text of the editbox. More...
 
virtual sf::String getText () const
 Returns the text inside the edit box. This text is not affected by the password character. More...
 
virtual void setTextSize (unsigned int textSize)
 Changes the character size of the text. More...
 
virtual unsigned int getTextSize () const
 Returns the character size of the text. More...
 
virtual void setTextFont (const sf::Font &font)
 Changes the font of the text. More...
 
virtual const sf::Font * getTextFont () const
 Returns the font of the text. More...
 
virtual void setPasswordChar (char passwordChar= '\0')
 Sets a password character. More...
 
virtual char getPasswordChar () const
 Returns the password character. More...
 
virtual void setMaximumCharacters (unsigned int maxChars=0)
 Change the character limit. More...
 
virtual unsigned int getMaximumCharacters () const
 Returns the character limit. More...
 
virtual void setBorders (unsigned int leftBorder=0, unsigned int topBorder=0, unsigned int rightBorder=0, unsigned int bottomBorder=0)
 Changes the border width and border height of the edit box. More...
 
virtual void changeColors (const sf::Color &textColor=sf::Color(0, 0, 0), const sf::Color &selectedTextColor=sf::Color(255, 255, 255), const sf::Color &selectedTextBackgroundColor=sf::Color(10, 110, 255), const sf::Color &selectionPointColor=sf::Color(110, 110, 255))
 Changes the colors from the edit box. More...
 
virtual void setTextColor (const sf::Color &textColor)
 Set the text color that will be used inside the edit box. More...
 
virtual void setSelectedTextColor (const sf::Color &selectedTextColor)
 Set the text color of the selected text that will be used inside the edit box. More...
 
virtual void setSelectedTextBackgroundColor (const sf::Color &selectedTextBackgroundColor)
 Set the background color of the selected text that will be used inside the edit box. More...
 
virtual const sf::Color & getTextColor () const
 Get the text color that is currently being used inside the edit box. More...
 
virtual const sf::Color & getSelectedTextColor () const
 Get the text color of the selected text that is currently being used inside the edit box. More...
 
virtual const sf::Color & getSelectedTextBackgroundColor () const
 Get the background color of the selected text that is currently being used inside the edit box. More...
 
virtual void limitTextWidth (bool limitWidth)
 Should the text width be limited or should you be able to type even if the edit box is full? More...
 
virtual void setSelectionPointPosition (unsigned int charactersBeforeSelectionPoint)
 Sets the flickering selection point to after a specific character. More...
 
- Public Member Functions inherited from tgui::OBJECT
 OBJECT ()
 Default constructor. More...
 
 OBJECT (const OBJECT &copy)
 Copy constructor. More...
 
virtual ~OBJECT ()
 Destructor. More...
 
OBJECToperator= (const OBJECT &right)
 Overload of assignment operator. More...
 
virtual void show ()
 Shows the object. More...
 
virtual void hide ()
 Hides the object. More...
 
virtual bool isVisible () const
 Returns true when the object is visible. More...
 
virtual void enable ()
 Enables the object. More...
 
virtual void disable ()
 Disables the object. More...
 
virtual bool isEnabled () const
 Returns true when the object is enabled. More...
 
virtual bool isDisabled () const
 Returns true when the object is disabled. More...
 
virtual bool isLoaded () const
 Returns true when the object is loaded successfully. More...
 
void focus ()
 Focus the object. More...
 
void unfocus ()
 Unfocus the object. More...
 
void focusNextObject ()
 Focuses the next object. More...
 
virtual bool isFocused () const
 Returns true when the object is focused and false otherwise. More...
 
virtual ObjectTypes getObjectType () const
 Returns the type of the object. More...
 
virtual void moveToFront ()
 Places the object before all other objects. More...
 
virtual void moveToBack ()
 Places the object behind all other objects. More...
 
- Public Member Functions inherited from tgui::OBJECT_BORDERS
 OBJECT_BORDERS ()
 Default constructor. More...
 
virtual Vector4u getBorders () const
 Returns the size of the borders as a tgui::Vector4u. More...
 

Public Attributes

sf::Color selectionPointColor
 The color of the flickering selection point. More...
 
unsigned int selectionPointWidth
 The width in pixels of the flickering selection point. More...
 
Alignment::alignments textAlignment
 The text alignment. More...
 

Constructor & Destructor Documentation

tgui::EditBox::EditBox ( )

Default constructor.

tgui::EditBox::EditBox ( const EditBox copy)

Copy constructor.

Parameters
copyInstance to copy
virtual tgui::EditBox::~EditBox ( )
virtual

Destructor.

Member Function Documentation

virtual void tgui::EditBox::changeColors ( const sf::Color &  textColor = sf::Color(0, 0, 0),
const sf::Color &  selectedTextColor = sf::Color(255, 255, 255),
const sf::Color &  selectedTextBackgroundColor = sf::Color(10, 110, 255),
const sf::Color &  selectionPointColor = sf::Color(110, 110, 255) 
)
virtual

Changes the colors from the edit box.

Parameters
textColorThe color of the text
selectedTextColorThe color of the text when it is selected
selectedTextBackgroundColorThe color of the background of the text that is selected
selectionPointColorThe color of the flickering selection point
virtual std::string tgui::EditBox::getLoadedPathname ( ) const
virtual

Returns the pathname that was used to load the edit box.

Returns
Pathname used to load the edit box. When the edit box has not been loaded yet then this function will return an empty string.
virtual unsigned int tgui::EditBox::getMaximumCharacters ( ) const
virtual

Returns the character limit.

Returns
The character limit. The function will return 0 when there is no limit.

There is no character limit by default.

virtual char tgui::EditBox::getPasswordChar ( ) const
virtual

Returns the password character.

Returns
The password character that is currently being used. When no password character is used then this function returns 0.
virtual Vector2f tgui::EditBox::getScaledSize ( ) const
virtual

Returns the size of the edit box, after the scaling transformation.

Returns
The size of the edit box.

Implements tgui::OBJECT.

virtual const sf::Color& tgui::EditBox::getSelectedTextBackgroundColor ( ) const
virtual

Get the background color of the selected text that is currently being used inside the edit box.

Returns
The background color of the selected text that is currently being used.
virtual const sf::Color& tgui::EditBox::getSelectedTextColor ( ) const
virtual

Get the text color of the selected text that is currently being used inside the edit box.

Returns
The selected text color that is currently being used.
virtual Vector2u tgui::EditBox::getSize ( ) const
virtual

Returns the size of the edit box, unaffected by scaling.

Returns
The size of the edit box.

Implements tgui::OBJECT.

virtual sf::String tgui::EditBox::getText ( ) const
virtual

Returns the text inside the edit box. This text is not affected by the password character.

Returns
The text of the edit box.
virtual const sf::Color& tgui::EditBox::getTextColor ( ) const
virtual

Get the text color that is currently being used inside the edit box.

Returns
The text color that is currently being used.
virtual const sf::Font* tgui::EditBox::getTextFont ( ) const
virtual

Returns the font of the text.

Returns
The font that is currently being used.
virtual unsigned int tgui::EditBox::getTextSize ( ) const
virtual

Returns the character size of the text.

Returns
The text size.
virtual void tgui::EditBox::limitTextWidth ( bool  limitWidth)
virtual

Should the text width be limited or should you be able to type even if the edit box is full?

Parameters
limitWidthShould there be a text width limit or not.

When set to true, you will no longer be able to add text when the edit box is full. The default value is false.

virtual bool tgui::EditBox::load ( const std::string &  pathname)
virtual

Loads the edit box images and optionally a matching text color.

Parameters
pathnameThe path to the folder that contains the images. The folder must also contain an info.txt file, which will give more information about the edit box.
Returns
  • true on success
  • false when the pathname is empty
  • false when the info.txt file was not found
  • false when the images couldn't be loaded
EditBox& tgui::EditBox::operator= ( const EditBox right)

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
virtual void tgui::EditBox::setBorders ( unsigned int  leftBorder = 0,
unsigned int  topBorder = 0,
unsigned int  rightBorder = 0,
unsigned int  bottomBorder = 0 
)
virtual

Changes the border width and border height of the edit box.

When the text is autoscaled then it will be drawn within these borders. The borders themselves are invisible. The borders are also used to define the clipping area. Note that these borders are scaled together with the image!

Parameters
leftBorderThe width of the left border
topBorderThe height of the top border
rightBorderThe width of the right border
bottomBorderThe height of the bottom border

Implements tgui::OBJECT_BORDERS.

virtual void tgui::EditBox::setMaximumCharacters ( unsigned int  maxChars = 0)
virtual

Change the character limit.

Parameters
maxCharsThe new character limit. Set it to 0 to disable the limit.

This character limit is disabled by default.

virtual void tgui::EditBox::setPasswordChar ( char  passwordChar = '\0')
virtual

Sets a password character.

Parameters
passwordCharThe new password character. If set to 0 then there is no password character.

When the text width is limited then this function might remove the last characters in the text if they no longer fit in the EditBox. You can avoid this by setting LimitTextWidth to false (which is the default).

See Also
limitTextWidth
virtual void tgui::EditBox::setSelectedTextBackgroundColor ( const sf::Color &  selectedTextBackgroundColor)
virtual

Set the background color of the selected text that will be used inside the edit box.

Parameters
selectedTextBackgroundColorThe new background color.
virtual void tgui::EditBox::setSelectedTextColor ( const sf::Color &  selectedTextColor)
virtual

Set the text color of the selected text that will be used inside the edit box.

Parameters
selectedTextColorThe new text color.
virtual void tgui::EditBox::setSelectionPointPosition ( unsigned int  charactersBeforeSelectionPoint)
virtual

Sets the flickering selection point to after a specific character.

Parameters
charactersBeforeSelectionPointThe new position.

Normally you will not need this function.

virtual void tgui::EditBox::setSize ( float  width,
float  height 
)
virtual

Changes the size of the edit box.

Parameters
widthThe new width of the edit box
heightThe new height of the edit box

Implements tgui::OBJECT.

virtual void tgui::EditBox::setText ( const sf::String &  text)
virtual

Changes the text of the editbox.

Parameters
textThe new text.

The last characters of the text might be removed in the following situations:

  • You have set a character limit and this text contains too much characters.
  • You have limited the text width and the text does not fit inside the EditBox.
See Also
setMaximumCharacters
limitTextWidth
virtual void tgui::EditBox::setTextColor ( const sf::Color &  textColor)
virtual

Set the text color that will be used inside the edit box.

Parameters
textColorThe new text color.
virtual void tgui::EditBox::setTextFont ( const sf::Font &  font)
virtual

Changes the font of the text.

When you don't call this function then the global font will be use. This global font can be changed by changing gloabalFont from the parent.

Parameters
fontThe new font.
virtual void tgui::EditBox::setTextSize ( unsigned int  textSize)
virtual

Changes the character size of the text.

Parameters
textSizeThe new size of the text. If the size is 0 (default) then the text will be scaled to fit in the edit box.

Member Data Documentation

sf::Color tgui::EditBox::selectionPointColor

The color of the flickering selection point.

unsigned int tgui::EditBox::selectionPointWidth

The width in pixels of the flickering selection point.

Alignment::alignments tgui::EditBox::textAlignment

The text alignment.


The documentation for this struct was generated from the following file: