uidesigner/com.nokia.sdt.series60.componentlibrary/components/controls/CEikImage_visual.js
author Steve Sobek <steve.sobek@nokia.com>
Tue, 14 Apr 2009 18:40:50 -0500
changeset 96 dc3dca9ced31
parent 2 d760517a8095
permissions -rw-r--r--
Fix TOC XML in hopes that 2.1 will build & carefully formatted lots of lines for readability.
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
include("../renderLibrary.js")
cawthron
parents:
diff changeset
    21
include("../srcgenLibrary.js")
cawthron
parents:
diff changeset
    22
cawthron
parents:
diff changeset
    23
function CEikImageVisual() {
cawthron
parents:
diff changeset
    24
}
cawthron
parents:
diff changeset
    25
cawthron
parents:
diff changeset
    26
CEikImageVisual.prototype.draw = function(instance, laf, graphics) {
cawthron
parents:
diff changeset
    27
	graphics.setBackground(getBackgroundColor(instance, laf));
cawthron
parents:
diff changeset
    28
	
cawthron
parents:
diff changeset
    29
	renderImage(CEikImageVisual.prototype, instance, laf, graphics, 
cawthron
parents:
diff changeset
    30
		0, 0, "image", true);
cawthron
parents:
diff changeset
    31
}
cawthron
parents:
diff changeset
    32
cawthron
parents:
diff changeset
    33
CEikImageVisual.prototype.getViewableSize = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
    34
	var	size = instance.properties.size;
cawthron
parents:
diff changeset
    35
	return new Point(size.width, size.height);
cawthron
parents:
diff changeset
    36
}
cawthron
parents:
diff changeset
    37
cawthron
parents:
diff changeset
    38
CEikImageVisual.prototype.isScaling = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
    39
	return isScalingIcons();
cawthron
parents:
diff changeset
    40
}
cawthron
parents:
diff changeset
    41
cawthron
parents:
diff changeset
    42
CEikImageVisual.prototype.getAlignmentWeights = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
    43
	var version = getComponentVersions();
cawthron
parents:
diff changeset
    44
	if (version.getMajor() >= 3 || version.getMinor() >= 8)
cawthron
parents:
diff changeset
    45
		return new Point(ImageUtils.ALIGN_CENTER_OR_LEFT, ImageUtils.ALIGN_CENTER_OR_TOP);
cawthron
parents:
diff changeset
    46
	else
cawthron
parents:
diff changeset
    47
		return new Point(ImageUtils.ALIGN_LEFT, ImageUtils.ALIGN_TOP);
cawthron
parents:
diff changeset
    48
}
cawthron
parents:
diff changeset
    49
cawthron
parents:
diff changeset
    50
CEikImageVisual.prototype.isPreservingAspectRatio = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
    51
	return true;
cawthron
parents:
diff changeset
    52
}
cawthron
parents:
diff changeset
    53
cawthron
parents:
diff changeset
    54
cawthron
parents:
diff changeset
    55
CEikImageVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
cawthron
parents:
diff changeset
    56
	var properties = instance.properties;
cawthron
parents:
diff changeset
    57
cawthron
parents:
diff changeset
    58
	var width = -1;
cawthron
parents:
diff changeset
    59
	var height = -1;
cawthron
parents:
diff changeset
    60
	if (wHint >= 0)
cawthron
parents:
diff changeset
    61
		width = wHint;
cawthron
parents:
diff changeset
    62
	if (hHint >= 0)
cawthron
parents:
diff changeset
    63
		height = hHint;
cawthron
parents:
diff changeset
    64
cawthron
parents:
diff changeset
    65
	var imgBounds = getImageBounds(instance, properties.image);
cawthron
parents:
diff changeset
    66
	if (imgBounds) {
cawthron
parents:
diff changeset
    67
		if (imgBounds.width > width)
cawthron
parents:
diff changeset
    68
			width = imgBounds.width;
cawthron
parents:
diff changeset
    69
		if (imgBounds.height > height)
cawthron
parents:
diff changeset
    70
			height = imgBounds.height;
cawthron
parents:
diff changeset
    71
	} else {
cawthron
parents:
diff changeset
    72
		if (width < 0)
cawthron
parents:
diff changeset
    73
			width = 16;
cawthron
parents:
diff changeset
    74
		if (height < 0)
cawthron
parents:
diff changeset
    75
			height = 16;
cawthron
parents:
diff changeset
    76
	}
cawthron
parents:
diff changeset
    77
		
cawthron
parents:
diff changeset
    78
	var bounds = new Point(width, height);
cawthron
parents:
diff changeset
    79
	return bounds;
cawthron
parents:
diff changeset
    80
}
cawthron
parents:
diff changeset
    81
cawthron
parents:
diff changeset
    82
setupCommonDirectImageEditing(CEikImageVisual.prototype, "image", 
cawthron
parents:
diff changeset
    83
	null  	// areafunction
cawthron
parents:
diff changeset
    84
);