﻿function Icon(iconURL)
{
    this.iconURL = iconURL;

    extend(this, Widget);
    
    this.updateSuspended = true;
    
    Toolkit.getImage(iconURL, getMethodPointer(this, function(url, image) {
        this.icon = image;
        this.preferredSize = {width: image.width, height:image.height};
        this.updateSuspended = false;
        
        this.domContainer.appendChild(image);
        
        if(this.container)
        {
            this.container.invokeUpdate();
        }
    }));
}

Icon.prototype = new Widget;

Icon.prototype.getPreferredSize = function()
{
    if(this.preferredSize)
    {
        return {width: this.preferredSize.width, height:this.preferredSize.height};
    } else
    {
        return {width: 0, height: 0};
    }
}

Icon.prototype.toString = function()
{
	return "Icon [iconURL = " + this.iconURL + "]";
}
