1 /**
2  * @file lv_xml_tabview_parser.c
3  *
4  */
5 
6 /*********************
7  *      INCLUDES
8  *********************/
9 #include "lv_xml_tabview_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_tabview_create(lv_xml_parser_state_t * state,const char ** attrs)39 void * lv_xml_tabview_create(lv_xml_parser_state_t * state, const char ** attrs)
40 {
41     LV_UNUSED(attrs);
42     void * item = lv_tabview_create(lv_xml_state_get_parent(state));
43 
44     return item;
45 }
46 
47 
lv_xml_tabview_apply(lv_xml_parser_state_t * state,const char ** attrs)48 void lv_xml_tabview_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("active", name)) lv_tabview_set_active(item, lv_xml_atoi(value), 0);
59         if(lv_streq("tab_bar_position", name)) lv_tabview_set_tab_bar_position(item, lv_xml_dir_to_enum(value));
60     }
61 }
62 
lv_xml_tabview_tab_bar_create(lv_xml_parser_state_t * state,const char ** attrs)63 void * lv_xml_tabview_tab_bar_create(lv_xml_parser_state_t * state, const char ** attrs)
64 {
65     LV_UNUSED(attrs);
66     void * item = lv_tabview_get_tab_bar(lv_xml_state_get_parent(state));
67     return item;
68 }
69 
70 
lv_xml_tabview_tab_bar_apply(lv_xml_parser_state_t * state,const char ** attrs)71 void lv_xml_tabview_tab_bar_apply(lv_xml_parser_state_t * state, const char ** attrs)
72 {
73     /*Apply the common properties, e.g. width, height, styles flags etc*/
74     lv_xml_obj_apply(state, attrs);
75 }
76 
lv_xml_tabview_tab_create(lv_xml_parser_state_t * state,const char ** attrs)77 void * lv_xml_tabview_tab_create(lv_xml_parser_state_t * state, const char ** attrs)
78 {
79     const char * text = lv_xml_get_value_of(attrs, "text");
80     void * item = lv_tabview_add_tab(lv_xml_state_get_parent(state), text);
81     return item;
82 }
83 
lv_xml_tabview_tab_apply(lv_xml_parser_state_t * state,const char ** attrs)84 void lv_xml_tabview_tab_apply(lv_xml_parser_state_t * state, const char ** attrs)
85 {
86     /*Apply the common properties, e.g. width, height, styles flags etc*/
87     lv_xml_obj_apply(state, attrs);
88 }
89 
90 /**********************
91  *   STATIC FUNCTIONS
92  **********************/
93 
94 #endif /* LV_USE_XML */
95