mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
lv_mbox: minor updates
This commit is contained in:
parent
df47565bd9
commit
398d5e32ae
@ -74,7 +74,7 @@ lv_obj_t * lv_app_notice_add(const char * format, ...)
|
||||
mbox = lv_mbox_create(notice_h, NULL);
|
||||
lv_obj_set_style(mbox, lv_mboxs_get(LV_MBOXS_INFO, NULL));
|
||||
lv_mbox_set_title(mbox, "");
|
||||
lv_mbox_set_txt(mbox, txt);
|
||||
lv_mbox_set_text(mbox, txt);
|
||||
lv_obj_set_opa(mbox, app_style->menu_opa);
|
||||
|
||||
#if LV_APP_NOTICE_SHOW_TIME != 0
|
||||
|
@ -201,6 +201,37 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
|
||||
/*Hide the title if it is an empty text*/
|
||||
if(title[0] == '\0') lv_obj_set_hidden(ext->title, true);
|
||||
else if (lv_obj_get_hidden(ext->title) != false) lv_obj_set_hidden(ext->title, false);
|
||||
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->txt, txt);
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a button to the message box
|
||||
* @param mbox pointer to message box object
|
||||
@ -242,15 +273,15 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
* A release action which can be assigned to a message box button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always false because the button is deleted with the mesage box
|
||||
* @return always lv_action_res_t because the button is deleted with the mesage box
|
||||
*/
|
||||
bool lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
lv_action_res_t lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_t * mbox = lv_mbox_get_from_btn(btn);
|
||||
|
||||
lv_obj_del(mbox);
|
||||
|
||||
return false;
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,39 +304,6 @@ void lv_mbox_auto_close(lv_obj_t * mbox, uint16_t tout)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
|
||||
/*Hide the title if it is an empty text*/
|
||||
if(title[0] == '\0') lv_obj_set_hidden(ext->title, true);
|
||||
else if (lv_obj_get_hidden(ext->title) != false) lv_obj_set_hidden(ext->title, false);
|
||||
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_txt(lv_obj_t * mbox, const char * txt)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->txt, txt);
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
@ -92,6 +92,20 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
*/
|
||||
bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title);
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
|
||||
|
||||
/**
|
||||
* Add a button to the message box
|
||||
* @param mbox pointer to message box object
|
||||
@ -105,9 +119,9 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
* A release action which can be assigned to a message box button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always false because the button is deleted with the mesage box
|
||||
* @return always LV_ACTION_RES_INV because the button is deleted with the message box
|
||||
*/
|
||||
bool lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
lv_action_res_t lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Automatically delete the message box after a given time
|
||||
@ -116,20 +130,6 @@ bool lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
*/
|
||||
void lv_mbox_auto_close(lv_obj_t * mbox, uint16_t tout);
|
||||
|
||||
/**
|
||||
* Set the title of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param title a '\0' terminated character string which will be the message box title
|
||||
*/
|
||||
void lv_mbox_set_title(lv_obj_t * mbox, const char * title);
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_txt(lv_obj_t * mbox, const char * txt);
|
||||
|
||||
/**
|
||||
* get the title of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
|
Loading…
x
Reference in New Issue
Block a user