uidesigner/com.nokia.sdt.series60.componentlibrary/components/statuspane/StatusPaneContextAppIcon_3.0.js
author dan.podwall@nokia.com
Mon, 06 Apr 2009 14:00:50 -0500
changeset 50 9107fae37cee
parent 2 d760517a8095
permissions -rw-r--r--
merge on RCL_2_0
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("../implLibrary.js")
cawthron
parents:
diff changeset
    20
cawthron
parents:
diff changeset
    21
function StatusPaneContextAppIcon() {
cawthron
parents:
diff changeset
    22
}
cawthron
parents:
diff changeset
    23
cawthron
parents:
diff changeset
    24
// IComponentValidator
cawthron
parents:
diff changeset
    25
StatusPaneContextAppIcon.prototype.validate = function(instance) {
cawthron
parents:
diff changeset
    26
	var str = checkImageProperty(instance, instance.properties.image);
cawthron
parents:
diff changeset
    27
	if (str)
cawthron
parents:
diff changeset
    28
		return [ createSimpleModelError(instance, "image", str, []) ];
cawthron
parents:
diff changeset
    29
	else
cawthron
parents:
diff changeset
    30
		return null;
cawthron
parents:
diff changeset
    31
}
cawthron
parents:
diff changeset
    32
cawthron
parents:
diff changeset
    33
StatusPaneContextAppIcon.prototype.queryPropertyChange = function(instance, propertyId, newValue) {
cawthron
parents:
diff changeset
    34
	if (propertyId == "image") {
cawthron
parents:
diff changeset
    35
		var str = checkImageProperty(instance, newValue);
cawthron
parents:
diff changeset
    36
		return str;	
cawthron
parents:
diff changeset
    37
	} else {
cawthron
parents:
diff changeset
    38
		return null;
cawthron
parents:
diff changeset
    39
	}
cawthron
parents:
diff changeset
    40
}
cawthron
parents:
diff changeset
    41
cawthron
parents:
diff changeset
    42
/**
cawthron
parents:
diff changeset
    43
 *	The app icon is a strange beast since it is specified only by file,
cawthron
parents:
diff changeset
    44
 * 	not by file and image.  S60 picks images from fixed indices in the file.
cawthron
parents:
diff changeset
    45
 *	When MBM files are used, the app/grid icon is a different size than the
cawthron
parents:
diff changeset
    46
 *	context icon, so two images are candidates, and the second one (if existing)
cawthron
parents:
diff changeset
    47
 *	is seen in the context icon.  When MIF files are used, the icon can be
cawthron
parents:
diff changeset
    48
 *	scaled for either position, so only the first image is used.
cawthron
parents:
diff changeset
    49
 *
cawthron
parents:
diff changeset
    50
 *	Note: this validation and this component do not get across the point
cawthron
parents:
diff changeset
    51
 *	that the app/grid icon may be different, so the user needs to find this
cawthron
parents:
diff changeset
    52
 *	out from experience.
cawthron
parents:
diff changeset
    53
 */
cawthron
parents:
diff changeset
    54
function checkImageProperty(instance, imageProperty) {
cawthron
parents:
diff changeset
    55
	var imageInfo = imageProperty.editableValue;
cawthron
parents:
diff changeset
    56
	if (imageInfo != null && imageInfo.multiImageInfo != null) {
cawthron
parents:
diff changeset
    57
		var theImage;
cawthron
parents:
diff changeset
    58
		if (imageInfo.bitmapInfo == null)
cawthron
parents:
diff changeset
    59
			return lookupString("MustBeMaskedImage");
cawthron
parents:
diff changeset
    60
			
cawthron
parents:
diff changeset
    61
		// get the first and second image from this file
cawthron
parents:
diff changeset
    62
		var firstImage = imageInfo.multiImageInfo.getImageAtIndex(0);
cawthron
parents:
diff changeset
    63
		var secondImage = imageInfo.multiImageInfo.getImageAtIndex(2); // step by 2 (bmp, mask)
cawthron
parents:
diff changeset
    64
		
cawthron
parents:
diff changeset
    65
		if (imageInfo.multiImageInfo.getFileType() == imageInfo.multiImageInfo.MBM_FILE) {
cawthron
parents:
diff changeset
    66
			// for mbms, the first image becomes the app/grid icon and the second is the context icon
cawthron
parents:
diff changeset
    67
			theImage = secondImage;
cawthron
parents:
diff changeset
    68
			if (secondImage == null)
cawthron
parents:
diff changeset
    69
				theImage = firstImage;
cawthron
parents:
diff changeset
    70
			if (imageInfo.bitmapInfo != theImage)
cawthron
parents:
diff changeset
    71
				return lookupString("MustBeFirstOrSecondBmp");
cawthron
parents:
diff changeset
    72
		} else {
cawthron
parents:
diff changeset
    73
			// for mifs, the first image is used in both the app/grid and the context icon
cawthron
parents:
diff changeset
    74
			theImage = firstImage;
cawthron
parents:
diff changeset
    75
			if (imageInfo.bitmapInfo != theImage)
cawthron
parents:
diff changeset
    76
				return lookupString("MustBeFirstSvg");
cawthron
parents:
diff changeset
    77
		}
cawthron
parents:
diff changeset
    78
		
cawthron
parents:
diff changeset
    79
		// verify image has a mask, else we won't get any image
cawthron
parents:
diff changeset
    80
		if (!imageInfo.bitmapInfo.isSVG() && imageInfo.maskInfo == null)
cawthron
parents:
diff changeset
    81
			return lookupString("MustBeMaskedImage");
cawthron
parents:
diff changeset
    82
	}
cawthron
parents:
diff changeset
    83
	return null;
cawthron
parents:
diff changeset
    84
	
cawthron
parents:
diff changeset
    85
}