2017-02-06 10:06:18 +01:00
|
|
|
/**
|
|
|
|
* @file lv_ddlist.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_DDLIST_H
|
|
|
|
#define LV_DDLIST_H
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_conf.h"
|
|
|
|
#if USE_LV_DDLIST != 0
|
|
|
|
#include "../lv_obj/lv_obj.h"
|
|
|
|
#include "../lv_objx/lv_page.h"
|
|
|
|
#include "../lv_objx/lv_label.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
/*Data of drop down list*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
lv_page_ext_t page; /*Ext. of ancestor*/
|
|
|
|
/*New data for this type */
|
|
|
|
lv_obj_t * opt_label; /*Label for the options*/
|
|
|
|
lv_action_res_t (*cb)(lv_obj_t *, uint16_t);
|
2017-02-06 16:05:02 +01:00
|
|
|
uint16_t sel_opt;
|
2017-02-06 10:06:18 +01:00
|
|
|
uint8_t opened :1;
|
2017-02-06 16:05:02 +01:00
|
|
|
uint8_t auto_size :1;
|
2017-02-06 10:06:18 +01:00
|
|
|
}lv_ddlist_ext_t;
|
|
|
|
|
|
|
|
/*Style of drop down list*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2017-04-10 11:33:38 +02:00
|
|
|
lv_pages_t page; /*Style of ancestor*/
|
2017-02-06 10:06:18 +01:00
|
|
|
/*New style element for this type */
|
2017-04-10 11:33:38 +02:00
|
|
|
lv_rects_t sel; /*Select rectangle*/
|
|
|
|
lv_labels_t label; /*Style of labels*/
|
2017-02-06 10:06:18 +01:00
|
|
|
}lv_ddlists_t;
|
|
|
|
|
|
|
|
/*Built-in styles of drop down list*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LV_DDLISTS_DEF,
|
|
|
|
}lv_ddlists_builtin_t;
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a drop down list objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new drop down list
|
|
|
|
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created drop down list
|
|
|
|
*/
|
|
|
|
lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal function of the drop down list
|
|
|
|
* @param ddlist pointer to a drop down list object
|
|
|
|
* @param sign a signal type from lv_signal_t enum
|
|
|
|
* @param param pointer to a signal specific variable
|
|
|
|
* @return true: the object is still valid (not deleted), false: the object become invalid
|
|
|
|
*/
|
|
|
|
bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the options in a drop down list
|
|
|
|
* @param ddlist pointer to drop down list object
|
|
|
|
* @param options an array of strings wit the text of the options.
|
|
|
|
* The lest element has to be "" (empty string)
|
|
|
|
* E.g. const char * opts[] = {"apple", "banana", "orange", ""};
|
|
|
|
*/
|
|
|
|
void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options);
|
|
|
|
|
2017-02-06 16:05:02 +01:00
|
|
|
/**
|
|
|
|
* Set the selected option
|
|
|
|
* @param ddlist pointer to drop down list object
|
|
|
|
* @param sel_opt id of the selected option (0 ... number of option - 1);
|
|
|
|
*/
|
|
|
|
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
|
|
|
|
|
2017-02-06 10:06:18 +01:00
|
|
|
/**
|
|
|
|
* Set a function to call when a new option is chosen
|
2017-02-06 16:05:02 +01:00
|
|
|
* @param ddlist pointer to a drop down list
|
2017-02-06 10:06:18 +01:00
|
|
|
* @param cb pointer to a call back function. Its prototype is:
|
|
|
|
* parameter 1: pointer to the drop down list
|
|
|
|
* parameter 2: id of the chosen item (0 ... number of options - 1)
|
|
|
|
* return LV_ACTION_RES_INV if the drop down list is deleted in the function else LV_ACTION_RES_OK
|
|
|
|
*/
|
|
|
|
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_res_t (*cb)(lv_obj_t *, uint16_t));
|
|
|
|
|
2017-02-06 16:05:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
|
|
|
|
* In this case the drop down list can be scrolled.
|
|
|
|
* @param ddlist pointer to a drop down list
|
|
|
|
* @param auto_size true: enable auto size, false: disable
|
|
|
|
*/
|
|
|
|
void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size);
|
|
|
|
|
2017-02-06 10:06:18 +01:00
|
|
|
/**
|
|
|
|
* Get the options of a drop down list
|
|
|
|
* @param ddlist pointer to drop down list object
|
|
|
|
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
|
|
|
|
*/
|
|
|
|
const char * lv_ddlist_get_options(lv_obj_t * ddlist);
|
|
|
|
|
2017-02-06 16:05:02 +01:00
|
|
|
/**
|
|
|
|
* Get the selected option
|
|
|
|
* @param ddlist pointer to drop down list object
|
|
|
|
* @return id of the selected option (0 ... number of option - 1);
|
|
|
|
*/
|
|
|
|
uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the auto size attribute.
|
|
|
|
* @param ddlist pointer to a drop down list
|
|
|
|
* @return true: the auto_size is enabled, false: disabled
|
|
|
|
*/
|
|
|
|
bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size);
|
|
|
|
|
2017-02-06 10:06:18 +01:00
|
|
|
/**
|
|
|
|
* Return with a pointer to a built-in style and/or copy it to a variable
|
|
|
|
* @param style a style name from lv_ddlists_builtin_t enum
|
|
|
|
* @param copy copy the style to this variable. (NULL if unused)
|
|
|
|
* @return pointer to an lv_ddlists_t style
|
|
|
|
*/
|
|
|
|
lv_ddlists_t * lv_ddlists_get(lv_ddlists_builtin_t style, lv_ddlists_t * copy);
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|