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 |
include("../renderLibrary.js")
|
|
21 |
include("../srcgenLibrary.js")
|
|
22 |
|
|
23 |
function CEikImageVisual() {
|
|
24 |
}
|
|
25 |
|
|
26 |
CEikImageVisual.prototype.draw = function(instance, laf, graphics) {
|
|
27 |
graphics.setBackground(getBackgroundColor(instance, laf));
|
|
28 |
|
|
29 |
renderImage(CEikImageVisual.prototype, instance, laf, graphics,
|
|
30 |
0, 0, "image", true);
|
|
31 |
}
|
|
32 |
|
|
33 |
CEikImageVisual.prototype.getViewableSize = function(instance, propertyId, laf) {
|
|
34 |
var size = instance.properties.size;
|
|
35 |
return new Point(size.width, size.height);
|
|
36 |
}
|
|
37 |
|
|
38 |
CEikImageVisual.prototype.isScaling = function(instance, propertyId, laf) {
|
|
39 |
return isScalingIcons();
|
|
40 |
}
|
|
41 |
|
|
42 |
CEikImageVisual.prototype.getAlignmentWeights = function(instance, propertyId, laf) {
|
|
43 |
var version = getComponentVersions();
|
|
44 |
if (version.getMajor() >= 3 || version.getMinor() >= 8)
|
|
45 |
return new Point(ImageUtils.ALIGN_CENTER_OR_LEFT, ImageUtils.ALIGN_CENTER_OR_TOP);
|
|
46 |
else
|
|
47 |
return new Point(ImageUtils.ALIGN_LEFT, ImageUtils.ALIGN_TOP);
|
|
48 |
}
|
|
49 |
|
|
50 |
CEikImageVisual.prototype.isPreservingAspectRatio = function(instance, propertyId, laf) {
|
|
51 |
return true;
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
CEikImageVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
|
|
56 |
var properties = instance.properties;
|
|
57 |
|
|
58 |
var width = -1;
|
|
59 |
var height = -1;
|
|
60 |
if (wHint >= 0)
|
|
61 |
width = wHint;
|
|
62 |
if (hHint >= 0)
|
|
63 |
height = hHint;
|
|
64 |
|
|
65 |
var imgBounds = getImageBounds(instance, properties.image);
|
|
66 |
if (imgBounds) {
|
|
67 |
if (imgBounds.width > width)
|
|
68 |
width = imgBounds.width;
|
|
69 |
if (imgBounds.height > height)
|
|
70 |
height = imgBounds.height;
|
|
71 |
} else {
|
|
72 |
if (width < 0)
|
|
73 |
width = 16;
|
|
74 |
if (height < 0)
|
|
75 |
height = 16;
|
|
76 |
}
|
|
77 |
|
|
78 |
var bounds = new Point(width, height);
|
|
79 |
return bounds;
|
|
80 |
}
|
|
81 |
|
|
82 |
setupCommonDirectImageEditing(CEikImageVisual.prototype, "image",
|
|
83 |
null // areafunction
|
|
84 |
);
|