org.symbian.tools.wrttools/projecttemplates/WRTKit/UI/View.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 View class is an abstract base class for views in the UI toolkit.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    20
// Don't use the View directly - instead use a concrete subclass like ListView.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    21
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    22
// Constructor.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    23
function View(id) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    24
    if (id != UI_NO_INIT_ID) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    25
        this.init(id);
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
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    29
// View inherits from UIElement.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    30
View.prototype = new UIElement(UI_NO_INIT_ID);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    31
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    32
// Currently focused control.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    33
View.prototype.focusedControl = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    34
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    35
// Initializer - called from constructor.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    36
View.prototype.init = function(id) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    37
    uiLogger.debug("View.init(" + id + ")");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    38
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    39
    // call superclass initializer
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    40
    UIElement.prototype.init.call(this, id);
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    41
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    42
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    43
// Returns the currently focused control; null if none.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    44
View.prototype.getFocusedControl = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    45
    return this.focusedControl;
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    46
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    47
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    48
// Used to notify the view that the focused control has changed.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    49
View.prototype.focusedControlChanged = function(control) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    50
    uiLogger.debug("View.focusedControlChanged(" + control + ")");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    51
    this.focusedControl = control;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    52
    // notify event listeners
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    53
    this.fireEvent(this.createEvent("FocusedControlChanged", this.focusedControl));
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    54
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    55
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    56
// Attempts to focus the first focusable control.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    57
// Override in subclasses as required.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    58
View.prototype.focusFirstControl = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    59
    uiLogger.debug("View.focusFirstControl()");
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    60
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    61
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    62
// Attempts to reset all control focus states.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    63
// Override in subclasses as required.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    64
View.prototype.resetControlFocusStates = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    65
    uiLogger.debug("View.resetControlFocusStates()");
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
    66
};