lv_table.h

Defines

LV_TABLE_CELL_NONE

Typedefs

typedef _lv_table_cell_ctrl_t lv_table_cell_ctrl_t

Enums

enum _lv_table_cell_ctrl_t

Values:

enumerator LV_TABLE_CELL_CTRL_MERGE_RIGHT
enumerator LV_TABLE_CELL_CTRL_TEXT_CROP
enumerator LV_TABLE_CELL_CTRL_CUSTOM_1
enumerator LV_TABLE_CELL_CTRL_CUSTOM_2
enumerator LV_TABLE_CELL_CTRL_CUSTOM_3
enumerator LV_TABLE_CELL_CTRL_CUSTOM_4

Functions

lv_obj_t *lv_table_create(lv_obj_t *parent)

Create a table object

Parameters:

parent -- pointer to an object, it will be the parent of the new table

Returns:

pointer to the created table

void lv_table_set_cell_value(lv_obj_t *obj, uint32_t row, uint32_t col, const char *txt)

Set the value of a cell.

Note

New roes/columns are added automatically if required

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

  • 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_fmt(lv_obj_t *obj, uint32_t row, uint32_t col, const char *fmt, ...)

Set the value of a cell. Memory will be allocated to store the text by the table.

Note

New roes/columns are added automatically if required

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

  • fmt -- printf-like format

void lv_table_set_row_count(lv_obj_t *obj, uint32_t row_cnt)

Set the number of rows

Parameters:
  • obj -- table pointer to a Table object

  • row_cnt -- number of rows

void lv_table_set_column_count(lv_obj_t *obj, uint32_t col_cnt)

Set the number of columns

Parameters:
  • obj -- table pointer to a Table object

  • col_cnt -- number of columns.

void lv_table_set_column_width(lv_obj_t *obj, uint32_t col_id, int32_t w)

Set the width of a column

Parameters:
  • obj -- table pointer to a Table object

  • col_id -- id of the column [0 .. LV_TABLE_COL_MAX -1]

  • w -- width of the column

void lv_table_add_cell_ctrl(lv_obj_t *obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl)

Add control bits to the cell.

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

  • ctrl -- OR-ed values from ::lv_table_cell_ctrl_t

void lv_table_clear_cell_ctrl(lv_obj_t *obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl)

Clear control bits of the cell.

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

  • ctrl -- OR-ed values from ::lv_table_cell_ctrl_t

void lv_table_set_cell_user_data(lv_obj_t *obj, uint16_t row, uint16_t col, void *user_data)

Add custom user data to the cell.

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

  • user_data -- pointer to the new user_data. Should be allocated by lv_malloc, and it will be freed automatically when the table is deleted or when the cell is dropped due to lower row or column count.

const char *lv_table_get_cell_value(lv_obj_t *obj, uint32_t row, uint32_t col)

Get the value of a cell.

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

Returns:

text in the cell

uint32_t lv_table_get_row_count(lv_obj_t *obj)

Get the number of rows.

Parameters:

obj -- table pointer to a Table object

Returns:

number of rows.

uint32_t lv_table_get_column_count(lv_obj_t *obj)

Get the number of columns.

Parameters:

obj -- table pointer to a Table object

Returns:

number of columns.

int32_t lv_table_get_column_width(lv_obj_t *obj, uint32_t col)

Get the width of a column

Parameters:
  • obj -- table pointer to a Table object

  • col -- id of the column [0 .. LV_TABLE_COL_MAX -1]

Returns:

width of the column

bool lv_table_has_cell_ctrl(lv_obj_t *obj, uint32_t row, uint32_t col, lv_table_cell_ctrl_t ctrl)

Get whether a cell has the control bits

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

  • ctrl -- OR-ed values from ::lv_table_cell_ctrl_t

Returns:

true: all control bits are set; false: not all control bits are set

void lv_table_get_selected_cell(lv_obj_t *obj, uint32_t *row, uint32_t *col)

Get the selected cell (pressed and or focused)

Parameters:
  • obj -- pointer to a table object

  • row -- pointer to variable to store the selected row (LV_TABLE_CELL_NONE: if no cell selected)

  • col -- pointer to variable to store the selected column (LV_TABLE_CELL_NONE: if no cell selected)

void *lv_table_get_cell_user_data(lv_obj_t *obj, uint16_t row, uint16_t col)

Get custom user data to the cell.

Parameters:
  • obj -- pointer to a Table object

  • row -- id of the row [0 .. row_cnt -1]

  • col -- id of the column [0 .. col_cnt -1]

Variables

const lv_obj_class_t lv_table_class
struct lv_table_cell_t

Public Members

lv_table_cell_ctrl_t ctrl
void *user_data

Custom user data

char txt[]
struct lv_table_t

Public Members

lv_obj_t obj
uint32_t col_cnt
uint32_t row_cnt
lv_table_cell_t **cell_data
int32_t *row_h
int32_t *col_w
uint32_t col_act
uint32_t row_act