lv_table updates
This commit is contained in:
@@ -22,6 +22,7 @@ extern "C" {
|
||||
#if USE_LV_TABLE != 0
|
||||
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -32,15 +33,9 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_TABLE_CELL_ALIGN_LEFT,
|
||||
LV_TABLE_CELL_ALIGN_RIGHT,
|
||||
LV_TABLE_CELL_ALIGN_CENTER,
|
||||
}lv_table_cell_align_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t align:2;
|
||||
uint8_t align:3;
|
||||
uint8_t right_merge:1;
|
||||
};
|
||||
uint8_t format_byte;
|
||||
@@ -59,8 +54,8 @@ typedef struct {
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_TABLE_STYLE_X,
|
||||
LV_TABLE_STYLE_Y,
|
||||
LV_TABLE_STYLE_BG,
|
||||
LV_TABLE_STYLE_CELL,
|
||||
};
|
||||
typedef uint8_t lv_table_style_t;
|
||||
|
||||
@@ -70,44 +65,127 @@ typedef uint8_t lv_table_style_t;
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a table objects
|
||||
* Create a table object
|
||||
* @param par pointer to an object, it will be the parent of the new table
|
||||
* @param copy pointer to a table object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created table
|
||||
*/
|
||||
lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
|
||||
void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const char * txt);
|
||||
|
||||
void lv_table_set_cell_format(lv_obj_t * table, uint16_t row, uint16_t col, lv_table_cell_align_t align);
|
||||
|
||||
void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col, bool en);
|
||||
|
||||
void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt);
|
||||
|
||||
void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt);
|
||||
|
||||
/*======================
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the value of a cell.
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @param txt text to display in the cell. It will be copied and saved so this variable is not required after this function call.
|
||||
*/
|
||||
void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const char * txt);
|
||||
|
||||
/**
|
||||
* Set the number of rows
|
||||
* @param table table pointer to a Table object
|
||||
* @param row_cnt number of rows
|
||||
*/
|
||||
void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt);
|
||||
|
||||
/**
|
||||
* Set the number of columns
|
||||
* @param table table pointer to a Table object
|
||||
* @param col_cnt number of columns. Must be < LV_TABLE_COL_MAX
|
||||
*/
|
||||
void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt);
|
||||
|
||||
/**
|
||||
* Set the width of a column
|
||||
* @param table table pointer to a Table object
|
||||
* @param col_id id of the column [0 .. LV_TABLE_COL_MAX -1]
|
||||
* @param w width of the column
|
||||
*/
|
||||
void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w);
|
||||
|
||||
/**
|
||||
* Set the text align in a cell
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @param align LV_LABEL_ALIGN_LEFT or LV_LABEL_ALIGN_CENTER or LV_LABEL_ALIGN_RIGHT
|
||||
*/
|
||||
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_label_align_t align);
|
||||
|
||||
/**
|
||||
* Merge a cell with the right neighbor. The value of the cell to the right won't be displayed.
|
||||
* @param table table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @param en true: merge right; false: don't merge right
|
||||
*/
|
||||
void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col, bool en);
|
||||
|
||||
/**
|
||||
* Set a style of a table.
|
||||
* @param table pointer to table object
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_table_set_style(lv_obj_t * table, lv_table_style_t type, lv_style_t *style);
|
||||
void lv_table_set_style(lv_obj_t * table, lv_table_style_t type, lv_style_t * style);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the value of a cell.
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return text in the cell
|
||||
*/
|
||||
const char * lv_table_get_cell_value(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
|
||||
/**
|
||||
* Get the number of rows.
|
||||
* @param table table pointer to a Table object
|
||||
* @return number of rows.
|
||||
*/
|
||||
uint16_t lv_table_get_row_cnt(lv_obj_t * table);
|
||||
|
||||
/**
|
||||
* Get the number of columns.
|
||||
* @param table table pointer to a Table object
|
||||
* @return number of columns.
|
||||
*/
|
||||
uint16_t lv_table_get_col_cnt(lv_obj_t * table);
|
||||
|
||||
/**
|
||||
* Get the width of a column
|
||||
* @param table table pointer to a Table object
|
||||
* @param col_id id of the column [0 .. LV_TABLE_COL_MAX -1]
|
||||
* @return width of the column
|
||||
*/
|
||||
lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id);
|
||||
|
||||
/**
|
||||
* Get the text align of a cell
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return LV_LABEL_ALIGN_LEFT (default in case of error) or LV_LABEL_ALIGN_CENTER or LV_LABEL_ALIGN_RIGHT
|
||||
*/
|
||||
lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
|
||||
/**
|
||||
* Get the cell merge attribute.
|
||||
* @param table table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return true: merge right; false: don't merge right
|
||||
*/
|
||||
bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
|
||||
/**
|
||||
* Get style of a table.
|
||||
* @param table pointer to table object
|
||||
|
||||
Reference in New Issue
Block a user