Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_cb.h
1476 views
1
/**
2
* @file lv_cb.h
3
*
4
*/
5
6
#ifndef LV_CB_H
7
#define LV_CB_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 USE_LV_CB != 0
23
24
/*Testing of dependencies*/
25
#if USE_LV_BTN == 0
26
#error "lv_cb: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
27
#endif
28
29
#if USE_LV_LABEL == 0
30
#error "lv_cb: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
31
#endif
32
33
#include "../lv_core/lv_obj.h"
34
#include "lv_btn.h"
35
#include "lv_label.h"
36
37
/*********************
38
* DEFINES
39
*********************/
40
41
/**********************
42
* TYPEDEFS
43
**********************/
44
45
/*Data of check box*/
46
typedef struct
47
{
48
lv_btn_ext_t bg_btn; /*Ext. of ancestor*/
49
/*New data for this type */
50
lv_obj_t * bullet; /*Pointer to button*/
51
lv_obj_t * label; /*Pointer to label*/
52
} lv_cb_ext_t;
53
54
enum {
55
LV_CB_STYLE_BG,
56
LV_CB_STYLE_BOX_REL,
57
LV_CB_STYLE_BOX_PR,
58
LV_CB_STYLE_BOX_TGL_REL,
59
LV_CB_STYLE_BOX_TGL_PR,
60
LV_CB_STYLE_BOX_INA,
61
};
62
typedef uint8_t lv_cb_style_t;
63
64
/**********************
65
* GLOBAL PROTOTYPES
66
**********************/
67
68
/**
69
* Create a check box objects
70
* @param par pointer to an object, it will be the parent of the new check box
71
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
72
* @return pointer to the created check box
73
*/
74
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy);
75
76
/*=====================
77
* Setter functions
78
*====================*/
79
80
/**
81
* Set the text of a check box
82
* @param cb pointer to a check box
83
* @param txt the text of the check box
84
*/
85
void lv_cb_set_text(lv_obj_t * cb, const char * txt);
86
87
/**
88
* Set the state of the check box
89
* @param cb pointer to a check box object
90
* @param checked true: make the check box checked; false: make it unchecked
91
*/
92
static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked)
93
{
94
lv_btn_set_state(cb, checked ? LV_BTN_STATE_TGL_REL : LV_BTN_STATE_REL);
95
}
96
97
/**
98
* Make the check box inactive (disabled)
99
* @param cb pointer to a check box object
100
*/
101
static inline void lv_cb_set_inactive(lv_obj_t * cb)
102
{
103
lv_btn_set_state(cb, LV_BTN_STATE_INA);
104
}
105
106
/**
107
* Set a function to call when the check box is clicked
108
* @param cb pointer to a check box object
109
*/
110
static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action)
111
{
112
lv_btn_set_action(cb, LV_BTN_ACTION_CLICK, action);
113
}
114
115
116
/**
117
* Set a style of a check box
118
* @param cb pointer to check box object
119
* @param type which style should be set
120
* @param style pointer to a style
121
* */
122
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style);
123
124
/*=====================
125
* Getter functions
126
*====================*/
127
128
/**
129
* Get the text of a check box
130
* @param cb pointer to check box object
131
* @return pointer to the text of the check box
132
*/
133
const char * lv_cb_get_text(const lv_obj_t * cb);
134
135
/**
136
* Get the current state of the check box
137
* @param cb pointer to a check box object
138
* @return true: checked; false: not checked
139
*/
140
static inline bool lv_cb_is_checked(const lv_obj_t * cb)
141
{
142
return lv_btn_get_state(cb) == LV_BTN_STATE_REL ? false : true;
143
}
144
145
/**
146
* Get the action of a check box
147
* @param cb pointer to a button object
148
* @return pointer to the action function
149
*/
150
static inline lv_action_t lv_cb_get_action(const lv_obj_t * cb)
151
{
152
return lv_btn_get_action(cb, LV_BTN_ACTION_CLICK);
153
}
154
155
156
/**
157
* Get a style of a button
158
* @param cb pointer to check box object
159
* @param type which style should be get
160
* @return style pointer to the style
161
* */
162
lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type);
163
164
/**********************
165
* MACROS
166
**********************/
167
168
#endif /*USE_LV_CB*/
169
170
#ifdef __cplusplus
171
} /* extern "C" */
172
#endif
173
174
#endif /*LV_CB_H*/
175
176