Skip to content

Commit b08a29b

Browse files
committed
Added Textarea XML parser for LVGL.
1 parent b658913 commit b08a29b

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

plugins/gui/lvgl_static/src/others/xml/lv_xml.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "parsers/lv_xml_obj_parser.h"
2323
#include "parsers/lv_xml_button_parser.h"
2424
#include "parsers/lv_xml_label_parser.h"
25+
#include "parsers/lv_xml_textarea_parser.h"
2526
#include "parsers/lv_xml_image_parser.h"
2627
#include "parsers/lv_xml_bar_parser.h"
2728
#include "parsers/lv_xml_slider_parser.h"
@@ -100,7 +101,7 @@ void lv_xml_init(void)
100101
lv_xml_widget_register("lv_spangroup", lv_xml_spangroup_create, lv_xml_spangroup_apply);
101102
lv_xml_widget_register("lv_spangroup-span", lv_xml_spangroup_span_create, lv_xml_spangroup_span_apply);
102103
lv_xml_widget_register("lv_buttonmatrix", lv_xml_buttonmatrix_create, lv_xml_buttonmatrix_apply);
103-
104+
lv_xml_widget_register("lv_textarea", lv_xml_textarea_create, lv_xml_textarea_apply);
104105
lv_xml_widget_register("lv_event-call_function", lv_xml_event_call_function_create, lv_xml_event_call_function_apply);
105106
}
106107

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @file lv_xml_textarea_parser.c
3+
*
4+
*/
5+
6+
/*********************
7+
* INCLUDES
8+
*********************/
9+
#include "lv_xml_textarea_parser.h"
10+
#if LV_USE_XML
11+
12+
#include "../../../lvgl.h"
13+
#include "../../../lvgl_private.h"
14+
15+
/*********************
16+
* DEFINES
17+
*********************/
18+
19+
/**********************
20+
* TYPEDEFS
21+
**********************/
22+
23+
/**********************
24+
* STATIC PROTOTYPES
25+
**********************/
26+
27+
/**********************
28+
* STATIC VARIABLES
29+
**********************/
30+
31+
/**********************
32+
* MACROS
33+
**********************/
34+
35+
/**********************
36+
* GLOBAL FUNCTIONS
37+
**********************/
38+
39+
void * lv_xml_textarea_create(lv_xml_parser_state_t * state, const char ** attrs)
40+
{
41+
LV_UNUSED(attrs);
42+
void * item = lv_textarea_create(lv_xml_state_get_parent(state));
43+
44+
return item;
45+
}
46+
47+
void lv_xml_textarea_apply(lv_xml_parser_state_t * state, const char ** attrs)
48+
{
49+
void * item = lv_xml_state_get_item(state);
50+
51+
lv_xml_obj_apply(state, attrs); /*Apply the common properties, e.g. width, height, styles flags etc*/
52+
53+
for(int i = 0; attrs[i]; i += 2) {
54+
const char * name = attrs[i];
55+
const char * value = attrs[i + 1];
56+
if(lv_streq("text", name)) lv_textarea_set_text(item, value);
57+
else if(lv_streq("placeholder", name)) lv_textarea_set_placeholder_text(item, value);
58+
else if(lv_streq("one_line", name)) lv_textarea_set_one_line(item, lv_xml_to_bool(value));
59+
else if(lv_streq("password", name)) lv_textarea_set_password_mode(item, lv_xml_to_bool(value));
60+
}
61+
}
62+
63+
/**********************
64+
* STATIC FUNCTIONS
65+
**********************/
66+
67+
68+
#endif /* LV_USE_XML */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @file lv_xml_label_parser.h
3+
*
4+
*/
5+
6+
#ifndef LV_TEXTAREA_XML_PARSER_H
7+
#define LV_TEXTAREA_XML_PARSER_H
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
/*********************
14+
* INCLUDES
15+
*********************/
16+
#include "../lv_xml.h"
17+
#if LV_USE_XML
18+
19+
/**********************
20+
* TYPEDEFS
21+
**********************/
22+
23+
/**********************
24+
* GLOBAL PROTOTYPES
25+
**********************/
26+
27+
void * lv_xml_textarea_create(lv_xml_parser_state_t * state, const char ** attrs);
28+
29+
void lv_xml_textarea_apply(lv_xml_parser_state_t * state, const char ** attrs);
30+
31+
/**********************
32+
* MACROS
33+
**********************/
34+
35+
#endif /* LV_USE_XML */
36+
37+
#ifdef __cplusplus
38+
} /*extern "C"*/
39+
#endif
40+
41+
#endif /*LV_LABEL_XML_PARSE_H*/

0 commit comments

Comments
 (0)