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