Master theme is a theme file that has the name of the program and is stored together with it. Master themes are loaded automatically when the application (= built program) is run and are used to secure its unique appearance as compared to other applications developed for the same company.
Application theme is a user-defined theme file that is loaded from the 4gl code and allows changing runtime appearance and behavior of the application depending on the current tasks and purposes.
Differences between master and application themes are summed up in the table below.
|
Master theme |
Application theme |
has the same name as the 4gl program |
|
|
must be stored in the same folder as the program executable file |
|
|
is loaded automatically when the application is run |
|
|
is loaded from the 4gl code |
|
|
can be created as a part of the Create new 4gl program wizard |
|
|
can be created by concatenating theme snippets |
|
|
is applied at design time |
|
|
is applied at runtime |
|
|
can be stored in any folder |
|
|
In their essence, master and user themes are the same XML-based .qxtheme files and have the same syntax and structure.
What differs is their purpose, location, and loading time.
Below you can see an example of a .qxtheme file that can serve both a master theme and as a user theme:
|
<?xml version="1.0" encoding="utf-8"?> <StyleSheet xmlns="http://querix.com"> <ElementFilter ElementName="Application"> <StyleSheet> <DoStyleAction> <SetProperty> <PropertyPath> <PropertyName>Font</PropertyName> <PropertyName>Family</PropertyName> </PropertyPath> <PropertyValue> <Name>Cambria</Name> </PropertyValue> </SetProperty> </DoStyleAction> <DoStyleAction> <SetProperty> <PropertyPath> <PropertyName>Timeout</PropertyName> </PropertyPath> <PropertyValue>10</PropertyValue> </SetProperty> </DoStyleAction> </StyleSheet> </ElementFilter> </StyleSheet> |
Both master and user themes can be edited in Lycia Theme Designer (recommended) and in the built-it text editor (if you have a considerable experience of creating and editing XML code).
If you want to edit your themes as the XML code, we recommend you first to study the topics given below:
Usually, master theme files are created together with 4gl programs.
To create a master theme, you have to check the create .qxtheme checkbox after entering the program name:
If you have missed this step, you can create your master theme file at any other point of the program design in the same way you create other .qxtheme file.
After you have created your master theme file, it is added to your 4gl program and you can open and edit it either in Lycia Theme Designer (by default, recommended) or in the text editor:
By default, your master theme file is empty:
Master theme files are edited in the same way as any other .qxtheme files (you can find some simple examples here):
Master theme files must be located in the same folder as the program executable file (this folder is specified in listener.xml):
The appearance properties set in the master theme for forms and form elements are applied both at design and at runtime:
Application themes are more flexible than master themes in terms of their creation, storage, and usage:
Application themes can be created in two ways:
populate an empty .qxtheme file in Lycia Theme Designer (for more details, refer here and here):
concatenate theme snippets stored on the client side into a application theme:
All the file names you use in your 4gl development must be platform-independent.
If you use platform-dependent names (e.g., combine upper and lower case, use colons, finish names with a full stop, etc.), please remember that they might cause different problems when you move your project to another platform.
Application themes (and their snippets) can be stored in any necessary location:
Contrary to master themes, application themes must be loaded from your 4gl program - from the 4gl code or another theme:
with the apply_theme() function:
CALL apply_theme("my_user_theme")
with the ui.Interface.loadStyles() method:
CALLui.Interface.loadStyles("my_user_theme")
by setting the Include property of the master theme or other application theme:
The appearance properties set in application themes for forms and form elements are applied only at runtime: