1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/lv_objx/lv_mbox.h

212 lines
5.4 KiB
C
Raw Normal View History

/**
* @file lv_mbox.h
2018-06-19 09:49:58 +02:00
*
*/
#ifndef LV_MBOX_H
#define LV_MBOX_H
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
2017-11-26 23:57:39 +01:00
#include "../../lv_conf.h"
#endif
#if LV_USE_MBOX != 0
2017-01-02 10:48:21 +01:00
/*Testing of dependencies*/
#if LV_USE_CONT == 0
#error "lv_mbox: lv_cont is required. Enable it in lv_conf.h (LV_USE_CONT 1) "
2017-01-02 10:48:21 +01:00
#endif
#if LV_USE_BTNM == 0
#error "lv_mbox: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNM 1) "
2017-01-02 10:48:21 +01:00
#endif
#if LV_USE_LABEL == 0
#error "lv_mbox: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
2017-01-02 10:48:21 +01:00
#endif
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
#include "lv_cont.h"
#include "lv_btnm.h"
#include "lv_label.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of message box*/
typedef struct
{
2017-04-13 16:12:03 +02:00
lv_cont_ext_t bg; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t *text; /*Text of the message box*/
lv_obj_t *btnm; /*Button matrix for the buttons*/
2017-11-08 11:07:29 +01:00
uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/
2018-06-19 09:49:58 +02:00
} lv_mbox_ext_t;
2018-09-18 13:59:40 +02:00
enum {
LV_MBOX_STYLE_BG,
LV_MBOX_STYLE_BTN_BG,
LV_MBOX_STYLE_BTN_REL,
LV_MBOX_STYLE_BTN_PR,
LV_MBOX_STYLE_BTN_TGL_REL,
LV_MBOX_STYLE_BTN_TGL_PR,
LV_MBOX_STYLE_BTN_INA,
2018-09-18 13:59:40 +02:00
};
typedef uint8_t lv_mbox_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a message box objects
* @param par pointer to an object, it will be the parent of the new message box
* @param copy pointer to a message box object, if not NULL then the new object will be copied from it
* @return pointer to the created message box
*/
lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy);
/*======================
* Add/remove functions
*=====================*/
/**
* Add button to the message box
* @param mbox pointer to message box object
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
*/
2019-03-12 06:20:45 +01:00
void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_mapaction);
2017-11-10 15:01:40 +01:00
/*=====================
* Setter functions
*====================*/
/**
2017-04-21 09:15:39 +02:00
* 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
*/
2017-04-21 09:15:39 +02:00
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
2017-11-08 11:07:29 +01:00
/**
2017-11-10 15:01:40 +01:00
* Set animation duration
2017-11-08 11:07:29 +01:00
* @param mbox pointer to a message box object
* @param anim_time animation length in milliseconds (0: no animation)
2017-11-08 11:07:29 +01:00
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time);
2017-11-08 11:07:29 +01:00
2017-04-21 09:15:39 +02:00
/**
2017-11-10 15:01:40 +01:00
* Automatically delete the message box after a given time
2017-04-21 09:15:39 +02:00
* @param mbox pointer to a message box object
2017-11-10 15:01:40 +01:00
* @param delay a time (in milliseconds) to wait before delete the message box
2017-04-21 09:15:39 +02:00
*/
2017-11-10 15:01:40 +01:00
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay);
2017-05-12 16:09:37 +02:00
/**
2017-11-10 15:01:40 +01:00
* Stop the auto. closing of message box
2017-05-12 16:09:37 +02:00
* @param mbox pointer to a message box object
*/
2017-11-10 15:01:40 +01:00
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
2017-05-12 16:09:37 +02:00
/**
* Set a style of a message box
* @param mbox pointer to a message box object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_mbox_set_style(lv_obj_t *mbox, lv_mbox_style_t type, lv_style_t *style);
2017-11-10 15:01:40 +01:00
2018-12-16 09:33:10 -05:00
/**
* Set whether recoloring is enabled. Must be called after `lv_mbox_add_btns`.
* @param btnm pointer to button matrix object
* @param en whether recoloring is enabled
*/
void lv_mbox_set_recolor(lv_obj_t * mbox, bool en);
2017-11-10 15:01:40 +01:00
/*=====================
* Getter functions
*====================*/
/**
* Get the text of the message box
* @param mbox pointer to a message box object
* @return pointer to the text of the message box
*/
const char * lv_mbox_get_text(const lv_obj_t * mbox);
/**
2019-03-12 06:20:45 +01:00
* Get the index of the lastly "activated" button by the user (pressed, released etc)
* Useful in the the `event_cb`.
* @param btnm pointer to button matrix object
* @return index of the last released button (LV_BTNM_BTN_NONE: if unset)
*/
uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox);
/**
* Get the text of the lastly "activated" button by the user (pressed, released etc)
* Useful in the the `event_cb`.
* @param btnm pointer to button matrix object
* @return text of the last released button (NULL: if unset)
*/
2019-03-12 06:20:45 +01:00
const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox);
2017-05-12 16:09:37 +02:00
/**
2017-11-10 15:01:40 +01:00
* Get the animation duration (close animation time)
2017-05-12 16:09:37 +02:00
* @param mbox pointer to a message box object
* @return animation length in milliseconds (0: no animation)
*/
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox);
2017-05-12 16:09:37 +02:00
2017-11-08 11:07:29 +01:00
2017-11-07 15:13:34 +01:00
/**
* Get a style of a message box
2017-11-07 15:13:34 +01:00
* @param mbox pointer to a message box object
* @param type which style should be get
* @return style pointer to a style
2017-11-07 15:13:34 +01:00
*/
lv_style_t * lv_mbox_get_style(const lv_obj_t *mbox, lv_mbox_style_t type);
2017-11-08 11:07:29 +01:00
2018-12-16 09:33:10 -05:00
/**
* Get whether recoloring is enabled
2019-02-28 09:08:53 +01:00
* @param mbox pointer to a message box object
2018-12-16 09:33:10 -05:00
* @return whether recoloring is enabled
*/
bool lv_mbox_get_recolor(const lv_obj_t * mbox);
2019-02-28 09:07:07 +01:00
/**
* Get message box button matrix
* @param mbox pointer to a message box object
* @return pointer to button matrix object
* @remarks return value will be NULL unless `lv_mbox_add_btns` has been already called
*/
lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox);
2017-11-07 16:18:38 +01:00
/**********************
* MACROS
**********************/
#endif /*LV_USE_MBOX*/
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
#endif
2017-07-09 15:32:49 +02:00
#endif /*LV_MBOX_H*/