TGUI  v0.6.10
Classes | Public Types | Public Member Functions | List of all members
tgui::EditBox Class Reference
Inheritance diagram for tgui::EditBox:
tgui::ClickableWidget tgui::WidgetBorders tgui::Widget tgui::Transformable tgui::CallbackManager

Classes

struct  Alignment
 The text alignment. More...
 

Public Types

- Public Types inherited from tgui::ClickableWidget
- Public Types inherited from tgui::Widget

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...
 
bool load (const std::string &configFileFilename, const std::string &sectionName="EditBox")
 Loads the widget. More...
 
const std::string & getLoadedConfigFile () const
 Returns the filename of the config file that was used to load the widget. More...
 
virtual void setPosition (float x, float y)
 Set the position of the widget. More...
 
void setSize (float width, float height)
 Changes the size of the edit box. More...
 
void setText (const sf::String &text)
 Changes the text of the editbox. More...
 
sf::String getText () const
 Returns the text inside the edit box. This text is not affected by the password character. More...
 
void setTextSize (unsigned int textSize)
 Changes the character size of the text. More...
 
unsigned int getTextSize () const
 Returns the character size of the text. More...
 
void setTextFont (const sf::Font &font)
 Changes the font of the text. More...
 
const sf::Font * getTextFont () const
 Returns the font of the text. More...
 
void setPasswordCharacter (char passwordChar= '\0')
 Sets a password character. More...
 
char getPasswordCharacter () const
 Returns the password character. More...
 
void setMaximumCharacters (unsigned int maxChars=0)
 Change the character limit. More...
 
unsigned int getMaximumCharacters () const
 Returns the character limit. More...
 
void setAlignment (Alignment::Alignments alignment)
 Change the text alignment. More...
 
Alignment::Alignments getAlignment ()
 Get the current text alignment. 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...
 
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...
 
void setTextColor (const sf::Color &textColor)
 Set the text color that will be used inside the edit box. More...
 
void setSelectedTextColor (const sf::Color &selectedTextColor)
 Set the text color of the selected text that will be used inside the edit box. More...
 
void setSelectedTextBackgroundColor (const sf::Color &selectedTextBackgroundColor)
 Set the background color of the selected text that will be used inside the edit box. More...
 
void setSelectionPointColor (const sf::Color &selectionPointColor)
 Set the color that will be used inside the edit box for the flickering selection point. More...
 
const sf::Color & getTextColor () const
 Get the text color that is currently being used inside the edit box. More...
 
const sf::Color & getSelectedTextColor () const
 Get the text color of the selected text that is currently being used inside the edit box. More...
 
const sf::Color & getSelectedTextBackgroundColor () const
 Get the background color of the selected text that is currently being used inside the edit box. More...
 
const sf::Color & getSelectionPointColor () const
 Get the color that is currently being used inside the edit box for the flickering selection point. More...
 
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...
 
void setSelectionPointPosition (unsigned int charactersBeforeSelectionPoint)
 Sets the flickering selection point to after a specific character. More...
 
void setSelectionPointWidth (unsigned int width=2)
 This will change the width of the selection point. More...
 
unsigned int getSelectionPointWidth () const
 Returns the width of the selection point. More...
 
void setNumbersOnly (bool numbersOnly=true)
 Changes whether the edit box accepts all characters or only numeric input. More...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency of the widget. More...
 
- Public Member Functions inherited from tgui::ClickableWidget
 ClickableWidget ()
 Default constructor. More...
 
 ClickableWidget (const ClickableWidget &copy)
 Copy constructor. More...
 
virtual ~ClickableWidget ()
 Destructor. More...
 
ClickableWidgetoperator= (const ClickableWidget &right)
 Overload of assignment operator. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the widget. More...
 
- Public Member Functions inherited from tgui::Widget
 Widget ()
 Default constructor. More...
 
 Widget (const Widget &copy)
 Copy constructor. More...
 
virtual ~Widget ()
 Destructor. More...
 
Widgetoperator= (const Widget &right)
 Overload of assignment operator. More...
 
virtual sf::Vector2f getAbsolutePosition () const
 Get the absolute position of the widget on the screen. More...
 
virtual void show ()
 Shows the widget. More...
 
virtual void hide ()
 Hides the widget. More...
 
bool isVisible () const
 Returns true when the widget is visible. More...
 
virtual void enable ()
 Enables the widget. More...
 
virtual void disable ()
 Disables the widget. More...
 
bool isEnabled () const
 Returns true when the widget is enabled. More...
 
bool isDisabled () const
 Returns true when the widget is disabled. More...
 
bool isLoaded () const
 Returns true when the widget is loaded successfully. More...
 
virtual void focus ()
 Focus the widget. More...
 
virtual void unfocus ()
 Unfocus the widget. More...
 
bool isFocused () const
 Returns true when the widget is focused and false otherwise. More...
 
WidgetTypes getWidgetType () const
 Returns the type of the widget. More...
 
ContainergetParent () const
 Returns a pointer to the parent widget. More...
 
unsigned char getTransparency () const
 Returns the transparency of the widget. More...
 
virtual void moveToFront ()
 Places the widget before all other widgets. More...
 
virtual void moveToBack ()
 Places the widget behind all other widgets. More...
 
void setCallbackId (unsigned int callbackId)
 Changes the callback id of the widget. More...
 
unsigned int getCallbackId ()
 Returns the callback id of the widget. More...
 
- Public Member Functions inherited from tgui::Transformable
 Transformable ()
 Default constructor. More...
 
virtual ~Transformable ()
 Destructor. More...
 
void setPosition (const sf::Vector2f &position)
 set the position of the widget More...
 
const sf::Vector2f & getPosition () const
 get the position of the widget More...
 
void move (float offsetX, float offsetY)
 Move the widget by a given offset. More...
 
void move (const sf::Vector2f &offset)
 Move the widget by a given offset. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the entire size that the widget is using. More...
 
void scale (float factorX, float factorY)
 Scale the widget. More...
 
void scale (const sf::Vector2f &factors)
 Scale the widget. More...
 
- Public Member Functions inherited from tgui::CallbackManager
void bindCallback (std::function< void()> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallback (void(T::*func)(), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallbackEx (std::function< void(const Callback &)> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallbackEx (void(T::*func)(const Callback &), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallback (unsigned int trigger)
 Bind one or more specific callback trigger(s) to the parent widget. More...
 
void unbindCallback (unsigned int trigger)
 Unbind all callback function bound to the given trigger. More...
 
void unbindAllCallback ()
 Unbind all callback functions bound to any callback. More...
 
- Public Member Functions inherited from tgui::WidgetBorders
 WidgetBorders ()
 Default constructor. More...
 
virtual ~WidgetBorders ()
 Destructor. More...
 
virtual Borders getBorders () const
 Returns the size of the borders as a tgui::Borders. More...
 

Member Enumeration Documentation

Defines specific triggers to EditBox.

Enumerator
TextChanged 

Text changed.

ReturnKeyPressed 

Return key was pressed.

AllEditBoxCallbacks 

All triggers defined in EditBox and its base classes.

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

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) 
)

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
Alignment::Alignments tgui::EditBox::getAlignment ( )

Get the current text alignment.

Returns
Text alignment
const std::string& tgui::EditBox::getLoadedConfigFile ( ) const

Returns the filename of the config file that was used to load the widget.

Returns
Filename of loaded config file. Empty string when no config file was loaded yet.
unsigned int tgui::EditBox::getMaximumCharacters ( ) const

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.

char tgui::EditBox::getPasswordCharacter ( ) const

Returns the password character.

Returns
The password character that is currently being used. When no password character is used then this function returns 0.
const sf::Color& tgui::EditBox::getSelectedTextBackgroundColor ( ) const

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.
const sf::Color& tgui::EditBox::getSelectedTextColor ( ) const

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.
const sf::Color& tgui::EditBox::getSelectionPointColor ( ) const

Get the color that is currently being used inside the edit box for the flickering selection point.

Returns
The color of the flickering selection point
unsigned int tgui::EditBox::getSelectionPointWidth ( ) const

Returns the width of the selection point.

Returns
width Width of the flickering selection point
sf::String tgui::EditBox::getText ( ) const

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

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

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

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

Returns the font of the text.

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

Returns the character size of the text.

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

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.

bool tgui::EditBox::load ( const std::string &  configFileFilename,
const std::string &  sectionName = "EditBox" 
)

Loads the widget.

Parameters
configFileFilenameFilename of the config file.
sectionNameName of the section in the file to load

The config file must contain a EditBox section with the needed information.

EditBox& tgui::EditBox::operator= ( const EditBox right)

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
void tgui::EditBox::setAlignment ( Alignment::Alignments  alignment)

Change the text alignment.

Parameters
alignmentThe new text alignment
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 auto-scaled 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::WidgetBorders.

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

Change the character limit.

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

This character limit is disabled by default.

void tgui::EditBox::setNumbersOnly ( bool  numbersOnly = true)

Changes whether the edit box accepts all characters or only numeric input.

Parameters
numbersOnlyShould the edit box only accept numbers?

By default the edit box accepts all text characters.

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

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::setPosition ( float  x,
float  y 
)
virtual

Set the position of the widget.

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable widget is (0, 0).

Parameters
xX coordinate of the new position
yY coordinate of the new position
See also
move, getPosition

Reimplemented from tgui::Transformable.

void tgui::EditBox::setSelectedTextBackgroundColor ( const sf::Color &  selectedTextBackgroundColor)

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

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

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

Parameters
selectedTextColorThe new text color.
void tgui::EditBox::setSelectionPointColor ( const sf::Color &  selectionPointColor)

Set the color that will be used inside the edit box for the flickering selection point.

Parameters
selectionPointColorThe color of the flickering selection point
void tgui::EditBox::setSelectionPointPosition ( unsigned int  charactersBeforeSelectionPoint)

Sets the flickering selection point to after a specific character.

Parameters
charactersBeforeSelectionPointThe new position.

Normally you will not need this function.

void tgui::EditBox::setSelectionPointWidth ( unsigned int  width = 2)

This will change the width of the selection point.

Parameters
widthNew width of the selection point
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

Reimplemented from tgui::ClickableWidget.

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

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
void tgui::EditBox::setTextColor ( const sf::Color &  textColor)

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

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

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 with the setGlobalFont function from the parent.

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

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.
virtual void tgui::EditBox::setTransparency ( unsigned char  transparency)
virtual

Changes the transparency of the widget.

Parameters
transparencyThe transparency of the widget. 0 is completely transparent, while 255 (default) means fully opaque.

Note that this will only change the transparency of the images. The parts of the widgets that use a color will not be changed. You must change them yourself by setting the alpha channel of the color.

Reimplemented from tgui::Widget.


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