Uwd.System.Desktop.Button = function(c){
	var config = {
		text : c.text,
		imageCls : c.iconCls,
		handler : c.handler,
		applyTo : Ext.get('x-desktop-buttons'),
		template : new Ext.Template(
                    '<div class="desktop-element">',
                    '  <div class="x-btn">',
                    '    <div class="desktop-element-image {0}"></div>',
                    '    <div class="desktop-element-label">{1}</div>',
                    '  </div>',
                    '</div>')
	};
	Uwd.System.Desktop.Button.superclass.constructor.call(this, config);
	
	this.getEl().on('contextmenu', function(e) {
		e.preventDefault();
		e.stopEvent();
	});
};

Ext.extend(Uwd.System.Desktop.Button, Ext.Button, {
	
    onRender : function(ct, position){
        if(!this.template){
            if(!Ext.Button.buttonTemplate){
                // hideous table template
                Ext.Button.buttonTemplate = new Ext.Template(
                    '<table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>',
                    '<td class="x-btn-left"><i>&#160;</i></td><td class="x-btn-center"><em unselectable="on"><button class="x-btn-text" type="{1}">{0}</button></em></td><td class="x-btn-right"><i>&#160;</i></td>',
                    "</tr></tbody></table>");
            }
            this.template = Ext.Button.buttonTemplate;
        }
        var btn, targs = [this.imageCls, this.text || '&#160;'];

        if(position){
            btn = this.template.insertBefore(position, targs, true);
        }else{
            btn = this.template.append(ct, targs, true);
        }
        
		var btnEl = btn.child('div.x-btn');
        btnEl.on('focus', this.onFocus, this);
        btnEl.on('blur', this.onBlur, this);

        this.initButtonEl(btnEl, btnEl);

        if(this.menu){
            this.el.child(this.menuClassTarget).addClass("x-btn-with-menu");
        }
        Ext.ButtonToggleMgr.register(this);
    }
	
});



