1 /** 2 * @file lv_obj_class.h 3 * 4 */ 5 6 #ifndef LV_OBJ_CLASS_H 7 #define LV_OBJ_CLASS_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include <stdint.h> 17 #include <stdbool.h> 18 19 /********************* 20 * DEFINES 21 *********************/ 22 23 /********************** 24 * TYPEDEFS 25 **********************/ 26 27 struct _lv_obj_t; 28 struct _lv_obj_class_t; 29 struct _lv_event_t; 30 31 typedef enum { 32 LV_OBJ_CLASS_EDITABLE_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/ 33 LV_OBJ_CLASS_EDITABLE_TRUE, 34 LV_OBJ_CLASS_EDITABLE_FALSE, 35 } lv_obj_class_editable_t; 36 37 typedef enum { 38 LV_OBJ_CLASS_GROUP_DEF_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/ 39 LV_OBJ_CLASS_GROUP_DEF_TRUE, 40 LV_OBJ_CLASS_GROUP_DEF_FALSE, 41 } lv_obj_class_group_def_t; 42 43 typedef void (*lv_obj_class_event_cb_t)(struct _lv_obj_class_t * class_p, struct _lv_event_t * e); 44 /** 45 * Describe the common methods of every object. 46 * Similar to a C++ class. 47 */ 48 typedef struct _lv_obj_class_t { 49 const struct _lv_obj_class_t * base_class; 50 void (*constructor_cb)(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj); 51 void (*destructor_cb)(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj); 52 #if LV_USE_USER_DATA 53 void * user_data; 54 #endif 55 void (*event_cb)(const struct _lv_obj_class_t * class_p, 56 struct _lv_event_t * e); /**< Widget type specific event function*/ 57 lv_coord_t width_def; 58 lv_coord_t height_def; 59 uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/ 60 uint32_t group_def : 2; /**< Value from ::lv_obj_class_group_def_t*/ 61 uint32_t instance_size : 16; 62 } lv_obj_class_t; 63 64 /********************** 65 * GLOBAL PROTOTYPES 66 **********************/ 67 68 /** 69 * Create an object form a class descriptor 70 * @param class_p pointer to a class 71 * @param parent pointer to an object where the new object should be created 72 * @return pointer to the created object 73 */ 74 struct _lv_obj_t * lv_obj_class_create_obj(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent); 75 76 void lv_obj_class_init_obj(struct _lv_obj_t * obj); 77 78 void _lv_obj_destruct(struct _lv_obj_t * obj); 79 80 bool lv_obj_is_editable(struct _lv_obj_t * obj); 81 82 bool lv_obj_is_group_def(struct _lv_obj_t * obj); 83 84 /********************** 85 * MACROS 86 **********************/ 87 88 #ifdef __cplusplus 89 } /*extern "C"*/ 90 #endif 91 92 #endif /*LV_OBJ_CLASS_H*/ 93