In this example we add four labels to a homogeneous table that has a padding of 5px between cells.
The first part consists of including the headers. In this case we are only working with the Elementary C++ binding and thus we need only to include him.
Now we need to actually start the code and set the elm_policy, which defines for a given policy group/identifier a new policy's value, respectively. In this example the only policy we need to set a value for is
ELM_POLICY_QUIT, possibles values for it are:
ELM_POLICY_QUIT_NONE:Never quit the application automatically;
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED:quit when the application's last window is closed;
ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN: quit when the application's last window is hidden;
As you can see, the policy we chose was to quit when the last win is hidden as opose to examples with the C bindings where we perpetually set it to quit when last win was closed. This changed was necessary because in C++ binding as the elm mainloop stop running all object are destroyed, references are unreferenced and events are stopped at ELM_MAIN().
Next step is creating an Elementary window, in this example we use the C++ binding method with the elm_win_util_standard_add that is a elm_win_legacy function, better explained below. And then we set the autohide state for it.
elm_win_util_standard_add (const char *name, const char *tittle) Adds a window object with standard setup. Parameters:
name- The name of the window;
title- The title for the window.
This creates a window but also puts in a standard background with
elm_bg_add(), as well as setting the window title to
title. The window type created is of type
ELM_WIN_BASIC, with the
NULL as the parent widget. Returns the created object or
NULL on failure.
And we also set the autohide state for win, autohide works similarly to
autodel, automatically handling "delete,request" signals when set to
true, with the difference that it will hide the window, instead of destroying it.
It is specially designed to work together with
ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting Elementary's main loop when all the windows are hidden.
autodeland autohide are not mutually exclusive. The window will be destructed if both autodel and autohide is set to
Now we construct the elm table and for this we use the C++ method below, setting it's parent.
We then add table as a resize_object to win informing that when the size of the win changes so should the box's size and make it visible.
Next step is to set the padding, in this case 5px and as we chosen for this example homogeneous_set to true.
We'll create for each cell on this table a simple elm_lable, using the C++ method below, setting it's parent. Set the text for the labels and make each visible. The parameters for packing the labels in our table will be better explain below.
When using pack in our table we are adding a child to a packing location of the table. The parameters are:
pack (evas::object subobj, int column, int row, int colspan, int rowspan)
Finally we just have to make our window visible. Then run the elm mainloop, starting to handle events and drawing operations.
Full code for this example: table_cxx_example_01.cc .
Our example will look like this: