<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2010 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package spark.skins.mobile.supportClasses
{
    
/**
 *  Actionscript based skin for toggle buttons. This class can not be used 
 *  by itself. You must subclass and specify a 
 *  backgroundClass and selectedBackgroundClass
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5 
 *  @productversion Flex 4.5
 */    
public class SelectableButtonSkinBase extends ButtonSkinBase
{
    public function SelectableButtonSkinBase()
    {
        super();
        gap = 15;
        paddingLeft = 15;
        paddingRight = 15;
        paddingTop = 15;
        paddingBottom = 15;
        
        useIconStyle = false;
    }
    
    
    private var changeFXGSkin:Boolean = false;
    private var currentStateIconClass:Class;
    
    /**
     *  The Class used to create the icon in the up state
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var upIconClass:Class;
    
    /**
     *  The Class used to create the icon in the selected up state 
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var upSelectedIconClass:Class;
    
    /**
     *  The Class used to create the icon in the down state
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var downIconClass:Class;
    
    /**
     *  The Class used to create the icon in the selected down state 
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var downSelectedIconClass:Class;
    
    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private 
     */
    override protected function commitCurrentState():void
    {    
        super.commitCurrentState();
        
        // Check for selected or not selected
        if (currentState != null)
        {
            if (currentState == "up")
                currentStateIconClass = upIconClass;
            else if (currentState == "down")
                currentStateIconClass = downIconClass;
            else if (currentState == "upAndSelected")
                currentStateIconClass = upSelectedIconClass;
            else if (currentState == "downAndSelected")
                currentStateIconClass = downSelectedIconClass;
            else if (currentState.indexOf("AndSelected") != -1)
                currentStateIconClass = upSelectedIconClass;
            else
                currentStateIconClass = upIconClass;
                        
            if (!(iconInstance is currentStateIconClass))
            {
                changeFXGSkin = true;
                invalidateProperties();
                invalidateSize();
                invalidateDisplayList();
            }
        }
    }
    
    /**
     *  @private 
     */
    override protected function commitProperties():void
    {
        super.commitProperties();
        
        if (changeFXGSkin)
        {
            changeFXGSkin = false;
            
            if (currentStateIconClass)
            {
                // Remove iconDisplay
                if (iconInstance != null)
                    removeChild(iconInstance);
                
                iconInstance = new currentStateIconClass();  
                
                addChild(iconInstance);
            }
        }
    }
    
    /**
     *  @private 
     */
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
        
        // TODO (jszeto) Does this need to go into a seperate DisplayObject to avoid it from getting 
        // clobbered by subclasses?
        // Draw a transparent hit area
        graphics.clear();
        graphics.beginFill(0,0);
        graphics.drawRect(0,0,unscaledWidth, unscaledHeight);
        graphics.endFill();
    }
    
    
    
}
}<commit_msg>Transferred from the Adobe Open Source Subversion Repository<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2010 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package spark.skins.mobile.supportClasses
{
    
/**
 *  Actionscript based skin for toggle buttons. This class can not be used 
 *  by itself. You must subclass and specify a 
 *  backgroundClass and selectedBackgroundClass
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 2.5 
 *  @productversion Flex 4.5
 */    
public class SelectableButtonSkinBase extends ButtonSkinBase
{
    public function SelectableButtonSkinBase()
    {
        super();
        gap = 15;
        paddingLeft = 15;
        paddingRight = 15;
        paddingTop = 15;
        paddingBottom = 15;
      
        // Instruct the super class to ignore the "icon" style.
        // Instead, we're going to use the protected members
        // (initialized in the sub-classes):
        // upIconClass, 
        // upSelectedIconClass, 
        // downIconClass,
        // downSelectedIconClass
        useIconStyle = false;
    }
    
    /**
     *  The Class used to create the icon in the up state
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var upIconClass:Class;
    
    /**
     *  The Class used to create the icon in the selected up state 
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var upSelectedIconClass:Class;
    
    /**
     *  The Class used to create the icon in the down state
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var downIconClass:Class;
    
    /**
     *  The Class used to create the icon in the selected down state 
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 2.5 
     *  @productversion Flex 4.5
     */
    protected var downSelectedIconClass:Class;
    
    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @private 
     */
    override protected function commitCurrentState():void
    {    
        super.commitCurrentState();
        
        // Check for selected or not selected
        if (currentState != null)
        {
            var currentStateIconClass:Class = upIconClass;
            if (currentState == "down")
                currentStateIconClass = downIconClass;
            else if (currentState == "upAndSelected")
                currentStateIconClass = upSelectedIconClass;
            else if (currentState == "downAndSelected")
                currentStateIconClass = downSelectedIconClass;
            else if (currentState.indexOf("AndSelected") != -1)
                currentStateIconClass = upSelectedIconClass;
            
            setIcon(currentStateIconClass);
        }
    }

    /**
     *  @private 
     */
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
        
        // TODO (jszeto) Does this need to go into a seperate DisplayObject to avoid it from getting 
        // clobbered by subclasses?
        // Draw a transparent hit area
        graphics.clear();
        graphics.beginFill(0,0);
        graphics.drawRect(0,0,unscaledWidth, unscaledHeight);
        graphics.endFill();
    }
}
}
{'fraction_non_alphanumeric': 0.14457142857142857, 'fraction_numerical': 0.013485714285714285, 'mean_word_length': 1.4896159317211948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7155832', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2173, 'n_words': 623}