![]() UJML Language Reference |
A partition file contains a UJML module designed to be linked to at run time or included in another file.
Partition files have a file extension of '.ujml' if they are linked or '.ujms' if they are included. For example, 'bar.ujml' is a linked partition and 'menu.ujms' contains state machines to include. A partition file contains a ujml root element, which contains a partition element. See Layout of UJML Files, ujml, partition.
Linked partition files are compiled to byte code. See Byte Code Files. A compiled partition is loaded by a UJML application or partition calling the _link() function. See Linking Files, _link() function. The partition then runs until the _unlink() function is called with the partition name or the _unloadSelf() function is called by the partition. See _unlink() function, _unloadSelf() function.
State machines from a partition file may be copied into a parent file using the include element. See Including Files, include. Partition files may include other files, meaning that the contents of those files are copied into the partition file when it is compiled and become part of the resulting byte code for that file. See Including Files.
The following example is a partition file that sets the values of some variables in the parent application file when it is linked to, and then it sets a shared state variable to indicate it has finished. It is part of the velocale.ujml sample.
<ujml>
<partition>
<state-variables>
<state-var name="sLocaleLoaded" type="boolean" access="import"/>
</state-variables>
<variables>
<var name="mSingleLineText" type="string" access="import"/>
<var name="mDefaultLabelText" type="string" access="import"/>
<var name="mMultiLineText" type="string" access="import"/>
<var name="mDefaultMultiLabelText" type="string" access="import"/>
<var name="mBackLabel" type="string" access="import"/>
<var name="mSettingsLabel" type="string" access="import"/>
<var name="mFontSize" type="int" access="import"/>
<var name="mFontStyleBold" type="boolean" access="import"/>
<var name="mFontStyleItalic" type="boolean" access="import"/>
<var name="mFontStyleUnderlined" type="boolean" access="import"/>
<var name="mFontStyleOutlined" type="boolean" access="import"/>
<var name="mFontFace" type="int" access="import"/>
<var name="mForeColor" type="int" access="import"/>
<var name="mBackColor" type="int" access="import"/>
<var name="mOpacity" type="int" access="import"/>
</variables>
<functions>
&ADD_MENU_SHARED_FUNCTION;
</functions>
<script>
// Load default text.
mDefaultLabelText = "Hello World!";
mDefaultMultiLabelText =
"We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness.";
// Load UI labels.
mBackLabel = "Back";
mSettingsLabel = "Settings";
// Load menu items.
addMenuItem("Device");
addMenuItem("Label");
addMenuItem("Multi-Label");
addMenuItem("Box");
addMenuItem("Round-Box");
addMenuItem("X-Oval");
addMenuItem("Line");
addMenuItem("Polyline");
addMenuItem("Polygon 1");
addMenuItem("Polygon 2");
addMenuItem("Image");
addMenuItem("Combined");
// Done.
sLocaleLoaded = true;
</script>
</partition>
</ujml>
The following example shows how to link to the partition above. It is part of the visualelements.ujml sample.
_link("Locale", _strcat(
_substring( _getStringProperty(&_PROPERTY_STRING_LOCALE;), 0, 2),
"/velocale.ujbc"));
The following example includes two state machines from different partition files. It is part of the visualelements.ujml sample.
<state-machines>
<include file="/../components/background.ujms" state-machine="Background" />
<include file="/../components/scrollmenu.ujms" state-machine="ScrollingMenu" />
</state-machines>|
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|