feat(checkbox): remove set/get state API functions
Use lv_obj_set/get_state() instead
This commit is contained in:
@@ -139,30 +139,6 @@ void lv_checkbox_set_text_static(lv_obj_t * cb, const char * txt)
|
|||||||
_lv_obj_handle_self_size_chg(cb);
|
_lv_obj_handle_self_size_chg(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the state of the check box
|
|
||||||
* @param cb pointer to a check box object
|
|
||||||
* @param checked true: make the check box checked; false: make it unchecked
|
|
||||||
*/
|
|
||||||
void lv_checkbox_set_checked(lv_obj_t * cb, bool checked)
|
|
||||||
{
|
|
||||||
if(checked) lv_obj_set_state(cb, LV_STATE_CHECKED);
|
|
||||||
else lv_obj_clear_state(cb, LV_STATE_CHECKED);
|
|
||||||
_lv_obj_remove_style_trans(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make the check box inactive (disabled)
|
|
||||||
* @param cb pointer to a check box object
|
|
||||||
* @param dis true; make the checkbox disabled; false: make the chackbox active
|
|
||||||
*/
|
|
||||||
void lv_checkbox_set_disabled(lv_obj_t * cb, bool dis)
|
|
||||||
{
|
|
||||||
if(dis) lv_obj_set_state(cb, LV_STATE_DISABLED);
|
|
||||||
else lv_obj_clear_state(cb, LV_STATE_DISABLED);
|
|
||||||
_lv_obj_remove_style_trans(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ extern "C" {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/*New data for this widget */
|
/*New data for this widget */
|
||||||
lv_style_list_t style_bullet;
|
lv_style_list_t style_bullet;
|
||||||
const char * txt;
|
char * txt;
|
||||||
uint32_t static_txt :1;
|
uint32_t static_txt :1;
|
||||||
} lv_checkbox_ext_t;
|
} lv_checkbox_ext_t;
|
||||||
|
|
||||||
@@ -64,42 +64,31 @@ lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy);
|
|||||||
*====================*/
|
*====================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the state of the check box
|
* Set the text of a check box. `txt` will be copied and may be deallocated
|
||||||
* @param cb pointer to a check box object
|
* after this function returns.
|
||||||
* @param checked true: make the check box checked; false: make it unchecked
|
* @param cb pointer to a check box
|
||||||
|
* @param txt the text of the check box. NULL to refresh with the current text.
|
||||||
*/
|
*/
|
||||||
void lv_checkbox_set_checked(lv_obj_t * cb, bool checked);
|
void lv_checkbox_set_text(lv_obj_t * cb, const char * txt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the check box inactive (disabled)
|
* Set the text of a check box. `txt` must not be deallocated during the life
|
||||||
* @param cb pointer to a check box object
|
* of this checkbox.
|
||||||
* @param dis true; make the checkbox disabled; false: make the checkbox active
|
* @param cb pointer to a check box
|
||||||
|
* @param txt the text of the check box. NULL to refresh with the current text.
|
||||||
*/
|
*/
|
||||||
void lv_checkbox_set_disabled(lv_obj_t * cb, bool dis);
|
void lv_checkbox_set_text_static(lv_obj_t * cb, const char * txt);
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current state of the check box
|
* Get the text of a check box
|
||||||
* @param cb pointer to a check box object
|
* @param cb pointer to check box object
|
||||||
* @return true: checked; false: not checked
|
* @return pointer to the text of the check box
|
||||||
*/
|
*/
|
||||||
static inline bool lv_checkbox_is_checked(const lv_obj_t * cb)
|
const char * lv_checkbox_get_text(const lv_obj_t * cb);
|
||||||
{
|
|
||||||
return lv_obj_get_state(cb) & LV_STATE_CHECKED ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get whether the check box is inactive or not.
|
|
||||||
* @param cb pointer to a check box object
|
|
||||||
* @return true: inactive; false: not inactive
|
|
||||||
*/
|
|
||||||
static inline bool lv_checkbox_is_disabled(const lv_obj_t * cb)
|
|
||||||
{
|
|
||||||
return lv_obj_get_state(cb) & LV_STATE_DISABLED ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
|
|||||||
Reference in New Issue
Block a user