2
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
include("../containers/containerLibrary.js")
|
|
21 |
include("../toolbar/toolbar_utils.js")
|
|
22 |
function CAknViewLayout() {
|
|
23 |
}
|
|
24 |
|
|
25 |
CAknViewLayout.prototype.layout = function(instance, laf) {
|
|
26 |
|
|
27 |
var screenWidth = instance.properties.size.width;
|
|
28 |
var screenHeight = instance.properties.size.height;
|
|
29 |
var children = instance.children;
|
|
30 |
|
|
31 |
var statusArea = getStatusPane(children);
|
|
32 |
if (statusArea != null) {
|
|
33 |
setBounds(statusArea, laf.getRectangle("status.pane.bounds"));
|
|
34 |
}
|
|
35 |
|
|
36 |
// Check for toolbar. The toolbar is a child of a view and depending
|
|
37 |
// on the size and orientation of the toolbar, the view needs to be adjusted
|
|
38 |
var hasToolBar = false;
|
|
39 |
var toolBarRect;
|
|
40 |
var toolBar = getToolbar(children);
|
|
41 |
if (toolBar) {
|
|
42 |
hasToolBar = true;
|
|
43 |
toolBarRect = setToolbarLayout(toolBar, laf);
|
|
44 |
}
|
|
45 |
|
|
46 |
var cba = getControlPane(children);
|
|
47 |
if (cba != null) {
|
|
48 |
setBounds(cba, laf.getRectangle("control.pane.bounds"));
|
|
49 |
}
|
|
50 |
|
|
51 |
var contents = getContents(children);
|
|
52 |
if (contents != null) {
|
|
53 |
var contentPaneRect = laf.getRectangle("content.pane.bounds");
|
|
54 |
var contentRect = new Rectangle(contentPaneRect.x, contentPaneRect.y, contentPaneRect.width, contentPaneRect.height);
|
|
55 |
/*
|
|
56 |
In later 5.0 versions, toolbar draws over content!!
|
|
57 |
if (hasToolBar){
|
|
58 |
var toolBarMarginPadding = laf.getInteger("control.toolbar.margin", 0);
|
|
59 |
// check if toolBar is vertical or horizontal
|
|
60 |
var isHorizontal = toolBar.properties.orientation == "Horizontal" ? true : false;
|
|
61 |
if (isHorizontal) {
|
|
62 |
contentRect.height -= toolBar.properties.size.height + toolBarMarginPadding + 1;
|
|
63 |
} else {
|
|
64 |
contentRect.width -= toolBar.properties.size.width + toolBarMarginPadding + 1;
|
|
65 |
contentRect.x += toolBar.properties.size.width + toolBarMarginPadding + 1;
|
|
66 |
}
|
|
67 |
}
|
|
68 |
*/
|
|
69 |
|
|
70 |
setBounds(contents, contentRect);
|
|
71 |
}
|
|
72 |
}
|
|
73 |
|
|
74 |
CAknViewLayout.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
|
|
75 |
return null;
|
|
76 |
}
|
|
77 |
|
|
78 |
// Sets the toolbar layout and its children as well as adjusts the parent view
|
|
79 |
// depending on the toolbar orientation.
|
|
80 |
// Returns the toolbar's size as Rectangle
|
|
81 |
function setToolbarLayout(instance, laf) {
|
|
82 |
|
|
83 |
var isPortrait = laf.getBoolean("is.portrait", true);
|
|
84 |
var properties = instance.properties;
|
|
85 |
var isHorizontal = properties.orientation == "Horizontal" ? true : false;
|
|
86 |
var toolBarMarginPadding = laf.getInteger("control.toolbar.margin", 0);
|
|
87 |
var contentRect = laf.getRectangle("content.pane.bounds");
|
|
88 |
var controlPaneRect = laf.getRectangle("control.pane.bounds");
|
|
89 |
var screenDim = laf.getDimension("screen.size");
|
|
90 |
var toolBarRect = new Rectangle(contentRect.x, contentRect.y, contentRect.width, contentRect.height);
|
|
91 |
var toolBarWidth = laf.getInteger("control.toolbar.height", 0);
|
|
92 |
var toolBarDim = getToolBarSize(instance, laf);
|
|
93 |
toolBarRect.width = toolBarDim.x; // width
|
|
94 |
toolBarRect.height = toolBarDim.y; // height
|
|
95 |
var toolBarHeight = toolBarWidth;
|
|
96 |
var isSmallBar = properties.smallToolbar == true ? true : false;
|
|
97 |
|
|
98 |
if (isHorizontal){
|
|
99 |
toolBarRect.x = contentRect.width / 2 - (toolBarRect.width / 2);
|
|
100 |
if (isPortrait)
|
|
101 |
toolBarRect.y = screenDim.y - controlPaneRect.height - toolBarHeight - toolBarMarginPadding;
|
|
102 |
else {
|
|
103 |
// landscape
|
|
104 |
toolBarRect.y = screenDim.y - toolBarHeight*2;
|
|
105 |
if (!isSmallBar){
|
|
106 |
var sBarRect = laf.getRectangle("status.bar2.bounds");
|
|
107 |
toolBarRect.y = screenDim.y - toolBarHeight - sBarRect.height - toolBarMarginPadding;
|
|
108 |
}
|
|
109 |
}
|
|
110 |
} else {
|
|
111 |
// vertical toolbar
|
|
112 |
toolBarRect.y = screenDim.y / 2 - (toolBarRect.height / 2);
|
|
113 |
if (isPortrait){
|
|
114 |
toolBarRect.y += (controlPaneRect.height/2);
|
|
115 |
}
|
|
116 |
toolBarRect.x = toolBarMarginPadding;
|
|
117 |
}
|
|
118 |
|
|
119 |
setBounds(instance, toolBarRect); // Set the bounds of the toolbar itself
|
|
120 |
return toolBarRect;
|
|
121 |
}
|
|
122 |
|
|
123 |
|