lv_label.h
API reference for lv_label.h
Functions
lv_label_set_text
Set a new text for a label. Memory will be allocated to store the text by the label.
void lv_label_set_text(lv_obj_t *obj, const char *text)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
text | const char * | '\0' terminated character string. May be NULL. When NULL the label is refreshed with its current text. |
If LV_USE_ARABIC_PERSIAN_CHARS is enabled the text will be modified to have the correct Arabic characters in it.
lv_label_set_text_fmt
Set a new formatted text for a label. Memory will be allocated to store the text by the label.
void lv_label_set_text_fmt(lv_obj_t *obj, const char *fmt,...)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
fmt | const char * | printf-like format string Example: lv_label_set_text_fmt(label1, "%d user", user_num); |
... |
If LV_USE_ARABIC_PERSIAN_CHARS is enabled the text will be modified to have the correct Arabic characters in it.
lv_label_set_text_vfmt
Set a new formatted text for a label. Memory will be allocated to store the text by the label. Example:
va_list args;
va_start(args, fmt);
lv_label_set_text_vfmt(label1, fmt, args);
va_end(args);void lv_label_set_text_vfmt(lv_obj_t *obj, const char *fmt, va_list args)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
fmt | const char * | printf-like format string |
args | va_list | variadic arguments list |
It ignores LV_USE_ARABIC_PERSIAN_CHARS
lv_label_set_text_static
Set a static text. It will not be saved by the label so the 'text' variable has to be 'alive' while the label exists.
void lv_label_set_text_static(lv_obj_t *obj, const char *text)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
text | const char * | pointer to a text. May be NULL. When NULL the current text is refreshed. |
It ignores LV_USE_ARABIC_PERSIAN_CHARS
lv_label_set_long_mode
Set the behavior of the label with text longer than the object size
void lv_label_set_long_mode(lv_obj_t *obj, lv_label_long_mode_t long_mode)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
long_mode | lv_label_long_mode_t | the new mode from 'lv_label_long_mode' enum. In LV_LONG_WRAP/DOT/SCROLL/SCROLL_CIRC the size of the label should be set AFTER this function |
lv_label_set_max_lines
Set the maximum number of lines that the label should display in LV_LABEL_LONG_MODE_WRAP and LV_LABEL_LONG_MODE_DOTS mode.
void lv_label_set_max_lines(lv_obj_t *obj, int32_t lines)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
lines | int32_t | number of lines to display (unlimited if not positive) |
lv_label_set_text_selection_start
Set where text selection should start
void lv_label_set_text_selection_start(lv_obj_t *obj, uint32_t index)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
index | uint32_t | character index from where selection should start. LV_LABEL_TEXT_SELECTION_OFF for no selection |
lv_label_set_text_selection_end
Set where text selection should end
void lv_label_set_text_selection_end(lv_obj_t *obj, uint32_t index)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
index | uint32_t | character index where selection should end. LV_LABEL_TEXT_SELECTION_OFF for no selection |
lv_label_set_recolor
Enable the recoloring by in-line commands
void lv_label_set_recolor(lv_obj_t *obj, bool en)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
en | bool | true: enable recoloring, false: disable Example: "This is a #ff0000 red# word" |
lv_label_set_translation_tag
Assign a translation tag for this label. Memory will be allocated to store the tag by the label. The label text will automatically update when the language is changed via lv_translation_set_language.
void lv_label_set_translation_tag(lv_obj_t *obj, const char *tag)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
tag | const char * | '\0' terminated character string. |
lv_label_get_text
Get the text of a label
char * lv_label_get_text(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object |
Returns: char * — the text of the label
lv_label_get_long_mode
Get the long mode of a label
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object |
Returns: lv_label_long_mode_t — the current long mode
lv_label_get_max_lines
Get the maximum number of lines that a label should display
int32_t lv_label_get_max_lines(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object |
Returns: int32_t — the maximum number of lines, if positive
lv_label_get_letter_pos
Get the relative x and y coordinates of a letter
void lv_label_get_letter_pos(const lv_obj_t *obj, uint32_t char_id, lv_point_t *pos)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object |
char_id | uint32_t | index of the character [0 ... text length - 1]. Expressed in character index, not byte index (different in UTF-8) |
pos | lv_point_t * | store the result here (E.g. index = 0 gives 0;0 coordinates if the text if aligned to the left) |
lv_label_get_letter_on
Get the index of letter on a relative point of a label.
uint32_t lv_label_get_letter_on(const lv_obj_t *obj, lv_point_t *pos_in, bool bidi)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to label object |
pos_in | lv_point_t * | pointer to point with coordinates on a the label |
bidi | bool | whether to use bidi processed |
Returns: uint32_t — The index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter if aligned to the left) Expressed in character index and not byte index (different in UTF-8)
lv_label_get_text_selection_start
Get the selection start index.
uint32_t lv_label_get_text_selection_start(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object. |
Returns: uint32_t — selection start index. LV_LABEL_TEXT_SELECTION_OFF if nothing is selected.
lv_label_get_text_selection_end
Get the selection end index.
uint32_t lv_label_get_text_selection_end(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object. |
Returns: uint32_t — selection end index. LV_LABEL_TXT_SEL_OFF if nothing is selected.
lv_label_get_recolor
Get the recoloring attribute.
bool lv_label_get_recolor(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object. |
Returns: bool — true: recoloring is enabled, false: recoloring is disabled
lv_label_create
Create a label object
lv_obj_t * lv_label_create(lv_obj_t *parent)| Name | Type | Description |
|---|---|---|
parent | lv_obj_t * | pointer to a parent widget May be NULL.. When NULL, the widget is created as a screen on the default display. |
Returns: lv_obj_t * — pointer to the created button
lv_label_is_char_under_pos
Check if a character is drawn under a point.
bool lv_label_is_char_under_pos(const lv_obj_t *obj, lv_point_t *pos)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to a label object |
pos | lv_point_t * | Point to check for character under |
Returns: bool — whether a character is drawn under the point
lv_label_bind_text
Bind an integer, string, or pointer Subject to a Label.
lv_observer_t * lv_label_bind_text(lv_obj_t *obj, lv_subject_t *subject, const char *fmt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to Label |
subject | lv_subject_t * | pointer to Subject |
fmt | const char * | optional printf-like format string with 1 format specifier (e.g. "%d °C"). May be NULL. When NULL the value is bound directly. |
Returns: lv_observer_t * — pointer to newly-created Observer
If fmt == NULL strings and pointers (\0 terminated string) will be shown as text as they are, integers as d, floats as %0.1f
lv_label_ins_text
Insert a text to a label. The label text cannot be static.
void lv_label_ins_text(lv_obj_t *obj, uint32_t pos, const char *txt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
pos | uint32_t | character index to insert. Expressed in character index and not byte index. 0: before first char. LV_LABEL_POS_LAST: after last char. |
txt | const char * | pointer to the text to insert |
lv_label_cut_text
Delete characters from a label. The label text cannot be static.
void lv_label_cut_text(lv_obj_t *obj, uint32_t pos, uint32_t cnt)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a label object |
pos | uint32_t | character index from where to cut. Expressed in character index and not byte index. 0: start in front of the first character |
cnt | uint32_t | number of characters to cut |
Enums
lv_label_long_mode_t
Long mode behaviors. Used in 'lv_label_ext_t'
| Name | Description |
|---|---|
LV_LABEL_LONG_MODE_WRAP | Keep the object width, wrap lines longer than object width and expand the object height |
LV_LABEL_LONG_MODE_DOTS | Keep the size and write dots at the end if the text is too long |
LV_LABEL_LONG_MODE_SCROLL | Keep the size and roll the text back and forth |
LV_LABEL_LONG_MODE_SCROLL_CIRCULAR | Keep the size and roll the text circularly |
LV_LABEL_LONG_MODE_CLIP | Keep the size and clip the text out of it |
Used by 1 function
lv_label_set_long_mode— paramlong_mode
_lv_property_label_id_t
| Name | Value |
|---|---|
LV_PROPERTY_LABEL_TEXT | (LV_PROPERTY_LABEL_START + ((int) 0 )) | (( 7 ) << 28 ) |
LV_PROPERTY_LABEL_LONG_MODE | (LV_PROPERTY_LABEL_START + ((int) 1 )) | (( 1 ) << 28 ) |
LV_PROPERTY_LABEL_MAX_LINES | (LV_PROPERTY_LABEL_START + ((int) 2 )) | (( 1 ) << 28 ) |
LV_PROPERTY_LABEL_TEXT_SELECTION_START | (LV_PROPERTY_LABEL_START + ((int) 3 )) | (( 1 ) << 28 ) |
LV_PROPERTY_LABEL_TEXT_SELECTION_END | (LV_PROPERTY_LABEL_START + ((int) 4 )) | (( 1 ) << 28 ) |
LV_PROPERTY_LABEL_END |
Macros
LV_LABEL_DOT_NUM
#define LV_LABEL_DOT_NUM 3LV_LABEL_POS_LAST
#define LV_LABEL_POS_LAST 0xFFFFLV_LABEL_TEXT_SELECTION_OFF
#define LV_LABEL_TEXT_SELECTION_OFF LV_DRAW_LABEL_NO_TXT_SELLV_LABEL_DEFAULT_TEXT
#define LV_LABEL_DEFAULT_TEXT "Text"Variables
lv_label_class
const lv_obj_class_t lv_label_classDependencies
Indirect dependencies
lv_anim.hlv_area.hlv_assert.hlv_bidi.hlv_color.hlv_color_op.hlv_display.hlv_draw_arc.hlv_draw_blur.hlv_draw_buf.hlv_draw_image.hlv_draw_label.hlv_draw_line.hlv_draw_rect.hlv_draw_triangle.hlv_event.hlv_ext_data.hlv_flex.hlv_fs.hlv_grad.hlv_grid.hlv_group.hlv_image_decoder.hlv_image_dsc.hlv_indev.hlv_layout.hlv_ll.hlv_log.hlv_math.hlv_matrix.hlv_mem.hlv_obj_class.hlv_obj_draw.hlv_obj_event.hlv_obj_pos.hlv_obj_property.hlv_obj_scroll.hlv_obj_style.hlv_obj_style_gen.hlv_obj_tree.hlv_palette.hlv_profiler.hlv_profiler_builtin.hlv_sprintf.hlv_string.hlv_style.hlv_style_gen.hlv_timer.h
Last updated on