Styles
Gui4j supports the style concept to simplify the description of graphical user interfaces with the same
look and feel. For instance, all editable number fields, should be displayed with white background, blue
text color and right alignment:
<edit value="getValue" setValue="setValue(?value)" alignment="right"
background=":Color.WHITE" foreground=":Color.BLUE"/>
For this look and feel we need three attribute values and for all edit components we have to repeat this
information. This is redundant information and much effort to change when the text color should now be black, for instance.
The style concept allows to group attribute values in a style and gui4j components simply refer to that style name:
<Style name="editNumber">
<Style_edit alignment="right" background=":Color.WHITE" foreground=":Color.BLUE"/>
</Style>
...
<edit value="getValue" setValue="setValue(?value)" style="editNumber"/>
The outer element Style introduces a new style name. For each supported guij4 component there is an additional
tag Style_tagName to define the corresponding style attributes. These tags are used inside the Style
element. In other elements a style is referenced using the style Attribut. The style reference only adds not already
defined attributes. For instance, if the background color is defined in the style and in the element referencing the style, then
the attribute value of the element referencing the style is used, since this has priorty.
Style Blocks
All definitions inside <StyleBegin name="styleName"/> and <StyleEnd/> uses implicitly the
style styleName if the style attribut is not defined.
Default Style
If an element is not inside a style block and the style attribut is not specified, then this element implicitly
uses a style with name Default. The application is free to define this style.
Style inheritance
It is possible to define a new style based on an already existing one. In this case, the new definitions overwrite and extend the
exisiting:
<Style name="editNumber" extends="Default">
<Style_edit alignment="right" background=":Color.WHITE" foreground=":Color.BLUE"/>
</Style>
...
<edit value="getValue" setValue="setValue(?value)" style="editNumber"/>