uidesigner/com.nokia.sdt.series60.componentlibrary/components/transient/CAknPreviewPopUp.js
author cawthron
Tue, 24 Mar 2009 22:20:21 -0500
changeset 2 d760517a8095
permissions -rw-r--r--
new
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
/*
cawthron
parents:
diff changeset
     2
* Copyright (c) 2009 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
include("../containers/containerLibrary.js")
cawthron
parents:
diff changeset
    18
include("../renderLibrary.js")
cawthron
parents:
diff changeset
    19
include("../implLibrary.js")
cawthron
parents:
diff changeset
    20
include("popupDialogLibrary.js")
cawthron
parents:
diff changeset
    21
cawthron
parents:
diff changeset
    22
function CAknPreviewPopUpVisual() {
cawthron
parents:
diff changeset
    23
}
cawthron
parents:
diff changeset
    24
cawthron
parents:
diff changeset
    25
CAknPreviewPopUpVisual.prototype.draw = function(instance, laf, graphics) {
cawthron
parents:
diff changeset
    26
	var properties = instance.properties;
cawthron
parents:
diff changeset
    27
	
cawthron
parents:
diff changeset
    28
	var rect = new Rectangle(0, 0, properties.size.width, properties.size.height);
cawthron
parents:
diff changeset
    29
	
cawthron
parents:
diff changeset
    30
	// fill background
cawthron
parents:
diff changeset
    31
	graphics.setBackground(getBackgroundColor(instance, laf));
cawthron
parents:
diff changeset
    32
	graphics.fillRectangle(rect);
cawthron
parents:
diff changeset
    33
cawthron
parents:
diff changeset
    34
	// draw frame
cawthron
parents:
diff changeset
    35
	var colorArray = [ null, // no color
cawthron
parents:
diff changeset
    36
		Colors.getColor(242,242,242),
cawthron
parents:
diff changeset
    37
		Colors.getColor(222,231,247),
cawthron
parents:
diff changeset
    38
		Colors.getColor(234,235,234),
cawthron
parents:
diff changeset
    39
		Colors.getColor(214,227,239),
cawthron
parents:
diff changeset
    40
		Colors.getColor(247,247,255)]
cawthron
parents:
diff changeset
    41
	drawFrame(rect, colorArray, graphics);
cawthron
parents:
diff changeset
    42
cawthron
parents:
diff changeset
    43
	var contentRect = new Rectangle(6, 6, rect.width - 12, rect.height - 12);
cawthron
parents:
diff changeset
    44
	var color = colorFromString(laf, properties.backColor);
cawthron
parents:
diff changeset
    45
	if (color != null) {
cawthron
parents:
diff changeset
    46
		graphics.setBackground(color);
cawthron
parents:
diff changeset
    47
		graphics.fillRectangle(contentRect);
cawthron
parents:
diff changeset
    48
	}
cawthron
parents:
diff changeset
    49
cawthron
parents:
diff changeset
    50
	if (properties.headingText.length > 0) {
cawthron
parents:
diff changeset
    51
		drawPreviewPopUpHeading(instance, graphics, laf);
cawthron
parents:
diff changeset
    52
	}
cawthron
parents:
diff changeset
    53
}
cawthron
parents:
diff changeset
    54
cawthron
parents:
diff changeset
    55
CAknPreviewPopUpVisual.prototype.layout = function(instance, laf) {
cawthron
parents:
diff changeset
    56
	var screenSize = laf.getDimension("screen.size");
cawthron
parents:
diff changeset
    57
	if (instance.properties.EFixedMode) {
cawthron
parents:
diff changeset
    58
		var mainPane = laf.getRectangle("content.pane.bounds");
cawthron
parents:
diff changeset
    59
		var portrait = laf.getBoolean("is.portrait", true);
cawthron
parents:
diff changeset
    60
		if (portrait) {
cawthron
parents:
diff changeset
    61
			instance.properties.location.x = mainPane.x + mainPane.width / 3;
cawthron
parents:
diff changeset
    62
		}
cawthron
parents:
diff changeset
    63
		else {
cawthron
parents:
diff changeset
    64
			instance.properties.location.x = mainPane.x + mainPane.width / 2;
cawthron
parents:
diff changeset
    65
		}
cawthron
parents:
diff changeset
    66
		instance.properties.location.y = mainPane.y;
cawthron
parents:
diff changeset
    67
		instance.properties.size.width = mainPane.width - instance.properties.location.x;
cawthron
parents:
diff changeset
    68
		instance.properties.size.height = mainPane.height;
cawthron
parents:
diff changeset
    69
	}
cawthron
parents:
diff changeset
    70
	else {
cawthron
parents:
diff changeset
    71
		// center it if not fixed mode
cawthron
parents:
diff changeset
    72
		instance.properties.location.x = (screenSize.x - instance.properties.size.width) / 2;
cawthron
parents:
diff changeset
    73
		instance.properties.location.y = (screenSize.y - instance.properties.size.height) / 2;
cawthron
parents:
diff changeset
    74
	}
cawthron
parents:
diff changeset
    75
}
cawthron
parents:
diff changeset
    76
cawthron
parents:
diff changeset
    77
CAknPreviewPopUpVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
cawthron
parents:
diff changeset
    78
	return null;
cawthron
parents:
diff changeset
    79
}
cawthron
parents:
diff changeset
    80
cawthron
parents:
diff changeset
    81
setupCommonDirectLabelEditing(CAknPreviewPopUpVisual.prototype, 
cawthron
parents:
diff changeset
    82
	"headingText", 
cawthron
parents:
diff changeset
    83
	null,
cawthron
parents:
diff changeset
    84
	function(instance, laf) { return getPreviewPopUpHeadingFont(laf); } 
cawthron
parents:
diff changeset
    85
	)
cawthron
parents:
diff changeset
    86
cawthron
parents:
diff changeset
    87
//====================================================================================
cawthron
parents:
diff changeset
    88
cawthron
parents:
diff changeset
    89
function CAknPreviewPopUpContainment() {
cawthron
parents:
diff changeset
    90
}
cawthron
parents:
diff changeset
    91
cawthron
parents:
diff changeset
    92
CAknPreviewPopUpContainment.prototype.getAllowedAttribute = function() {
cawthron
parents:
diff changeset
    93
	return "is-caknpreviewpopup-content";
cawthron
parents:
diff changeset
    94
}
cawthron
parents:
diff changeset
    95
cawthron
parents:
diff changeset
    96
setupAttributeBasedQueryContainment(CAknPreviewPopUpContainment.prototype);
cawthron
parents:
diff changeset
    97
cawthron
parents:
diff changeset
    98
//====================================================================================
cawthron
parents:
diff changeset
    99
cawthron
parents:
diff changeset
   100
function CAknPreviewPopUpInit() {
cawthron
parents:
diff changeset
   101
}
cawthron
parents:
diff changeset
   102
cawthron
parents:
diff changeset
   103
CAknPreviewPopUpInit.prototype.getClassName = function(instance) {
cawthron
parents:
diff changeset
   104
	return "C" + titleCase(instance.properties.name);
cawthron
parents:
diff changeset
   105
}
cawthron
parents:
diff changeset
   106
cawthron
parents:
diff changeset
   107
CAknPreviewPopUpInit.prototype.initialize = function(instance, isConfigured) {
cawthron
parents:
diff changeset
   108
	if (!isConfigured) {
cawthron
parents:
diff changeset
   109
		instance.properties.className = this.getClassName(instance);
cawthron
parents:
diff changeset
   110
	}
cawthron
parents:
diff changeset
   111
}
cawthron
parents:
diff changeset
   112
cawthron
parents:
diff changeset
   113
CAknPreviewPopUpInit.prototype.propertyChanged = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   114
	if (propertyId == "name") {
cawthron
parents:
diff changeset
   115
		instance.properties.className = this.getClassName(instance);
cawthron
parents:
diff changeset
   116
	}
cawthron
parents:
diff changeset
   117
	else if (propertyId == "EFixedMode") {
cawthron
parents:
diff changeset
   118
		instance.forceLayout();
cawthron
parents:
diff changeset
   119
	}
cawthron
parents:
diff changeset
   120
}
cawthron
parents:
diff changeset
   121
cawthron
parents:
diff changeset
   122
//====================================================================================
cawthron
parents:
diff changeset
   123
cawthron
parents:
diff changeset
   124
function CAknPreviewPopUpEventInfo() {
cawthron
parents:
diff changeset
   125
}
cawthron
parents:
diff changeset
   126
cawthron
parents:
diff changeset
   127
CAknPreviewPopUpEventInfo.prototype.getEventGroups = function(instance) {
cawthron
parents:
diff changeset
   128
	return ["CAknPreviewPopUp"];
cawthron
parents:
diff changeset
   129
}
cawthron
parents:
diff changeset
   130
cawthron
parents:
diff changeset
   131
CAknPreviewPopUpEventInfo.prototype.getDefaultEventName = function(instance) {
cawthron
parents:
diff changeset
   132
	return "handlePointerEvent";
cawthron
parents:
diff changeset
   133
}
cawthron
parents:
diff changeset
   134
cawthron
parents:
diff changeset
   135
//====================================================================================
cawthron
parents:
diff changeset
   136