qnx.fuse.ui.theme.ThemeGlobals

ThemeGlobals

Properties | Methods | Constants | Examples


Packageqnx.fuse.ui.theme
Classpublic class ThemeGlobals
InheritanceThemeGlobals Inheritance Object

ThemeGlobals is an class to retrieve assets and style information based on the current theme. You can use it to switch between the built in white and black themes for the AIR components, or you can specify your own themes and newly instantiated components will automatically use them.

Class information:
BlackBerry 10 Version:   10.0.0
Found in:  qnxui.swc

View the examples



Public Properties

 PropertyDefined By
  currentTheme : String
[static] Gets or sets the current theme for components.
ThemeGlobals
  defaultTheme : String
[static] [read-only] Gets the default theme of the device.
ThemeGlobals
  keyboardShortcutsEnabled : Boolean
[static] [read-only] Boolean that returns true of keyboard shortcuts are enabled on the current device.
ThemeGlobals
  useDeviceLocale : Boolean = false
[static] When true, UIComponents will default their locale property to be the same as the locale of the device.
ThemeGlobals
  useOLED : Boolean
[static] When true, ThemeGlobals will return assets and styles optimized for OLED devices when the application is running on a device with an OLED screen.
ThemeGlobals

Public Methods

 MethodDefined By
  
[static] Returns the minimum interactive area in pixels for interactive elements.
ThemeGlobals
  
getSkinAsset(assetIdentifier:String, themeName:String = null):DisplayObject
[static] Returns an instance of the asset as defined by the specified theme.
ThemeGlobals
  
getTextFormat(selector:String, state:String = up, themeName:String = null):TextFormat
[static] Given a CSS selector getTextFormat returns a TextFormat object styled based on matching CSS rules in the current theme's CSS.
ThemeGlobals
  
injectCSS(css:String, themeName:String = null):void
[static] Overlays the supplied CSS string on to the supplied theme's CSS definition.
ThemeGlobals
  
injectStyleArray(arr:Array, themeName:String = null):void
[static] Overlays the supplied array of style definitions on to the supplied theme's CSS definition.
ThemeGlobals
  
lookupStyle(selector:String, themeName:String = null):IStyleable
[static] Looks up a collection of style information associated with the given selector.
ThemeGlobals
  
lookupValue(selector:String, property:String, themeName:String = null):*
[static] Looks up a single value from a collection of styles returned from a selector.
ThemeGlobals
  
registerTheme(themeName:String, theme:ThemeBase):void
[static] Allows you to register your own SkinFactory to supply different skin classes based on the currently set theme.
ThemeGlobals

Public Constants

 ConstantDefined By
  BLACK : String = theme_black
[static] A static constant that represents the black theme.
ThemeGlobals
  WHITE : String = theme_white
[static] A static constant that represents the white theme.
ThemeGlobals

Property Detail

currentTheme


currentTheme:String

Gets or sets the current theme for components. All newly instantiated skins will use the theme supplied here. If you are using a custom theme, you must first register an object that extends ThemeBase with ThemeGlobals.registerTheme before setting the current theme. The prepackaged themes, ThemeGlobals.WHITE and ThemeGlobals.BLACK, are already registered.

The default value is ThemeGlobals.WHITE.


Implementation

public static function get currentTheme():String
public static function set currentTheme(value:String):void

See also

registerTheme()

defaultTheme


defaultTheme:String  [read-only]

Gets the default theme of the device.

Some device may have a different default theme then others. UI components are never automatically set based on this value. However, there are some platform level components, not instaniated by applications, which use this property in order to style themselves.


Implementation

public static function get defaultTheme():String

keyboardShortcutsEnabled


keyboardShortcutsEnabled:Boolean  [read-only]

Boolean that returns true of keyboard shortcuts are enabled on the current device. Devices with physical keyboards will have keyboard shortcuts enabled, while those with virtual keyboards will have them disabled.


Implementation

public static function get keyboardShortcutsEnabled():Boolean

useDeviceLocale


public static var useDeviceLocale:Boolean = false

When true, UIComponents will default their locale property to be the same as the locale of the device.

Enabling this will cause certain components to layout differently based on locale. In the future this may cause layouts to be mirrored when the device locale is set to a right to left locale, such as Arabic or Hebrew.

The default value is false.

See also

qnx.fuse.ui.core.UIComponent.locale

useOLED


useOLED:Boolean

When true, ThemeGlobals will return assets and styles optimized for OLED devices when the application is running on a device with an OLED screen. If the application is running on a non-OLED device or the desktop, this property has no effect and will always return false.

Set this value in the constructor of your application before any components have been created. If you create a component before setting this value, it will be ignored and non-OLED assets will be returned.


Implementation

public static function get useOLED():Boolean
public static function set useOLED(value:Boolean):void

Method Detail

getCSS()


qnx_internal static function getCSS(themeName:String = null):CSS

Returns the cascading style sheet information for the defined theme.

Parameters

themeName:String (default = null) — String The theme whose CSS you wish to retrieve. If no themeName is supplied the current theme's CSS is returned.

Returns

CSS — CSS The cascading style sheet for the theme.

getMinimumInteractiveArea()


public static function getMinimumInteractiveArea():int

Returns the minimum interactive area in pixels for interactive elements. Any element the user can touch should be at least this large in order to be easily touchable.

Returns

int — The minimum interactive area in pixels for interactive elements.

getSkinAsset()


public static function getSkinAsset(assetIdentifier:String, themeName:String = null):DisplayObject

Returns an instance of the asset as defined by the specified theme.

This method calls the getSkinAsset() method of the specified theme. For further implementation details see the documentation for the ThemeBase#getSkinAsset() method.

Parameters

assetIdentifier:String — The key of the asset.
themeName:String (default = null) — The name of the theme to get. If null, the value of the currentTheme is used.

Returns

DisplayObject — An instantiated instance of the asset in the current theme.

Throws

Error — If the identifier key cannot be found in the assetMapping dictionary.

See also

qnx.fuse.ui.utils.DisplayObjectUtils.getDisplayAsset()
ThemeBase.getSkinAsset()

getTextFormat()


public static function getTextFormat(selector:String, state:String = up, themeName:String = null):TextFormat

Given a CSS selector getTextFormat returns a TextFormat object styled based on matching CSS rules in the current theme's CSS.

If no rule can be found that matches the selector, a new TextFormat instance is returned with default properties.

Parameters

selector:String — A String CSS selector to query with.
state:String (default = up) — An optional state to use in the selector. States appended to the selectorOrComponent parameter are ignored in favor of the state parameter.
themeName:String (default = null) — The name of the theme that contains the CSS to query. If null, the value of the currentTheme is used.

Returns

TextFormat — TextFormat A styled TextFormat object.

See also

qnx.fuse.ui.text.TextFormat

injectCSS()


public static function injectCSS(css:String, themeName:String = null):void

Overlays the supplied CSS string on to the supplied theme's CSS definition. If no theme is provided then ThemeGlobals.currentTheme is used.

injectCSS allows you to override default CSS values to style the built in components, or your own.

Parameters

css:String — A CSS string to overlay over the current theme's existing CSS definition.
themeName:String (default = null) — String The theme whose CSS you wish to retrieve. If no themeName is supplied the current theme's CSS is returned.

injectStyleArray()


public static function injectStyleArray(arr:Array, themeName:String = null):void

Overlays the supplied array of style definitions on to the supplied theme's CSS definition. Style data should be serialized in to a linear buffer where the first element of the Array is a selector, and the next is an interger (n) that dictates how many key/value pairs follow in the array. After n elements, we know the next element to be a selector, and the pattern repeats. For example, here is an array that contains 2 selectors, which each have two styles defined. var arr:Array = ["Label", 2, "text-color", 0xff00ff, "text-bold", true, "TextArea", 2, "text-color", 0x00ff00, "text-style":"content"]; Unlike inject(), selectors can only be separated by single spaces, and cannot have any leading or trailing white space.

Parameters

arr:Array — Array An array of selectors and styles defined in the above format.
themeName:String (default = null) — String The theme whose CSS you wish to retrieve. If no themeName is supplied the current theme's CSS is returned.

lookupStyle()


public static function lookupStyle(selector:String, themeName:String = null):IStyleable

Looks up a collection of style information associated with the given selector.

Parameters

selector:String — A CSS selector.
themeName:String (default = null) — The theme whose css you wish to look in. If no themeName is supplied, the current theme's CSS is queried.

Returns

IStyleable — An IStylable object that contains all the styles that apply for the selector.

lookupValue()


public static function lookupValue(selector:String, property:String, themeName:String = null):*

Looks up a single value from a collection of styles returned from a selector.

Parameters

selector:String — A CSS selector.
property:String — The property name
themeName:String (default = null)

Returns

* — The value of the css property, contained within the results of the supplied selector. The value may be any primitive type.

registerTheme()


public static function registerTheme(themeName:String, theme:ThemeBase):void

Allows you to register your own SkinFactory to supply different skin classes based on the currently set theme.

Parameters

themeName:String — The name used to identify the theme.
theme:ThemeBase — The ITheme instance to use to supply skins.

Constant Detail

BLACK


public static const BLACK:String = theme_black

A static constant that represents the black theme.

WHITE


public static const WHITE:String = theme_white

A static constant that represents the white theme.

Examples

The following example shows how to add your own custom CSS styles to the currently active theme. After it runs, all new instances of Label will have red text.

var css : String = "Label { text-color:#ff0000; }";
ThemeGlobals.injectCSS( css );
     




comments powered by Disqus