acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

table.md (3296B)

      1 ```eval_rst
      2 .. include:: /header.rst
      3 :github_url: |github_link_base|/widgets/core/table.md
      4 ```
      5 # Table (lv_table)
      6 
      7 ## Overview
      8 
      9 Tables, as usual, are built from rows, columns, and cells containing texts.
     10 
     11 The Table object is very lightweight because only the texts are stored. No real objects are created for cells but they are just drawn on the fly.
     12 
     13 The Table is added to the default group (if it is set). Besides the Table is an editable object to allow selecting a cell with encoder navigation too.
     14 
     15 ## Parts and Styles
     16 - `LV_PART_MAIN` The background of the table uses all the typical background style properties.
     17 - `LV_PART_ITEMS` The cells of the table also use all the typical background style properties and the text properties.
     18 
     19 
     20 ## Usage
     21 
     22 ### Set cell value
     23 
     24 The cells can store only text so numbers need to be converted to text before displaying them in a table.
     25 
     26 `lv_table_set_cell_value(table, row, col, "Content")`. The text is saved by the table so it can be even a local variable.
     27 
     28 Line breaks can be used in the text like `"Value\n60.3"`.
     29 
     30 New rows and columns are automatically added is required
     31 
     32 ### Rows and Columns
     33 
     34 To explicitly set number of rows and columns use `lv_table_set_row_cnt(table, row_cnt)` and `lv_table_set_col_cnt(table, col_cnt)`
     35 
     36 ### Width and Height
     37 
     38 The width of the columns can be set with `lv_table_set_col_width(table, col_id, width)`. The overall width of the Table object will be set to the sum of columns widths.
     39 
     40 The height is calculated automatically from the cell styles (font, padding etc) and the number of rows.
     41 
     42 ### Merge cells
     43 
     44 Cells can be merged horizontally with `lv_table_add_cell_ctrl(table, row, col, LV_TABLE_CELL_CTRL_MERGE_RIGHT)`. To merge more adjacent cells call this function for each cell.
     45 
     46 ### Scroll
     47 If the label's width or height is set to `LV_SIZE_CONTENT` that size will be used to show the whole table in the respective direction.
     48 E.g. `lv_obj_set_size(table, LV_SIZE_CONTENT, LV_SIZE_CONTENT)` automatically sets the table size to show all the columns and rows.
     49 
     50 If the width or height is set to a smaller number than the "intrinsic" size then the table becomes scrollable.
     51 
     52 ## Events
     53 - `LV_EVENT_VALUE_CHANGED` Sent when a new cell is selected with keys.
     54 - `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for the following types:
     55     - `LV_TABLE_DRAW_PART_CELL` The individual cells of the table
     56         - `part`: `LV_PART_ITEMS`
     57         - `draw_area`: area of the indicator
     58         - `rect_dsc`
     59         - `label_dsc`
     60         - `id`: current row × col count + current column
     61 
     62 See the events of the [Base object](/widgets/obj) too.
     63 
     64 Learn more about [Events](/overview/event).
     65 
     66 ## Keys
     67 
     68 The following *Keys* are processed by the Tables:
     69 - `LV_KEY_RIGHT/LEFT/UP/DOWN/` Select a cell.
     70 
     71 Note that, as usual, the state of `LV_KEY_ENTER` is translated to `LV_EVENT_PRESSED/PRESSING/RELEASED` etc.
     72 
     73 `lv_table_get_selected_cell(table, &row, &col)` can be used to get the currently selected cell. Row and column will be set to `LV_TABLE_CELL_NONE` no cell is selected.
     74 
     75 Learn more about [Keys](/overview/indev).
     76 
     77 ## Example
     78 
     79 ```eval_rst
     80 
     81 .. include:: ../../../examples/widgets/table/index.rst
     82 
     83 ```
     84 
     85 ### MicroPython
     86 No examples yet.
     87 
     88 ## API
     89 
     90 ```eval_rst
     91 
     92 .. doxygenfile:: lv_table.h
     93   :project: lvgl
     94 
     95 ```