/*
 * Copyright © 2008  Neogeo Technologies, Toulouse, France

 * This file is part of Opencarto web map publishing system project
 *
 * Opencarto is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Opencarto is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Opencarto.  If not, see <http://www.gnu.org/licenses/>.
 */

Ext.namespace('Ext.ol');
 
/**
 *
 * @class olPanel
 * @extends Ext.Panel
 */
Ext.ol.OLPanel = Ext.extend(Ext.Panel, {
    initComponent : function(){
        
        var defConfig = {
            projection: "EPSG:27572",
            units:"m",
            resolutions: [],
            border: false,
            maxExtent: '',
            controls:[]
        };
        
        Ext.applyIf(this,defConfig);
        
        Ext.ol.OLPanel.superclass.initComponent.call(this);        
        
    },
    afterRender : function(){
        var wh = this.ownerCt.getSize();
        Ext.applyIf(this, wh);
        Ext.ol.OLPanel.superclass.afterRender.call(this);    
        this.map = new OpenLayers.Map(this.body.dom,
            {
                numZoomLevels: this.resolutions.length,
                controls:this.controls,
                resolutions:this.resolutions,
                projection:this.projection,
                units:this.units,
                maxExtent:this.maxExtent
            
            });
        this.contentEl = this.map.div;
       
    },
    
    onResize : function(w, h){
        
        if (typeof this.getMap() == 'object') {
            this.map.updateSize();
        }
        
        Ext.ol.OLPanel.superclass.onResize.call(this, w, h);

    },
    setSize : function(width, height, animate){
        
        if (typeof this.getMap() == 'object') {
            this.map.updateSize();
        }
        
        Ext.ol.OLPanel.superclass.setSize.call(this, width, height, animate);
        
    },
    getMap : function(){
        
    
     return this.map;
        
    }
 
});

Ext.reg('olpannel',Ext.ol.OLPanel); 