Pebble Foundation Classes  0.2.0
C++ for Pebble
TextLayer

Layer that displays and formats a text string. More...

Collaboration diagram for TextLayer:

Typedefs

typedef struct TextLayer TextLayer
 

Functions

TextLayer * text_layer_create (GRect frame)
 
void text_layer_destroy (TextLayer *text_layer)
 Destroys a TextLayer previously created by text_layer_create.
 
Layer * text_layer_get_layer (TextLayer *text_layer)
 
void text_layer_set_text (TextLayer *text_layer, const char *text)
 
const char * text_layer_get_text (TextLayer *text_layer)
 
void text_layer_set_background_color (TextLayer *text_layer, GColor color)
 
void text_layer_set_text_color (TextLayer *text_layer, GColor color)
 
void text_layer_set_overflow_mode (TextLayer *text_layer, GTextOverflowMode line_mode)
 
void text_layer_set_font (TextLayer *text_layer, GFont font)
 
void text_layer_set_text_alignment (TextLayer *text_layer, GTextAlignment text_alignment)
 
void text_layer_enable_screen_text_flow_and_paging (TextLayer *text_layer, uint8_t inset)
 
void text_layer_restore_default_text_flow_and_paging (TextLayer *text_layer)
 
GSize text_layer_get_content_size (TextLayer *text_layer)
 
void text_layer_set_size (TextLayer *text_layer, const GSize max_size)
 

Detailed Description

Layer that displays and formats a text string.

The geometric information (bounds, frame) of the Layer is used as the "box" in which the text is drawn. The TextLayer also has a number of other properties that influence how the text is drawn. Most important of these properties are: a pointer to the string to draw itself, the font, the text color, the background color of the layer, the overflow mode and alignment of the text inside the layer.

See also
Layers
Drawing Text
Fonts

Function Documentation

◆ text_layer_create()

TextLayer* text_layer_create ( GRect  frame)

Creates a new TextLayer on the heap and initializes it with the default values.

The text layer is automatically marked dirty after this operation.

Parameters
frameThe frame with which to initialze the TextLayer
Returns
A pointer to the TextLayer. NULL if the TextLayer could not be created

◆ text_layer_enable_screen_text_flow_and_paging()

void text_layer_enable_screen_text_flow_and_paging ( TextLayer *  text_layer,
uint8_t  inset 
)

Enables text flow following the boundaries of the screen and pagination that introduces extra line spacing at page breaks to avoid partially clipped lines for the TextLayer. If the TextLayer is part of a ScrollLayer the ScrollLayer's frame will be used to configure paging.

Note
Make sure the TextLayer is part of the view hierarchy before calling this function. Otherwise it has no effect.
Parameters
text_layerThe TextLayer for which to enable text flow and paging
insetAdditional amount of pixels to inset to the inside of the screen for text flow
See also
text_layer_restore_default_text_flow_and_paging
graphics_text_attributes_enable_screen_text_flow
graphics_text_attributes_enable_paging

◆ text_layer_get_content_size()

GSize text_layer_get_content_size ( TextLayer *  text_layer)

Calculates the size occupied by the current text of the TextLayer

Parameters
text_layerthe TextLayer for which to calculate the text's size
Returns
The size occupied by the current text of the TextLayer

◆ text_layer_get_layer()

Layer* text_layer_get_layer ( TextLayer *  text_layer)

Gets the "root" Layer of the text layer, which is the parent for the sub- layers used for its implementation.

Parameters
text_layerPointer to the TextLayer for which to get the "root" Layer
Returns
The "root" Layer of the text layer.

◆ text_layer_get_text()

const char* text_layer_get_text ( TextLayer *  text_layer)

Gets the pointer to the string that the TextLayer is using.

Parameters
text_layerThe TextLayer for which to get the text
See also
text_layer_set_text

◆ text_layer_restore_default_text_flow_and_paging()

void text_layer_restore_default_text_flow_and_paging ( TextLayer *  text_layer)

Restores text flow and paging for the TextLayer to the rectangular defaults.

Parameters
text_layerThe TextLayer for which to restore text flow and paging
See also
text_layer_enable_screen_text_flow_and_paging
graphics_text_attributes_restore_default_text_flow
graphics_text_attributes_restore_default_paging

◆ text_layer_set_background_color()

void text_layer_set_background_color ( TextLayer *  text_layer,
GColor  color 
)

Sets the background color of the bounding box that will be drawn behind the text

Parameters
text_layerThe TextLayer of which to set the background color
colorThe new GColor to set the background to
See also
text_layer_set_text_color

◆ text_layer_set_font()

void text_layer_set_font ( TextLayer *  text_layer,
GFont  font 
)

Sets the font of the TextLayer

Parameters
text_layerThe TextLayer of which to set the font
fontThe new GFont for the TextLayer
See also
fonts_get_system_font
fonts_load_custom_font

◆ text_layer_set_overflow_mode()

void text_layer_set_overflow_mode ( TextLayer *  text_layer,
GTextOverflowMode  line_mode 
)

Sets the line break mode of the TextLayer

Parameters
text_layerThe TextLayer of which to set the overflow mode
line_modeThe new GTextOverflowMode to set

◆ text_layer_set_size()

void text_layer_set_size ( TextLayer *  text_layer,
const GSize  max_size 
)

Update the size of the text layer This is a convenience function to update the frame of the TextLayer.

Parameters
text_layerThe TextLayer of which to set the size
max_sizeThe new size for the TextLayer

◆ text_layer_set_text()

void text_layer_set_text ( TextLayer *  text_layer,
const char *  text 
)

Sets the pointer to the string where the TextLayer is supposed to find the text at a later point in time, when it needs to draw itself.

Parameters
text_layerThe TextLayer of which to set the text
textThe new text to set onto the TextLayer. This must be a null-terminated and valid UTF-8 string!
Note
The string is not copied, so its buffer most likely cannot be stack allocated, but is recommended to be a buffer that is long-lived, at least as long as the TextLayer is part of a visible Layer hierarchy.
See also
text_layer_get_text

◆ text_layer_set_text_alignment()

void text_layer_set_text_alignment ( TextLayer *  text_layer,
GTextAlignment  text_alignment 
)

Sets the alignment of the TextLayer

Parameters
text_layerThe TextLayer of which to set the alignment
text_alignmentThe new text alignment for the TextLayer
See also
GTextAlignment

◆ text_layer_set_text_color()

void text_layer_set_text_color ( TextLayer *  text_layer,
GColor  color 
)

Sets the color of text that will be drawn

Parameters
text_layerThe TextLayer of which to set the text color
colorThe new GColor to set the text color to
See also
text_layer_set_background_color