2.5 QHTML Look and alias functionalities

It is common to have parameters repeated over and over for all widgets in a container of the window, or for all widgets of the same type inside the window. For example, the backgroungColor of many widgets may be set to the same value (red for example) to give a uniform background to the window. QHTML provides two functionalities to define parameters in a global way : looks and aliases. Note that they share the same two limitations :

Note that you can mix aliases and looks together. Parameters defined by looks have a higher prior than those defined by aliases.

2.5.1 Looks

Looks define a set of default value associated to widgets. Looks are automatically passed from container widgets to their contained widgets. Looks are a very convenient way to define all default parameters for a rectangular area of the window. A look is created by QHTML.newLook. A look furnishes two procedures as features of the look:

All widgets (almost) support the look parameter that can be specified a QHTML look.

local 
  MyLook={QHTML.newLook}
  {MyLook.set button(backgroundColor:red)}
  {MyLook.set label(backgroundColor:red)}
in 
  {{QHTML.build toplevel(look:MyLook
                         td(label(value:"Hello world")
                            label(value:"Amazing colors !")
                            button(value:"Ok")
                            button(value:"Ok also")))} show}
end

2.5.2 Aliases

An alias defines another name for a widget, a name that is associated to a set of default parameters. Aliases are well adapted to define default values to a specific kind of widgets that are spread throughout entire windows. QHTML provides:

{QHTML.setAlias redLabel label(backgroundColor:red)}
{QHTML.setAlias yellowLabel label(backgroundColor:yellow)}
{{QHTML.build toplevel(td(redLabel(value:"This label is red")
                          yellowLabel(value:"This label is yellow")))} show}


Donatien Grolaux
Version 1.3.0 (20010902)