﻿function ComboBoxModel(text, elements)
{
    this.onTextChanged = new EventDelegate();
    
    if(text)
    {
        this.text = text;
    } else
    {
        this.text = "Untitled";
    } 
    
    if(!elements)
    {
        elements = [];
    }
        
    ListModel.apply(this, [elements]);
}

ComboBoxModel.prototype = new ListModel;

ComboBoxModel.prototype.getText = function()
{
    return this.text;
};

ComboBoxModel.prototype.setText = function(text)
{
    if(!text)
    {
        throw new Error("CombBoxModel.setText() - parameter 'text' cannot be null");
    } else
    {
        var oldText = this.text;
        this.text = text;
        
        this.onTextChanged.fireEvent(this, oldText, text);
    }
};
