/**1* @file lv_cb.h2*3*/45#ifndef LV_CB_H6#define LV_CB_H78#ifdef __cplusplus9extern "C" {10#endif1112/*********************13* INCLUDES14*********************/15#ifdef LV_CONF_INCLUDE_SIMPLE16#include "lv_conf.h"17#else18#include "../../lv_conf.h"19#endif2021#if USE_LV_CB != 02223/*Testing of dependencies*/24#if USE_LV_BTN == 025#error "lv_cb: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "26#endif2728#if USE_LV_LABEL == 029#error "lv_cb: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "30#endif3132#include "../lv_core/lv_obj.h"33#include "lv_btn.h"34#include "lv_label.h"3536/*********************37* DEFINES38*********************/3940/**********************41* TYPEDEFS42**********************/4344/*Data of check box*/45typedef struct46{47lv_btn_ext_t bg_btn; /*Ext. of ancestor*/48/*New data for this type */49lv_obj_t * bullet; /*Pointer to button*/50lv_obj_t * label; /*Pointer to label*/51} lv_cb_ext_t;5253enum {54LV_CB_STYLE_BG,55LV_CB_STYLE_BOX_REL,56LV_CB_STYLE_BOX_PR,57LV_CB_STYLE_BOX_TGL_REL,58LV_CB_STYLE_BOX_TGL_PR,59LV_CB_STYLE_BOX_INA,60};61typedef uint8_t lv_cb_style_t;6263/**********************64* GLOBAL PROTOTYPES65**********************/6667/**68* Create a check box objects69* @param par pointer to an object, it will be the parent of the new check box70* @param copy pointer to a check box object, if not NULL then the new object will be copied from it71* @return pointer to the created check box72*/73lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy);7475/*=====================76* Setter functions77*====================*/7879/**80* Set the text of a check box81* @param cb pointer to a check box82* @param txt the text of the check box83*/84void lv_cb_set_text(lv_obj_t * cb, const char * txt);8586/**87* Set the state of the check box88* @param cb pointer to a check box object89* @param checked true: make the check box checked; false: make it unchecked90*/91static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked)92{93lv_btn_set_state(cb, checked ? LV_BTN_STATE_TGL_REL : LV_BTN_STATE_REL);94}9596/**97* Make the check box inactive (disabled)98* @param cb pointer to a check box object99*/100static inline void lv_cb_set_inactive(lv_obj_t * cb)101{102lv_btn_set_state(cb, LV_BTN_STATE_INA);103}104105/**106* Set a function to call when the check box is clicked107* @param cb pointer to a check box object108*/109static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action)110{111lv_btn_set_action(cb, LV_BTN_ACTION_CLICK, action);112}113114115/**116* Set a style of a check box117* @param cb pointer to check box object118* @param type which style should be set119* @param style pointer to a style120* */121void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style);122123/*=====================124* Getter functions125*====================*/126127/**128* Get the text of a check box129* @param cb pointer to check box object130* @return pointer to the text of the check box131*/132const char * lv_cb_get_text(const lv_obj_t * cb);133134/**135* Get the current state of the check box136* @param cb pointer to a check box object137* @return true: checked; false: not checked138*/139static inline bool lv_cb_is_checked(const lv_obj_t * cb)140{141return lv_btn_get_state(cb) == LV_BTN_STATE_REL ? false : true;142}143144/**145* Get the action of a check box146* @param cb pointer to a button object147* @return pointer to the action function148*/149static inline lv_action_t lv_cb_get_action(const lv_obj_t * cb)150{151return lv_btn_get_action(cb, LV_BTN_ACTION_CLICK);152}153154155/**156* Get a style of a button157* @param cb pointer to check box object158* @param type which style should be get159* @return style pointer to the style160* */161lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type);162163/**********************164* MACROS165**********************/166167#endif /*USE_LV_CB*/168169#ifdef __cplusplus170} /* extern "C" */171#endif172173#endif /*LV_CB_H*/174175176