qnx.fuse.ui.listClasses.AlternatingCellRenderer

AlternatingCellRenderer

Properties | Methods | Examples


Packageqnx.fuse.ui.listClasses
Classpublic class AlternatingCellRenderer
InheritanceAlternatingCellRenderer Inheritance CellRenderer Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip

The AlternatingCellRenderer class is the default cell renderer for the List class.

As the name suggests, AlternatingCellRenderer renders the cells in the list using alternating row colors, such that each adjacent row uses a different color.



Class information:
PlayBook Tablet OS Version:   1.0.6

View the examples

See also

CellRenderer
List



Public Properties

 PropertyDefined By
 Inheritedcolumn : int
Gets or sets the column of the cell.
CellRenderer
 Inheriteddata : Object
Gets or sets the data object for the cell renderer.
CellRenderer
 InheritedexplicitHeight : Number
[read-only] Returns the explicit height (actual height, in pixels) of the UI component.
UIComponent
 InheritedexplicitWidth : Number
[read-only] Returns the explicit width (actual width, in pixels) of the UI component.
UIComponent
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
 Inheritedindex : int
Gets or sets the index of the cell.
CellRenderer
 InheritedisHeader : Boolean
[read-only] Returns a Boolean indicating whether or not the cell is a header.
CellRenderer
 InheritedlayoutData : Object
Returns the layout data for the object.
UIComponent
 InheritedminHeight : Number
Gets or sets the minimum preferred height of the control.
UIComponent
 InheritedminWidth : Number
Gets or sets the minimum preferred width of the control.
UIComponent
 Inheritedrow : int
Gets or sets the row of the cell.
CellRenderer
 Inheritedsection : int
Gets or sets the section of the cell.
CellRenderer
 Inheritedstate : String
Gets or sets the state of the component.
SkinnableComponent

Public Methods

 MethodDefined By
  
Creates a new AlternatingCellRenderer instance.
AlternatingCellRenderer
 Inherited
childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner that may affect this object's layout.
UIComponent
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
Returns the size options for the given control.
UIComponent
 Inherited
getTextFormatForState(textState:String):TextFormat
Returns the TextFormat object for a specified state.
CellRenderer
 Inherited
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered.
UIComponent
 Inherited
Calling this method results in a call to the components validateProperties() method before the display list is rendered.
UIComponent
 Inherited
measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
This method calls doMeasure() in order to calculate the preferred size of the control.
UIComponent
 Inherited
setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting the explicitWidth and explicitHeight.
UIComponent
 Inherited
setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified by the arguments.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setSkin(newSkin:Object):void
Set the skin object on the component for it to render.
SkinnableComponent
 Inherited
setTextFormatForState(format:TextFormat, textState:String):void
Sets the TextFormat object for the label of a given state.
CellRenderer
 Inherited
Validates the display list of the component by calling the updateDisplayList().
UIComponent
 Inherited
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary.
UIComponent
 Inherited
Validates the properties of the component by calling the commitProperties() method.
UIComponent

Protected Methods

 MethodDefined By
 Inherited
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
UIComponent
 Inherited
doMeasure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
Performs a measurement on the control, and returns a LayoutMeasurement instance containing the available width and height within the layout.
UIComponent
 Inherited
flushCache():void
Invoked as part of parentLayoutChanged.
UIComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
Invalidates the parent's size and display list if includeInLayout property is set to true.
UIComponent
 Inherited
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
Sets the size and position of the children of the component.
UIComponent
 Inherited
updateSkin(unscaledWidth:Number, unscaledHeight:Number):void
Updates the skin.
SkinnableComponent

Constructor Detail

AlternatingCellRenderer()


public function AlternatingCellRenderer()

Creates a new AlternatingCellRenderer instance.

Examples

In the following example, a custom AlternatingCellRenderer class is created in order to place a check box component inside of each cell. The AlternatingCellRenderer is used to display grocery items. The class contains event listeners to provide custom processing for mouse click events.

package  
{
    import flash.events.Event;
    import flash.events.MouseEvent;
    
    import qnx.fuse.ui.buttons.CheckBox;
    import qnx.fuse.ui.listClasses.AlternatingCellRenderer;
    
    
    public class MyCustomCellRenderer extends AlternatingCellRenderer 
    {
        
        private var myCB:CheckBox;
        
        public function MyCustomCellRenderer()
        {
        }
        
        override protected function init():void 
        {
            super.init();
            
            myCB = new CheckBox();
            myCB.x = 250;
            myCB.y = 10;
            this.addChild(myCB);
            
            myCB.addEventListener( MouseEvent.CLICK, onClick );
            //add this listener in order to block the mouse down event from the list
            //see the onMouseDown method to see how to stop the event propagation
            myCB.addEventListener( MouseEvent.MOUSE_DOWN, onMouseDown);
        }
        
        //this will prevent the cell from being selected when the button is clicked down
        private function onMouseDown(event:MouseEvent):void 
        {
            event.stopImmediatePropagation();
        }
        
        private function onClick(event:MouseEvent):void 
        {
            dispatchEvent( new Event( Event.SELECT, true, true ) );
        }
    }
}
     

The following sample application calls the custom AlternatingCellRenderer class that is listed above.

package
{
    import flash.display.Sprite;
    
    import qnx.ui.data.DataProvider;
    import qnx.fuse.ui.listClasses.List;
    import qnx.fuse.ui.listClasses.ListSelectionMode;
    
    
    
    [SWF(height="600", width="1024", 
    frameRate="30", backgroundColor="#FFFFFF")]
    public class CustomListSample extends Sprite
    {
        
        public function CustomListSample()
        {
            initializeUI();
        }
        
        
        private function initializeUI():void
        {
            var arrItems:Array=[];
            
            arrItems.push({label: "Apples"});
            arrItems.push({label: "Potatoes"});
            arrItems.push({label: "Oranges"});
            arrItems.push({label: "Tomatoes"});
            arrItems.push({label: "Carrots"});
            arrItems.push({label: "Eggplant"});
            arrItems.push({label: "Celery"});
            arrItems.push({label: "Milk"});
            arrItems.push({label: "Ham"});
            arrItems.push({label: "Cheese"});
            arrItems.push({label: "Bacon"});
            
            var myList:List = new List();
            
            myList.setPosition(100, 200);
            myList.width = 300;
            myList.height = 300;
            myList.selectionMode = ListSelectionMode.MULTIPLE;
            
            myList.dataProvider = new DataProvider(arrItems);
            myList.cellRenderer = MyCustomCellRenderer;
            
            this.addChild(myList);
        }
    }
}