![]() |
PROTO::KLUDGE
0.1
Quick prototyping library for games using SDL and OpenGL.
|
Drawable text using a Texture as its drawable resource. Part of the Decorator pattern along with the Drawable class. More...
#include <Text.hpp>
Public Types | |
enum | renderMode { solid, shaded, blended, blendedWrapped } |
Render mode used by SDL internally to draw the Text. More... | |
Public Member Functions | |
Text (Font *const font, const char *text) | |
Text (Font *const font, Texture *const texture, const char *text) | |
Text (Font *const font, Texture *const texture, const SDL_Rect &rect, const char *text) | |
Text (textData td) | |
Construct a Text from a textData struct. More... | |
virtual | ~Text () |
void | setTextData (textData &t) |
Set the data for the Text object. More... | |
textData & | getTextData () |
Get the current text data for the Text object. More... | |
void | setFont (Font *const font) |
Set the Font for the Text object. More... | |
Font * | getFont () |
Get the Font from the Text object. More... | |
void | setTexture (Texture *const texture) |
Set the Texture for the Text object. More... | |
Texture * | getTexture () |
Get the Texture from the Text object. More... | |
void | setBoundsRect (SDL_Rect &rect) |
Set the bounding rectangle for the Text. More... | |
const SDL_Rect & | getBoundsRect () |
Get the current bounding rectangle of the Text. More... | |
void | setPosition (glm::vec2 pos) |
glm::vec2 | getPosition () |
void | setString (const char *str) |
Set the string for the Text object. More... | |
const char * | getString () |
Get the string for the Text object. More... | |
void | setColor (const SDL_Color &color) |
Set the color of the Font for the Text object. More... | |
SDL_Color & | getColor () |
Get the color of the Font for the Text object (default is white). More... | |
void | setBackgroundColor (SDL_Color c) |
Set the color of the Text bounding box (background). More... | |
const SDL_Color & | getBackgroundColor () |
Get the SDL_Color corresponding to the Text background color (bounding box). More... | |
void | setRenderMode (Uint32 mode, Uint32 length=0) |
Set the mode for rendering the Text (renderMode::solid, renderMode::shaded, or renderMode::blended). More... | |
Uint32 | getRenderMode () |
Get the current render mode for the Text (default is renderMode::solid). More... | |
void | setCenter (SDL_Point &point) |
Set the center point for the Text. More... | |
const SDL_Point & | getCenter () |
Get the current center point of the Text. More... | |
void | setFlip (SDL_RendererFlip &type) |
Set the flip type for the Text (SDL_FLIP_NONE, SDL_FLIP_HORIZONTAL, SDL_FLIP_VERTICAL). More... | |
const SDL_RendererFlip & | getFlip () |
Get the current flip type for the Text (default is SDL_FLIP_NONE). More... | |
void | draw (SDL_Renderer *const renderTarget, SDL_Rect *const renderTargetRect) override |
Draw the Sprite to a render target. More... | |
![]() | |
Drawable () | |
Drawable constructor. Call explicitly in inherited classes. More... | |
virtual | ~Drawable () |
Private Member Functions | |
Text () | |
Inaccessible - Text needs a Font at a minimum. More... | |
void | updateTexture () |
Used internally when the render mode is initialized or changed. Never call this in a loop unless you want memory leaks!!! This function calls SDL_CreateTextureFromSurface(...) which will keep allocating memory on each call. More... | |
Private Attributes | |
textData | m_data |
Data important to the construction and state maintenance of a Text. More... | |
Uint32 | m_wrapLength |
If text is rendered in blended and wrapped mode, the width at which lines wrap is required. More... | |
Drawable text using a Texture as its drawable resource. Part of the Decorator pattern along with the Drawable class.
enum pk::Text::renderMode |
Render mode used by SDL internally to draw the Text.
Enumerator | |
---|---|
solid | |
shaded | |
blended | |
blendedWrapped |
pk::Text::Text | ( | Font *const | font, |
const char * | text | ||
) |
pk::Text::Text | ( | Font *const | font, |
Texture *const | texture, | ||
const SDL_Rect & | rect, | ||
const char * | text | ||
) |
pk::Text::Text | ( | textData | td | ) |
|
virtual |
|
overridevirtual |
Draw the Sprite to a render target.
SDL_Renderer | * const renderTarget - the renderer to draw with. |
SDL_Rect | * const renderTargetRect - the area of the render target to draw to. |
Implements pk::Drawable.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the current flip type for the Text (default is SDL_FLIP_NONE).
|
inline |
|
inline |
|
inline |
Get the current render mode for the Text (default is renderMode::solid).
|
inline |
Get the string for the Text object.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void pk::Text::setColor | ( | const SDL_Color & | color | ) |
|
inline |
Set the flip type for the Text (SDL_FLIP_NONE, SDL_FLIP_HORIZONTAL, SDL_FLIP_VERTICAL).
SDL_RendererFlip | type - an integer corresponding to an SDL_RendererFlip constant. |
|
inline |
|
inline |
|
inline |
Set the mode for rendering the Text (renderMode::solid, renderMode::shaded, or renderMode::blended).
Uint32 | mode - a plain integer corresponding to a renderMode:: enum value. |
|
inline |
Set the string for the Text object.
const | char * str - a C-style string. |
|
inline |
|
inline |
|
private |
Used internally when the render mode is initialized or changed. Never call this in a loop unless you want memory leaks!!! This function calls SDL_CreateTextureFromSurface(...) which will keep allocating memory on each call.
|
private |
Data important to the construction and state maintenance of a Text.
|
private |
If text is rendered in blended and wrapped mode, the width at which lines wrap is required.