type=elements factorys

The contents of a factorys of type=elements specify miscellaneous operations on widgets that were created by other factories and layout managers that generated from a theme file.

Manual processing of an elements factory

<factory type="elements" id="initialize-dialog">

  <!-- ... -->

  <request_focus>
    <focusable>name</focusable>
  </request_focus>

  <!-- ... -->
</factory>


x::w::uielements widgets;

widgets.generate("initialize-dialog", generators);

A x::w::uielements's generator() processes the factory of type=elements and the given id. The x::w::uielements presumably holds widgets and other objects already created by other layouts and factorys, and a factory of type=elements's typical use case is to invoke methods common to all widgets and other objects.

Processing an elements factory after creating a new widget or container

<factory type="elements" id="initialize-dialog">

  <!-- ... -->

  <request_focus>
    <focusable>name</focusable>
  </request_focus>

  <!-- ... -->
</factory>


   <!-- somewhere else, in another factory: -->

    <element id="name">
      <input_field />
        <config>
	  <columns>30</columns>
	</config>

	<elements>initialize-dialog</elements>
    </element>

An element or a container has an optional elements that gives the id of a factory of type=elements. The type=elements factory gets processed after generate() the layout or factory with the element/container that referenced the elements factory.

The x::w::uielements contains the generated widgets, by name. And the elements factory theme referenced the generated widgets by name. The elements factory invokes common methods shared by all, or most, widgets, such as setting the input focus, or showing or hiding them. This makes it possible to use the theme file to create widgets and show() them, automatically. Since the element factory runs after all widgets get generate(), referencing an element factory that show_all()s the container its referenced from results in creating all widgets in the container, and then showing them.

show, hide, show_all, and hide_all

<factory id="initialize-focus" type="elements">
  <show_all>
    <name>new-page</name>
  </show_all>
</factory>

These elements reference widgets by name. name references any generate()-ed widget, by name; and this invokes the widget's corresponding method.

autofocus, get_focus_first, get_focus_before, get_focus_after, get_focus_before_me, get_focus_after_me, and request_focus

<factory id="initialize-focus" type="elements">

  <autofocus>
    <enable>name_radio_button_option</enable>
  </autofocus>

  <autofocus>
    <disable>name_radio_button_option</disable>
  </autofocus>

  <get_focus_after>
    <focusable>name_input_field</focusable>
    <after_focusable>name_radio_button_option</after_focusable>
  </get_focus_after>

  <request_focus>
    <focusable>name_input_field</focusable>
  </request_focus>
</factory>

These elements reference focusable widgets by name. get_focus_first, get_focus_before, get_focus_after, get_focus_before_me, get_focus_after_me, and request_focus require focusable that gives a name of a focusable widget whose method of the same name gets invoked.

autofocus contains either an enable or a disable that gives a name of a focusable widget whose autofocus() method gets invoked with either a true or a false value, respectively.

request_focus's optional <now_or_never/> sets this method's optional parameter.

get_focus_before and get_focus_after also require before_focusable or after_focusable, respectively, that names the other focusable widget.

get_focus_before_me and get_focus_after_me require one or more other_focusables. Each other_focusables names one focusable widget; this forms the corresponding method's std::vector parameter.