LittlevGL  3.20.00.19
lv_table.h
Go to the documentation of this file.
1 
6 #ifndef LV_TABLE_H
7 #define LV_TABLE_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  * INCLUDES
15  *********************/
16 #ifdef LV_CONF_INCLUDE_SIMPLE
17 #include "lv_conf.h"
18 #else
19 #include "../../../lv_conf.h"
20 #endif
21 
22 #if LV_USE_TABLE != 0
23 
24 /*Testing of dependencies*/
25 #if LV_USE_LABEL == 0
26 #error "lv_table: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
27 #endif
28 
29 #include "../lv_core/lv_obj.h"
30 #include "lv_label.h"
31 
32 /*********************
33  * DEFINES
34  *********************/
35 #ifndef LV_TABLE_COL_MAX
36 #define LV_TABLE_COL_MAX 12
37 #endif
38 
39 #define LV_TABLE_CELL_STYLE_CNT 4
40 /**********************
41  * TYPEDEFS
42  **********************/
43 
49 typedef union
50 {
51  struct
52  {
53  uint8_t align : 2;
54  uint8_t right_merge : 1;
55  uint8_t type : 2;
56  uint8_t crop : 1;
57  } s;
58  uint8_t format_byte;
59 } lv_table_cell_format_t;
60 
61 /*Data of table*/
62 typedef struct
63 {
64  /*New data for this type */
65  uint16_t col_cnt;
66  uint16_t row_cnt;
67  char ** cell_data;
68  const lv_style_t * cell_style[LV_TABLE_CELL_STYLE_CNT];
69  lv_coord_t col_w[LV_TABLE_COL_MAX];
70 } lv_table_ext_t;
71 
72 /*Styles*/
73 enum {
74  LV_TABLE_STYLE_BG,
75  LV_TABLE_STYLE_CELL1,
76  LV_TABLE_STYLE_CELL2,
77  LV_TABLE_STYLE_CELL3,
78  LV_TABLE_STYLE_CELL4,
79 };
80 typedef uint8_t lv_table_style_t;
81 
82 /**********************
83  * GLOBAL PROTOTYPES
84  **********************/
85 
92 lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy);
93 
94 /*=====================
95  * Setter functions
96  *====================*/
97 
106 void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const char * txt);
107 
113 void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt);
114 
120 void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt);
121 
128 void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w);
129 
137 void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_label_align_t align);
138 
146 void lv_table_set_cell_type(lv_obj_t * table, uint16_t row, uint16_t col, uint8_t type);
147 
155 void lv_table_set_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col, bool crop);
156 
164 void lv_table_set_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col, bool en);
165 
172 void lv_table_set_style(lv_obj_t * table, lv_table_style_t type, const lv_style_t * style);
173 
174 /*=====================
175  * Getter functions
176  *====================*/
177 
185 const char * lv_table_get_cell_value(lv_obj_t * table, uint16_t row, uint16_t col);
186 
192 uint16_t lv_table_get_row_cnt(lv_obj_t * table);
193 
199 uint16_t lv_table_get_col_cnt(lv_obj_t * table);
200 
207 lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id);
208 
217 lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col);
218 
226 lv_label_align_t lv_table_get_cell_type(lv_obj_t * table, uint16_t row, uint16_t col);
227 
235 lv_label_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col);
236 
244 bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col);
245 
252 const lv_style_t * lv_table_get_style(const lv_obj_t * table, lv_table_style_t type);
253 
254 /*=====================
255  * Other functions
256  *====================*/
257 
258 /**********************
259  * MACROS
260  **********************/
261 
262 #endif /*LV_USE_TABLE*/
263 
264 #ifdef __cplusplus
265 } /* extern "C" */
266 #endif
267 
268 #endif /*LV_TABLE_H*/
Definition: lv_obj.h:184
#define LV_TABLE_COL_MAX
Definition: lv_conf_checker.h:669
struct _lv_obj_t * par
Definition: lv_obj.h:186
Definition: lv_style.h:57
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale