1 /**
2  * @file lv_mbox.h
3  *
4  */
5 
6 #ifndef LV_MSGBOX_H
7 #define LV_MSGBOX_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../../lvgl.h"
17 
18 #if LV_USE_MSGBOX
19 
20 /*Testing of dependencies*/
21 #if LV_USE_BTNMATRIX == 0
22 #error "lv_mbox: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX  1) "
23 #endif
24 
25 #if LV_USE_LABEL == 0
26 #error "lv_mbox: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL  1) "
27 #endif
28 
29 /*********************
30  *      DEFINES
31  *********************/
32 
33 /**********************
34  *      TYPEDEFS
35  **********************/
36 
37 typedef struct {
38     lv_obj_t obj;
39     lv_obj_t * title;
40     lv_obj_t * close_btn;
41     lv_obj_t * content;
42     lv_obj_t * text;
43     lv_obj_t * btns;
44 } lv_msgbox_t;
45 
46 extern const lv_obj_class_t lv_msgbox_class;
47 extern const lv_obj_class_t lv_msgbox_content_class;
48 extern const lv_obj_class_t lv_msgbox_backdrop_class;
49 
50 /**********************
51  * GLOBAL PROTOTYPES
52  **********************/
53 
54 /**
55  * Create a message box object
56  * @param parent        pointer to parent or NULL to create a full screen modal message box
57  * @param title         the title of the message box
58  * @param txt           the text of the message box
59  * @param btn_txts      the buttons as an array of texts terminated by an "" element. E.g. {"btn1", "btn2", ""}
60  * @param add_close_btn true: add a close button
61  * @return              pointer to the message box object
62  */
63 lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[],
64                             bool add_close_btn);
65 
66 lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj);
67 
68 lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj);
69 
70 lv_obj_t * lv_msgbox_get_text(lv_obj_t * obj);
71 
72 lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj);
73 
74 lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj);
75 
76 /**
77  * Get the index of the selected button
78  * @param mbox message box object
79  * @return     index of the button (LV_BTNMATRIX_BTN_NONE: if unset)
80  */
81 uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox);
82 
83 const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox);
84 
85 void lv_msgbox_close(lv_obj_t * mbox);
86 
87 void lv_msgbox_close_async(lv_obj_t * mbox);
88 
89 /**********************
90  *      MACROS
91  **********************/
92 
93 #endif /*LV_USE_MSGBOX*/
94 
95 #ifdef __cplusplus
96 } /*extern "C"*/
97 #endif
98 
99 #endif /*LV_MSGBOX_H*/
100