Symbian.org/WRTKit/UI/TextPane.js
changeset 18 b73e6caf0031
equal deleted inserted replaced
17:5dc2963cd75f 18:b73e6caf0031
       
     1 // ////////////////////////////////////////////////////////////////////////////
       
     2 // Symbian Foundation Example Code
       
     3 //
       
     4 // This software is in the public domain. No copyright is claimed, and you 
       
     5 // may use it for any purpose without license from the Symbian Foundation.
       
     6 // No warranty for any purpose is expressed or implied by the authors or
       
     7 // the Symbian Foundation. 
       
     8 // ////////////////////////////////////////////////////////////////////////////
       
     9 
       
    10 ///////////////////////////////////////////////////////////////////////////////
       
    11 // The TextPane class implements a control that displays HTML content.
       
    12 
       
    13 // Constructor.
       
    14 function TextPane(id, caption, text) {
       
    15     if (id != UI_NO_INIT_ID) {
       
    16         this.init(id, caption, text);
       
    17     }
       
    18 }
       
    19 
       
    20 // TextPane inherits from Control.
       
    21 TextPane.prototype = new Control(UI_NO_INIT_ID);
       
    22 
       
    23 // Content element for TextPane text.
       
    24 TextPane.prototype.contentElement = null;
       
    25 
       
    26 // Initializer - called from constructor.
       
    27 TextPane.prototype.init = function(id, caption, text) {
       
    28     uiLogger.debug("TextPane.init(" + id + ", " + caption + ", " + text + ")");
       
    29     
       
    30     // call superclass initializer
       
    31     Control.prototype.init.call(this, id, caption);
       
    32     
       
    33     // create content element
       
    34     this.contentElement = document.createElement("div");
       
    35     this.controlElement.appendChild(this.contentElement);
       
    36     
       
    37     // set the text
       
    38     this.setText(text);
       
    39 }
       
    40 
       
    41 // Returns the enabled state for the control.
       
    42 TextPane.prototype.isEnabled = function() {
       
    43     return true;
       
    44 }
       
    45 
       
    46 // Returns the focusable state for the control.
       
    47 TextPane.prototype.isFocusable = function() {
       
    48     return false;
       
    49 }
       
    50 
       
    51 // Returns the control text.
       
    52 TextPane.prototype.getText = function() {
       
    53     return this.contentElement.innerHTML;
       
    54 }
       
    55 
       
    56 // Sets the text for the control.
       
    57 TextPane.prototype.setText = function(text) {
       
    58     uiLogger.debug("TextPane.setText(" + text + ")");
       
    59     this.contentElement.innerHTML = (text == null) ? "" : text;
       
    60     this.updateStyleFromState();
       
    61 }
       
    62 
       
    63 // Updates the style of the control to reflects the state of the control.
       
    64 TextPane.prototype.updateStyleFromState = function() {
       
    65     uiLogger.debug("TextPane.updateStyleFromState()");
       
    66     
       
    67     // set element class names
       
    68     this.setClassName(this.rootElement, "TextPane");
       
    69 //    this.setClassName(this.assemblyElement, "ControlAssembly ControlAssemblyNormal");
       
    70 //    this.setClassName(this.captionElement, "ControlCaption ControlCaptionNormal");
       
    71 //    this.setClassName(this.controlElement, "ControlElement");
       
    72 //    this.setClassName(this.contentElement, "TextPane");
       
    73 }