Ext.define('ComboboxClass15', {
    extend: 'DisplayableAction',
    constructor: function(cfgXML, o, actionSequence){
        this.OptionButton = null;
        this.SelectionBox = null;
        this.ComboBox = null;
        this.Text = "";
        this.FontFamily = 'Arial';
        this.FontSize = 14;
        this.FontWeight = 'Normal';
        this.FontStyle = 'Normal';
        this.ValueString = "";
        this.IsEditable = false;
        this.IsRespondOnSelected = false;
        this.callParent([ cfgXML, o, actionSequence]);
        //start self
        this.Text = XmlHelper.tryGetValue(cfgXML, "text", TryGetValueOption.Normal, "");
        this.FontFamily = XmlHelper.getString(cfgXML, "fontFamily");
        this.FontSize = XmlHelper.getFloat(cfgXML, "fontSize");
        this.FontStyle = XmlHelper.getString(cfgXML, "fontStyle");
        this.FontWeight = XmlHelper.getString(cfgXML, "fontWeight");
        this.FontColor = XmlHelper.getString(cfgXML, "fontColor");
        this.ValueString = XmlHelper.getString(cfgXML, "valueString");
        this.InitialValue = XmlHelper.tryGetValue(cfgXML, 'selectedValue', TryGetValueOption.Normal, '');
        this.IsEditable = XmlHelper.getBoolean(cfgXML, "isEditable");
        this.IsRespondOnSelected = XmlHelper.getBoolean(cfgXML, "isRespondOnSelected");
        this.SelectedValue = ExpressionEngine.evalExpression(this.InitialValue);
    },
    reset: function(){
        this.SelectedValue = ExpressionEngine.evalExpression(this.InitialValue);
    },
    getInteractionValue: function(){
        return this.SelectionBox.dom.value;
    },
    getOptionString: function(selectedValue){
        var optionStr = "";
        var values = this.ValueString.split("|");
        for (var i = 0; i < values.length; i++) {
            optionStr += Ext.String.format("<option value='{0}' {1} >{0}</option>\n ", values[i], (values[i] == selectedValue ? 'selected' : ''));//    "<option value='" + values[i] + "'>" + values[i] + "</option>\n";
        }
        return optionStr;
    },
    getTextStyle: function(){
        var textStyle = "font-family:" + this.FontFamily + ";";
        textStyle += "font-size:" + this.FontSize + "px;";
        textStyle += "font-style:" + this.FontStyle + ";";
        textStyle += "font-weight:" + this.FontWeight + ";";
        textStyle += "color:" + this.FontColor + ";";
        return textStyle;
    },
    initializeDC: function(bg){
        //initialize the pictureBox first
        this.initializeDisplayComponent(bg);
        this.SelectionBox = this.ContentContainer.createChild({
            ObjectType: "COMBOBOXOBJECT",
            tag: "select",
            id: this.ObjectType + "-" + this.id + "-SelectionBox",
            name: this.Name,
            html: this.getOptionString(this.SelectedValue),
            style: "position:absolute;width:100%;height:100%;" + this.getTextStyle()
        });
        this.setupEventListeners();
    },
    setupEventListeners: function(){
        this.SelectionBox.addListener("change", this.onSelected, this);
    },
    onSelected: function(evt, el, o){
        evt.stopPropagation();
        this.SelectedValue = this.getInteractionValue();
        if (this.IsRespondOnSelected) {
            var v = this.getInteractionValue();
            Author.DisplayManager.tryToTriggerResponse(this.Name, v, v);
        }
    },
    processAction: function(bg){
        if (this.IsChangeAction) {
            Author.DisplayManager.changeAction(this);
        }
        this.initializeDC(bg);
        this.setInitialVisibility();
        this.applyEffect();
        return {MoveOn: true, Interval: 0};
    }
});



