element
s<factory type="grid" id="statusrow"> <!-- ... --> <element> <name>label</name> </element> <!-- ... --> </factory> x::w::uielements element_factory{ { {"label", [] (const x::w::factory &factory) { factory->create_label("Label"); } } } };
An element
with a
name
(a “named element”)
invokes the named callback from the
x::w::uielements
parameter to
generate
().
This callback receives an
x::w::factory
parameter which gets used, presumably, to create a widget.
The first member of the
x::w::uielements
object is map. The map's key is a std::string
,
and the
name
value gives the callback's key value. An exception gets thrown
if the name
key does not exist.
It's possible that the same
name
value appears more than once, in the
same or different
factory
s. Each occurence of a
name
results in the callback getting
invoked.
<element id="button"> <button> <element> <label type="theme_text">Calculate</label> </element> </button> </element></programlisting> </informalexample> </blockquote> <para> An <tag class='element'>element</tag> without a <tag class='element'>name</tag> creates one of several supported widgets directly, without invoking an application callback, using the given parameters. Supported widgets: </para> <itemizedlist> <listitem> <para> <link linkend="uixmlfactorylabelelement"><classname>&ns;::w::label</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactorycanvaselement"><classname>&ns;::w::canvas</classname></link>es </para> </listitem> <listitem> <para> <link linkend="uixmlfactoryfocusablelabelelement"><classname>&ns;::w::focusable_label</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactorybuttonelement"><classname>&ns;::w::button</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactoryinputfieldelement"><classname>&ns;::w::input_field</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactorydateinputfieldelement"><classname>&ns;::w::date_input_field</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactorycheckboxelement">Checkbox</link> <classname>&ns;::w::image_button</classname>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactoryradioelement">Radio</link> <classname>&ns;::w::image_button</classname>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactoryprogressbarelement"><classname>&ns;::w::progressbar</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactorycolorpickerelement"><classname>&ns;::w::color_picker</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactoryfontpickerelement"><classname>&ns;::w::font_picker</classname></link>s </para> </listitem> <listitem> <para> <link linkend="uixmlfactoryscrollbarelement"><classname>&ns;::w::scrollbar</classname></link>s </para> </listitem> </itemizedlist> <para> These <tag class="element">element</tag> elements have an optional <tag class="attribute">id</tag> attribute. After the widgets get generated, <link linkend="uixmlgenerate"><classname>&ns;::w::uielements</classname></link>'s <methodname>get_element</methodname>() retrieves the created widget with the specified <tag class="attribute">id</tag>. Duplicate <tag class="attribute">id</tag>s get ignored; <methodname>get_element</methodname>() returns the most recently-created widget with the specified <tag class="attribute">id</tag>. </para> <para> These <tag class="element">element</tag>s have optional <link linkend="uixmlelementtooltip">tooltip tags</link> and an optional <tag class="context">context</tag> that <link linkend="uixmlelementcontext">creates a context popup menu for the widget</link>. </para> <blockquote> <informalexample> <programlisting><![CDATA[ <factory id="option-table-header-1" type="factory"> <element> <label type='theme_text'>Name</label> </element> </header>
A type
=“factory”
factory
represents a factory
superclass that creates only these generic widgets.