1 /**
2  *@file lv_theme.h
3  *
4  */
5 
6 #ifndef LV_THEME_H
7 #define LV_THEME_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *    INCLUDES
15  *********************/
16 #include "../core/lv_obj.h"
17 
18 /*********************
19  *    DEFINES
20  *********************/
21 
22 /**********************
23  *    TYPEDEFS
24  **********************/
25 
26 struct _lv_theme_t;
27 struct _lv_disp_t;
28 
29 typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *);
30 
31 typedef struct _lv_theme_t {
32     lv_theme_apply_cb_t apply_cb;
33     struct _lv_theme_t * parent;    /**< Apply the current theme's style on top of this theme.*/
34     void * user_data;
35     struct _lv_disp_t * disp;
36     lv_color_t color_primary;
37     lv_color_t color_secondary;
38     const lv_font_t * font_small;
39     const lv_font_t * font_normal;
40     const lv_font_t * font_large;
41     uint32_t flags;                 /*Any custom flag used by the theme*/
42 } lv_theme_t;
43 
44 /**********************
45  *  GLOBAL PROTOTYPES
46  **********************/
47 
48 /**
49  * Get the theme assigned to the display of the object
50  * @param obj       pointer to a theme object
51  * @return          the theme of the object's display (can be NULL)
52  */
53 lv_theme_t  * lv_theme_get_from_obj(lv_obj_t * obj);
54 
55 /**
56  * Apply the active theme on an object
57  * @param obj pointer to an object
58  */
59 void lv_theme_apply(lv_obj_t * obj);
60 
61 /**
62  * Set a base theme for a theme.
63  * The styles from the base them will be added before the styles of the current theme.
64  * Arbitrary long chain of themes can be created by setting base themes.
65  * @param new_theme pointer to theme which base should be set
66  * @param parent pointer to the base theme
67  */
68 void lv_theme_set_parent(lv_theme_t * new_theme, lv_theme_t * parent);
69 
70 /**
71  * Set an apply callback for a theme.
72  * The apply callback is used to add styles to different objects
73  * @param theme pointer to theme which callback should be set
74  * @param apply_cb pointer to the callback
75  */
76 void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);
77 
78 /**
79  * Get the small font of the theme
80  * @param obj pointer to an object
81  * @return pointer to the font
82  */
83 const lv_font_t * lv_theme_get_font_small(lv_obj_t * obj);
84 /**
85  * Get the normal font of the theme
86  * @param obj pointer to an object
87  * @return pointer to the font
88  */
89 const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj);
90 
91 /**
92  * Get the subtitle font of the theme
93  * @param obj pointer to an object
94  * @return pointer to the font
95  */
96 const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj);
97 
98 /**
99  * Get the primary color of the theme
100  * @param obj pointer to an object
101  * @return the color
102  */
103 lv_color_t lv_theme_get_color_primary(lv_obj_t * obj);
104 
105 /**
106  * Get the secondary color of the theme
107  * @param obj pointer to an object
108  * @return the color
109  */
110 lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj);
111 
112 /**********************
113  *    MACROS
114  **********************/
115 
116 #ifdef __cplusplus
117 } /*extern "C"*/
118 #endif
119 
120 #endif /*LV_THEME_H*/
121