SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::TextRef Struct Reference

Semi-safe reference for Text.

Inheritance diagram for SDL::TextRef:
Inheritance graph
[legend]
Collaboration diagram for SDL::TextRef:
Collaboration graph
[legend]

Public Member Functions

 TextRef (TextParam resource=nullptr) noexcept
 Constructs from TextParam. More...
 
 TextRef (TextRaw resource) noexcept
 Constructs from TextParam. More...
 
constexpr TextRef (const TextRef &other) noexcept=default
 Copy constructor.
 
 ~TextRef ()
 Destructor.
 
constexpr Text (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Text (const TextRaw resource) noexcept
 Constructs from TextParam. More...
 
constexpr Text (const Text &other) noexcept=default
 Copy constructor.
 
constexpr Text (Text &&other) noexcept
 Move constructor.
 
constexpr Text (const TextRef &other)=delete
 
constexpr Text (TextRef &&other)=delete
 
 Text (TextEngineParam engine, FontParam font, std::string_view text)
 Create a text object from UTF-8 text and a text engine. More...
 
- Public Member Functions inherited from SDL::Text
constexpr Text (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Text (const TextRaw resource) noexcept
 Constructs from TextParam. More...
 
constexpr Text (Text &&other) noexcept
 Move constructor.
 
constexpr Text (const TextRef &other)=delete
 
constexpr Text (TextRef &&other)=delete
 
 Text (TextEngineParam engine, FontParam font, std::string_view text)
 Create a text object from UTF-8 text and a text engine. More...
 
constexpr const TextRaw operator-> () const noexcept
 member access to underlying TextRaw.
 
constexpr TextRaw operator-> () noexcept
 member access to underlying TextRaw.
 
 ~Text ()
 Destructor.
 
constexpr Textoperator= (Text &&other) noexcept
 Assignment operator.
 
constexpr TextRaw get () const noexcept
 Retrieves underlying TextRaw.
 
constexpr TextRaw release () noexcept
 Retrieves underlying TextRaw and clear this.
 
constexpr auto operator<=> (const Text &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
constexpr operator TextParam () const noexcept
 Converts to TextParam.
 
void Destroy ()
 Destroy a text object created by a text engine. More...
 
void DrawSurface (Point p, SurfaceParam surface) const
 Draw text to an SDL surface. More...
 
void DrawRenderer (FPoint p) const
 Draw text to an SDL renderer. More...
 
GPUAtlasDrawSequenceGetGPUDrawData () const
 Get the geometry data needed for drawing the text. More...
 
PropertiesRef GetProperties () const
 Get the properties associated with a text object. More...
 
void SetEngine (TextEngineParam engine)
 Set the text engine used by a text object. More...
 
TextEngineParam GetEngine () const
 Get the text engine used by a text object. More...
 
bool SetFont (FontParam font)
 Set the font used by a text object. More...
 
FontRef GetFont () const
 Get the font used by a text object. More...
 
void SetDirection (Direction direction)
 Set the direction to be used for text shaping a text object. More...
 
Direction GetDirection () const
 Get the direction to be used for text shaping a text object. More...
 
void SetScript (Uint32 script)
 Set the script to be used for text shaping a text object. More...
 
Uint32 GetScript () const
 Get the script used for text shaping a text object. More...
 
void SetColor (Color c)
 Set the color of a text object. More...
 
void SetColorFloat (FColor c)
 Set the color of a text object. More...
 
void GetColor (Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
 Get the color of a text object. More...
 
Color GetColor () const
 Get the color of a text object. More...
 
void GetColorFloat (float *r, float *g, float *b, float *a) const
 Get the color of a text object. More...
 
FColor GetColorFloat () const
 Get the color of a text object. More...
 
void SetPosition (const PointRaw &p)
 Set the position of a text object. More...
 
void GetPosition (int *x, int *y) const
 Get the position of a text object. More...
 
Point GetPosition () const
 Get the position of a text object. More...
 
void SetWrapWidth (int wrap_width)
 Set whether wrapping is enabled on a text object. More...
 
int GetWrapWidth () const
 Get whether wrapping is enabled on a text object. More...
 
void SetWrapWhitespaceVisible (bool visible)
 Set whether whitespace should be visible when wrapping a text object. More...
 
bool IsWrapWhitespaceVisible () const
 Return whether whitespace is shown when wrapping a text object. More...
 
void SetString (std::string_view string)
 Set the UTF-8 text used by a text object. More...
 
void InsertString (int offset, std::string_view string)
 Insert UTF-8 text into a text object. More...
 
void AppendString (std::string_view string)
 Append UTF-8 text to a text object. More...
 
void DeleteString (int offset, int length)
 Delete UTF-8 text from a text object. More...
 
void GetSize (int *w, int *h) const
 Get the size of a text object. More...
 
Point GetSize () const
 Get the size of a text object. More...
 
void GetSubString (int offset, SubString *substring) const
 Get the substring of a text object that surrounds a text offset. More...
 
SubStringIterator begin () const
 Get iterator to first substring.
 
SubStringIterator end () const
 Get iterator to one past last substring.
 
SubStringIterator GetSubStringForLine (int line) const
 Get iterator to substring of a text object that contains the given line. More...
 
void GetSubStringForLine (int line, SubString *substring) const
 Get the substring of a text object that contains the given line. More...
 
OwnArray< SubString * > GetSubStrings () const
 Get all substrings of a text object. More...
 
OwnArray< SubString * > GetSubStringsForRange (int offset, int length=-1) const
 Get the substrings of a text object that contain a range of text. More...
 
SubStringIterator GetSubStringForPoint (Point p) const
 Get the portion of a text string that is closest to a point. More...
 
void GetSubStringForPoint (Point p, SubString *substring) const
 Get the portion of a text string that is closest to a point. More...
 
void GetPreviousSubString (const SubString &substring, SubString *previous) const
 Get the previous substring in a text object. More...
 
void GetNextSubString (const SubString &substring, SubString *next) const
 Get the next substring in a text object. More...
 
void Update ()
 Update the layout of a text object. More...
 
const char * GetText () const
 A copy of the UTF-8 string that this text object represents, useful for layout, debugging and retrieving substring text.
 
int GetNumLines () const
 The number of lines in the text, 0 if it's empty.
 

Additional Inherited Members

- Protected Member Functions inherited from SDL::Text
constexpr Text (const Text &other) noexcept=default
 Copy constructor.
 
constexpr Textoperator= (const Text &other) noexcept=default
 Assignment operator.
 

Constructor & Destructor Documentation

◆ TextRef() [1/2]

SDL::TextRef::TextRef ( TextParam  resource = nullptr)
inlinenoexcept
Parameters
resourcea TextRaw or Text.

This does not takes ownership!

◆ TextRef() [2/2]

SDL::TextRef::TextRef ( TextRaw  resource)
inlinenoexcept
Parameters
resourcea TextRaw or Text.

This does not takes ownership!

Member Function Documentation

◆ Text() [1/2]

constexpr SDL::Text::Text ( const TextRaw  resource)
inlineexplicitconstexprnoexcept
Parameters
resourcea TextRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.

◆ Text() [2/2]

SDL::Text::Text ( TextEngineParam  engine,
FontParam  font,
std::string_view  text 
)
inline
Parameters
enginethe text engine to use when creating the text object, may be nullptr.
fontthe font to render with.
textthe text to use, in UTF-8 encoding.
Postcondition
a Text object or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the font and text engine.
Since
This function is available since SDL_ttf 3.0.0.
See also
Text.Destroy

The documentation for this struct was generated from the following file: