﻿derive(InputViewImage, ClassInput);
function InputViewImage() {

    override(this, 'Init');
    this.Init = function() {
        this.ClassInput_Init(arguments[0],arguments[1],arguments[2],arguments[3]);
        if(Designer_obj) {
            this.Property_Add(5, 'Acci&oacute;n Click', 'ActionList', 'ActClick', 'ActClick');
            this.Property_Add(29, 'Valor defecto', 'ImageValue', 'TextDefault', 'TextDefault');
            this.Property_Add(40, 'Tipo', 'Combo', 'Type', 'Type', 'Captcha');
            this.Property_Add(41, 'Max. ancho', 'Text', 'MaxWidth', 'MaxWidth', '');
            this.Property_Add(42, 'Max. height', 'Text', 'MaxHeight', 'MaxHeight', '');
        }
    }

    this.ClientToServerPass = function() {
        return false;
    }

    this.set_ActClick = function(aValue) {
        this.set_Attr('t20', aValue);
        this.Frm[this.FrmCount + 1] = aValue;
    }
    this.get_ActClick = function() {
        return this.get_Attr('t20'); 
    }
    this.ExecActClick = function(aRef) {
        var lObj = window[this.get_ActClick() + '_obj'];
        if(lObj) {
            lObj.Execute(aRef);
        }
    }

    this.get_Type = function() {
        return this.Frm[this.FrmCount + 2];
    }
    this.set_Type = function(aValue) {
        this.Frm[this.FrmCount + 2] = aValue;
        if(Designer_obj)
            setTimeout('Designer_obj.Render()',500);
    }

    this.get_MaxWidth = function() {
        return this.Frm[this.FrmCount + 3];
    }
    this.set_MaxWidth = function(aValue) {
        this.Frm[this.FrmCount + 3] = aValue;
        if (Designer_obj)
            setTimeout('Designer_obj.Render()', 500);
    }

    this.get_MaxHeight = function() {
        return this.Frm[this.FrmCount + 4];
    }
    this.set_MaxHeight = function(aValue) {
        this.Frm[this.FrmCount + 4] = aValue;
        if (Designer_obj)
            setTimeout('Designer_obj.Render()', 500);
    }
}


function AfterLoadImageView(aRef, aWidth, aHeight) {
    aWidth = parseInt(aWidth);
    aHeight = parseInt(aHeight);
    if (aWidth > 0 || aHeight > 0) {
        var limg = new Image();
        limg.src = aRef.src;
        if (aWidth > 0) {
            if (limg.width > aWidth)
                aRef.width = aWidth;
            if (aHeight > 0) {
                if (aRef.offsetHeight > aHeight)
                    aRef.height = aHeight;
            }
        } else {
            if (limg.height > aHeight)
                aRef.height = aHeight;
        }
    }
}



