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. NULL to refresh with the 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. NULL to refresh with the current text. |
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_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. |
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_TEXT_SELECTION_START | (LV_PROPERTY_LABEL_START + ((int) 2 )) | (( 1 ) << 28 ) |
LV_PROPERTY_LABEL_TEXT_SELECTION_END | (LV_PROPERTY_LABEL_START + ((int) 3 )) | (( 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_array.hlv_assert.hlv_bidi.hlv_color.hlv_color_op.hlv_conf_kconfig.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_property_names.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_style_properties.hlv_tick.hlv_timer.h
How is this guide?
Last updated on