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