1 /**
2  * @file lv_imagebutton.h
3  *
4  */
5 
6 #ifndef LV_IMAGEBUTTON_H
7 #define LV_IMAGEBUTTON_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../core/lv_obj.h"
17 
18 #if LV_USE_IMAGEBUTTON != 0
19 
20 /*********************
21  *      DEFINES
22  *********************/
23 typedef enum {
24     LV_IMAGEBUTTON_STATE_RELEASED,
25     LV_IMAGEBUTTON_STATE_PRESSED,
26     LV_IMAGEBUTTON_STATE_DISABLED,
27     LV_IMAGEBUTTON_STATE_CHECKED_RELEASED,
28     LV_IMAGEBUTTON_STATE_CHECKED_PRESSED,
29     LV_IMAGEBUTTON_STATE_CHECKED_DISABLED,
30     LV_IMAGEBUTTON_STATE_NUM,
31 } lv_imagebutton_state_t;
32 
33 /**********************
34  *      TYPEDEFS
35  **********************/
36 LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_imagebutton_class;
37 
38 /**********************
39  * GLOBAL PROTOTYPES
40  **********************/
41 
42 /**
43  * Create an image button object
44  * @param parent pointer to an object, it will be the parent of the new image button
45  * @return pointer to the created image button
46  */
47 lv_obj_t * lv_imagebutton_create(lv_obj_t * parent);
48 
49 /*======================
50  * Add/remove functions
51  *=====================*/
52 
53 /*=====================
54  * Setter functions
55  *====================*/
56 
57 /**
58  * Set images for a state of the image button
59  * @param imagebutton   pointer to an image button object
60  * @param state         for which state set the new image
61  * @param src_left      pointer to an image source for the left side of the button (a C array or path to
62  * a file)
63  * @param src_mid       pointer to an image source for the middle of the button (ideally 1px wide) (a C
64  * array or path to a file)
65  * @param src_right     pointer to an image source for the right side of the button (a C array or path
66  * to a file)
67  */
68 void lv_imagebutton_set_src(lv_obj_t * imagebutton, lv_imagebutton_state_t state, const void * src_left,
69                             const void * src_mid,
70                             const void * src_right);
71 
72 /**
73  * Use this function instead of `lv_obj_add/remove_state` to set a state manually
74  * @param imagebutton   pointer to an image button object
75  * @param state         the new state
76  */
77 void lv_imagebutton_set_state(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
78 
79 /*=====================
80  * Getter functions
81  *====================*/
82 
83 /**
84  * Get the left image in a given state
85  * @param imagebutton   pointer to an image button object
86  * @param state         the state where to get the image (from `lv_button_state_t`) `
87  * @return              pointer to the left image source (a C array or path to a file)
88  */
89 const void * lv_imagebutton_get_src_left(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
90 
91 /**
92  * Get the middle image in a given state
93  * @param imagebutton   pointer to an image button object
94  * @param state         the state where to get the image (from `lv_button_state_t`) `
95  * @return              pointer to the middle image source (a C array or path to a file)
96  */
97 const void * lv_imagebutton_get_src_middle(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
98 
99 /**
100  * Get the right image in a given state
101  * @param imagebutton   pointer to an image button object
102  * @param state         the state where to get the image (from `lv_button_state_t`) `
103  * @return              pointer to the left image source (a C array or path to a file)
104  */
105 const void * lv_imagebutton_get_src_right(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
106 
107 /*=====================
108  * Other functions
109  *====================*/
110 
111 /**********************
112  *      MACROS
113  **********************/
114 
115 #endif /*LV_USE_IMAGEBUTTON*/
116 
117 #ifdef __cplusplus
118 } /*extern "C"*/
119 #endif
120 
121 #endif /*LV_IMAGEBUTTON_H*/
122