Summary:
See also: Dynamic User Interface.
Presentation Styles allow you to define a set of attributes to be used in graphical objects.
Presentation Styles are provided to centralize attributes
related to the decoration of user interface elements. The elements can automatically get decoration
attributes implicitly with global styles, or explicitly by naming a specific
style in the style
attribute of the element.
<StyleList>
<Style name="style-identifier"
>
<StyleAttribute name="attribute-name"
value="attribute-value" />
[...]
</Style>
[...]
</StyleList>
where style-identifier can be:
{ *
| element-type
| .style-name
| element-type.style-name }
Window
).style
attribute.Presentation Styles are provided to centralize attributes
related to the decoration of user interface elements. The elements can automatically get decoration
attributes implicitly with global styles or explicitly by naming a specific
style in the style
attribute of the element.
You can define a style as global or specific. Global styles are applied
implicitly, while specific styles are applied to elements having a style-name
in the style
attribute. In the definition of a style, the 'name' attribute is used as a
selector to apply style attributes to graphical elements.
A style identified by a star (*) is a global style that is automatically applied to all elements:
01
<Style name="*" >
A style identified by an element-type is a global style that is automatically applied to all objects of this type.
01
<Style name="Window" >02
<Style name="Edit" >03
<Style name="ComboBox" >
A style identified by a style-name is a specific style that can be applied to any element types using that style:
01
<Style name=".important" >02
<Style name=".smallfont" >
A style identified by an element-type followed by a dot and a style-name is a specific style that will only be applied to elements of the given type:
01
<Style name="Window.main" >02
<Style name="Edit.mandatory" >
To apply a specific style, set the style-name in the style
attribute of the node
representing the graphical element in the Abstract User Interface tree.
There are different ways to set the style
attribute of a
element:
A typical use is defining the style in form files; for example, for a input field:
01
EDIT f001 = customer.fname, STYLE = "info";
By using the space character as a separator, you can combine several styles:
01
EDIT f001 = customer.fname, STYLE = "info highlight mandatory";
A style attribute may be inherited by the descendents of a given node in the
Abstract User Interface tree. For example, when using a style defining a fontFamily
in a GROUPBOX container, you would expect that all the children in that
groupbox have the same font. However, some style attributes should not be
inherited, such as backgroundImage
.
Style inheritance is implicitly defined according to the attribute. The following sections contain tables with descriptions of style attributes, including the implicit inheritance for each attribute.
Presentation Styles are defined in the Abstract User
Interface tree, under the UserInterface
node, in a StyleList
node following the syntax described above. The StyleList
node holds a list of Style
nodes
that define a set of attribute values. Attribute values are defined in StyleAttribute
nodes, with a name
and a value
attribute.
Presentation Styles can be defined in an XML file that has the "4st
"
extension. By default, the runtime system searches the current directory for a file named "default.4st
". If this file does not exist, it searches
the directories defined in the DBPATH
environment variable. If the file was not found using DBPATH, standard window styles are
loaded from the "FGLDIR/lib/default.4st
"
file.
You can overwrite the default search by loading a specific Presentation Style file
with the ui.Interface.loadStyles() method.
This method accepts an absolute path with the "4st
"
extension, or a simple file name without the "4st
"
extension. If you give a simple
file name, for example "mystyles
", the runtime
system searches for the "mystyles.4st
" file in the current
directory. If the file does not
exist, it searches in the directories defined in the
DBPATH environment variable.
4st
"
files.01
<StyleList>02
<Style name="*" >03
<StyleAttribute name="fontFamily" value="serif" />04
</Style>05
<Style name=".important" >06
<StyleAttribute name="textColor" value="#ff0000" />07
</Style>08
<Style name="Window" >09
<StyleAttribute name="toolBarPosition" value="top" />10
<StyleAttribute name="statusBarType" value="default" />11
</Style>12
<Style name="Window.dialog" >13
<StyleAttribute name="toolBarPosition" value="none" />14
<StyleAttribute name="statusBarType" value="node" />15
</Style>16
</StyleList>
Styles do not apply to all types of nodes that the Abstract User Interface can hold.
The following table lists the supported element types that can use a style:
Element Type | Description |
Window |
Windows elements containing forms. See Window style attributes. |
Form |
Form (Style defined with LAYOUT(STYLE="name")). |
Table |
Table container |
This section describes how to specify a value for style attributes defining
colors such as textColor
.
{ generic-color | #rrggbb }
The language defines a set of generic colors, interpreted by the front end according to the graphical capability of the workstation.
Generic color name | RGB Value | Color sample |
white |
#FFFFFF |
|
black |
#000000 |
|
darkGray |
#808080 |
|
gray |
#A9A9A9 |
|
lightGray |
#D3D3D3 |
|
darkBlue |
#00008B |
|
blue |
#0000FF |
|
lightBlue |
#ADD8E6 |
|
darkCyan |
#008B8B |
|
cyan |
#00FFFF |
|
lightCyan |
#E0FFFF |
|
darkMagenta |
#8B008B |
|
magenta |
#FF00FF |
|
lightMagenta |
#FFC0FF |
|
darkOlive |
#505000 |
|
olive |
#808000 |
|
lightOlive |
#AAAA44 |
|
darkGreen |
#008000 |
|
green |
#00FF00 |
|
lightGreen |
#00FFB0 |
|
darkTeal |
#005050 |
|
teal |
#008080 |
|
lightTeal |
#33CCCC |
|
darkRed |
#8B0000 |
|
red |
#FF0000 |
|
lightRed |
#FF8080 |
|
darkOrange |
#FF8C00 |
|
orange |
#FFA500 |
|
lightOrange |
#FFCC00 |
|
darkYellow |
#AAAA00 |
|
yellow |
#FFFF00 |
|
lightYellow |
|
You can also specify a generic system color:
Generic system color name | Meaning |
window |
Window background. |
windowText |
Text in Windows. |
buttonFace |
Face color for three-dimensional display elements. |
buttonText |
Text on PushButtons. |
highLight |
Item(s) selected in a control. |
highLightText |
Text of item(s) selected in a control |
infoBackground |
Background color for tooltip controls. |
infoText |
Text color for tooltip controls. |
grayText |
Grayed (disabled) text. |
appWorkSpace |
Background color of multiple document interface |
background |
Desktop background |
You can also specify a color with the RGB notation, starting with a # dash character.
Each value of the RGB color specification must be provided in hexadecimal, in the range [00-FF].
<StyleAttribute name="textColor"
value="blue" />
<StyleAttribute name="textColor"
value="#00ff45" />
A desktop application should follow the current desktop settings. The front-end program (GDC, GJC, HTML browser) tries to determine the default font for the desktop, and also offers a global font chooser to let the end-user define which font best matches his expectations. In most cases, it is not possible to know what a potential end user might expect regarding the font family. Therefore, the configuration should avoid using explicit font families, and should use only the fontWeight/fontStyle/fontSize properties . A known font family should be added to the configuration only if the client can't determine a proper default font family for the desired platform When using font sizes you should use the abstract sizes medium , large, small, or sizes relative to the user-chosen font (em units), rather than absolute point values. In an HTML browser you can choose two fonts (proportional/fixed), and a well-designed document should not use more than two fonts . This is also valid for applications.
This section describes the possible values of the fontFamily
style attribute.
font-family [,...]
The language defines a set of generic font families, interpreted by the front end according to the graphical capability of the workstation:
Generic font family name | Real font family example | Text sample |
serif |
Times | This is a nice font! |
sans-serif |
Arial | This is a nice font! |
cursive |
Comic Sans Ms | This is a nice font! |
fantasy |
Algerian | This is a nice font! |
monospace |
Courier New | This is a nice font! |
Any other name is interpreted as a specific font family, which identifies a local font supported by the front-end. Usually, it is one of the fonts installed on the workstation operating system. See front-end documentation for a list of supported local fonts.
Any font name containing white-spaces must be quoted, with single quotes.
You can specify a comma-separated list of font families.
<StyleAttribute name="fontFamily"
value="sans-serif" />
<StyleAttribute name="fontFamily"
value="'Courier New'" />
<StyleAttribute name="fontFamily"
value="'Times New Roman',Times,serif" />
This section describes the possible values of the fontSize
style attribute.
{ generic-size | nnpt | xxem
}
small
'
or 'xx-large
'.The language defines a set of generic font sizes, interpreted by the front end according to the graphical capability of the workstation.
xx-small, x-small, small, medium, large, x-large, xx-large.
You can also specify an absolute font size, by giving a numeric value followed by the units (pt):
<StyleAttribute name="fontSize"
value="medium" />
<StyleAttribute name="fontSize"
value="xx-large" />
<StyleAttribute name="fontSize"
value="12pt" />
<StyleAttribute name="fontSize"
value="1em" />
The style attributes described in this section apply to any graphical elements, such as windows, layout containers, or form items.
Attribute | Inh. | Description |
backgroundImage |
No | Defines an image file to be displayed in the background. The value can be a simple local image filename without an extension or an URL. Default is no value (no background image). |
backgroundColor |
No | Defines the color to be used to fill the background of the object. For possible values, see Colors. Default is no value (default color of the object). |
fontFamily |
Yes | Defines the name of the font. For possible values, see Font Families. Default is no value (default object font or inherited font). |
fontSize |
Yes | Defines the size of the characters. For possible values, see Font Sizes. Default is no value (default object font or inherited font). |
fontStyle |
Yes | Defines the style of characters. The values can be "normal", "italic"
or "oblique" . Default is no value (default object font or inherited font). |
fontWeight |
Yes | Defines the weight of the characters. The values can be "light" , "normal" ,
"bold" ,
"demi-bold" or
"black" .Default is no value (default object font or inherited font). |
textColor |
Yes | Defines the color to be used to paint the text of the object. For possible values, see Colors. Default is no value (default object color or inherited color). |
textDecoration |
Yes | Defines the decoration for the text. The values can be "overline" , "underline"
or "line-through" .Default is no value (default object font or inherited font). |
The following table shows the presentation attributes for Windows:
Attribute | Inh. | Description | ||||||||||||||||||||||||||
windowType |
No | Defines the basic type of the window. Values can be "normal"
or "modal" .Normal windows are displayed as typical application windows. Modal windows are displayed at the top of all other windows, typically used for temporary dialogs. Default is "normal" . |
||||||||||||||||||||||||||
windowState |
No | Defines the initial state of a window. Values can be "normal"
or "maximized" .Default is "normal" . |
||||||||||||||||||||||||||
windowOptionClose |
No | Defines if the window can be closed with a system menu option or window
header button. Values can be "yes" ,
"no"
or "auto" . When the value is "auto" ,
the option is enabled according to the window type.Default is "auto" .Warning: This attribute may have a different behavior in accordance with the front end operating system. For example, when no system menu is used, it may not be possible to have this option enabled. |
||||||||||||||||||||||||||
windowOptionMinimize |
No | Defines if the window can be minimized with a system menu option or
window header button. Values can be "yes" ,
"no"
or "auto" . When the value is "auto" ,
the option is enabled according to the window type.Default is "auto" .Warning: This attribute may have a different behavior in accordance with the front end operating system. For example, when no system menu is used, it may not be possible to have this option enabled. |
||||||||||||||||||||||||||
windowOptionMaximize |
No | Defines if the window can be maximized with a system menu option or
window header button. Values can be "yes" ,
"no"
or "auto" . When the value is "auto" ,
the option is enabled according to the window type.Default is "auto" .Warning: This attribute may have a different behavior in accordance with the front end operating system. For example, when no system menu is used, it may not be possible to have this option enabled. |
||||||||||||||||||||||||||
windowSystemMenu |
No | Defines if the window shows a system menu. Values can be "yes" ,
"no"
or "auto" . When the value is "auto" ,
the system menu is enabled according to the window type.Default is "auto" . |
||||||||||||||||||||||||||
sizable |
No | Defines if the window can be resized by the user. Values can be "yes" ,
"no"
or "auto" . When the value is "auto" , the window
becomes resizable if the content of the first displayed form has resizable
elements; for example, when using a form with a TABLE
container or an TEXTEDIT
with STRETCH attribute.Warning: When the value is "auto" ,
the window becomes resizable based on the first form used in the window;
the content of further forms is ignored.Default is "yes" . |
||||||||||||||||||||||||||
position |
No | Indicates the initial position of the window. Values can be
"default" , "field" , "center" or
"center2" . When "default" ,
the windows are displayed according to the window manager rules. With "center" ,
the window is displayed in the center of the screen. With "center2" ,
the window is displayed in the center of the current window.Default is "default" . |
||||||||||||||||||||||||||
border |
No | Defines the border type of the window. Values can be "normal" ,
"frame" , "tool" or "none" . When
the value is "normal" , the border is standard, with a normal window
header with a caption; when "frame" , only a frame
appears, typically without a window header; when "tool" , a
small window header is used; when "none" , the window
has no border.Default is "normal" . |
||||||||||||||||||||||||||
forceDefaultSettings |
No | Indicates if the window content must be initialized with the saved
positions and sizes. By default, windows are re-opened at the position and
with the size they had when they were closed. You can force the use of the
initial settings with this attribute. This applies also to column position
and width in tables. Default is "0" . |
||||||||||||||||||||||||||
actionPanelPosition |
No | Defines the position of the action button frame (OK/Cancel).
Values can be "none" , "top" ,
"left" , "bottom" or "right" .Default is "right" . |
||||||||||||||||||||||||||
actionPanelButtonSize |
No | Defines the width of buttons. Values can be "normal" ,
"shrink" , "tiny" , "small" ,
"medium" , "large" or "huge" . When
the values are "normal" or "shrink" , buttons are sized
according to the text or image; "shrink" uses the
minimum size needed to display the content of the button.Default is "normal" . |
||||||||||||||||||||||||||
actionPanelButtonSpace |
No | Defines the space between buttons. Values can be "none" ,
"tiny" , "small" , "medium" ,
"large" or "huge" .Default is "medium" . |
||||||||||||||||||||||||||
ringMenuPosition |
No | Defines the position of the ring menu frame (MENU).
Values can be "none" , "top" ,
"left" , "bottom" or "right" .Default is "right" . |
||||||||||||||||||||||||||
ringMenuButtonSize |
No | Defines the width of buttons. Values can be "normal" ,
"shrink" , "tiny" , "small" ,
"medium" , "large" or "huge" . When
the values are "normal" or "shrink" , buttons are sized
according to the text or image; "shrink" uses the
minimum size needed to display the content of the button.Default is "normal" . |
||||||||||||||||||||||||||
ringMenuButtonSpace |
No | Defines the space between buttons. Values can be "none" ,
"tiny" , "small" , "medium" ,
"large" or "huge" .Default is "medium" . |
||||||||||||||||||||||||||
toolBarPosition |
No | Indicates the position of the toolbar, when a
toolbar is defined. Values can be "none" , "top" ,
"left" , "bottom" or "right" .Default is "top" . |
||||||||||||||||||||||||||
startMenuPosition |
No | Indicates the position of the startmenu,
when one is defined. Values can be "none" , "tree" ,
"menu" or "poptree" . When
the value is "tree" ,
the startmenu is displayed as a treeview always visible on the right side of
the window; when "menu" , the startmenu is displayed as
a pull-down menu, always visible at the top of the window; when "poptree" ,
the startmenu is displayed as a treeview in a popup window that you can
open with a short-cut (see startMenuShortcut ). Default is "none" . |
||||||||||||||||||||||||||
startMenuSize |
No | Defines the size of the startmenu,
when one is defined and the position is defined as "tree" or "poptree" .
The values can be "tiny" , "small" ,
"medium" , "large" or "huge" .Default is "medium" . |
||||||||||||||||||||||||||
startMenuShortcut |
No | Defines the shortcut key to open a startmenu,
when the position is defined as "poptree" .Default is "control-shift-F12" . |
||||||||||||||||||||||||||
statusBarType |
No | Defines the type of status bar the window will display:
Default is |
The following table shows the presentation attributes for Tables:
Attribute | Inh. | Description |
highlightColor |
No | Defines the highlight color of rows for a table. For possible values, see Colors. |
highlightCurrentRow |
No | Indicates if the current row must be highlighted in a table. Values can
be 1 or 0. By default, when a Table is in read-only mode (DISPLAY ARRAY), the front-end automatically highlights the current row. But in editable mode (INPUT ARRAY), no row highlighting is done by default. You can change this behavior by setting this attribute to 1. |
highlightCurrentCell |
No | Indicates if the current cell must be highlighted in a table. Values can
be 1 or 0. By default the current edit cell in table has a white background. You can change this behavior by setting this attribute to 1, to use the same color as when highlightCurrentRow is used. Only some type of cells like checkboxes can be highlighted. Normal editor cells stay in white, because this is the editor background color. |
showGrid |
No | Indicates if the grid lines must be visible in a table. Values can be 1
or 0. By default, when a Table is in editable mode (INPUT ARRAY), the front-end displays grid lines in the table. You can change this behavior by setting this attribute to 0. |
The following table shows the presentation attributes for ComboBox and Radiogroup:
Attribute | Inh. | Description |
autoSelectionStart |
No | Defines the item from which the auto-selection will start, when pressing
keys. Possible values are "first", "current". If 'first', the auto-selection will look for the first corresponding item after the first item of the object. If 'current', it will look for the first corresponding item after the current item of the object. Default is "current". |
The following table shows the presentation attributes for TextEdit:
Attribute | Inh. | Description |
textFormat |
No | Defines the kind of rendering of the content of the TextEdit widget. Possible values are "plain", "html". If 'first', the value assigned to this widget is interpreted as plain text. If 'html', it is interpreted as HTML. The support for HTML is basic: for example you can't add links, frames... |