1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/lv_objx/lv_list.h

177 lines
4.9 KiB
C
Raw Normal View History

2016-06-22 17:24:02 +02:00
/**
* @file lv_list.h
*
*/
#ifndef LV_LIST_H
#define LV_LIST_H
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2016-06-22 17:24:02 +02:00
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_LIST != 0
2017-01-02 10:48:21 +01:00
/*Testing of dependencies*/
2017-05-15 09:14:48 +02:00
#if USE_LV_PAGE == 0
#error "lv_list: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
#endif
2017-01-02 10:48:21 +01:00
#if USE_LV_BTN == 0
#error "lv_list: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
#endif
#if USE_LV_LABEL == 0
#error "lv_list: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
#endif
#if USE_LV_IMG == 0
#error "lv_list: lv_img is required. Enable it in lv_conf.h (USE_LV_IMG 1) "
#endif
2017-05-15 09:14:48 +02:00
2016-06-22 17:24:02 +02:00
#include "../lv_obj/lv_obj.h"
#include "lv_page.h"
#include "lv_btn.h"
2016-07-12 01:16:27 +02:00
#include "lv_label.h"
#include "lv_img.h"
2016-06-22 17:24:02 +02:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of list*/
typedef struct
{
2017-04-11 10:50:57 +02:00
lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */
2017-04-21 09:15:39 +02:00
lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/
lv_style_t * style_img; /*Style of the list element images on buttons*/
uint8_t sb_out :1; /*1: Keep space for the scrollbar*/
}lv_list_ext_t;
2016-06-22 17:24:02 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a list objects
* @param par pointer to an object, it will be the parent of the new list
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
* @return pointer to the created list
*/
2016-10-07 11:15:46 +02:00
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the list
* @param list pointer to a list object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
2016-10-07 11:15:46 +02:00
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
/**
* Add a list element to the list
* @param list pointer to list object
* @param img_fn file name of an image before the text (NULL if unused)
* @param txt text of the list element (NULL if unused)
* @param rel_action pointer to release action function (like with lv_btn)
* @return pointer to the new list element which can be customized (a button)
*/
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action);
2016-10-07 11:15:46 +02:00
/**
* Move the list elements up by one
* @param list pointer a to list object
*/
2016-10-07 11:15:46 +02:00
void lv_list_up(lv_obj_t * list);
/**
* Move the list elements down by one
* @param list pointer to a list object
*/
void lv_list_down(lv_obj_t * list);
2017-04-21 09:15:39 +02:00
/**
* Enable/Disable to scrollbar outside attribute
* @param list pointer to list object
* @param out true: reduce the buttons width therefore scroll bar will be out of the buttons,
* false: keep button size and place scroll bar on the buttons
*/
void lv_list_set_sb_out(lv_obj_t * list, bool out);
/**
* Enable or disable the text rolling on a list element
* @param liste pinter to list element
* @param en true: enable text scrolling, false: disable text scrolling
*/
void lv_list_set_element_text_roll(lv_obj_t * liste, bool en);
2017-04-21 09:15:39 +02:00
/**
* Set styles of the list elements of a list in each state
* @param list pointer to list object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param trel pointer to a style for toggled releases state
* @param tpr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_list_set_styles_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
2017-04-28 16:12:35 +02:00
lv_style_t * trel, lv_style_t * tpr,
lv_style_t * ina);
2017-04-21 09:15:39 +02:00
/**
* Set the styles of the list element image (typically to set symbol font)
* @param list pointer to list object
* @param style pointer to the new style of the button images
*/
void lv_list_set_style_img(lv_obj_t * list, lv_style_t * style);
/**
* Get the text of a list element
* @param liste pointer to list element
* @return pointer to the text
*/
2017-04-28 16:12:35 +02:00
const char * lv_list_get_element_text(lv_obj_t * liste);
2016-07-12 01:16:27 +02:00
2017-04-21 09:15:39 +02:00
/**
* Get the scroll bar outside attribute
* @param list pointer to list object
* @param en true: scroll bar outside the buttons, false: scroll bar inside
*/
bool lv_list_get_sb_out(lv_obj_t * list, bool en);
/**
* Get the style of the list elements in a given state
* @param list pointer to a list object
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
*/
lv_style_t * lv_list_get_style_liste(lv_obj_t * list, lv_btn_state_t state);
2017-04-21 09:15:39 +02:00
/**
* Get the style of the list elements images
* @param list pointer to a list object
* @return pointer to the image style
*/
lv_style_t * lv_list_get_style_img(lv_obj_t * list, lv_btn_state_t state);
2016-06-22 17:24:02 +02:00
/**********************
* MACROS
**********************/
2017-07-09 15:32:49 +02:00
#endif /*USE_LV_LIST*/
2016-06-22 17:24:02 +02:00
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
2016-06-22 17:24:02 +02:00
#endif
2017-07-09 15:32:49 +02:00
#endif /*LV_LIST_H*/