/**
 * This is the TextDisplay widget.  It serves as a container to display the text output 
 * of the equation object.
 */
PrtTextDisplay.prototype = new abstract_Widget(); // Attach to prototype.
function PrtTextDisplay() {
  // Properties:
  this.strId = "textDisplay";
  this.strInnerHtml = "";
  this.strClearTextClickCode = "window.top."+this.EVENT_RECEIVER_METHOD+"(\"ClearTextOutput\")";
  // Methods:
  this.getHtml   = TextDisplay_getHtml;
  this.updateDom = TextDisplay_updateDom;
  this.getData   = TextDisplay_getData;
  this.display   = TextDisplay_display;
  this.clear     = TextDisplay_clear;
}


TextDisplay.prototype = new PrtTextDisplay();
/**
 * This is the class constructor for the TextDisplay class.
 * @param strInnerHtml  OPTIONAL  InnerHtml to display in the widget.
 */
function TextDisplay(strInnerHtml) {
  if (arguments.length > 0) {
    this.strInnerHtml = strInnerHtml;
  }
}


/**
 * This method returns the HTML needed to display this widget.
 * @return strHtml  A string containing the above.
 */
function TextDisplay_getHtml() {
  var strButtonHtml = 
      " <div id='clearTextBtnBox'>  "
    + "   <input type='button'   id='clearDisplay'  title='Tip -> Click this to reduce the time needed to display a new graphing.' "
    + "          value='Clear Output Window'                                 "
    + "          onclick='eval(" + this.strClearTextClickCode + ");'         "
    + "    >  \n "
    + " </div>";
  return ("<div id='"+this.strId+"'>"+this.strInnerHtml+"</div>"+strButtonHtml);
}


/**
 * This method updates the innerHTML property of the widget's 
 * DOM object.
 * @param strAdditionalHtml  The HTML to append to that already in the div.
 */
function TextDisplay_updateDom(strAdditionalHtml) {
  var divDomRef = this.getDomObj();
  if (divDomRef) {
    if (strAdditionalHtml != null) {
      divDomRef.innerHTML += strAdditionalHtml;
    }
    return true;
  } else {
    return false;
  }
}


/**
 * This method returns the data held by this widget
 * @return string  The data held by this widget.
 */
function TextDisplay_getData() {
  if (this.getDomObj()) {
    return this.getDomObj().innerHTML;
  }
}


/**
 * This method handles adding to the display. 
 * @param strAdditionalHtml  The HTML to append to that already in the widget.
 */
function TextDisplay_display(strAdditionalHtml) {
  this.updateDom(strAdditionalHtml);
}


/**
 * This method handles clearing the widget's display. 
 */
function TextDisplay_clear() {
  this.getDomObj().innerHTML = "";
}
