BigW Consortium Gitlab

Commit 398d5e32 by Gabor

lv_mbox: minor updates

parent df47565b
......@@ -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
......
......@@ -202,6 +202,37 @@ 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)
{
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
* @param btn_txt the text of the button
......@@ -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
*====================*/
......
......@@ -93,6 +93,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
* @param btn_txt the text of the button
......@@ -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
......@@ -117,20 +131,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
* @return pointer to the title of the message box
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment