x::w::new_listlayoutmanager new_list; new_list.columns=3; x::w::focusable_container list=f->create_focusable_container( [] (const x::w::focusable_container &c) { }, new_list); x::w::listlayoutmanager llmanager=list->get_layoutmanager(); llmanager->append_items( { "Lorem", "Ipsum", "Dolor", x::w::separator{}, "Sit", "Amet", "consectetur", });
This is an example of creating a list with three columns.
x::w::new_listlayoutmanager
initializes
columns
to a default value of 1, resulting in one
list item per row.
All previous examples in this chapter used this default
configuration. This example sets columns
to 3,
resulting in three columns per list item. This example creates a list
with two rows, and a
x::w::separator
between them.
The resulting list's size
() is 3: a list item
with three columns, a separator, and another list item with three
columns.
The results of creating a list with more than one column are as follows. Using the example of a list with three columns:
When creating new list items (using
append_items
(),
insert_items
(), et. al.)
a separate text string goes into each column, and gets
individually specified.
The number of consecutive text strings is always a multiple of three.
Each consecutive sequence of text strings creates one new list item.
size
() increases by 1.
However, an x::w::separator
only
appears once.
The list layout manager automatically aligns list columns. Each column gets sized wide enough for the widest contents of the column, in all list rows.
It's also possible to synchronize the widths of columns of two or more selection lists. If they're positioned above each other, and their enclosing containers size them to the same width, then their respective columns will align with each other. See the section called “Panes with synchronized lists” for an example of doing this.
Each consecutive sequence of three text strings (and each
individual x::w::separator
, as usual),
forms one new logical list item, increasing the list's
size
() by 1, as usual.
The list layout manager continues to automatically number
all logical items in the list. All other list methods,
such as enabled
() or
selected
(), still reference each
logical item using its numbered index.