Project members: Style

With the style member you define a switch to control the derivation of class, autoobject, constant, bitmap resource and font resource variants. The derivation of variants is a feature allowing you to provide multiple versions of one and the same class, constant, etc. by conditionally overriding the original member with a variant member. The selection of the appropriate version takes place dynamically at the runtime depending on whether the style used in the condition is currently active or not. Style members are represented in Composer by following bricks:

Style members are used usually in applications implementing multiple versions of its look-and-feel. The styles are also useful to dynamically enable or disable individual application features or to manage multiple device/product variants with a single application binary.

Please note, style members can exist only at the root level of the project. Moreover, the maximum number of style members within a project is strictly limited to 32.

Add new style

First switch to the Composer containing the project main page.

Then, in the Gallery window, ensure that the folder Chora is opened.

Look in the folder for the template named Style.

With the mouse, select the template and drag it into the Composer.

Drop the template within the Composer.

Adding a new style member.

Please note the limitation of max. 32 style members within a single project.

Name the style

First ensure, that the style member is selected.

Press the key F2 or select the menu item EDITRename ....

Enter the new style name in the Inspector window.

The assigned name identifies globally the style within your project allowing the style to be involved e.g. in expressions to conditionally build your application. The style names appear also in the styles selection list.

Duplicate an existing style

You can create a copy of an already existing style member. Please note the limitation of max. 32 style members within a single project.

First ensure, that the style member is selected.

Press the keys CtrlC and CtrlV in succession ...

... or hold the key Ctrl pressed while you drag and drop the selected style member.

Finally rename the just duplicated style member.

Derive variants

Once defined a style member, you can use its name in the VariantCond attribute of any variant deriver from a class, autoobject, constant, bitmap resource or font resource member. The variant will become active, when the specified style is enabled at the runtime in the global variable styles.

Use the style in expressions

The name of the style member can be used within Chora expressions wherever an operand with data type styles is expected. In particular, the style names are used in conjunction with the global variable styles to individually enable/disable the styles at the runtime and thus to control the selection of derived variant members. Chora syntax expects the style names to be enclosed in a pair of [...] (square brackets). For example:

// Activate the style with the name 'HiRes' styles = styles + [ HiRes ];

Determine the current styles set

At the design and prototyping time the styles can be enabled conveniently by using the styles selection combobox. This selection has however no effect on the generated code. To enable/disable a style at the runtime, use the global variable styles.

Control the code generation

With the attribute Generator you can selectively control, whether variant members depending on the respective style should be taken in account during the code generation or not. Configuring this attribute with the value false will exclude all affected variants from your project unless the condition of a variant includes other styles or profiles.

Delete a style

First ensure, that the style member is selected.

Press the key DEL or select the menu item EDITDelete.

Attributes of a style

The following table shows the complete list of attributes provided by the style member:

Attribute name

Short description

Brick

Determines the position and the size of a style member brick within the Composer window.

Description

Contains the description for the style member.

Generator

Controls the code generation for the affected style member.

InstantUpdate

Controls the variant behaviour of members depending on this style.