SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::TextBase Struct Reference

Base class to Text. More...

Inheritance diagram for SDL::TextBase:
[legend]

Public Member Functions

constexpr operator TextConstRef () const noexcept
 Converts to TextConstRef.
void Destroy ()
 Destroy a text object created by a text engine.
void DrawSurface (Point p, SurfaceRef surface) const
 Draw text to an SDL surface.
void DrawRenderer (FPoint p) const
 Draw text to an SDL renderer.
GPUAtlasDrawSequenceGetGPUDrawData () const
 Get the geometry data needed for drawing the text.
PropertiesRef GetProperties () const
 Get the properties associated with a text object.
void SetEngine (TextEngineRef engine)
 Set the text engine used by a text object.
TextEngineRef GetEngine () const
 Get the text engine used by a text object.
bool SetFont (FontRef font)
 Set the font used by a text object.
FontRef GetFont () const
 Get the font used by a text object.
void SetDirection (Direction direction)
 Set the direction to be used for text shaping a text object.
Direction GetDirection () const
 Get the direction to be used for text shaping a text object.
void SetScript (Uint32 script)
 Set the script to be used for text shaping a text object.
Uint32 GetScript () const
 Get the script used for text shaping a text object.
void SetColor (Color c)
 Set the color of a text object.
void SetColorFloat (FColor c)
 Set the color of a text object.
void GetColor (Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
 Get the color of a text object.
Color GetColor () const
 Get the color of a text object.
void GetColorFloat (float *r, float *g, float *b, float *a) const
 Get the color of a text object.
FColor GetColorFloat () const
 Get the color of a text object.
void SetPosition (const PointRaw &p)
 Set the position of a text object.
void GetPosition (int *x, int *y) const
 Get the position of a text object.
Point GetPosition () const
 Get the position of a text object.
void SetWrapWidth (int wrap_width)
 Set whether wrapping is enabled on a text object.
int GetWrapWidth () const
 Get whether wrapping is enabled on a text object.
void SetWrapWhitespaceVisible (bool visible)
 Set whether whitespace should be visible when wrapping a text object.
bool IsWrapWhitespaceVisible () const
 Return whether whitespace is shown when wrapping a text object.
void SetString (std::string_view string)
 Set the UTF-8 text used by a text object.
void InsertString (int offset, std::string_view string)
 Insert UTF-8 text into a text object.
void AppendString (std::string_view string)
 Append UTF-8 text to a text object.
void DeleteString (int offset, int length)
 Delete UTF-8 text from a text object.
void GetSize (int *w, int *h) const
 Get the size of a text object.
Point GetSize () const
 Get the size of a text object.
void GetSubString (int offset, SubString *substring) const
 Get the substring of a text object that surrounds a text offset.
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.
void GetSubStringForLine (int line, SubString *substring) const
 Get the substring of a text object that contains the given line.
OwnArray< SubString * > GetSubStrings () const
 Get all substrings of a text object.
OwnArray< SubString * > GetSubStringsForRange (int offset, int length=-1) const
 Get the substrings of a text object that contain a range of text.
SubStringIterator GetSubStringForPoint (Point p) const
 Get the portion of a text string that is closest to a point.
void GetSubStringForPoint (Point p, SubString *substring) const
 Get the portion of a text string that is closest to a point.
void GetPreviousSubString (const SubString &substring, SubString *previous) const
 Get the previous substring in a text object.
void GetNextSubString (const SubString &substring, SubString *next) const
 Get the next substring in a text object.
void Update ()
 Update the layout of a text object.
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.
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr ResourceBaseT (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBaseT (std::nullptr_t)
 Constructs null/invalid.
constexpr ResourceBaseT (const ResourceBaseT &)=default
 Copy constructor.
constexpr ResourceBaseT (ResourceBaseT &&) noexcept=default
 Move constructor.
Public Member Functions inherited from SDL::ResourceBaseT< TextRaw, TextRawConst >
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr operator bool () const
 Converts to bool.
constexpr auto operator<=> (const ResourceBaseT &other) const=default
 Comparison.
constexpr RawConstPointer operator-> () const noexcept
 member access to underlying resource pointer.
constexpr RawPointer get () const noexcept
 Retrieves underlying resource pointer.
constexpr RawPointer release () noexcept
 Retrieves underlying resource pointer and clear this.

Additional Inherited Members

Public Types inherited from SDL::ResourceBaseT< TextRaw, TextRawConst >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.
Protected Member Functions inherited from SDL::ResourceBaseT< TextRaw, TextRawConst >
constexpr ~ResourceBaseT ()=default
 Destructor.
constexpr ResourceBaseToperator= (const ResourceBaseT &)=default
 Assignment operator.

Detailed Description

Base class to Text.

See also
Text

Member Function Documentation

◆ GetSubStringForLine()

SubStringIterator SDL::TextBase::GetSubStringForLine ( int line) const

Get iterator to substring of a text object that contains the given line.

If line is greater than or equal to text->num_lines this will return an iterator equal to end().

Parameters
linea zero-based line index, in the range [0 .. text->num_lines-1].
Returns
iterator on success or false on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the text.
Since
This function is available since SDL_ttf 3.0.0.

◆ GetSubStringForPoint()

SubStringIterator SDL::TextBase::GetSubStringForPoint ( Point p) const

Get the portion of a text string that is closest to a point.

This will return the closest substring of text to the given point.

Parameters
pthe coordinates relative to the top-left side of the text, may be outside the bounds of the text area.
Returns
the iterator on success or false on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the text.
Since
This function is available since SDL_ttf 3.0.0.

◆ GetSubStrings()

OwnArray< SubString * > SDL::TextBase::GetSubStrings ( ) const
inline

Get all substrings of a text object.

Returns
a nullptr terminated array of substring pointers or nullptr on failure; call GetError() for more information.
Thread safety:
This function should be called on the thread that created the text.
Since
This function is available since SDL_ttf 3.0.0.

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