26 #ifndef TGUI_CHAT_BOX_HPP 27 #define TGUI_CHAT_BOX_HPP 30 #include <TGUI/Widget.hpp> 31 #include <TGUI/Widgets/Panel.hpp> 32 #include <TGUI/Widgets/Scrollbar.hpp> 41 class ChatBoxRenderer;
49 typedef std::shared_ptr<ChatBox>
Ptr;
50 typedef std::shared_ptr<const ChatBox>
ConstPtr;
60 unsigned int sublines = 1;
61 std::shared_ptr<sf::Font> font;
134 void setSize(
const Layout2d& size)
override;
146 virtual sf::Vector2f getFullSize()
const override;
160 void addLine(
const sf::String& text);
175 void addLine(
const sf::String& text,
unsigned int textSize);
190 void addLine(
const sf::String& text,
const sf::Color& color);
205 void addLine(
const sf::String& text,
const sf::Color& color,
unsigned int textSize,
const Font& font =
nullptr);
218 sf::String getLine(std::size_t lineIndex)
const;
229 sf::Color getLineColor(std::size_t lineIndex)
const;
240 unsigned int getLineTextSize(std::size_t lineIndex)
const;
251 std::shared_ptr<sf::Font> getLineFont(std::size_t lineIndex)
const;
263 bool removeLine(std::size_t lineIndex);
270 void removeAllLines();
279 std::size_t getLineAmount();
291 void setLineLimit(std::size_t maxLines);
303 std::size_t getLineLimit();
314 virtual void setFont(
const Font& font)
override;
324 void setTextSize(
unsigned int size);
345 void setTextColor(
const Color& color);
400 void setLinesStartFromTop(
bool startFromTop =
true);
412 bool getLinesStartFromTop()
const;
423 void setNewLinesBelowOthers(
bool newLinesBelowOthers =
true);
432 bool getNewLinesBelowOthers()
const;
441 virtual void setOpacity(
float opacity)
override;
452 virtual sf::Vector2f getWidgetOffset()
const override;
460 virtual void setParent(
Container* parent)
override;
466 virtual bool mouseOnWidget(
float x,
float y)
const override;
471 virtual void leftMousePressed(
float x,
float y)
override;
476 virtual void leftMouseReleased(
float x,
float y)
override;
481 virtual void mouseMoved(
float x,
float y)
override;
486 virtual void mouseWheelMoved(
int delta,
int x,
int y)
override;
491 virtual void mouseNoLongerOnWidget()
override;
496 virtual void mouseNoLongerDown()
override;
505 void recalculateLineText(Line& line);
511 void recalculateAllLines();
517 void recalculateFullTextHeight();
523 void updateDisplayedText();
529 void updateRendering();
547 virtual void reload(
const std::string& primary =
"",
const std::string& secondary =
"",
bool force =
false)
override;
555 return std::make_shared<ChatBox>(*this);
562 virtual void draw(sf::RenderTarget& target, sf::RenderStates states)
const override;
568 unsigned int m_textSize = 18;
569 sf::Color m_textColor = sf::Color::Black;
571 std::size_t m_maxLines = 0;
573 float m_fullTextHeight = 0;
575 bool m_linesStartFromTop =
false;
576 bool m_newLinesBelowOthers =
true;
580 std::deque<Line> m_lines;
613 virtual void setProperty(std::string property,
const std::string& value)
override;
627 virtual void setProperty(std::string property, ObjectConverter&& value)
override;
639 virtual ObjectConverter getProperty(std::string property)
const override;
648 virtual std::map<std::string, ObjectConverter> getPropertyValuePairs()
const override;
657 void setBorderColor(
const Color& borderColor);
668 void setBackgroundColor(
const Color& backgroundColor);
680 void setBackgroundTexture(
const Texture& texture);
692 void setPadding(
const Padding& padding)
override;
699 void draw(sf::RenderTarget& target, sf::RenderStates states)
const;
708 Padding getScaledPadding()
const;
714 virtual std::shared_ptr<WidgetRenderer> clone(Widget* widget)
override;
722 sf::Color m_borderColor;
723 sf::Color m_backgroundColor;
725 Texture m_backgroundTexture;
727 friend class ChatBox;
735 #endif // TGUI_TEXT_BOX_HPP Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: ChatBox.hpp:553
Implicit converter for colors.
Definition: Color.hpp:39
Class to store the position or size of a widget.
Definition: Layout.hpp:254
std::shared_ptr< const ChatBox > ConstPtr
Shared constant widget pointer.
Definition: ChatBox.hpp:50
ChatBoxRenderer(ChatBox *chatBox)
Constructor.
Definition: ChatBox.hpp:600
std::shared_ptr< ChatBox > Ptr
Shared widget pointer.
Definition: ChatBox.hpp:49
Definition: ChatBox.hpp:56
std::shared_ptr< ChatBoxRenderer > getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed...
Definition: ChatBox.hpp:120
const sf::Color & getTextColor() const
Returns the default color of the text.
Definition: ChatBox.hpp:354
unsigned int getTextSize() const
Returns the default character size of the text.
Definition: ChatBox.hpp:333
Container widget.
Definition: Container.hpp:47
Definition: ChatBox.hpp:590
Definition: ChatBox.hpp:45