26#ifndef TGUI_TEXT_BOX_HPP 
   27#define TGUI_TEXT_BOX_HPP 
   30#include <TGUI/CopiedSharedPtr.hpp> 
   31#include <TGUI/Widgets/Scrollbar.hpp> 
   32#include <TGUI/Renderers/TextBoxRenderer.hpp> 
   33#include <TGUI/Text.hpp> 
   50        typedef std::shared_ptr<TextBox> 
Ptr; 
 
   51        typedef std::shared_ptr<const TextBox> 
ConstPtr; 
 
  114        void setText(
const sf::String& text, 
bool triggerTextChangedSignal = 
false);
 
  272#ifndef TGUI_REMOVE_DEPRECATED_CODE 
  283        TGUI_DEPRECATED(
"Use setHorizontalScrollbarPolicy instead") void setHorizontalScrollbarPresent(
bool present);
 
  294        TGUI_DEPRECATED("Use getHorizontalScrollbarPolicy instead") 
bool isHorizontalScrollbarPresent() const;
 
  307        TGUI_DEPRECATED("Use setVerticalScrollbarPolicy instead") 
void setVerticalScrollbarPresent(
bool present);
 
  318        TGUI_DEPRECATED("Use getVerticalScrollbarPolicy instead") 
bool isVerticalScrollbarPresent() const;
 
  436        void leftMousePressed(
Vector2f pos) 
override;
 
  441        void leftMouseReleased(
Vector2f pos) 
override;
 
  446        void mouseMoved(
Vector2f pos) 
override;
 
  451        void keyPressed(
const sf::Event::KeyEvent& event) 
override;
 
  456        void textEntered(std::uint32_t Key) 
override;
 
  461        bool mouseWheelScrolled(
float delta, 
Vector2f pos) 
override;
 
  466        void mouseNoLongerOnWidget() 
override;
 
  471        void leftMouseButtonNoLongerDown() 
override;
 
  481        sf::Vector2<std::size_t> findCaretPosition(
Vector2f position) 
const;
 
  487        std::size_t getIndexOfSelectionPos(sf::Vector2<std::size_t> selectionPos) 
const;
 
  490#ifndef TGUI_REMOVE_DEPRECATED_CODE 
  495        TGUI_DEPRECATED(
"Use getSelectionStart and getSelectionEnd instead") std::pair<std::
size_t, std::
size_t> findTextSelectionPositions() const;
 
  502        void selectText(
float posX, 
float posY);
 
  509        void deleteSelectedCharacters();
 
  515        void rearrangeText(
bool keepSelection);
 
  520        void updateScrollbars();
 
  525        void updateSelectionTexts();
 
  531        void backspaceKeyPressed();
 
  536        void deleteKeyPressed();
 
  541        void copySelectedTextToClipboard();
 
  546        void cutSelectedTextToClipboard();
 
  551        void pasteTextFromClipboard();
 
  556        void selectAllText();
 
  561        void moveCaretPageUp();
 
  566        void moveCaretPageDown();
 
  571        void moveCaretLeft(
bool shiftPressed);
 
  576        void moveCaretRight(
bool shiftPressed);
 
  581        void moveCaretWordBegin();
 
  586        void moveCaretWordEnd();
 
  596        void draw(sf::RenderTarget& target, sf::RenderStates states) 
const override;
 
  611        bool update(sf::Time elapsedTime) 
override;
 
  617        void recalculatePositions();
 
  623        void recalculateVisibleLines();
 
  650        std::unique_ptr<DataIO::Node> 
save(SavingRenderersMap& renderers) 
const override;
 
  656        void load(
const std::unique_ptr<DataIO::Node>& node, 
const LoadingRenderersMap& renderers) 
override;
 
  664            return std::make_shared<TextBox>(*
this);
 
  671        SignalString onTextChange = {
"TextChanged"};     
 
  672        Signal onSelectionChange = {
"SelectionChanged"}; 
 
  679        unsigned int m_lineHeight = 24;
 
  682        float m_maxLineWidth;
 
  684        std::vector<sf::String> m_lines;
 
  687        std::size_t m_maxChars = 0;
 
  690        std::size_t m_topLine = 1;
 
  691        std::size_t m_visibleLines = 1;
 
  694        sf::Vector2<std::size_t> m_selStart;
 
  695        sf::Vector2<std::size_t> m_selEnd;
 
  696        std::pair<sf::Vector2<std::size_t>, sf::Vector2<std::size_t>> m_lastSelection;
 
  700        bool m_caretVisible = 
true;
 
  702        Text m_textBeforeSelection;
 
  703        Text m_textSelection1;
 
  704        Text m_textSelection2;
 
  705        Text m_textAfterSelection1;
 
  706        Text m_textAfterSelection2;
 
  709        std::vector<FloatRect> m_selectionRects;
 
  718        bool m_possibleDoubleClick = 
false;
 
  720        bool m_readOnly = 
false;
 
  722        bool m_monospacedFontOptimizationEnabled = 
false;
 
  724        Sprite m_spriteBackground;
 
  729        Color   m_borderColorCached;
 
  730        Color   m_backgroundColorCached;
 
  731        Color   m_caretColorCached;
 
  732        Color   m_selectedTextBackgroundColorCached;
 
  733        float   m_caretWidthCached = 1;
 
Wrapper for colors.
Definition: Color.hpp:49
 
Definition: CopiedSharedPtr.hpp:40
 
Class to store the position or size of a widget.
Definition: Layout.hpp:260
 
Definition: Outline.hpp:39
 
Signal to which the user can subscribe to get callbacks from.
Definition: Signal.hpp:231
 
Definition: Sprite.hpp:46
 
Definition: TextBoxRenderer.hpp:37
 
Text box widget.
Definition: TextBox.hpp:47
 
void rendererChanged(const std::string &property) override
Function called when one of the properties of the renderer is changed.
 
void setVerticalScrollbarValue(unsigned int value)
Changes the thumb position of the vertical scrollbar.
 
void setHorizontalScrollbarPolicy(Scrollbar::Policy policy)
Changes when the horizontal scrollbar should be displayed.
 
bool mouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
 
std::shared_ptr< TextBox > Ptr
Shared widget pointer.
Definition: TextBox.hpp:50
 
void setDefaultText(const sf::String &text)
Changes the default text of the textbox. This is the text drawn when the text box is empty.
 
void setMaximumCharacters(std::size_t maxChars=0)
Changes the maximum character limit.
 
void setFocused(bool focused) override
Focus or unfocus the widget.
 
const sf::String & getDefaultText() const
Returns the default text of the text box. This is the text drawn when the text box is empty.
 
std::size_t getCaretPosition() const
Returns after which character the blinking cursor is currently located.
 
unsigned int getVerticalScrollbarValue() const
Returns the thumb position of the vertical scrollbar.
 
void setSize(const Layout2d &size) override
Changes the size of the text box.
 
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: TextBox.hpp:662
 
bool isReadOnly() const
Checks if the text box read-only or writable.
 
void setText(const sf::String &text, bool triggerTextChangedSignal=false)
Changes the text of the text box.
 
static TextBox::Ptr create()
Creates a new text box widget.
 
Signal & getSignal(std::string signalName) override
Retrieves a signal based on its name.
 
const sf::String & getText() const
Returns the text of the text box.
 
void setHorizontalScrollbarValue(unsigned int value)
Changes the thumb position of the horizontal scrollbar.
 
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
 
unsigned int getHorizontalScrollbarValue() const
Returns the thumb position of the horizontal scrollbar.
 
void enableMonospacedFontOptimization(bool enable=true)
Changes whether an optimization is made that only works when using a monospaced font.
 
void setCaretPosition(std::size_t charactersBeforeCaret)
Sets the blinking caret to after a specific character.
 
TextBoxRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
 
Scrollbar::Policy getHorizontalScrollbarPolicy() const
Returns when the horizontal scrollbar should be displayed.
 
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.
 
std::size_t getSelectionEnd() const
Returns the index where the selection ends.
 
void setSelectedText(std::size_t selectionStartIndex, std::size_t selectionEndIndex)
Changes which part of the text is selected.
 
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
Draw the widget to a render target.
 
TextBoxRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
 
void setReadOnly(bool readOnly=true)
Makes the text box read-only or make it writable again.
 
void setTextSize(unsigned int size) override
Changes the character size of the text.
 
static TextBox::Ptr copy(TextBox::ConstPtr textBox)
Makes a copy of another text box.
 
std::size_t getSelectionStart() const
Returns the index where the selection starts.
 
std::shared_ptr< const TextBox > ConstPtr
Shared constant widget pointer.
Definition: TextBox.hpp:51
 
void addText(const sf::String &text)
Appends some text to the text that was already in the text box.
 
std::size_t getLinesCount() const
Returns the amount of lines that the text occupies in the TextBox.
 
std::size_t getMaximumCharacters() const
Returns the maximum character limit.
 
void setVerticalScrollbarPolicy(Scrollbar::Policy policy)
Changes when the vertical scrollbar should be displayed.
 
Scrollbar::Policy getVerticalScrollbarPolicy() const
Returns when the vertical scrollbar should be displayed.
 
sf::String getSelectedText() const
Returns the text that you currently have selected.
 
Definition: Vector2f.hpp:39
 
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37