lv_label.h
Defines
-
LV_LABEL_WAIT_CHAR_COUNT
-
LV_LABEL_DOT_NUM
-
LV_LABEL_POS_LAST
-
LV_LABEL_TEXT_SELECTION_OFF
-
LV_LABEL_DEFAULT_TEXT
Typedefs
-
typedef _lv_label_long_mode_t lv_label_long_mode_t
Enums
-
enum _lv_label_long_mode_t
Long mode behaviors. Used in 'lv_label_ext_t'
Values:
-
enumerator LV_LABEL_LONG_WRAP
Keep the object width, wrap lines longer than object width and expand the object height
-
enumerator LV_LABEL_LONG_DOT
Keep the size and write dots at the end if the text is too long
-
enumerator LV_LABEL_LONG_SCROLL
Keep the size and roll the text back and forth
-
enumerator LV_LABEL_LONG_SCROLL_CIRCULAR
Keep the size and roll the text circularly
-
enumerator LV_LABEL_LONG_CLIP
Keep the size and clip the text out of it
-
enumerator LV_LABEL_LONG_WRAP
Functions
-
lv_obj_t *lv_label_create(lv_obj_t *parent)
Create a label object
- Parameters:
parent -- pointer to an object, it will be the parent of the new label.
- Returns:
pointer to the created button
-
void lv_label_set_text(lv_obj_t *obj, const char *text)
Set a new text for a label. Memory will be allocated to store the text by the label.
- Parameters:
obj -- pointer to a label object
text -- '\0' terminated character string. NULL to refresh with the current text.
-
void lv_label_set_text_static(lv_obj_t *obj, const char *text)
Set a static text. It will not be saved by the label so the 'text' variable has to be 'alive' while the label exists.
- Parameters:
obj -- pointer to a label object
text -- pointer to a text. NULL to refresh with the current text.
-
void lv_label_set_long_mode(lv_obj_t *obj, lv_label_long_mode_t long_mode)
Set the behavior of the label with text longer than the object size
- Parameters:
obj -- pointer to a label object
long_mode -- 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
-
void lv_label_set_text_selection_start(lv_obj_t *obj, uint32_t index)
Set where text selection should start
- Parameters:
obj -- pointer to a label object
index -- character index from where selection should start.
LV_LABEL_TEXT_SELECTION_OFF
for no selection
-
void lv_label_set_text_selection_end(lv_obj_t *obj, uint32_t index)
Set where text selection should end
- Parameters:
obj -- pointer to a label object
index -- character index where selection should end.
LV_LABEL_TEXT_SELECTION_OFF
for no selection
-
char *lv_label_get_text(const lv_obj_t *obj)
Get the text of a label
- Parameters:
obj -- pointer to a label object
- Returns:
the text of the label
-
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t *obj)
Get the long mode of a label
- Parameters:
obj -- pointer to a label object
- Returns:
the current long mode
-
bool lv_label_get_recolor(const lv_obj_t *obj)
Get the recoloring attribute
- Parameters:
obj -- pointer to a label object
- Returns:
true: recoloring is enabled, false: disable
-
void lv_label_get_letter_pos(const lv_obj_t *obj, uint32_t char_id, lv_point_t *pos)
Get the relative x and y coordinates of a letter
- Parameters:
obj -- pointer to a label object
char_id -- index of the character [0 ... text length - 1]. Expressed in character index, not byte index (different in UTF-8)
pos -- store the result here (E.g. index = 0 gives 0;0 coordinates if the text if aligned to the left)
-
uint32_t lv_label_get_letter_on(const lv_obj_t *obj, lv_point_t *pos_in)
Get the index of letter on a relative point of a label.
- Parameters:
obj -- pointer to label object
pos_in -- pointer to point with coordinates on a the label
- Returns:
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)
-
bool lv_label_is_char_under_pos(const lv_obj_t *obj, lv_point_t *pos)
Check if a character is drawn under a point.
- Parameters:
obj -- pointer to a label object
pos -- Point to check for character under
- Returns:
whether a character is drawn under the point
-
uint32_t lv_label_get_text_selection_start(const lv_obj_t *obj)
Get the selection start index.
- Parameters:
obj -- pointer to a label object.
- Returns:
selection start index.
LV_LABEL_TEXT_SELECTION_OFF
if nothing is selected.
-
uint32_t lv_label_get_text_selection_end(const lv_obj_t *obj)
Get the selection end index.
- Parameters:
obj -- pointer to a label object.
- Returns:
selection end index.
LV_LABEL_TXT_SEL_OFF
if nothing is selected.
-
void lv_label_ins_text(lv_obj_t *obj, uint32_t pos, const char *txt)
Insert a text to a label. The label text can not be static.
- Parameters:
obj -- pointer to a label object
pos -- character index to insert. Expressed in character index and not byte index. 0: before first char. LV_LABEL_POS_LAST: after last char.
txt -- pointer to the text to insert
-
void lv_label_cut_text(lv_obj_t *obj, uint32_t pos, uint32_t cnt)
Delete characters from a label. The label text can not be static.
- Parameters:
obj -- pointer to a label object
pos -- character index from where to cut. Expressed in character index and not byte index. 0: start in from of the first character
cnt -- number of characters to cut
Variables
-
const lv_obj_class_t lv_label_class
-
struct lv_label_t
Public Members
-
char *text
-
char *tmp_ptr
-
char tmp[3 + 1]
-
union lv_label_t::[anonymous] dot
-
uint32_t dot_end
-
uint32_t sel_start
-
uint32_t sel_end
-
lv_point_t size_cache
-
lv_point_t offset
-
lv_label_long_mode_t long_mode
-
uint8_t static_txt
-
uint8_t recolor
-
uint8_t expand
-
uint8_t dot_tmp_alloc
-
uint8_t invalid_size_cache
-
char *text