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