![]() UJML Language Reference |
Determining the device context in which your UJML application is running.
The device context is the capabilities and restrictions of a device. See Device Independence. To write device-independent UJML applications, you need to determine this context at run time and adjust your application's behavior as needed. You can do this with UJML using its rich set of functions and entity argument values which allow you to discover a great deal about the device at run time. See Device Information Functions, Device Information Entities. You should become thoroughly familiar with the device information functions and their possible parameter values.
There are many different types of device context. Most are concerned with the hardware characteristics of the device. See Screen Resolution, Color Support, Image Support, Audio Support. Others help you to determine software support for UJML components and other extended capabilities. See Components, Property Bag Functions.
Yet another type of device context is the current device locale, required for localized applications. See Locale Independence.
You can easily optimize your application by determining the device context values your application needs when it starts and then caching those values in variables. This avoids the overhead of calling the device information functions every time you display a visual element or play a sound. You should also resize and locate visual elements when your program starts and then cache the position and size values instead of recalculating them each time the visual element is displayed.
The following example shows how to load a text variable with several different types of device context values. It is part of the visualelements.ujml sample, which uses device context throughout to create a similar experience on many different devices.
text = _strcat("Platform: ", _getStringProperty(&_PROPERTY_STRING_PLATFORM;));
text = _strcat(text, " -- X-OVAL");
if (_isSupported(&_X_OVAL;))
{
text = _strcat(text, " is supported");
}
else
{
text = _strcat(text, " is not supported");
}
text = _strcat(text, " -- POLYGON FILL");
if (_isSupported(&_X_POLYGON_BG;))
{
text = _strcat(text, " is supported");
}
else
{
text = _strcat(text, " is not supported");
}
text = _strcat(text, " -- ROUND-BOX");
if (_isSupported(&_X_ROUND_BOX_ARC;))
{
text = _strcat(text, " is supported");
}
else
{
text = _strcat(text, " is not supported");
}
text = _strcat(text, " -- IMAGE SCALING");
if (_isSupported(&_X_IMAGE_SCALING;))
{
text = _strcat(text, " is supported");
}
else
{
text = _strcat(text, " is not supported");
}
text = _strcat(text, " -- ALPHA OPACITY");
if (_isSupported(&_COLOR_ALPHA;))
{
text = _strcat(text, " is supported");
}
else
{
text = _strcat(text, " is not supported");
}
text = _strcat(text, " -- PROPERTY-BAG");
if (_isSupported(&_X_PROPERTY_BAG;))
{
text = _strcat(text, " is supported");
}
else
{
text = _strcat(text, " is not supported");
}|
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|