mikroSDK Reference Manual
lv_textarea.h
Go to the documentation of this file.
1
6#ifndef LV_TEXTAREA_H
7#define LV_TEXTAREA_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_TEXTAREA != 0
19
20/*Testing of dependencies*/
21#if LV_USE_LABEL == 0
22#error "lv_ta: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)"
23#endif
24
25#include "../core/lv_obj.h"
26#include "lv_label.h"
27
28/*********************
29 * DEFINES
30 *********************/
31#define LV_TEXTAREA_CURSOR_LAST (0x7FFF) /*Put the cursor after the last character*/
32
33LV_EXPORT_CONST_INT(LV_TEXTAREA_CURSOR_LAST);
34
35/**********************
36 * TYPEDEFS
37 **********************/
38
39/*Data of text area*/
40typedef struct {
41 lv_obj_t obj;
42 lv_obj_t * label; /*Label of the text area*/
43 char * placeholder_txt; /*Place holder label. only visible if text is an empty string*/
44 char * pwd_tmp; /*Used to store the original text in password mode*/
45 char * pwd_bullet; /*Replacement characters displayed in password mode*/
46 const char * accepted_chars; /*Only these characters will be accepted. NULL: accept all*/
47 uint32_t max_length; /*The max. number of characters. 0: no limit*/
48 uint16_t pwd_show_time; /*Time to show characters in password mode before change them to '*'*/
49 struct {
50 lv_coord_t valid_x; /*Used when stepping up/down to a shorter line.
51 *(Used by the library)*/
52 uint32_t pos; /*The current cursor position
53 *(0: before 1st letter; 1: before 2nd letter ...)*/
54 lv_area_t area; /*Cursor area relative to the Text Area*/
55 uint32_t txt_byte_pos; /*Byte index of the letter after (on) the cursor*/
56 uint8_t show : 1; /*Cursor is visible now or not (Handled by the library)*/
57 uint8_t click_pos : 1; /*1: Enable positioning the cursor by clicking the text area*/
58 } cursor;
59#if LV_LABEL_TEXT_SELECTION
60 uint32_t sel_start; /*Temporary values for text selection*/
61 uint32_t sel_end;
62 uint8_t text_sel_in_prog : 1; /*User is in process of selecting*/
63 uint8_t text_sel_en : 1; /*Text can be selected on this text area*/
64#endif
65 uint8_t pwd_mode : 1; /*Replace characters with '*'*/
66 uint8_t one_line : 1; /*One line mode (ignore line breaks)*/
67} lv_textarea_t;
68
69extern const lv_obj_class_t lv_textarea_class;
70
71enum {
72 LV_PART_TEXTAREA_PLACEHOLDER = LV_PART_CUSTOM_FIRST,
73};
74
75/**********************
76 * GLOBAL PROTOTYPES
77 **********************/
78
84lv_obj_t * lv_textarea_create(lv_obj_t * parent);
85
86/*======================
87 * Add/remove functions
88 *=====================*/
89
96void lv_textarea_add_char(lv_obj_t * obj, uint32_t c);
97
103void lv_textarea_add_text(lv_obj_t * obj, const char * txt);
104
109void lv_textarea_del_char(lv_obj_t * obj);
110
115void lv_textarea_del_char_forward(lv_obj_t * obj);
116
117/*=====================
118 * Setter functions
119 *====================*/
120
126void lv_textarea_set_text(lv_obj_t * obj, const char * txt);
127
133void lv_textarea_set_placeholder_text(lv_obj_t * obj, const char * txt);
134
142void lv_textarea_set_cursor_pos(lv_obj_t * obj, int32_t pos);
143
149void lv_textarea_set_cursor_click_pos(lv_obj_t * obj, bool en);
150
156void lv_textarea_set_password_mode(lv_obj_t * obj, bool en);
157
163void lv_textarea_set_password_bullet(lv_obj_t * obj, const char * bullet);
164
170void lv_textarea_set_one_line(lv_obj_t * obj, bool en);
171
177void lv_textarea_set_accepted_chars(lv_obj_t * obj, const char * list);
178
184void lv_textarea_set_max_length(lv_obj_t * obj, uint32_t num);
185
193void lv_textarea_set_insert_replace(lv_obj_t * obj, const char * txt);
194
200void lv_textarea_set_text_selection(lv_obj_t * obj, bool en);
201
207void lv_textarea_set_password_show_time(lv_obj_t * obj, uint16_t time);
208
217void lv_textarea_set_align(lv_obj_t * obj, lv_text_align_t align);
218
219/*=====================
220 * Getter functions
221 *====================*/
222
228const char * lv_textarea_get_text(const lv_obj_t * obj);
229
235const char * lv_textarea_get_placeholder_text(lv_obj_t * obj);
236
242lv_obj_t * lv_textarea_get_label(const lv_obj_t * obj);
243
249uint32_t lv_textarea_get_cursor_pos(const lv_obj_t * obj);
250
256bool lv_textarea_get_cursor_click_pos(lv_obj_t * obj);
257
263bool lv_textarea_get_password_mode(const lv_obj_t * obj);
264
270const char * lv_textarea_get_password_bullet(lv_obj_t * obj);
271
277bool lv_textarea_get_one_line(const lv_obj_t * obj);
278
284const char * lv_textarea_get_accepted_chars(lv_obj_t * obj);
285
291uint32_t lv_textarea_get_max_length(lv_obj_t * obj);
292
298bool lv_textarea_text_is_selected(const lv_obj_t * obj);
299
305bool lv_textarea_get_text_selection(lv_obj_t * obj);
306
312uint16_t lv_textarea_get_password_show_time(lv_obj_t * obj);
313
314/*=====================
315 * Other functions
316 *====================*/
317
322void lv_textarea_clear_selection(lv_obj_t * obj);
323
328void lv_textarea_cursor_right(lv_obj_t * obj);
329
334void lv_textarea_cursor_left(lv_obj_t * obj);
335
340void lv_textarea_cursor_down(lv_obj_t * obj);
341
346void lv_textarea_cursor_up(lv_obj_t * obj);
347
348/**********************
349 * MACROS
350 **********************/
351
352#endif /*LV_USE_TEXTAREA_H*/
353
354#ifdef __cplusplus
355} /*extern "C"*/
356#endif
357
358#endif /*LV_TEXTAREA_H*/
@ LV_PART_CUSTOM_FIRST
Definition lv_obj.h:78
Definition lv_obj_class.h:49
Definition lv_obj.h:174
Definition lv_area.h:43