A table is like a box but with 2 dimensions. You have the same kind of APIs as with boxes. An item inside the table can span multiple columns and rows, and even overlap with other items (and it can then be raised or lowered accordingly to adjust stacking if there is overlap).
Table Examples | |
---|---|
A First Table Example | A Second Table Example |
To create a table, use the elm_table_add()
function:
Evas_Object *table = elm_table_add(parent);
Items are added to the table with the elm_table_pack()
function. This function
takes as parameters the table, the item to add to the table, and the position
where to add the item: column, row, and the size of the item in number of rows
and columns (colspan and rowspan). If we want to create an icon that takes 3
columns and rows and a button that only takes 1 row and column, the code will
look like this:
ic = elm_icon_add(table); elm_image_file_set(ic, "icon.png", NULL); evas_object_show(ic); elm_table_pack(table, ic, 0, 0, 3, 3); btn = elm_button_add(table); elm_object_text_set(btn, "Click me i'm famous"); evas_object_show(btn); elm_table_pack(table, btn, 3, 1, 1, 1); evas_object_show(table);
If you want to change the position of the item after adding it, use the
elm_table_pack_set()
function. This function takes as parameters the item
whose position to change, the new column, the new row, and the size of the
item in number of rows and columns (colspan and rowspan).
To add padding around the item, use the elm_table_padding_set()
function. The
second parameter is the padding between columns, and the third parameter is
the padding between rows:
elm_table_padding_set(table, 10, 10);
To change the alignment and size of an item, use the evas_object_size_hint
parameters. They are used in the same way as with boxes. You can set the same
size and weight to each item by using the homogeneous parameter:
elm_table_homogeneous_set(table, EINA_TRUE);
To clear the table, use the elm_table_clear()
function. If the clear
parameter is EINA_TRUE
, the table items are deleted. The
evas_object_del()
function will be called on each item.