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

Public Types

- Public Types inherited from tgui::Widget

Public Member Functions

 ChatBox ()
 Default constructor. More...
 
 ChatBox (const ChatBox &copy)
 Copy constructor. More...
 
virtual ~ChatBox ()
 Desturctor. More...
 
ChatBoxoperator= (const ChatBox &right)
 Overload of assignment operator. More...
 
bool load (const std::string &configFileFilename, const std::string &sectionName="ChatBox")
 Loads the widget. More...
 
const std::string & getLoadedConfigFile () const
 Returns the filename of the config file that was used to load the widget. More...
 
void setSize (float width, float height)
 Changes the size of the chat box. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the chat box. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the full size of the chat box. More...
 
void addLine (const sf::String &text)
 Add a new line of text to the chat box. More...
 
void addLine (const sf::String &text, unsigned int textSize)
 Add a new line of text to the chat box. More...
 
void addLine (const sf::String &text, const sf::Color &color)
 Add a new line of text to the chat box. More...
 
void addLine (const sf::String &text, const sf::Color &color, unsigned int textSize, const sf::Font *font=nullptr)
 Add a new line of text to the chat box. More...
 
sf::String getLine (unsigned int lineIndex)
 Returns the contents of the requested line. More...
 
bool removeLine (unsigned int lineIndex)
 Removes the requested line. More...
 
void removeAllLines ()
 Removes all lines from the chat box. More...
 
unsigned int getLineAmount ()
 Returns the amount of lines in the chat box. More...
 
void setLineLimit (unsigned int maxLines)
 Set a maximum amount of lines in the chat box. More...
 
void setTextFont (const sf::Font &font)
 Changes the default font of the text. More...
 
const sf::Font * getTextFont () const
 Returns the default font of the text. More...
 
void setTextSize (unsigned int size)
 Changes the default character size of the text. More...
 
unsigned int getTextSize () const
 Returns the default character size of the text. More...
 
void setTextColor (const sf::Color &color)
 Changes the default color of the text. More...
 
const sf::Color & getTextColor () const
 Returns the default color of the text. 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 chat box. More...
 
void setBackgroundColor (const sf::Color &backgroundColor)
 Set the background color that will be used inside the chat box. More...
 
void setBorderColor (const sf::Color &borderColor)
 Set the border color that will be used inside the chat box. More...
 
const sf::Color & getBackgroundColor () const
 Get the background color that is currently being used inside the chat box. More...
 
const sf::Color & getBorderColor () const
 Get the border color that is currently being used inside the chat box. More...
 
void setLineSpacing (unsigned int lineSpacing)
 Changes the line spacing of all lines. More...
 
void setLinesStartFromBottom (bool startFromBottom)
 Let the first lines start from the top or from the bottom of the chat box. More...
 
bool setScrollbar (const std::string &scrollbarConfigFileFilename)
 Changes the scrollbar of the chat box. More...
 
void removeScrollbar ()
 Removes the scrollbar from the chat box (if there is one). 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 ChatBox.

Enumerator
AllChatBoxCallbacks 

All triggers defined in ChatBox and its base classes.

Constructor & Destructor Documentation

tgui::ChatBox::ChatBox ( )

Default constructor.

tgui::ChatBox::ChatBox ( const ChatBox copy)

Copy constructor.

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

Desturctor.

Member Function Documentation

void tgui::ChatBox::addLine ( const sf::String &  text)

Add a new line of text to the chat box.

The whole text passed to this function will be considered as one line for the getLine and removeLine functions, even if it is too long and gets split over multiple lines.

The default text color and character size will be used.

Parameters
textText that will be added to the chat box
void tgui::ChatBox::addLine ( const sf::String &  text,
unsigned int  textSize 
)

Add a new line of text to the chat box.

The whole text passed to this function will be considered as one line for the getLine and removeLine functions, even if it is too long and gets split over multiple lines.

The default text color will be used.

Parameters
textText that will be added to the chat box
textSizeSize of the text
void tgui::ChatBox::addLine ( const sf::String &  text,
const sf::Color &  color 
)

Add a new line of text to the chat box.

The whole text passed to this function will be considered as one line for the getLine and removeLine functions, even if it is too long and gets split over multiple lines.

The default character size will be used.

Parameters
textText that will be added to the chat box
colorColor of the text
void tgui::ChatBox::addLine ( const sf::String &  text,
const sf::Color &  color,
unsigned int  textSize,
const sf::Font *  font = nullptr 
)

Add a new line of text to the chat box.

The whole text passed to this function will be considered as one line for the getLine and removeLine functions, even if it is too long and gets split over multiple lines.

Parameters
textText that will be added to the chat box
colorColor of the text
textSizeSize of the text
fontFont of the text (nullptr to use default font)
const sf::Color& tgui::ChatBox::getBackgroundColor ( ) const

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

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

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

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

Returns the full size of the chat box.

This is the size including the borders.

Returns
Full size of the chat box

Reimplemented from tgui::Transformable.

sf::String tgui::ChatBox::getLine ( unsigned int  lineIndex)

Returns the contents of the requested line.

Parameters
lineIndexThe index of the line of which you request the contents. The first line has index 0.
Returns
The contents of the requested line. An empty string will be returned when the index is too high.
unsigned int tgui::ChatBox::getLineAmount ( )

Returns the amount of lines in the chat box.

Returns
Number of lines in the chat box
const std::string& tgui::ChatBox::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.
virtual sf::Vector2f tgui::ChatBox::getSize ( ) const
virtual

Returns the size of the chat box.

This size does not include the borders.

Returns
Size of the chat box

Implements tgui::Transformable.

const sf::Color& tgui::ChatBox::getTextColor ( ) const

Returns the default color of the text.

Returns
The currently used default text color.
const sf::Font* tgui::ChatBox::getTextFont ( ) const

Returns the default font of the text.

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

Returns the default character size of the text.

Returns
The currently used default text size.
bool tgui::ChatBox::load ( const std::string &  configFileFilename,
const std::string &  sectionName = "ChatBox" 
)

Loads the widget.

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

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

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

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
void tgui::ChatBox::removeAllLines ( )

Removes all lines from the chat box.

bool tgui::ChatBox::removeLine ( unsigned int  lineIndex)

Removes the requested line.

Parameters
lineIndexThe index of the line that should be removed. The first line has index 0.
Returns
True if the line was removed, false if no such line existed (index too high).
void tgui::ChatBox::removeScrollbar ( )

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

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

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

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

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

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

Parameters
borderColorThe color of the borders
virtual void tgui::ChatBox::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 chat 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::ChatBox::setLineLimit ( unsigned int  maxLines)

Set a maximum amount of lines in the chat box.

Only the last maxLines lines will be kept. Lines above those will be removed. Set to 0 to disable the line limit (default).

Parameters
maxLinesThe maximum amount of lines that the chat box can contain.
void tgui::ChatBox::setLineSpacing ( unsigned int  lineSpacing)

Changes the line spacing of all lines.

By default, line spacing is chosen based on the font and character size. This also means that when mixing different text styles in ChatBox, lines can have different line spacings. By calling this function, all line spacings will be set to the value passed to this function.

The line spacing should be equal or greater than the text size to avoid overlapping lines.

Parameters
lineSpacingNew line spacing for all lines
void tgui::ChatBox::setLinesStartFromBottom ( bool  startFromBottom)

Let the first lines start from the top or from the bottom of the chat box.

Note that this only makes a difference when the lines don't fill the entire chat box. This does not change the order of the lines, new lines will always be below older lines.

Parameters
startFromBottomLet the first lines be placed at the bottom of the chat box, or remain at the top?
bool tgui::ChatBox::setScrollbar ( const std::string &  scrollbarConfigFileFilename)

Changes the scrollbar of the chat 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::ChatBox::setSize ( float  width,
float  height 
)
virtual

Changes the size of the chat box.

This size does not include the borders.

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

Implements tgui::Transformable.

void tgui::ChatBox::setTextColor ( const sf::Color &  color)

Changes the default color of the text.

Parameters
colorThe new default text color.
void tgui::ChatBox::setTextFont ( const sf::Font &  font)

Changes the default 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::ChatBox::setTextSize ( unsigned int  size)

Changes the default character size of the text.

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