This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new a380955  switch Tree to a TreeItemRenderer based on UIComponent.  
Should fix #646 although some tweaking of the visuals will probably be needed
a380955 is described below

commit a38095599152e375c4151b652ed83578a70012ed
Author: Alex Harui <[email protected]>
AuthorDate: Tue Jan 7 01:18:42 2020 -0800

    switch Tree to a TreeItemRenderer based on UIComponent.  Should fix #646 
although some tweaking of the visuals will probably be needed
---
 .../MXRoyale/src/main/resources/defaults.css       |   9 +-
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |   1 +
 .../royale/mx/controls/listClasses/ListBase.as     |   6 +-
 .../mx/controls/listClasses/ListVerticalLayout.as  | 185 +++++++++
 .../mx/controls/treeClasses/TreeItemRenderer.as    | 437 +++++++++++++++++----
 5 files changed, 558 insertions(+), 80 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css 
b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index b35b81a..3f2d325 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -421,10 +421,17 @@ TextInput
 
 Tree
 {
+       IBeadLayout: 
ClassReference("mx.controls.listClasses.ListVerticalLayout");
        IBeadModel: 
ClassReference("mx.controls.beads.models.SingleSelectionICollectionViewModel");
        IBeadController: 
ClassReference("org.apache.royale.html.beads.controllers.TreeSingleSelectionMouseController");
        IDataProviderItemRendererMapper: 
ClassReference("mx.controls.treeClasses.DataItemRendererFactoryForICollectionViewHierarchicalData");
-       IItemRenderer: 
ClassReference("org.apache.royale.html.supportClasses.TreeXMLItemRenderer");
+       IItemRenderer: 
ClassReference("mx.controls.treeClasses.TreeItemRenderer");
+}
+
+TreeItemRenderer
+{
+       IBeadController: 
ClassReference("org.apache.royale.html.beads.controllers.ItemRendererMouseController");
+       cursor: pointer;
 }
 
 ToggleButtonBar
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as 
b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index 7c38a53..e519b85 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -79,6 +79,7 @@ internal class MXRoyaleClasses
        import mx.rpc.remoting.CompressedRemoteObject; 
mx.rpc.remoting.CompressedRemoteObject;
        import mx.controls.treeClasses.ITreeDataDescriptor; ITreeDataDescriptor;
        import mx.controls.treeClasses.TreeListData; TreeListData;
+    import mx.controls.listClasses.ListVerticalLayout; ListVerticalLayout;
        import 
mx.controls.listClasses.DataItemRendererFactoryForICollectionViewData; 
DataItemRendererFactoryForICollectionViewData;
     import 
mx.controls.listClasses.VirtualDataItemRendererFactoryForICollectionViewData; 
VirtualDataItemRendererFactoryForICollectionViewData;
     import mx.controls.listClasses.VirtualDataItemRendererFactoryForIListData; 
VirtualDataItemRendererFactoryForIListData;
diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
index 9d37def..19c3c68 100644
--- 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
@@ -43,6 +43,7 @@ import 
org.apache.royale.core.IContainerBaseStrandChildrenHost;
 import org.apache.royale.core.IDataProviderItemRendererMapper;
 import org.apache.royale.core.IFactory;
 import org.apache.royale.core.IItemRendererClassFactory;
+import org.apache.royale.core.IItemRendererProvider;
 import org.apache.royale.core.ILayoutChild;
 import org.apache.royale.core.ILayoutHost;
 import org.apache.royale.core.ILayoutParent;
@@ -50,6 +51,7 @@ import org.apache.royale.core.ILayoutView;
 import org.apache.royale.core.IListPresentationModel;
 import org.apache.royale.core.IParent;
 import org.apache.royale.core.ISelectionModel;
+import org.apache.royale.core.IStrandWithPresentationModel;
 import org.apache.royale.core.ValuesManager;
 import org.apache.royale.events.Event;
 import org.apache.royale.events.ValueEvent;
@@ -90,7 +92,9 @@ use namespace mx_internal;
      *  @productversion Royale 0.0
      *  @royalesuppresspublicvarwarning
        */
-       public class ListBase extends ScrollControlBase implements 
IContainerBaseStrandChildrenHost, IContainer, ILayoutParent, ILayoutView
+       public class ListBase extends ScrollControlBase 
+        implements IContainerBaseStrandChildrenHost, IContainer, 
ILayoutParent, 
+                    ILayoutView, IItemRendererProvider, 
IStrandWithPresentationModel
        {  //extends UIComponent
        
        
diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListVerticalLayout.as
 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListVerticalLayout.as
new file mode 100644
index 0000000..f35a330
--- /dev/null
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListVerticalLayout.as
@@ -0,0 +1,185 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package mx.controls.listClasses
+{
+       import org.apache.royale.core.LayoutBase;
+       
+       import org.apache.royale.core.IBeadLayout;
+       import org.apache.royale.core.IBeadModel;
+    import org.apache.royale.core.IBorderPaddingMarginValuesImpl;
+       import org.apache.royale.core.ILayoutChild;
+       import org.apache.royale.core.ILayoutHost;
+       import org.apache.royale.core.ILayoutView;
+       import org.apache.royale.core.ILayoutParent;
+    import org.apache.royale.core.IListPresentationModel;
+       import org.apache.royale.core.IParentIUIBase;
+       import org.apache.royale.core.IStrand;
+    import org.apache.royale.core.IStrandWithPresentationModel;
+       import org.apache.royale.core.IUIBase;
+    import org.apache.royale.core.layout.EdgeData;
+       import org.apache.royale.core.ValuesManager;
+       COMPILE::JS
+       {
+               import org.apache.royale.core.WrappedHTMLElement;
+       }
+       import org.apache.royale.events.Event;
+       import org.apache.royale.events.IEventDispatcher;
+       import org.apache.royale.geom.Rectangle;
+       import org.apache.royale.utils.CSSUtils;
+
+       /**
+        *  The ListVerticalLayout class is a simple layout
+        *  bead.  It takes the set of children and lays them out
+        *  vertically in one column, using absolute positioning
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.0
+        */
+       public class ListVerticalLayout extends LayoutBase implements 
IBeadLayout
+       {
+               /**
+                *  Constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.0
+                */
+               public function ListVerticalLayout()
+               {
+                       super();
+               }
+
+               /**
+                *  Layout children vertically
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.0
+                *  @royaleignorecoercion org.apache.royale.core.ILayoutHost
+                *  @royaleignorecoercion org.apache.royale.core.IParentIUIBase
+                *  @royaleignorecoercion 
org.apache.royale.core.WrappedHTMLElement
+                */
+               override public function layout():Boolean
+               {
+                       COMPILE::SWF
+                       {
+                               var contentView:ILayoutView = layoutView;
+
+                               var n:Number = contentView.numElements;
+                               if (n == 0) return false;
+
+                               var maxWidth:Number = 0;
+                               var maxHeight:Number = 0;
+                               var hostWidthSizedToContent:Boolean = 
host.isWidthSizedToContent();
+                               var hostHeightSizedToContent:Boolean = 
host.isHeightSizedToContent();
+                               var hostWidth:Number = host.width;
+                               var hostHeight:Number = host.height;
+
+                               var ilc:ILayoutChild;
+                               var data:Object;
+                               var canAdjust:Boolean = false;
+
+                               var paddingMetrics:EdgeData = 
(ValuesManager.valuesImpl as 
IBorderPaddingMarginValuesImpl).getPaddingMetrics(host);
+                               var borderMetrics:EdgeData = 
(ValuesManager.valuesImpl as 
IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
+                               
+                               // adjust the host's usable size by the 
metrics. If hostSizedToContent, then the
+                               // resulting adjusted value may be less than 
zero.
+                               hostWidth -= paddingMetrics.left + 
paddingMetrics.right + borderMetrics.left + borderMetrics.right;
+                               hostHeight -= paddingMetrics.top + 
paddingMetrics.bottom + borderMetrics.top + borderMetrics.bottom;
+
+                               var xpos:Number = borderMetrics.left + 
paddingMetrics.left;
+                               var ypos:Number = borderMetrics.top + 
paddingMetrics.top;
+
+                               // First pass determines the data about the 
child.
+                               for(var i:int=0; i < n; i++)
+                               {
+                                       var child:IUIBase = 
contentView.getElementAt(i) as IUIBase;
+                                       if (child == null || !child.visible) 
continue;
+                                       var positions:Object = 
childPositions(child);
+                                       var margins:Object = 
childMargins(child, hostWidth, hostHeight);
+
+                                       ilc = child as ILayoutChild;
+
+                                       ypos += margins.top;
+
+                                       var childXpos:Number = xpos + 
margins.left; // default x position
+
+                                       var childWidth:Number = child.width;
+                                       if (ilc != null && 
!isNaN(ilc.percentWidth)) {
+                                               childWidth = hostWidth * 
ilc.percentWidth/100.0;
+                                               ilc.setWidth(childWidth);
+                                       }
+                                       else if (ilc.isWidthSizedToContent() && 
!margins.auto)
+                                       {
+                                               childWidth = hostWidth;
+                                               ilc.setWidth(childWidth);
+                                       }
+                                       if (margins.auto)
+                                               childXpos = (hostWidth - 
childWidth) / 2;
+                                               
+                                       if (ilc) {
+                                               ilc.setX(childXpos);
+                                               ilc.setY(ypos);
+
+                                               if (!isNaN(ilc.percentHeight)) {
+                                                       var newHeight:Number = 
hostHeight * ilc.percentHeight / 100;
+                                                       
ilc.setHeight(newHeight);
+                                               }
+
+                                       } else {
+                                               child.x = childXpos;
+                                               child.y = ypos;
+                                       }
+
+                                       ypos += child.height + margins.bottom;
+                               }
+                               return true;
+                       }
+                       COMPILE::JS
+                       {
+                               var children:Array;
+                               var i:int;
+                               var n:int;
+                var rowHeight:Number = ((host as 
IStrandWithPresentationModel).presentationModel as 
IListPresentationModel).rowHeight;
+                               var contentView:IParentIUIBase = layoutView as 
IParentIUIBase;
+                               contentView.element.style["vertical-align"] = 
"top";
+                               
+                               children = contentView.internalChildren();
+                               n = children.length;
+                var yy:int = 0;
+                               for (i = 0; i < n; i++)
+                               {
+                                       var child:WrappedHTMLElement = 
children[i] as WrappedHTMLElement;
+                                       if (child == null) continue;
+                                       child.style.top = yy + "px";
+                    child.style.width = host.width + "px";
+                                       
child.royale_wrapper.dispatchEvent('sizeChanged');
+                    yy += rowHeight;
+                               }
+
+                               return true;
+                       }
+               }
+
+       }
+}
diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/treeClasses/TreeItemRenderer.as
 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/treeClasses/TreeItemRenderer.as
index 4e8f5cd..687c84c 100644
--- 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/treeClasses/TreeItemRenderer.as
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/treeClasses/TreeItemRenderer.as
@@ -46,9 +46,10 @@ import mx.managers.ISystemManager;
 import mx.utils.PopUpUtil;
 
  */
-import mx.core.IFlexDisplayObject;
+import mx.controls.Label;
 import mx.controls.listClasses.BaseListData;
-import org.apache.royale.html.supportClasses.TreeItemRenderer;
+import mx.core.IFlexDisplayObject;
+
 import mx.core.mx_internal;
 import mx.core.UIComponent;
 import mx.core.IDataRenderer;
@@ -56,6 +57,12 @@ import mx.controls.listClasses.IDropInListItemRenderer;
 
 use namespace mx_internal;
 
+import org.apache.royale.core.ISelectableItemRenderer;
+import org.apache.royale.core.ValuesManager;
+import org.apache.royale.events.Event;
+import org.apache.royale.html.util.getLabelFromData;
+import org.apache.royale.html.supportClasses.TreeListData;
+
 /**
  *  The TreeItemRenderer class defines the default item renderer for a Tree 
control. 
  *  By default, the item renderer draws the text associated with each item in 
the tree, 
@@ -72,7 +79,8 @@ use namespace mx_internal;
  *  @playerversion AIR 1.1
  *  @productversion Flex 3
  */
-public class TreeItemRenderer extends UIComponent implements 
IDataRenderer,IDropInListItemRenderer
+public class TreeItemRenderer extends UIComponent 
+    implements IDataRenderer, IDropInListItemRenderer, ISelectableItemRenderer
 {
    
 
@@ -93,8 +101,20 @@ public class TreeItemRenderer extends UIComponent 
implements IDataRenderer,IDrop
     public function TreeItemRenderer()
     {
         super();
+        typeNames = "TreeItemRenderer";
     }
 
+    override protected function createChildren():void
+    {
+        super.createChildren();
+        if (numChildren == 0)
+        {
+            label = new Label();
+            addChild(label);
+            disclosureIcon = new Label();
+            addChild(disclosureIcon);
+        }
+    }
    
     
//--------------------------------------------------------------------------
     //
@@ -102,78 +122,6 @@ public class TreeItemRenderer extends UIComponent 
implements IDataRenderer,IDrop
     //
     
//--------------------------------------------------------------------------
 
-       private var _data:Object
- 
-       public function get data():Object   
-       {     
-       return _data;    
-       }       
-       /**  
-       *  @private    
-       */
-
-       public function set data(value:Object):void   
-       {       
-       _data = value;     
-       //dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));  
-       }
-
-
-       private var _listData:BaseListData 
-       //_listData:AdvancedDataGridListData;
-
-       [Bindable("dataChange")]
-
-
-       /**
-       *  
-       The implementation of the <code>listData</code> property as 
-       *  
-       defined by the IDropInListItemRenderer interface.
-       *  The text of the renderer is set to the <code>label</code>
-
-       *  property of this property.
-       *
-       *  @see mx.controls.listClasses.IDropInListItemRenderer
-       *  
-       *  @langversion 3.0
-
-       *  @playerversion Flash 9
-       *  @playerversion AIR 1.1
-       *  @productversion Royale 0.9.3
-       */
-
-       public function get listData():BaseListData
-
-       {
-       return _listData;
-       }
-
-       /**
-       *  @private
-       */
-
-
-       public function set listData(value:BaseListData):void
-       {
-       _listData = value;
-       /*_listData = AdvancedDataGridListData(value);
-
-       if (nestLevel && !invalidatePropertiesFlag)
-
-       {
-
-       UIComponentGlobals.layoutManager.invalidateProperties(this);
-
-       invalidatePropertiesFlag = true;
-
-       UIComponentGlobals.layoutManager.invalidateSize(this);
-
-       invalidateSizeFlag = true;
-
-       } 
-       */
-       }
     
     //----------------------------------
     //  icon
@@ -201,7 +149,7 @@ public class TreeItemRenderer extends UIComponent 
implements IDataRenderer,IDrop
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    protected var label:Object;
+    protected var label:Label;
     
  
        //----------------------------------
@@ -217,7 +165,7 @@ public class TreeItemRenderer extends UIComponent 
implements IDataRenderer,IDrop
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    protected var disclosureIcon:IFlexDisplayObject;
+    protected var disclosureIcon:Label;
 
     
//--------------------------------------------------------------------------
     //
@@ -241,9 +189,342 @@ public class TreeItemRenderer extends UIComponent 
implements IDataRenderer,IDrop
         return label;
     }
     
-       
+    
//--------------------------------------------------------------------------
+    //
+    //  Copied from UIItemRendererBase.  Good case for finding a better way to 
+    //  share code like this
+    //
+    
//--------------------------------------------------------------------------
+    
+
+    /**
+     * @private
+     */
+    override public function addedToParent():void
+    {
+        super.addedToParent();
+        
+        // very common for item renderers to be resized by their containers,
+        addEventListener("widthChanged", sizeChangeHandler);
+        addEventListener("heightChanged", sizeChangeHandler);
+        addEventListener("sizeChanged", sizeChangeHandler);
+        
+        // each MXML file can also have styles in fx:Style block
+        ValuesManager.valuesImpl.init(this);
+        
+        dispatchEvent(new Event("initBindings"));
+        dispatchEvent(new Event("initComplete"));
+        
+    }
+    
+    private var _itemRendererParent:Object;
+    
+    /**
+     * The parent container for the itemRenderer instance.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get itemRendererParent():Object
+    {
+        return _itemRendererParent;
+    }
+    public function set itemRendererParent(value:Object):void
+    {
+        _itemRendererParent = value;
+    }
+        
+    private var _backgroundColor:uint = 0xFFFFFF;
+    override public function get backgroundColor():uint
+    {
+        return _backgroundColor;
+    }
+    override public function set backgroundColor(value:uint):void
+    {
+        _backgroundColor = value;
+    }
+    
+    private var _highlightColor:uint = 0xCEDBEF;
+    public function get highlightColor():uint
+    {
+        return _highlightColor;
+    }
+    public function set highlightColor(value:uint):void
+    {
+        _highlightColor = value;
+    }
+    
+    private var _selectedColor:uint = 0xA8C6EE;
+    public function get selectedColor():uint
+    {
+        return _selectedColor;
+    }
+    public function set selectedColor(value:uint):void
+    {
+        _selectedColor = value;
+    }
+    
+    private var _downColor:uint = 0x808080;
+    public function get downColor():uint
+    {
+        return _downColor;
+    }
+    public function set downColor(value:uint):void
+    {
+        _downColor = value;
+    }
+    
+    protected var useColor:uint = backgroundColor;
+    
+    private var _data:Object;
+    
+    [Bindable("__NoChangeEvent__")]
+    /**
+     *  The data being represented by this itemRenderer. This can be something 
simple like a String or
+     *  a Number or something very complex.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get data():Object
+    {
+        return _data;
+    }
+    public function set data(value:Object):void
+    {
+        _data = value;
+        text = dataToString(value);
+        
+        var treeListData:mx.controls.treeClasses.TreeListData = listData as 
mx.controls.treeClasses.TreeListData;
+        var indentSpace:String = "    ";
+        var extraSpace:String = " ";
+        
+        COMPILE::JS {
+            indentSpace = "\u00a0\u00a0\u00a0\u00a0";
+            extraSpace = "\u00a0";
+        }
+            
+            var indent:String = "";
+        for (var i:int=0; i < treeListData.depth - 1; i++) {
+            indent += indentSpace;
+        }
+        
+        indent += (treeListData.hasChildren ? (treeListData.isOpen ? "▼" : 
"▶") : "") + extraSpace;
+        
+        disclosureIcon.text = indent;
+
+    }
+    
+    protected function dataToString(value:Object):String
+    {
+        return getLabelFromData(this,value);
+    }
+
+    private var _listData:Object;
+    
+    [Bindable("__NoChangeEvent__")]
+    /**
+     *  Additional data about the list structure the itemRenderer may
+     *  find useful.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get listData():Object
+    {
+        return _listData;
+    }
+    public function set listData(value:Object):void
+    {
+        if (value is org.apache.royale.html.supportClasses.TreeListData)
+        {
+            var otld:org.apache.royale.html.supportClasses.TreeListData = 
value as org.apache.royale.html.supportClasses.TreeListData;
+            var tld:mx.controls.treeClasses.TreeListData = new 
mx.controls.treeClasses.TreeListData();
+            tld.depth = otld.depth;
+            tld.hasChildren = otld.hasChildren;
+            tld.isOpen = otld.isOpen;
+            value = tld;
+        }
+        _listData = value;
+    }
+    
+    private var _labelField:String = "label";
+    
+    /**
+     * The name of the field within the data to use as a label. Some 
itemRenderers use this field to
+     * identify the value they should show while other itemRenderers ignore 
this if they are showing
+     * complex information.
+     */
+    public function get labelField():String
+    {
+        return _labelField;
+    }
+    public function set labelField(value:String):void
+    {
+        _labelField = value;
+    }
+    
+    private var _index:int;
+    
+    /**
+     *  The position with the dataProvider being shown by the itemRenderer 
instance.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get index():int
+    {
+        return _index;
+    }
+    public function set index(value:int):void
+    {
+        _index = value;
+    }
+    
+    private var _hovered:Boolean;
+    
+    /**
+     *  Whether or not the itemRenderer is in a hovered state.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get hovered():Boolean
+    {
+        return _hovered;
+    }
+    public function set hovered(value:Boolean):void
+    {
+        _hovered = value;
+        updateRenderer();
+    }
+    
+    private var _selected:Boolean;
+    
+    /**
+     *  Whether or not the itemRenderer is in a selected state.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get selected():Boolean
+    {
+        return _selected;
+    }
+    public function set selected(value:Boolean):void
+    {
+        _selected = value;
+        updateRenderer();
+    }
+    
+    private var _down:Boolean;
+    
+    /**
+     *  Whether or not the itemRenderer is in a down (or pre-selected) state.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get down():Boolean
+    {
+        return _down;
+    }
+    public function set down(value:Boolean):void
+    {
+        _down = value;
+        updateRenderer();
+    }
+    
+    /**
+     * @private
+     */
+    public function updateRenderer():void
+    {
+        if (down)
+            useColor = downColor;
+        else if (hovered)
+            useColor = highlightColor;
+        else if (selected)
+            useColor = selectedColor;
+        else
+            useColor = backgroundColor;
+        COMPILE::JS
+        {
+            element.style.backgroundColor = '#' + useColor.toString(16);
+        }
+    }
+    
+    /**
+     * @private
+     */
+    private function sizeChangeHandler(event:Event):void
+    {
+        adjustSize();
+    }
+    
+    /**
+     *  This function is called whenever the itemRenderer changes size. 
Sub-classes should override
+     *  this method an handle the size change.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function adjustSize():void
+    {
+        updateDisplayList(width, height);
+    }
    
+    override protected function updateDisplayList(unscaledWidth:Number, 
unscaledHeight:Number):void
+    {
+        label.x = disclosureIcon.width;
+        label.y = 2;
+        disclosureIcon.y = 2;
+    }
 
+    public function set text(value:String):void
+    {
+        COMPILE::JS
+        {
+            if (value == "undefined")
+            {
+                if (labelField.charAt(0) == '@')
+                    value = data["attribute"](labelField);
+                else
+                    value = data["child"](labelField).toString();
+            }
+        }
+        label.text = value;
+    }
+
+    /**
+     *  The text currently displayed by the itemRenderer instance.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get text():String
+    {
+        return label.text;
+    }
+    
 }
 
 }

Reply via email to