
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2011 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*
* $DateTime: $
*
* Adobe Output Module 4.0
*
* MediaGallery Originally Written by Quality Process Incorporated, Enhanced by
* Adobe Systems China. Contact Sheet written by Adobe Systems China.
* 
*
**************************************************************************/
AOM.CustomIconButton = function(iconbutton) {
	this.initialize(iconbutton);
}

AOM.CustomIconButton.prototype.initialize = function(iconbutton) {
	if (iconbutton == undefined)  {
		return false;
	}

	//add mouse event listener
    iconbutton.addEventListener ('mousedown', AOM.CustomIconButton.doDown, false);
    
    // Change the text width
    if (iconbutton.text != undefined)
    {
        var agfx = iconbutton.graphics;
        var textSize = agfx.measureString(iconbutton.text,  agfx.font);
		if (textSize > 0)
			iconbutton.preferredSize.width = textSize.width + AOM.BOX_WIDTH + AOM.BOX_SPACE;
    }

	return true;
}

AOM.CustomIconButton.doDown = function(event) {
     var iconbutton = event.target;
     if (!iconbutton.enabled) return;
	 
     iconbutton.onMouseDown();
     iconbutton.notify("onDraw");
}


