App:Library:LVGL:docs:Widgets:Table (lv table)

提供: robot-jp wiki
ナビゲーションに移動検索に移動

https://docs.lvgl.io/latest/en/html/widgets/table.html

Table (lv_table)

Overview

英文 自動翻訳

Tables, as usual, are built from rows, columns, and cells containing texts.

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.

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.

テーブルは、通常通り、テキストを含む行、列、セルから構築されます。

テーブル・オブジェクトは、テキストだけが格納されるため、非常に軽量です。セルについては、実際のオブジェクトは作成されず、その場で描画されるだけです。

テーブルは、(それが設定されていれば)デフォルトグループに追加されます。さらに、テーブルは編集可能なオブジェクトであり、エンコーダ・ナビゲーションでセルを選択することもできます。

戻る : Previous


Parts and Styles

英文 自動翻訳
  • LV_PART_MAIN The background of the table uses all the typical background style properties.
  • LV_PART_ITEMS The cells of the table also use all the typical background style properties and the text properties.
  • LV_PART_MAIN 表の背景は、通常の背景スタイルプロパティをすべて使用します。
  • LV_PART_ITEMS 表のセルにも、通常の背景スタイルプロパティとテキストプロパティをすべて使用します。
戻る : Previous


Usage

Set cell value

英文 自動翻訳

The cells can store only text so numbers need to be converted to text before displaying them in a table.

lv_table_set_cell_value(table, row, col, "Content"). The text is saved by the table so it can be even a local variable.

Line breaks can be used in the text like "Value\n60.3".

New rows and columns are automatically added is required

セルはテキストしか格納できないので、表中に表示する前に数値をテキストに変換する必要がある。

lv_table_set_cell_value(table, row, col, "Content"). テキストはテーブルで保存されるので、ローカル変数でもよい。

テキストは、"Value\n60.3"のように改行することができる。

新しい行と列は必要に応じて自動的に追加される。

戻る : Previous


Rows and Columns

英文 自動翻訳

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)

行と列の数を明示的に設定するには, lv_table_set_row_cnt(table, row_cnt)lv_table_set_col_cnt(table, col_cnt) を用います.
戻る : Previous


Width and Height

英文 自動翻訳

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.

The height is calculated automatically from the cell styles (font, padding etc) and the number of rows.

列の幅は lv_table_set_col_width(table, col_id, width)で設定することができる。表オブジェクトの全体の幅は、列の幅の合計に設定されます。

高さは、セルのスタイル(フォント、パディングなど)と行数から自動的に計算されます。

戻る : Previous


Merge cells

英文 自動翻訳

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.

列の幅は lv_table_add_cell_ctrl(table, row, col, LV_TABLE_CELL_CTRL_MERGE_RIGHT) で設定することができる。表オブジェクトの全体の幅は、列の幅の合計に設定されます。

高さは、セルのスタイル(フォント、パディングなど)と行数から自動的に計算されます。

戻る : Previous


Scroll

英文 自動翻訳

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.


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.

If the width or height is set to a smaller number than the "intrinsic" size then the table becomes scrollable.

ラベルのwidthまたはheightにLV_SIZE_CONTENTが設定されている場合、そのサイズがテーブル全体をそれぞれの方向に表示するために使用されます。


例:lv_obj_set_size(table, LV_SIZE_CONTENT, LV_SIZE_CONTENT) は自動的にテーブルのサイズを設定し、すべての列と行を表示するようにします。


もし、width または height が "intrinsic" サイズより小さい数値に設定されると、テーブルはスクロール可能になる。

戻る : Previous


Events

英文 自動翻訳
  • LV_EVENT_VALUE_CHANGED Sent when a new cell is selected with keys.
  • LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END are sent for the following types:
    • LV_TABLE_DRAW_PART_CELL The individual cells of the table
      • part: LV_PART_ITEMS
      • draw_area: area of the indicator
      • rect_dsc
      • label_dsc
      • id: current row × col count + current column


See the events of the Base object too.

Learn more about Events.

  • LV_EVENT_VALUE_CHANGED キーで新しいセルが選択されたときに送信されます。
  • LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END は以下のタイプで送出されます。
    • LV_TABLE_DRAW_PART_CELLテーブルの個々のセル
      • part: LV_PART_ITEMS
      • draw_area: インジケータの領域
      • rect_dsc
      • label_dsc
      • id: 現在の行数×col数+現在の列数


Baseオブジェクトのイベントも参照してください。

イベントの詳細を確認してください。

戻る : Previous


Keys

英文 自動翻訳
The following Keys are processed by the Tables:
  • LV_KEY_RIGHT/LEFT/UP/DOWN/ Select a cell.


Note that, as usual, the state of LV_KEY_ENTER is translated to LV_EVENT_PRESSED/PRESSING/RELEASED etc.


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.

Learn more about Keys.

以下のKeyはTablesで処理される。
  • LV_KEY_RIGHT/LEFT/UP/DOWN/ セルを選択する。


例によって、LV_KEY_ENTER の状態は、LV_EVENT_PRESSED/PRESSING/RELEASEDなどに変換されることに注意する。


lv_table_get_selected_cell(table, &row, &col)は現在選択されているセルを取得するために使用することができます。


行と列はLV_TABLE_CELL_NONE に設定され、セルが選択されることはありません。


キーの詳細を確認してください。

戻る : Previous


Example

英文 自動翻訳

Simple table

LVGL docs example 109.png

Lightweighted list from table

LINK=https://docs.lvgl.io/8.2/widgets/core/table.html#lightweighted-list-from-table

MicroPython

No examples yet.

戻る : Previous


API

英文 自動翻訳

Typedefs

typedef uint8_t lv_table_cell_ctrl_t

Enums

enum [anonymous]

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

enum lv_table_draw_part_type_t

type field in lv_obj_draw_part_dsc_t if class_p = lv_table_class Used in LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END Values:
enumerator LV_TABLE_DRAW_PART_CELL
A cell

Functions

LV_EXPORT_CONST_INT(LV_TABLE_CELL_NONE)

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, uint16_t row, uint16_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, uint16_t row, uint16_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_cnt(lv_obj_t *obj, uint16_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_col_cnt(lv_obj_t *obj, uint16_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_col_width(lv_obj_t *obj, uint16_t col_id, lv_coord_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, uint16_t row, uint16_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, uint16_t row, uint16_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

const char *lv_table_get_cell_value(lv_obj_t *obj, uint16_t row, uint16_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

uint16_t lv_table_get_row_cnt(lv_obj_t *obj)

Get the number of rows.
Parameters
obj -- table pointer to a Table object
Returns
number of rows.

uint16_t lv_table_get_col_cnt(lv_obj_t *obj)

Get the number of columns.
Parameters
obj -- table pointer to a Table object
Returns
number of columns.

lv_coord_t lv_table_get_col_width(lv_obj_t *obj, uint16_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, uint16_t row, uint16_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, uint16_t *row, uint16_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)

Variables

const lv_obj_class_t lv_table_class

struct lv_table_t

Public Members
lv_obj_t obj
uint16_t col_cnt
uint16_t row_cnt
char **cell_data
lv_coord_t *row_h
lv_coord_t *col_w
uint16_t col_act
uint16_t row_act


Typedef

typedef uint8_t lv_table_cell_ctrl_t

列挙型

列挙型[匿名]

値:
列挙子LV_TABLE_CELL_CTRL_MERGE_RIGHT
列挙子LV_TABLE_CELL_CTRL_TEXT_CROP
列挙子LV_TABLE_CELL_CTRL_CUSTOM_1
列挙子LV_TABLE_CELL_CTRL_CUSTOM_2
列挙子LV_TABLE_CELL_CTRL_CUSTOM_3
列挙子LV_TABLE_CELL_CTRL_CUSTOM_4

列挙型lv_table_draw_part_type_t

type使用されるlv_obj_draw_part_dsc_t場合のフィールドと値:class_p = lv_table_classTypedefLV_EVENT_DRAW_PART_BEGINTypedefLV_EVENT_DRAW_PART_END
列挙子LV_TABLE_DRAW_PART_CELL
細胞

機能

LV_EXPORT_CONST_INT(LV_TABLE_CELL_NONE)

lv_obj_t * lv_table_create(lv_obj_t * parent)

テーブルオブジェクトを作成する
パラメーター
parent-オブジェクトへのポインタ。新しいテーブルの親になります
戻り値
作成されたテーブルへのポインタ

void lv_table_set_cell_value(lv_obj_t * obj、uint16_t row、uint16_t col、const char * txt)

セルの値を設定します。注必要に応じて、新しい卵/列が自動的に追加されます
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • 行-行のID[0.. row_cnt -1]
  • col--列のID[0.. col_cnt -1]
  • txt-セルに表示するテキスト。これはコピーおよび保存されるため、この関数呼び出しの後にこの変数は必要ありません。

void lv_table_set_cell_value_fmt(lv_obj_t * obj、uint16_t row、uint16_t col、const char * fmt、...)

セルの値を設定します。テーブルごとにテキストを保存するためのメモリが割り当てられます。注必要に応じて、新しい卵/列が自動的に追加されます
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • 行-行のID[0.. row_cnt -1]
  • col--列のID[0.. col_cnt -1]
  • fmt --- printflike format

void lv_table_set_row_cnt(lv_obj_t * obj、uint16_t row_cnt)

行数を設定する
パラメーター
  • obj-テーブルオブジェクトへのテーブルポインタ
  • row_cnt-行数

void lv_table_set_col_cnt(lv_obj_t * obj、uint16_t col_cnt)

列数を設定する
パラメーター
  • obj-テーブルオブジェクトへのテーブルポインタ
  • col_cnt-列の数。

void lv_table_set_col_width(lv_obj_t * obj、uint16_t col_id、lv_coord_t w)

列の幅を設定します
パラメーター
  • obj-テーブルオブジェクトへのテーブルポインタ
  • col_id--列のID[0.. LV_TABLE_COL_MAX -1]
  • w-列の幅

void lv_table_add_cell_ctrl(lv_obj_t * obj、uint16_t row、uint16_t col、lv_table_cell_ctrl_t ctrl)

セルに制御ビットを追加します。
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • 行-行のID[0.. row_cnt -1]
  • col--列のID[0.. col_cnt -1]
  • ctrl-::lv_table_cell_ctrl_tからのOR-ed値

void lv_table_clear_cell_ctrl(lv_obj_t * obj、uint16_t row、uint16_t col、lv_table_cell_ctrl_t ctrl)

セルの制御ビットをクリアします。
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • 行-行のID[0.. row_cnt -1]
  • col--列のID[0.. col_cnt -1]
  • ctrl-::lv_table_cell_ctrl_tからのOR-ed値

const char * lv_table_get_cell_value(lv_obj_t * obj、uint16_t row、uint16_t col)

セルの値を取得します。
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • 行-行のID[0.. row_cnt -1]
  • col--列のID[0.. col_cnt -1]
戻り値
セル内のテキスト

uint16_t lv_table_get_row_cnt(lv_obj_t * obj)

行数を取得します。
パラメーター
obj-テーブルオブジェクトへのテーブルポインタ
戻り値
行の数。

uint16_t lv_table_get_col_cnt(lv_obj_t * obj)

列数を取得します。
パラメーター
obj-テーブルオブジェクトへのテーブルポインタ
戻り値
列の数。

lv_coord_t lv_table_get_col_width(lv_obj_t * obj、uint16_t col)

列の幅を取得する
パラメーター
  • obj-テーブルオブジェクトへのテーブルポインタ
  • col--列のID[0.. LV_TABLE_COL_MAX -1]
戻り値
列の幅

bool lv_table_has_cell_ctrl(lv_obj_t * obj、uint16_t row、uint16_t col、lv_table_cell_ctrl_t ctrl)

セルに制御ビットがあるかどうかを取得します
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • 行-行のID[0.. row_cnt -1]
  • col--列のID[0.. col_cnt -1]
  • ctrl-::lv_table_cell_ctrl_tからのOR-ed値
戻り値
true:すべての制御ビットが設定されます。false:すべての制御ビットが設定されているわけではありません

void lv_table_get_selected_cell(lv_obj_t * obj、uint16_t * row、uint16_t * col)

選択したセルを取得します(押された、またはフォーカスされた)
パラメーター
  • obj-テーブルオブジェクトへのポインタ
  • row-選択した行を格納する変数へのポインタ(LV_TABLE_CELL_NONE:セルが選択されていない場合)
  • col-選択した列を格納する変数へのポインタ(LV_TABLE_CELL_NONE:セルが選択されていない場合)

変数

const lv_obj_class_t lv_table_class

struct lv_table_t

パブリックメンバー
lv_obj_t obj
uint16_t col_cnt
uint16_t row_cnt
char ** cell_data
lv_coord_t * row_h
lv_coord_t * col_w
uint16_t col_act
uint16_t row_act


戻る : Previous