uidesigner/com.nokia.sdt.series60.componentlibrary/components/transient/ConfirmationQuery_visual.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) 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
include("../renderLibrary.js")
cawthron
parents:
diff changeset
    20
include("../messageLibrary.js")
cawthron
parents:
diff changeset
    21
include("../cba/cbaLibrary.js")
cawthron
parents:
diff changeset
    22
include("popupDialogLibrary.js")
cawthron
parents:
diff changeset
    23
cawthron
parents:
diff changeset
    24
function ConfirmationQueryVisual() {
cawthron
parents:
diff changeset
    25
}
cawthron
parents:
diff changeset
    26
cawthron
parents:
diff changeset
    27
ConfirmationQueryVisual.prototype.draw = function(instance, laf, graphics) {
cawthron
parents:
diff changeset
    28
	var properties = instance.properties;
cawthron
parents:
diff changeset
    29
cawthron
parents:
diff changeset
    30
	// first draw the CBA
cawthron
parents:
diff changeset
    31
	var leftText = lookupString("Yes");
cawthron
parents:
diff changeset
    32
	var rightText = lookupString("No");
cawthron
parents:
diff changeset
    33
	var middleText = "";
cawthron
parents:
diff changeset
    34
	var r = laf.getRectangle("control.pane.bounds");
cawthron
parents:
diff changeset
    35
	var rect = new Rectangle(r.x, r.y, r.width, r.height);
cawthron
parents:
diff changeset
    36
	rect.x -= properties.location.x;
cawthron
parents:
diff changeset
    37
	rect.y -= properties.location.y;
cawthron
parents:
diff changeset
    38
	drawCBA(leftText, rightText, middleText, new Point(rect.x, rect.y), new Point(rect.width, rect.height), laf, graphics);
cawthron
parents:
diff changeset
    39
cawthron
parents:
diff changeset
    40
	// then draw the query dialog
cawthron
parents:
diff changeset
    41
	var iconRect = getIconRect(getLeftOfDialogWithCBA(laf), laf);
cawthron
parents:
diff changeset
    42
	var flags = Font.ALIGN_LEFT | Font.WRAPPING_ENABLED;
cawthron
parents:
diff changeset
    43
	rect = calculateQueryBounds(properties, laf, flags, iconRect);
cawthron
parents:
diff changeset
    44
	drawPopupDialog(instance, laf, graphics, flags, rect, iconRect, getLeftOfDialogWithCBA(laf));	
cawthron
parents:
diff changeset
    45
}
cawthron
parents:
diff changeset
    46
cawthron
parents:
diff changeset
    47
function calculateQueryBounds(properties, laf, flags, iconRect) {
cawthron
parents:
diff changeset
    48
	var rect;
cawthron
parents:
diff changeset
    49
	
cawthron
parents:
diff changeset
    50
	// calculate the bounds of the dialog (just like a note)
cawthron
parents:
diff changeset
    51
	var bounds = calculateBounds(properties, laf, flags, iconRect.x, getLeftOfDialogWithCBA(laf));
cawthron
parents:
diff changeset
    52
	var portrait = laf.getBoolean("is.portrait", true);
cawthron
parents:
diff changeset
    53
	if (portrait)
cawthron
parents:
diff changeset
    54
		rect = new Rectangle(bounds.x, 0, bounds.width, bounds.height);
cawthron
parents:
diff changeset
    55
	else
cawthron
parents:
diff changeset
    56
		rect = new Rectangle(0, bounds.y, bounds.width, bounds.height);
cawthron
parents:
diff changeset
    57
		
cawthron
parents:
diff changeset
    58
	return rect;
cawthron
parents:
diff changeset
    59
}
cawthron
parents:
diff changeset
    60
cawthron
parents:
diff changeset
    61
ConfirmationQueryVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
cawthron
parents:
diff changeset
    62
	return null;
cawthron
parents:
diff changeset
    63
}
cawthron
parents:
diff changeset
    64
cawthron
parents:
diff changeset
    65
// IDirectLabelEdit
cawthron
parents:
diff changeset
    66
ConfirmationQueryVisual.prototype.getPropertyPaths = function(instance) {
cawthron
parents:
diff changeset
    67
	return new Array("text");
cawthron
parents:
diff changeset
    68
}
cawthron
parents:
diff changeset
    69
cawthron
parents:
diff changeset
    70
ConfirmationQueryVisual.prototype.getLabelBounds = function(instance, propertyPath, laf) {
cawthron
parents:
diff changeset
    71
	var properties = instance.properties;
cawthron
parents:
diff changeset
    72
	var iconRect = getIconRect(getLeftOfDialogWithCBA(laf), laf);
cawthron
parents:
diff changeset
    73
	var flags = Font.ALIGN_LEFT | Font.WRAPPING_ENABLED;
cawthron
parents:
diff changeset
    74
	rect = calculateQueryBounds(properties, laf, flags, iconRect);
cawthron
parents:
diff changeset
    75
	rect.width -= iconRect.width;
cawthron
parents:
diff changeset
    76
	
cawthron
parents:
diff changeset
    77
	return rect;
cawthron
parents:
diff changeset
    78
}
cawthron
parents:
diff changeset
    79
cawthron
parents:
diff changeset
    80
ConfirmationQueryVisual.prototype.getLabelFont = function(instance, propertyPath, laf) {
cawthron
parents:
diff changeset
    81
	return laf.getFont("message.font");
cawthron
parents:
diff changeset
    82
}
cawthron
parents:
diff changeset
    83
cawthron
parents:
diff changeset
    84
ConfirmationQueryVisual.prototype.layout = function(instance, laf) {
cawthron
parents:
diff changeset
    85
	var properties = instance.properties;
cawthron
parents:
diff changeset
    86
	var portrait = laf.getBoolean("is.portrait", true);
cawthron
parents:
diff changeset
    87
cawthron
parents:
diff changeset
    88
	var flags = Font.ALIGN_LEFT | Font.WRAPPING_ENABLED;
cawthron
parents:
diff changeset
    89
	var iconRect = getIconRect(getLeftOfDialogWithCBA(laf), laf);
cawthron
parents:
diff changeset
    90
	var rect = calculateBounds(properties, laf, flags, iconRect.x, getLeftOfDialogWithCBA(laf));
cawthron
parents:
diff changeset
    91
	var d = laf.getDimension("screen.size");
cawthron
parents:
diff changeset
    92
cawthron
parents:
diff changeset
    93
	if (portrait) {
cawthron
parents:
diff changeset
    94
		properties.location.x = 0;
cawthron
parents:
diff changeset
    95
		properties.location.y = rect.y;
cawthron
parents:
diff changeset
    96
		properties.size.width = d.x;
cawthron
parents:
diff changeset
    97
		properties.size.height = d.y - rect.y;
cawthron
parents:
diff changeset
    98
	}
cawthron
parents:
diff changeset
    99
	else {
cawthron
parents:
diff changeset
   100
		properties.location.x = rect.x;
cawthron
parents:
diff changeset
   101
		properties.location.y = 0;
cawthron
parents:
diff changeset
   102
		properties.size.width = d.x - rect.x;
cawthron
parents:
diff changeset
   103
		properties.size.height = d.y;
cawthron
parents:
diff changeset
   104
	}
cawthron
parents:
diff changeset
   105
}
cawthron
parents:
diff changeset
   106
cawthron
parents:
diff changeset
   107
ConfirmationQueryVisual.prototype.propertyChanged = function(instance, property) {
cawthron
parents:
diff changeset
   108
	if (property == "text") {
cawthron
parents:
diff changeset
   109
		instance.forceLayout();
cawthron
parents:
diff changeset
   110
	}
cawthron
parents:
diff changeset
   111
}
cawthron
parents:
diff changeset
   112