LittlevGL  3.20.00.19
lv_btnm.h
Go to the documentation of this file.
1 
6 #ifndef LV_BTNM_H
7 #define LV_BTNM_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  * INCLUDES
15  *********************/
16 #ifdef LV_CONF_INCLUDE_SIMPLE
17 #include "lv_conf.h"
18 #else
19 #include "../../../lv_conf.h"
20 #endif
21 
22 #if LV_USE_BTNM != 0
23 
24 #include "../lv_core/lv_obj.h"
25 #include "lv_label.h"
26 #include "lv_btn.h"
27 
28 /*********************
29  * DEFINES
30  *********************/
31 #define LV_BTNM_WIDTH_MASK 0x0007
32 #define LV_BTNM_BTN_NONE 0xFFFF
33 
34 /**********************
35  * TYPEDEFS
36  **********************/
37 
39 enum {
40  LV_BTNM_CTRL_HIDDEN = 0x0008,
41  LV_BTNM_CTRL_NO_REPEAT = 0x0010,
42  LV_BTNM_CTRL_INACTIVE = 0x0020,
43  LV_BTNM_CTRL_TGL_ENABLE = 0x0040,
44  LV_BTNM_CTRL_TGL_STATE = 0x0080,
45  LV_BTNM_CTRL_CLICK_TRIG = 0x0100,
46 };
47 typedef uint16_t lv_btnm_ctrl_t;
48 
49 /*Data of button matrix*/
50 typedef struct
51 {
52  /*No inherited ext.*/ /*Ext. of ancestor*/
53  /*New data for this type */
54  const char ** map_p; /*Pointer to the current map*/
55  lv_area_t * button_areas; /*Array of areas of buttons*/
56  lv_btnm_ctrl_t * ctrl_bits; /*Array of control bytes*/
57  const lv_style_t * styles_btn[_LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/
58  uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
59  uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_BTN_NONE*/
60  uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */
61  uint8_t recolor : 1; /*Enable button recoloring*/
62  uint8_t one_toggle : 1; /*Single button toggled at once*/
63 } lv_btnm_ext_t;
64 
65 enum {
66  LV_BTNM_STYLE_BG,
67  LV_BTNM_STYLE_BTN_REL,
68  LV_BTNM_STYLE_BTN_PR,
69  LV_BTNM_STYLE_BTN_TGL_REL,
70  LV_BTNM_STYLE_BTN_TGL_PR,
71  LV_BTNM_STYLE_BTN_INA,
72 };
73 typedef uint8_t lv_btnm_style_t;
74 
75 /**********************
76  * GLOBAL PROTOTYPES
77  **********************/
78 
86 lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy);
87 
88 /*=====================
89  * Setter functions
90  *====================*/
91 
99 void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]);
100 
113 void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t ctrl_map[]);
114 
121 void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id);
122 
129 void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, const lv_style_t * style);
130 
136 void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en);
137 
143 void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
144 
150 void lv_btnm_clear_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
151 
157 void lv_btnm_set_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl);
158 
165 void lv_btnm_clear_btn_ctrl_all(lv_obj_t * btnm, lv_btnm_ctrl_t ctrl);
166 
176 void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width);
177 
187 void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle);
188 
189 /*=====================
190  * Getter functions
191  *====================*/
192 
198 const char ** lv_btnm_get_map_array(const lv_obj_t * btnm);
199 
205 bool lv_btnm_get_recolor(const lv_obj_t * btnm);
206 
213 uint16_t lv_btnm_get_active_btn(const lv_obj_t * btnm);
214 
221 const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm);
222 
229 uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm);
230 
238 const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id);
239 
248 bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
249 
256 const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type);
257 
263 bool lv_btnm_get_one_toggle(const lv_obj_t * btnm);
264 /**********************
265  * MACROS
266  **********************/
267 
268 #endif /*LV_USE_BTNM*/
269 
270 #ifdef __cplusplus
271 } /* extern "C" */
272 #endif
273 
274 #endif /*LV_BTNM_H*/
Definition: lv_obj.h:184
struct _lv_obj_t * par
Definition: lv_obj.h:186
Definition: lv_area.h:46
Definition: lv_style.h:57
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale