1 /**
2 * @file lv_xml_dropdown_parser.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_xml_dropdown_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
lv_xml_dropdown_create(lv_xml_parser_state_t * state,const char ** attrs)39 void * lv_xml_dropdown_create(lv_xml_parser_state_t * state, const char ** attrs)
40 {
41 LV_UNUSED(attrs);
42 void * item = lv_dropdown_create(lv_xml_state_get_parent(state));
43
44 return item;
45 }
46
47
lv_xml_dropdown_apply(lv_xml_parser_state_t * state,const char ** attrs)48 void lv_xml_dropdown_apply(lv_xml_parser_state_t * state, const char ** attrs)
49 {
50 void * item = lv_xml_state_get_item(state);
51
52 lv_xml_obj_apply(state, attrs); /*Apply the common properties, e.g. width, height, styles flags etc*/
53
54 for(int i = 0; attrs[i]; i += 2) {
55 const char * name = attrs[i];
56 const char * value = attrs[i + 1];
57
58 if(lv_streq("options", name)) lv_dropdown_set_options(item, value);
59 if(lv_streq("text", name)) lv_dropdown_set_text(item, value);
60 if(lv_streq("selected", name)) lv_dropdown_set_selected(item, lv_xml_atoi(value), LV_ANIM_OFF);
61 if(lv_streq("symbol", name)) lv_dropdown_set_symbol(item, lv_xml_get_image(value));
62 }
63 }
64
lv_xml_dropdown_list_create(lv_xml_parser_state_t * state,const char ** attrs)65 void * lv_xml_dropdown_list_create(lv_xml_parser_state_t * state, const char ** attrs)
66 {
67 LV_UNUSED(attrs);
68
69 return lv_dropdown_get_list(lv_xml_state_get_parent(state));
70 }
71
lv_xml_dropdown_list_apply(lv_xml_parser_state_t * state,const char ** attrs)72 void lv_xml_dropdown_list_apply(lv_xml_parser_state_t * state, const char ** attrs)
73 {
74 LV_UNUSED(state);
75 LV_UNUSED(attrs);
76
77 lv_xml_obj_apply(state, attrs);
78 }
79
80 /**********************
81 * STATIC FUNCTIONS
82 **********************/
83
84 #endif /* LV_USE_XML */
85