﻿if (!Poseidon.Controls.Print.Module) {
    Poseidon.Controls.Print.Module = {};
}

Poseidon.Controls.Print.Module.CompassRose = Ext.extend(Poseidon.Controls.Print.Module.DraggableModule, {
    style: 'background-color: transparent;',
    bodyStyle: 'background-color: transparent; border: 0px solid transparent;',

    stretch: this.stretch || false,

    getAlignPosition: function () {
        return { x: this.align_x || this.x || 0, y: this.align_y || this.y || 0 };
    },

    setAlignPosition: function (x, y) {
        this.align_x = x;
        this.align_y = y;
    },

    moduleType: 'compass_rose',

    imageSrc: '/images/print/compassrose.png',

    layout: 'fit',

    initComponent: function () {		
        var config = {
			width: Math.round(this.print_width * OpenLayers.DOTS_PER_INCH / this.dpi),
			height: Math.round(this.print_height * OpenLayers.DOTS_PER_INCH / this.dpi),
            items:
            [
                {
                    xtype: 'box',
                    autoEl:
                    {
                        tag: 'img',
                        src: this.imageSrc
                    }
                }
            ]
        };

        Ext.apply(this, Ext.apply(this.initialConfig, config));
        Poseidon.Controls.Print.Module.CompassRose.superclass.initComponent.apply(this, arguments);
    },

    getObject: function () {
        return {
            "module_id": this.module_id,
            "module_name": this.module_name,
            "width": this.width,
            "height": this.height,
            "x": this.x,
            "y": this.y,
			"print_width": this.print_width,
			"print_height": this.print_height,
            "align_x": this.align_x || this.x || 0,
            "align_y": this.align_y || this.y || 0,
            "align": this.align
        };
    },

    align: this.align || Poseidon.Controls.Print.AlignTypesEnum.TOP_LEFT,

    z_index: this.z_index || 100
});
