Added wrt files, prior to converting into Qt/C++.
[ptas] / wrt / zouba / WRTKit / UI / View.js
1 /*\r
2 � Copyright 2008 Nokia Corporation. All rights reserved.\r
3 \r
4 IMPORTANT:  The Nokia software ("WRTKit and Example Widget files") is supplied to you by Nokia\r
5 Corporation (�Nokia�) in consideration of your agreement to the following terms. Your use, installation\r
6 and/or redistribution of the WRTKit and Example Widget files constitutes acceptance of these terms. If\r
7 you do not agree with these terms, please do not use, install, or redistribute the WRTKit and Example\r
8 Widget files.\r
9 \r
10 In consideration of your agreement to abide by the following terms, and subject to these terms, Nokia\r
11 grants you a personal, non-exclusive license, under Nokia�s copyrights in the WRTKit and Example\r
12 Widget files, to use, reproduce, and redistribute the WRTKit and Example files, in text form (for HTML,\r
13 CSS, or JavaScript files) or binary form (for associated images), for the sole purpose of creating S60\r
14 Widgets.\r
15 \r
16 If you redistribute the WRTKit and Example files, you must retain this entire notice in all such\r
17 redistributions of the WRTKit and Example files.\r
18 \r
19 You may not use the name, trademarks, service marks or logos of Nokia to endorse or promote products\r
20 that include the WRTKit and Example files without the prior written explicit agreement with Nokia.\r
21 Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by\r
22 Nokia herein, including but not limited to any patent rights that may be infringed by your products that\r
23 incorporate the WRTKit and Example files or by other works in which the WRTKit and Example files\r
24 may be incorporated.\r
25 \r
26 The WRTKit and Example files are provided on an "AS IS" basis.  NOKIA MAKES NO\r
27 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED\r
28 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A\r
29 PARTICULAR PURPOSE, REGARDING THE EXAMPLES OR ITS USE AND OPERATION\r
30 ALONE OR IN COMBINATION WITH YOUR PRODUCTS.\r
31 \r
32 IN NO EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR\r
33 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
34 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
35 INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, AND/OR\r
36 DISTRIBUTION OF THE EXAMPLES, HOWEVER CAUSED AND WHETHER UNDER THEORY\r
37 OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE,\r
38 EVEN IF NOKIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
39 \r
40 */\r
41 \r
42 ///////////////////////////////////////////////////////////////////////////////\r
43 // The View class is an abstract base class for views in the UI toolkit.\r
44 // Don't use the View directly - instead use a concrete subclass like ListView.\r
45 \r
46 // Constructor.\r
47 function View(id) {\r
48     if (id != UI_NO_INIT_ID) {\r
49         this.init(id);\r
50     }\r
51 }\r
52 \r
53 // View inherits from UIElement.\r
54 View.prototype = new UIElement(UI_NO_INIT_ID);\r
55 \r
56 // Currently focused control.\r
57 View.prototype.focusedControl = null;\r
58 \r
59 // Initializer - called from constructor.\r
60 View.prototype.init = function(id) {\r
61     uiLogger.debug("View.init(" + id + ")");\r
62     \r
63     // call superclass initializer\r
64     UIElement.prototype.init.call(this, id);\r
65 }\r
66 \r
67 // Returns the currently focused control; null if none.\r
68 View.prototype.getFocusedControl = function() {\r
69     return this.focusedControl;\r
70 }\r
71 \r
72 // Used to notify the view that the focused control has changed.\r
73 View.prototype.focusedControlChanged = function(control) {\r
74     uiLogger.debug("View.focusedControlChanged(" + control + ")");\r
75     this.focusedControl = control;\r
76     // notify event listeners\r
77     this.fireEvent(this.createEvent("FocusedControlChanged", this.focusedControl));\r
78 }\r
79 \r
80 // Attempts to focus the first focusable control.\r
81 // Override in subclasses as required.\r
82 View.prototype.focusFirstControl = function() {\r
83     uiLogger.debug("View.focusFirstControl()");\r
84 }\r
85 \r
86 // Attempts to reset all control focus states.\r
87 // Override in subclasses as required.\r
88 View.prototype.resetControlFocusStates = function() {\r
89     uiLogger.debug("View.resetControlFocusStates()");\r
90 }\r