1 /**
2 * @file lv_templ.c
3 *
4 */
5
6 /**
7 * TODO Remove these instructions
8 * Search and replace: templ -> object short name with lower case(e.g. btn, label etc)
9 * TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
10 *
11 * You can remove the defined() clause from the #if statement below. This exists because
12 * LV_USE_TEMPL is not in lv_conf.h or lv_conf_template.h by default.
13 */
14
15 /*********************
16 * INCLUDES
17 *********************/
18 //#include "lv_templ.h" /*TODO uncomment this*/
19
20 #if defined(LV_USE_TEMPL) && LV_USE_TEMPL != 0
21
22 /*********************
23 * DEFINES
24 *********************/
25 #define MY_CLASS (&lv_templ_class)
26
27 /**********************
28 * TYPEDEFS
29 **********************/
30
31 /**********************
32 * STATIC PROTOTYPES
33 **********************/
34 static void lv_templ_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
35 static void lv_templ_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
36 static void lv_templ_event(const lv_obj_class_t * class_p, lv_event_t * e);
37
38 /**********************
39 * STATIC VARIABLES
40 **********************/
41 const lv_obj_class_t lv_templ_class = {
42 .constructor_cb = lv_templ_constructor,
43 .destructor_cb = lv_templ_destructor,
44 .event_cb = lv_templ_event,
45 .width_def = LV_DPI_DEF,
46 .height_def = LV_DPI_DEF,
47 .instance_size = sizeof(lv_templ_t),
48 .group_def = LV_OBJ_CLASS_GROUP_DEF_INHERIT,
49 .editable = LV_OBJ_CLASS_EDITABLE_INHERIT,
50 .base_class = &lv_templ_class,
51 .name = "templ",
52 };
53
54 /**********************
55 * MACROS
56 **********************/
57
58 /**********************
59 * GLOBAL FUNCTIONS
60 **********************/
61
lv_templ_create(lv_obj_t * parent)62 lv_obj_t * lv_templ_create(lv_obj_t * parent)
63 {
64
65 LV_LOG_INFO("begin");
66 lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
67 lv_obj_class_init_obj(obj);
68 return obj;
69 }
70
71 /*======================
72 * Add/remove functions
73 *=====================*/
74
75 /*
76 * New object specific "add" or "remove" functions come here
77 */
78
79 /*=====================
80 * Setter functions
81 *====================*/
82
83 /*
84 * New object specific "set" functions come here
85 */
86
87 /*=====================
88 * Getter functions
89 *====================*/
90
91 /*
92 * New object specific "get" functions come here
93 */
94
95 /*=====================
96 * Other functions
97 *====================*/
98
99 /*
100 * New object specific "other" functions come here
101 */
102
103 /**********************
104 * STATIC FUNCTIONS
105 **********************/
106
lv_templ_constructor(const lv_obj_class_t * class_p,lv_obj_t * obj)107 static void lv_templ_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
108 {
109 LV_UNUSED(class_p);
110 LV_TRACE_OBJ_CREATE("begin");
111
112 lv_templ_t * templ = (lv_templ_t *)obj;
113 /*Initialize the widget's data*/
114
115 LV_TRACE_OBJ_CREATE("finished");
116 }
117
lv_templ_destructor(const lv_obj_class_t * class_p,lv_obj_t * obj)118 static void lv_templ_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
119 {
120 lv_templ_t * templ = (lv_templ_t *)obj;
121 /*Free the widget specific data*/
122 }
123
lv_templ_event(const lv_obj_class_t * class_p,lv_event_t * e)124 static void lv_templ_event(const lv_obj_class_t * class_p, lv_event_t * e)
125 {
126 LV_UNUSED(class_p);
127
128 lv_result_t res;
129
130 /*Call the ancestor's event handler*/
131 res = lv_obj_event_base(MY_CLASS, e);
132 if(res != LV_RESULT_OK) return;
133
134 /*Add the widget specific event handling here*/
135 }
136
137 #else /*Enable this file at the top*/
138
139 /*This dummy typedef exists purely to silence -Wpedantic.*/
140 typedef int keep_pedantic_happy;
141 #endif
142