Packagecom.sibirjak.jakute
Classpublic class JCSS

Jakute Styling Engine (JCSS).

The single instance of this class provides global settings and operations that affect all components:

  1. Initialize JCSS.
  2. Register a component instance in the JCSS system.
  3. Register a type to be recognized by JCSS.
  4. Register a style value formatter.
  5. Set global styles.
  6. Start and commit a bulk update.



Public Properties
 PropertyDefined by
  stageEventPriority : int
Stage event (add, remove) listening priority.
JCSS
Public Methods
 MethodDefined by
  
JCSS()
JCSS.
JCSS
  
clearStyle(selector:String, styleName:String = null):void
JCSS
  
Executes a bulk update that was started via startBulkUpdate().
JCSS
  
registerComponent(component:DisplayObject, adapter:JCSS_Adapter):void
Registers a component instance in JCSS.
JCSS
  
registerStyleValueFormatter(formatterKey:String, formatter:JCSS_IValueFormatter):void
Registers a style value formatter function.
JCSS
  
registerType(Type:Class, Adapter:Class, matchExactType:Boolean = false):void
Registers an type to be automatically detected by JCSS.
JCSS
  
setStyle(selector:String, styleName:String, styleValue:uint, priority:* = 1):void
Sets a global style.
JCSS
  
setStyleSheet(styleSheet:String):void
Sets a global style sheet.
JCSS
  
Starts a bulk update procedure.
JCSS
  
startTypeMonitoring(stage:Stage):void
Starts the automatic type registration.
JCSS
  
Returns a formatted tree of all currently set style rules.
JCSS
  
unregisterComponent(component:DisplayObject):void
Removes a component instance from JCSS.
JCSS
Property detail
applicationStyleManagerproperty
applicationStyleManager:JCSS_ApplicationStyleManager  [read-only]Implementation
    jcss_internal function get applicationStyleManager():JCSS_ApplicationStyleManager
stageEventPriorityproperty 
stageEventPriority:int  [read-write]

Stage event (add, remove) listening priority.

Default is 11.

Implementation
    public function get stageEventPriority():int
    public function set stageEventPriority(value:int):void
Constructor detail
JCSS()constructor
public function JCSS()

JCSS.

Do not call the private constructor.

Method detail
clearStyle()method
public function clearStyle(selector:String, styleName:String = null):voidParameters
selector:String
 
styleName:String (default = null)
commitBulkUpdate()method 
public function commitBulkUpdate():void

Executes a bulk update that was started via startBulkUpdate().

Affected components are notified only once regardless of the specific changes between startBulkUpdate() and this command.

Ancestor components are always notified before their children. A further order is not specified. It can be possible that children of different branches are notified alternating, e.g. C-1, C-2, C-2.1, C-2.2, C-1.3, C-2.4, C-1.1

getComponentStyleManager()method 
jcss_internal function getComponentStyleManager(component:DisplayObject):JCSS_ComponentStyleManagerParameters
component:DisplayObject

Returns
JCSS_ComponentStyleManager
getStyleValueFormatter()method 
jcss_internal function getStyleValueFormatter(key:String):JCSS_IValueFormatterParameters
key:String

Returns
JCSS_IValueFormatter
registerComponent()method 
public function registerComponent(component:DisplayObject, adapter:JCSS_Adapter):void

Registers a component instance in JCSS.

After the registration the component is enabled to receive styles and style change notifications.

Registering a component twice throws an error.

Registering the same adapter with different components throws an error.

Registering a component that is already in the display list throws an error.

Parameters
component:DisplayObject — The display object to be styled.
 
adapter:JCSS_Adapter — The JCSS component adapter.
registerStyleValueFormatter()method 
public function registerStyleValueFormatter(formatterKey:String, formatter:JCSS_IValueFormatter):void

Registers a style value formatter function.

The given key can be afterwards used to define component style formats. There is a default list of formatters in JCSS_StyleFormats.

   public function customFormatter(value : *) : CustomType {
    return doSomeConversion(value);
   }
   
Parameters
formatterKey:String — The key of the custom formatter.
 
formatter:JCSS_IValueFormatter — The custom formatter function.

See also

JCSS_StyleFormat
registerType()method 
public function registerType(Type:Class, Adapter:Class, matchExactType:Boolean = false):void

Registers an type to be automatically detected by JCSS.

JCSS sets a listener to the stage.ADDED_TO_STAGE event. Any added display object that matches a formerly set type registration, is automatically initialized.

Using the matchExactType flag you can determine whether a component should exactly be of the specified type (tests getQualifiedClassName(component) == getQualifiedClassName(Type)) or is allowed to be a sub class or an implementor (tests component is Type).

Parameters
Type:Class — The type to be watched.
 
Adapter:Class — The adapter class to be used with the component that matchs the type.
 
matchExactType:Boolean (default = false) — Flag to control the component to Type comparision.
setStyle()method 
public function setStyle(selector:String, styleName:String, styleValue:uint, priority:* = 1):void

Sets a global style.

It is possible to repeatedly invoke this method with equal style rules. They are then merged together for performance reasons, no worries, too.

Parameters
selector:String — A selector that matchs a particular component.
 
styleName:String — The name of the style to set.
 
styleValue:uint — The value of the style to set.
 
priority:* (default = 1) — The style priority (null, "!important" or "default").
setStyleSheet()method 
public function setStyleSheet(styleSheet:String):void

Sets a global style sheet.

The style sheet usually is loaded from an external source but still may be created at runtime in the application.

   var styleSheet : String = <styles><![CDATA[
    Box {
     backgroundColor: 0xFF0000;
    }
   ]]></styles>.toString()
   

It is possible to repeatedly invoke this method with different style sheets. Equal style rules in different or the same sheet are merged together for performance reasons, no worries.

Parameters
styleSheet:String — The global stylesheet.
startBulkUpdate()method 
public function startBulkUpdate():void

Starts a bulk update procedure.

If invoked, affected components are buffered and notified only once after a later call of commitBulkUpdate(). If there are different styles or state to set, that might affect a particular multiple times, it is recommended to wrap the update in the bulk transaction.

startTypeMonitoring()method 
public function startTypeMonitoring(stage:Stage):void

Starts the automatic type registration.

You need to call this method before registering a type to be detected by JCSS. The JCSS type monitoring requires this stage instance to set a listener to the stage.ADDED_TO_STAGE event.

Parameters
stage:Stage — The state reference.
styleRuleTreeAsString()method 
public function styleRuleTreeAsString():String

Returns a formatted tree of all currently set style rules.

The following example shows a style sheet and its tree representation.

   var styleSheet : String = <styles><![CDATA[
   
       ToolTip {
           borderSize: 0;
       }
   
       Blue {
           backgroundColor: #0000CC;
           borderColor: #000066;
           color: #FFFFFF;
       }
   
       Blue ToolTip {
           backgroundColor: #6666FF;
           color: #FFFFFF;
       }
   
       Red {
           backgroundColor: #CC0000;
           borderColor: #660000;
           color: #FFFFFF;
       }
   
       Red ToolTip {
           backgroundColor: #FF6666;
           color: #FFFFFF;
       }
   
       Yellow {
           backgroundColor: #CCCC00;
           borderColor: #666600;
       }
   
       Yellow ToolTip {
           backgroundColor: #FFFF66;
       }
   
   ]]></styles>.toString();
   
   [This 2]
   |_____[Yellow 22]
       | >This Yellow specifity:2 {
       |    backgroundColor: #CCCC00 (12);
       |    borderColor: #666600 (13);
       | }
       |_____[ToolTip 26]
           | >This Yellow ToolTip specifity:3 {
           |    backgroundColor: #FFFF66 (14);
           | }
   |_____[Blue 8]
       | >This Blue specifity:2 {
       |    backgroundColor: #0000CC (2);
       |    color: #FFFFFF (4);
       |    borderColor: #000066 (3);
       | }
       |_____[ToolTip 12]
           | >This Blue ToolTip specifity:3 {
           |    backgroundColor: #6666FF (5);
           |    color: #FFFFFF (6);
           | }
   |_____[ToolTip 5]
       | >This ToolTip specifity:2 {
       |    borderSize: 0 (1);
       | }
   |_____[Red 15]
       | >This Red specifity:2 {
       |    backgroundColor: #CC0000 (7);
       |    color: #FFFFFF (9);
       |    borderColor: #660000 (8);
       | }
       |_____[ToolTip 19]
           | >This Red ToolTip specifity:3 {
           |    backgroundColor: #FF6666 (10);
           |    color: #FFFFFF (11);
           | }
   

Returns
String
unregisterComponent()method 
public function unregisterComponent(component:DisplayObject):void

Removes a component instance from JCSS.

This method cleans up all references to the given component and makes it eligible for garbage collection.

Parameters
component:DisplayObject — The display object to remove from JCSS.