mikroSDK Reference Manual
lv_label.h
Go to the documentation of this file.
1
6#ifndef LV_LABEL_H
7#define LV_LABEL_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#if LV_USE_LABEL != 0
19
20#include <stdarg.h>
21#include "../core/lv_obj.h"
22#include "../font/lv_font.h"
23#include "../font/lv_symbol_def.h"
24#include "../misc/lv_txt.h"
25#include "../draw/lv_draw.h"
26
27/*********************
28 * DEFINES
29 *********************/
30#define LV_LABEL_WAIT_CHAR_COUNT 3
31#define LV_LABEL_DOT_NUM 3
32#define LV_LABEL_POS_LAST 0xFFFF
33#define LV_LABEL_TEXT_SELECTION_OFF LV_DRAW_LABEL_NO_TXT_SEL
34
35LV_EXPORT_CONST_INT(LV_LABEL_DOT_NUM);
36LV_EXPORT_CONST_INT(LV_LABEL_POS_LAST);
37LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SELECTION_OFF);
38
39/**********************
40 * TYPEDEFS
41 **********************/
42
44enum {
45 LV_LABEL_LONG_WRAP,
46 LV_LABEL_LONG_DOT,
47 LV_LABEL_LONG_SCROLL,
48 LV_LABEL_LONG_SCROLL_CIRCULAR,
49 LV_LABEL_LONG_CLIP,
50};
51typedef uint8_t lv_label_long_mode_t;
52
53typedef struct {
54 lv_obj_t obj;
55 char * text;
56 union {
57 char * tmp_ptr; /*Pointer to the allocated memory containing the character replaced by dots*/
58 char tmp[LV_LABEL_DOT_NUM + 1]; /*Directly store the characters if <=4 characters*/
59 } dot;
60 uint32_t dot_end; /*The real text length, used in dot mode*/
61
62#if LV_LABEL_LONG_TXT_HINT
64#endif
65
66#if LV_LABEL_TEXT_SELECTION
67 uint32_t sel_start;
68 uint32_t sel_end;
69#endif
70
71 lv_point_t offset; /*Text draw position offset*/
72 lv_label_long_mode_t long_mode : 3; /*Determine what to do with the long texts*/
73 uint8_t static_txt : 1; /*Flag to indicate the text is static*/
74 uint8_t recolor : 1; /*Enable in-line letter re-coloring*/
75 uint8_t expand : 1; /*Ignore real width (used by the library with LV_LABEL_LONG_SCROLL)*/
76 uint8_t dot_tmp_alloc : 1; /*1: dot is allocated, 0: dot directly holds up to 4 chars*/
77} lv_label_t;
78
79extern const lv_obj_class_t lv_label_class;
80
81/**********************
82 * GLOBAL PROTOTYPES
83 **********************/
84
90lv_obj_t * lv_label_create(lv_obj_t * parent);
91
92/*=====================
93 * Setter functions
94 *====================*/
95
101void lv_label_set_text(lv_obj_t * obj, const char * text);
102
109void lv_label_set_text_fmt(lv_obj_t * obj, const char * fmt, ...) LV_FORMAT_ATTRIBUTE(2, 3);
110
117void lv_label_set_text_static(lv_obj_t * obj, const char * text);
118
125void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode);
126
133void lv_label_set_recolor(lv_obj_t * obj, bool en);
134
140void lv_label_set_text_sel_start(lv_obj_t * obj, uint32_t index);
141
147void lv_label_set_text_sel_end(lv_obj_t * obj, uint32_t index);
148
149/*=====================
150 * Getter functions
151 *====================*/
152
158char * lv_label_get_text(const lv_obj_t * obj);
159
165lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * obj);
166
172bool lv_label_get_recolor(const lv_obj_t * obj);
173
181void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t * pos);
182
190uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in);
191
198bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos);
199
205uint32_t lv_label_get_text_selection_start(const lv_obj_t * obj);
206
212uint32_t lv_label_get_text_selection_end(const lv_obj_t * obj);
213
214/*=====================
215 * Other functions
216 *====================*/
217
225void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt);
226
234void lv_label_cut_text(lv_obj_t * obj, uint32_t pos, uint32_t cnt);
235
236/**********************
237 * MACROS
238 **********************/
239
240#endif /*LV_USE_LABEL*/
241
242#ifdef __cplusplus
243} /*extern "C"*/
244#endif
245
246#endif /*LV_LABEL_H*/
Definition lv_draw_label.h:54
Definition lv_obj_class.h:49
Definition lv_obj.h:174
Definition lv_area.h:37