Hezhou Air724UG LuatOS-Air LVGL API control-Table

Table

image.png

Sample code

     --创建表格
     Table1 = lvgl.table_create(lvgl.scr_act(),nil)

     --设置表格为4行5列
     lvgl.table_set_row_cnt(Table1,4)
     lvgl.table_set_col_cnt(Table1,5)

     --给每个单元格赋值
     lvgl.table_set_cell_value(Table1, 0, 0, "选手")
     lvgl.table_set_cell_value(Table1, 1, 0, "1号")
     lvgl.table_set_cell_value(Table1, 2, 0, "2号")
     lvgl.table_set_cell_value(Table1, 3, 0, "3号")
     lvgl.table_set_cell_value(Table1, 0, 1, "性别")
     lvgl.table_set_cell_value(Table1, 1, 1, "男")
     lvgl.table_set_cell_value(Table1, 2, 1, "男")
     lvgl.table_set_cell_value(Table1, 3, 1, "女")
     lvgl.table_set_cell_value(Table1, 0, 2, "身高(m)")
     lvgl.table_set_cell_value(Table1, 1, 2, "180")
     lvgl.table_set_cell_value(Table1, 2, 2, "176")
     lvgl.table_set_cell_value(Table1, 3, 2, "168")
     lvgl.table_set_cell_value(Table1, 0, 3, "体重(kg)")
     lvgl.table_set_cell_value(Table1, 1, 3, "72")
     lvgl.table_set_cell_value(Table1, 2, 3, "68")
     lvgl.table_set_cell_value(Table1, 3, 3, "56")
     lvgl.table_set_cell_value(Table1, 0, 4, "星座")
     lvgl.table_set_cell_value(Table1, 1, 4, "白羊座")
     lvgl.table_set_cell_value(Table1, 2, 4, "射手座")
     lvgl.table_set_cell_value(Table1, 3, 4, "金牛座")

     --设置表格对齐方式
     lvgl.obj_align(Table1,Father,lvgl.ALIGN_IN_TOP_MID,0,0)

     --设置单元格类型
     lvgl.table_set_cell_type(Table1,0,0,3)
     lvgl.table_set_cell_type(Table1,0,1,3)
     lvgl.table_set_cell_type(Table1,0,2,3)
     lvgl.table_set_cell_type(Table1,0,3,3)
     lvgl.table_set_cell_type(Table1,0,4,3)

     --设置类型样式
     lvgl.obj_add_style(Label1, lvgl.TABLE_PART_CELL3, demo_ThemeFontStyle_PURPLE)

     --设置单元格对齐方式
     --lvgl.table_set_cell_align(Table1,0,2,lvgl.LABEL_ALIGN_RIGHT)
     --lvgl.table_set_cell_align(Table1,1,2,lvgl.LABEL_ALIGN_LEFT)
     --lvgl.table_set_cell_align(Table1,2,2,lvgl.LABEL_ALIGN_CENTER)

     --获取并显示单元格属性
     Label1 = lvgl.label_create(lvgl.scr_act(),nil)
     lvgl.label_set_text(Label1,"获取单元格(0,0)的值: 
     "..lvgl.table_get_cell_value(Table1,0,0).."\n\n获取行数: 
     "..lvgl.table_get_row_cnt(Table1).."\n\n获取列数: 
     "..lvgl.table_get_col_cnt(Table1).."\n\n获取第一列的列宽: 
     "..lvgl.table_get_col_width(Table1,0).."\n\n获取第二列的列宽: 
     "..lvgl.table_get_col_width(Table1,1).."\n\n获取单元格(0,2)的文本对齐方式: 
     "..lvgl.table_get_cell_align(Table1,0,2).."\n\n获取单元格(0,2)类型: 
     "..lvgl.table_get_cell_type(Table1,0,2).."\n\n获取单元格(0,2)的裁剪属性: 
     "..lvgl.table_get_cell_crop(Table1,0,2).."\n\n获取单元格(3,0)合并属性: 
     "..tostring(lvgl.table_get_cell_merge_right(Table1,3,0)))
     lvgl.obj_align(Label1,nil,lvgl.LABEL_ALIGN_LEFT,-209,93)
     lvgl.obj_add_style(Label1, lvgl.LABEL_PART_MAIN, demo_ThemeStyle_IndicAndFont)

API

lvgl.table_create

transfer lvgl.table_create(par,copy)
Function Create table object
return Pointer to the created table
parameter
par Pointer to the object that will be the parent object of the new table
copy Pointer to the table object from which the new object will be copied if not nil

lvgl.table_set_row_cnt

transfer lvgl.table_set_row_cnt(table, row_cnt)
Function Set the number of rows
return none
parameter
table pointer to table object
row_cnt Number of lines

lvgl.table_set_col_cnt

transfer lvgl.table_set_col_cnt(table, col_cnt)
Function Set the number of columns
return none
parameter
table pointer to table object
col_cnt Number of columns

lvgl.table_set_cell_value

transfer lvgl.table_set_cell_valuet(table, row, col, “Content”)
Function Set cell content
return none
parameter
table pointer to table object
row Line number
col column number
“Content” The content displayed in the cell where the row and column are located

lvgl.table_set_cell_type

transfer lvgl.table_set_cell_typet(table, row, col, type)
Function Set cell type
return none
parameter
table pointer to table object
row Line number
col column number
type Type, the type is a fixed value: 1, 2, 3, 4

lvgl.table_set_cell_align

transfer lvgl.table_set_cell_align(table, row, col, align)
Function Set cell text alignment
return none
parameter
table pointer to table object
row Line number
col column number
align Alignment
lvgl.LABEL_ALIGN_LEFT
lvgl.LABEL_ALIGN_LEFT
lvgl.LABEL_ALIGN_CENTER
lvgl.LABEL_ALIGN_AUTO

lvgl.table_set_col_width

transfer lvgl.table_set_col_width(table, col, width)
Function Set column width
return none
parameter
table pointer to table object
col column number
width column width

lvgl.table_get_cell_value

transfer lvgl.table_get_cell_value(table, row, col)
Function Get cell content
return cell content
parameter
table pointer to table object
row Line number
col column number

lvgl.table_get_row_cnt

transfer lvgl.table_get_row_cnt(table)
Function Get the number of table rows
return Number of table rows
parameter
table pointer to table object

lvgl.table_get_col_cnt

transfer lvgl.table_get_col_cnt(table)
Function Get the number of table columns
return Number of table columns
parameter
table pointer to table object

lvgl.table_get_col_width

transfer lvgl.table_get_col_width(table, col)
Function Get column width
return column width
parameter
table pointer to table object
col column number

lvgl.table_get_cell_align

transfer lvgl.table_get_cell_align(table, row, col)
Function Get cell text alignment
return Alignment
parameter
table pointer to table object
row Line number
col column number

lvgl.table_get_cell_type

transfer lvgl.table_get_cell_type(table, row, col)
Function Get cell type
return type
parameter
table pointer to table object
row Line number
col column number

Test firmware versions and scripts

LuatOS-HMI_V3211_RDA8910.pac
Table.7z

Reference link (C language)

Guess you like

Origin blog.csdn.net/l531798151/article/details/132818076