org.symbian.tools.wrttools/projecttemplates/WRTKit/UI/Separator.js
author Eugene Ostroukhov <eugeneo@symbian.org>
Tue, 16 Mar 2010 18:01:11 -0700
changeset 273 b1f63c2c240c
parent 211 7b148352159e
permissions -rw-r--r--
Bug 2072 - Update .js files with EPL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
210
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     1
/**
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     2
 * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies).
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     3
 * All rights reserved.
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     4
 * This component and the accompanying materials are made available
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     6
 * which accompanies this distribution, and is available
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     8
 *
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     9
 * Initial Contributors:
273
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    10
 * Nokia Corporation - initial contribution.
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    11
 * 
210
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
    12
 * Contributors:
273
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    13
 * 
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    14
 * Description:
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    15
 * 
210
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
    16
 */
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    17
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    18
///////////////////////////////////////////////////////////////////////////////
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    19
// The Separator class is used to provide a visual separator in a list.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    20
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    21
// Constructor.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    22
function Separator(id) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    23
    if (id != UI_NO_INIT_ID) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    24
        this.init(id);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    25
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    26
}
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    27
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    28
// Separator inherits from Control.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    29
Separator.prototype = new Control(UI_NO_INIT_ID);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    30
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    31
// Reference to the separator element.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    32
Separator.prototype.separatorElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    33
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    34
// Separator row element.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    35
Separator.prototype.tableRowElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    36
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    37
// Left cell element.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    38
Separator.prototype.tableLeftCellElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    39
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    40
// Center cell element.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    41
Separator.prototype.tableCenterCellElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    42
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    43
// Right cell element.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    44
Separator.prototype.tableRightCellElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    45
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    46
// Initializer - called from constructor.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    47
Separator.prototype.init = function(id) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    48
    uiLogger.debug("Separator.init(" + id + ")");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    49
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    50
    // call superclass initializer
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    51
    Control.prototype.init.call(this, id, null);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    52
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    53
    // remove caption and control elements
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    54
    this.assemblyElement.removeChild(this.captionElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    55
    this.assemblyElement.removeChild(this.controlElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    56
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    57
    // create separator
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    58
    this.separatorElement = document.createElement("table");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    59
    this.tableRowElement = document.createElement("tr");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    60
    this.tableLeftCellElement = document.createElement("td");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    61
    this.tableCenterCellElement = document.createElement("td");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    62
    this.tableRightCellElement = document.createElement("td");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    63
    this.tableRowElement.appendChild(this.tableLeftCellElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    64
    this.tableRowElement.appendChild(this.tableCenterCellElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    65
    this.tableRowElement.appendChild(this.tableRightCellElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    66
    this.separatorElement.appendChild(this.tableRowElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    67
    this.assemblyElement.appendChild(this.separatorElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    68
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    69
    // update style
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    70
    this.updateStyleFromState();
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    71
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    72
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    73
// Returns the enabled state for the control.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    74
Separator.prototype.isEnabled = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    75
    return true;
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    76
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    77
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    78
// Returns the focusable state for the control.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    79
Separator.prototype.isFocusable = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    80
    return false;
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    81
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    82
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    83
// Updates the style of the control to reflects the state of the control.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    84
Separator.prototype.updateStyleFromState = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    85
    uiLogger.debug("Separator.updateStyleFromState()");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    86
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    87
    // set element class names
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    88
    this.setClassName(this.rootElement, "Control");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    89
    this.setClassName(this.assemblyElement, "ControlAssembly ControlAssemblyNormal");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    90
    this.setClassName(this.separatorElement, "Separator");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    91
    this.setClassName(this.tableRowElement, "SeparatorRow");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    92
    this.setClassName(this.tableLeftCellElement, "SeparatorLeftCell");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    93
    this.setClassName(this.tableCenterCellElement, "SeparatorCenterCell");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    94
    this.setClassName(this.tableRightCellElement, "SeparatorRightCell");
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    95
};