Within the Prototyper or Composer window, the style setting are used according to the current selection within the Embedded Wizard toolbar. On the target the style needs to be set explicitely! This can be done on Embedded Wizard side e.g. within the Init() method of your application class:
Styles = [MyStyle];
Or on ‘C’-side by a function call after the initialization of the EmWi application:
EwSetStyles( MyStyle );
According to the selected style, Embedded Wizard decides during the creation of a new object, what variant should be created. So if you change the style in the Chora code, it has no effect on existing UI objects. To get the new style active, you need to destroy the existing objects and create them again.
If you don’t see a style as expected, check the following possible sources of the problem:
- Is the correct style selected in Embedded Wizard?
- Is the variant condition of your variant class correct?
- Does the variant exist for the class?
- Are visible objects recreated after a style change?
To recreate existing UI objects, Embedded Wizard offers a property ‘Style’ in the class Core::Root (base class of your application class) for that purpose. It can be changed e.g. from within a slot method of a styles menu.
GetRoot().Styles = ( styles + [ AquaStyle ]) - [ Win95Style ];
The class Core::Root automatically broadcasts a style event to all existing objects. This event can be processed in the HandleEvent() method of all objects that need to recreated.
styleEvent = (Core::StylesEvent)aEvent;
if ((styleEvent != null ) && ( styleEvent.NewStyles != styleEvent.OldStyles ))
/* Solution 1: If your class exists in several variants, then it is
necessary to create and to open a new instance of your own class
and to remove this instance from its parent */
/* Solution 2: If your class just uses constants or resources which
exist in different variants, then simply reassign all style dependent
color constants or resources once again to the members of this class
=> as a result they will be loaded according the new style */
Icon.Color = Res::ThemeColor;
Caption.Color = Res::CaptionColor;
Background.Bitmap = Res::Background;
return super( aEvent );