26#ifndef TGUI_CHAT_BOX_HPP
27#define TGUI_CHAT_BOX_HPP
30#include <TGUI/CopiedSharedPtr.hpp>
31#include <TGUI/Widgets/Scrollbar.hpp>
32#include <TGUI/Renderers/ChatBoxRenderer.hpp>
33#include <TGUI/Text.hpp>
46 typedef std::shared_ptr<ChatBox>
Ptr;
47 typedef std::shared_ptr<const ChatBox>
ConstPtr;
69 ChatBox(
const char* typeName =
"ChatBox",
bool initRenderer =
true);
117 using Widget::setSize;
352 void leftMousePressed(
Vector2f pos)
override;
357 void leftMouseReleased(
Vector2f pos)
override;
362 void mouseMoved(
Vector2f pos)
override;
367 bool mouseWheelScrolled(
float delta,
Vector2f pos)
override;
372 void mouseNoLongerOnWidget()
override;
377 void leftMouseButtonNoLongerDown()
override;
386 void recalculateLineText(
Line& line);
392 void recalculateAllLines();
398 void recalculateFullTextHeight();
404 void updateDisplayedText();
410 void updateRendering();
438 std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
444 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
458 return std::make_shared<ChatBox>(*
this);
465 Color m_textColor = Color::Black;
468 std::size_t m_maxLines = 0;
470 float m_fullTextHeight = 0;
472 bool m_linesStartFromTop =
false;
473 bool m_newLinesBelowOthers =
true;
477 std::deque<Line> m_lines;
479 Sprite m_spriteBackground;
484 Color m_backgroundColorCached;
485 Color m_borderColorCached;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Definition ChatBoxRenderer.hpp:37
Definition ChatBox.hpp:43
unsigned int getScrollbarValue() const
Returns the thumb position of the scrollbar.
std::size_t getLineAmount()
Returns the amount of lines in the chat box.
void setTextSize(unsigned int size) override
Changes the character size of the text.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
static ChatBox::Ptr copy(ChatBox::ConstPtr chatBox)
Makes a copy of another chat box.
ChatBoxRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void removeAllLines()
Removes all lines from the chat box.
bool getLinesStartFromTop() const
Returns whether the first lines start from the top or from the bottom of the chat box.
static ChatBox::Ptr create()
Creates a new chat box widget.
std::shared_ptr< const ChatBox > ConstPtr
Shared constant widget pointer.
Definition ChatBox.hpp:47
void setLinesStartFromTop(bool startFromTop=true)
Lets the first lines start from the top or from the bottom of the chat box.
void addLine(const String &text, Color color)
Adds a new line of text to the chat box.
std::size_t getLineLimit()
Returns the maximum amount of lines in the chat box.
void addLine(const String &text, Color color, TextStyles style)
Adds a new line of text to the chat box.
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the widget to a render target.
const Color & getTextColor() const
Returns the default color of the text.
std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
void addLine(const String &text)
Adds a new line of text to the chat box.
bool getNewLinesBelowOthers() const
Returns whether new lines are added below the other lines or above them.
Color getLineColor(std::size_t lineIndex) const
Returns the color of the requested line.
void setSize(const Layout2d &size) override
Changes the size of the chat box.
void setNewLinesBelowOthers(bool newLinesBelowOthers=true)
Sets whether new lines are added below the other lines or above them.
ChatBoxRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
TextStyles getTextStyle() const
Returns the default text style.
std::shared_ptr< ChatBox > Ptr
Shared widget pointer.
Definition ChatBox.hpp:46
TextStyles getLineTextStyle(std::size_t lineIndex) const
Returns the text style of the requested line.
void setScrollbarValue(unsigned int value)
Changes the thumb position of the scrollbar.
void setTextColor(Color color)
Changes the default color of the text.
void setTextStyle(TextStyles style)
Changes the default text style.
String getLine(std::size_t lineIndex) const
Returns the contents of the requested line.
void setLineLimit(std::size_t maxLines)
Sets a maximum amount of lines in the chat box.
bool removeLine(std::size_t lineIndex)
Removes the requested line.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition ChatBox.hpp:456
Wrapper for colors.
Definition Color.hpp:63
Definition CopiedSharedPtr.hpp:40
Class to store the position or size of a widget.
Definition Layout.hpp:262
Definition Outline.hpp:39
Wrapper class to store strings.
Definition String.hpp:79
Wrapper for text styles.
Definition TextStyle.hpp:58
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
Definition ChatBox.hpp:53
States used for drawing.
Definition RenderStates.hpp:39