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

Public Types

- Public Types inherited from tgui::Widget

Public Member Functions

 TextBox ()
 Default constructor. More...
 
 TextBox (const TextBox &copy)
 Copy constructor. More...
 
virtual ~TextBox ()
 Desturctor. More...
 
TextBoxoperator= (const TextBox &right)
 Overload of assignment operator. More...
 
bool load (const std::string &configFileFilename, const std::string &sectionName="TextBox")
 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 setSize (float width, float height)
 Changes the size of the text box. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the text box. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the full size of the text box. More...
 
void setText (const sf::String &text)
 Changes the text of the text box. More...
 
void addText (const sf::String &text)
 Appends some text to the text that was already in the text box. More...
 
sf::String getText () const
 Returns the text of the text box. 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 setTextSize (unsigned int size)
 Changes the character size of the text. More...
 
unsigned int getTextSize () const
 Returns the character size of the text. More...
 
void setMaximumCharacters (unsigned int maxChars=0)
 Changes the maximum character limit. More...
 
unsigned int getMaximumCharacters () const
 Returns the maximum 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 text box. More...
 
void changeColors (const sf::Color &backgroundColor=sf::Color(50, 50, 50), 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 &borderColor=sf::Color(0, 0, 0), const sf::Color &selectionPointColor=sf::Color(110, 110, 255))
 Changes the colors from the text box. More...
 
void setBackgroundColor (const sf::Color &backgroundColor)
 Set the background color that will be used inside the text box. More...
 
void setTextColor (const sf::Color &textColor)
 Set the text color that will be used inside the text box. More...
 
void setSelectedTextColor (const sf::Color &selectedTextColor)
 Set the text color of the selected text that will be used inside the text box. More...
 
void setSelectedTextBackgroundColor (const sf::Color &selectedTextBackgroundColor)
 Set the background color of the selected text that will be used inside the text box. More...
 
void setBorderColor (const sf::Color &borderColor)
 Set the border color that will be used inside the text box. More...
 
void setSelectionPointColor (const sf::Color &selectionPointColor)
 Set the color that will be used inside the text box for the flickering selection point. More...
 
const sf::Color & getBackgroundColor () const
 Get the background color that is currently being used inside the text box. More...
 
const sf::Color & getTextColor () const
 Get the text color that is currently being used inside the text box. More...
 
const sf::Color & getSelectedTextColor () const
 Get the text color of the selected text that is currently being used inside the text box. More...
 
const sf::Color & getSelectedTextBackgroundColor () const
 Get the background color of the selected text that is currently being used inside the text box. More...
 
const sf::Color & getBorderColor () const
 Get the border color that is currently being used inside the text box. More...
 
const sf::Color & getSelectionPointColor () const
 Get the color that is currently being used inside the text box for the flickering selection point. More...
 
void setSelectionPointPosition (unsigned int charactersBeforeSelectionPoint)
 Sets the flickering selection point to after a specific character. More...
 
bool setScrollbar (const std::string &scrollbarConfigFileFilename)
 Changes the scrollbar of the text box. More...
 
void removeScrollbar ()
 Removes the scrollbar from the text box (if there is one). 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 setReadOnly (bool readOnly=true)
 Make the text box read-only or make it writable again. More...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency 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...
 
virtual void setPosition (float x, float y)
 Set the position of the widget. 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...
 
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 TextBox.

Enumerator
TextChanged 

Text has changed.

AllTextBoxCallbacks 

All triggers defined in TextBox and its base classes.

Constructor & Destructor Documentation

tgui::TextBox::TextBox ( )

Default constructor.

tgui::TextBox::TextBox ( const TextBox copy)

Copy constructor.

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

Desturctor.

Member Function Documentation

void tgui::TextBox::addText ( const sf::String &  text)

Appends some text to the text that was already in the text box.

Parameters
textText that will be added to the text that is already in the text box
void tgui::TextBox::changeColors ( const sf::Color &  backgroundColor = sf::Color(50, 50, 50),
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 &  borderColor = sf::Color(0, 0, 0),
const sf::Color &  selectionPointColor = sf::Color(110, 110, 255) 
)

Changes the colors from the text box.

Parameters
backgroundColorThe color of the background of the text box.
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
borderColorThe color of the borders
selectionPointColorThe color of the flickering selection point
const sf::Color& tgui::TextBox::getBackgroundColor ( ) const

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

Returns
The color of the background of the text box
const sf::Color& tgui::TextBox::getBorderColor ( ) const

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

Returns
The color of the borders
virtual sf::Vector2f tgui::TextBox::getFullSize ( ) const
virtual

Returns the full size of the text box.

This is the size including the borders.

Returns
Full size of the text box

Reimplemented from tgui::Transformable.

const std::string& tgui::TextBox::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::TextBox::getMaximumCharacters ( ) const

Returns the maximum character limit.

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

There is no character limit by default.

const sf::Color& tgui::TextBox::getSelectedTextBackgroundColor ( ) const

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

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

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

Returns
The selected text color that is currently being used.
const sf::Color& tgui::TextBox::getSelectionPointColor ( ) const

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

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

Returns the width of the selection point.

Returns
width Width of the flickering selection point
virtual sf::Vector2f tgui::TextBox::getSize ( ) const
virtual

Returns the size of the text box.

This size does not include the borders.

Returns
Size of the text box

Implements tgui::Transformable.

sf::String tgui::TextBox::getText ( ) const

Returns the text of the text box.

Returns
The text that is currently inside the text box
const sf::Color& tgui::TextBox::getTextColor ( ) const

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

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

Returns the font of the text.

Returns
Pointer to the font that is currently being used
unsigned int tgui::TextBox::getTextSize ( ) const

Returns the character size of the text.

Returns
The current text size.
bool tgui::TextBox::load ( const std::string &  configFileFilename,
const std::string &  sectionName = "TextBox" 
)

Loads the widget.

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

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

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

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
void tgui::TextBox::removeScrollbar ( )

Removes the scrollbar from the text box (if there is one).

When there are too many lines to fit in the text box then some lines will be removed.

void tgui::TextBox::setBackgroundColor ( const sf::Color &  backgroundColor)

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

Parameters
backgroundColorThe new background color.
void tgui::TextBox::setBorderColor ( const sf::Color &  borderColor)

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

Parameters
borderColorThe color of the borders
virtual void tgui::TextBox::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 text box.

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::TextBox::setMaximumCharacters ( unsigned int  maxChars = 0)

Changes the maximum character limit.

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

This character limit is disabled by default.

void tgui::TextBox::setReadOnly ( bool  readOnly = true)

Make the text box read-only or make it writable again.

Parameters
readOnlyShould the text box be read-only?

When the text box is read-only, you can no longer delete characters and type text. Selecting text, copying text and even calling the setText function will still work.

bool tgui::TextBox::setScrollbar ( const std::string &  scrollbarConfigFileFilename)

Changes the scrollbar of the text box.

Parameters
scrollbarConfigFileFilenameFilename of the config file. The config file must contain a Scrollbar section with the needed information.
Returns
  • true when the scrollbar was successfully loaded
  • false when the loading of the scrollbar failed
void tgui::TextBox::setSelectedTextBackgroundColor ( const sf::Color &  selectedTextBackgroundColor)

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

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

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

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

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

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

Sets the flickering selection point to after a specific character.

Parameters
charactersBeforeSelectionPointThe amount of characters that are before the selection point

Normally you will not need this function.

If the selection point is outside the visible area, the text box will scroll to show the part where the selection point is located. So calling setSelectionPointPosition(0) will always make the scrollbar go completely to the top.

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

This will change the width of the selection point.

Parameters
widthNew width of the selection point
virtual void tgui::TextBox::setSize ( float  width,
float  height 
)
virtual

Changes the size of the text box.

This size does not include the borders.

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

Implements tgui::Transformable.

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

Changes the text of the text box.

Parameters
textNew text
void tgui::TextBox::setTextColor ( const sf::Color &  textColor)

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

Parameters
textColorThe new text color.
void tgui::TextBox::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::TextBox::setTextSize ( unsigned int  size)

Changes the character size of the text.

Parameters
sizeThe new text size. The minimum text size is 8.
virtual void tgui::TextBox::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: