uidesigner/com.nokia.sdt.series60.componentlibrary/components/controls/CAknButton.js
author Dan Podwall <dan.podwall@nokia.com>
Mon, 27 Apr 2009 15:10:32 -0500
branchRCL_2_0
changeset 129 d13aa008da33
parent 2 d760517a8095
permissions -rw-r--r--
merge RCL_2_0 to MCL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
/*
cawthron
parents:
diff changeset
     2
* Copyright (c) 2007 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
cawthron
parents:
diff changeset
    22
function CAknButton() {
cawthron
parents:
diff changeset
    23
}
cawthron
parents:
diff changeset
    24
cawthron
parents:
diff changeset
    25
CAknButton.prototype.draw = function(instance, laf, graphics) {
cawthron
parents:
diff changeset
    26
	var borderPadding = 3;
cawthron
parents:
diff changeset
    27
	var properties = instance.properties;
cawthron
parents:
diff changeset
    28
	var width = properties.size.width - borderPadding;
cawthron
parents:
diff changeset
    29
	var height = properties.size.height - borderPadding;
cawthron
parents:
diff changeset
    30
	var x = 0;
cawthron
parents:
diff changeset
    31
	var y = 0;
cawthron
parents:
diff changeset
    32
cawthron
parents:
diff changeset
    33
	// fill 
cawthron
parents:
diff changeset
    34
	if (properties.buttonNoFrame == false){
cawthron
parents:
diff changeset
    35
		graphics.setBackground(laf.getColor("control.button.fill"));
cawthron
parents:
diff changeset
    36
		graphics.setForeground(laf.getColor("screen.background"));
cawthron
parents:
diff changeset
    37
		graphics.setBackground(laf.getColor("control.button.fill")); 
cawthron
parents:
diff changeset
    38
		graphics.fillGradientRectangle(x, y, width, height, true)
cawthron
parents:
diff changeset
    39
		// edge
cawthron
parents:
diff changeset
    40
		graphics.setForeground(laf.getColor("control.button.outline"))
cawthron
parents:
diff changeset
    41
		graphics.drawRectangle(new Rectangle(0, 0, width, height))
cawthron
parents:
diff changeset
    42
	
cawthron
parents:
diff changeset
    43
		// shadows
cawthron
parents:
diff changeset
    44
		graphics.setForeground(laf.getColor("control.button.shadow.inner"))
cawthron
parents:
diff changeset
    45
		graphics.drawLine(x + 1, y + height + 1, x + width + 1, y + height + 1)
cawthron
parents:
diff changeset
    46
		graphics.drawLine(x + width + 1, y + 1, x + width + 1, y + height + 1)
cawthron
parents:
diff changeset
    47
		
cawthron
parents:
diff changeset
    48
		graphics.setForeground(laf.getColor("control.button.shadow.outer"))
cawthron
parents:
diff changeset
    49
		graphics.drawLine(x + 0, y + height + 0, x + width + 0, y + height + 0)
cawthron
parents:
diff changeset
    50
		graphics.drawLine(x + width + 0, y + 0, x + width + 0, y + height + 0)
cawthron
parents:
diff changeset
    51
	}
cawthron
parents:
diff changeset
    52
	var fontFlags = getFontFlagsFromProperties(properties);
cawthron
parents:
diff changeset
    53
	
cawthron
parents:
diff changeset
    54
	if (properties.images.bmpfile != ""){
cawthron
parents:
diff changeset
    55
		
cawthron
parents:
diff changeset
    56
		var inToolbar = instance.parent.component.isOfType("com.nokia.sdt.series60.Toolbar");
cawthron
parents:
diff changeset
    57
		if (instance.properties.buttonText != "" && !inToolbar) {
cawthron
parents:
diff changeset
    58
			// there's an image and text and it's a button on the main pane (not in toolbar)
cawthron
parents:
diff changeset
    59
			renderImage(CAknButton.prototype, instance, laf, graphics, 
cawthron
parents:
diff changeset
    60
				borderPadding, borderPadding, "images", true, "normal");
cawthron
parents:
diff changeset
    61
			var imageBounds = getImageBounds(instance, properties.images, "normal");
cawthron
parents:
diff changeset
    62
			var textOffsetForImage = getTextOffsetForImage(imageBounds, properties);
cawthron
parents:
diff changeset
    63
			drawButtonTextItem(instance, instance.properties.buttonText, new Point(0, 0), new Point(width, height), laf, graphics, textOffsetForImage, fontFlags);
cawthron
parents:
diff changeset
    64
		} else {
cawthron
parents:
diff changeset
    65
			// there's only an image: draw the specified image on the button
cawthron
parents:
diff changeset
    66
			if (!inToolbar) // not in toolbar so center image horizontally
cawthron
parents:
diff changeset
    67
				x = width / 2 - height + 3*borderPadding;
cawthron
parents:
diff changeset
    68
			y = borderPadding;
cawthron
parents:
diff changeset
    69
			renderImage(CAknButton.prototype, instance, laf, graphics, 
cawthron
parents:
diff changeset
    70
				x, y, "images", true, "normal");
cawthron
parents:
diff changeset
    71
		}
cawthron
parents:
diff changeset
    72
	
cawthron
parents:
diff changeset
    73
	} else {
cawthron
parents:
diff changeset
    74
		// there's only text
cawthron
parents:
diff changeset
    75
		graphics.setForeground(laf.getColor("EEikColorButtonText"));
cawthron
parents:
diff changeset
    76
		var textOffsetForImage = new Point(0, 0);
cawthron
parents:
diff changeset
    77
		drawButtonTextItem(instance, instance.properties.buttonText, new Point(0, 0), new Point(width, height), laf, graphics, textOffsetForImage, fontFlags);
cawthron
parents:
diff changeset
    78
	}
cawthron
parents:
diff changeset
    79
}
cawthron
parents:
diff changeset
    80
cawthron
parents:
diff changeset
    81
/**
cawthron
parents:
diff changeset
    82
* Get text offsets when text and image are together so that the text is not overwriting the image
cawthron
parents:
diff changeset
    83
*/
cawthron
parents:
diff changeset
    84
function getTextOffsetForImage(imageBounds, properties){
cawthron
parents:
diff changeset
    85
	var imageDim = 0;
cawthron
parents:
diff changeset
    86
	if (imageBounds != null)
cawthron
parents:
diff changeset
    87
		imageDim = properties.size.height;
cawthron
parents:
diff changeset
    88
	// if it's left aligned and image is on left
cawthron
parents:
diff changeset
    89
	if (properties.textAndIconAlignment == "CAknButton::EIconBeforeText" && 
cawthron
parents:
diff changeset
    90
		(properties.horizTextAlign == "CGraphicsContext::ELeft" ||
cawthron
parents:
diff changeset
    91
		properties.horizTextAlign == "CGraphicsContext::ECenter"))  
cawthron
parents:
diff changeset
    92
	{
cawthron
parents:
diff changeset
    93
		return new Point(imageDim, 0);	
cawthron
parents:
diff changeset
    94
	}
cawthron
parents:
diff changeset
    95
	// if it's right aligned and image is on right
cawthron
parents:
diff changeset
    96
	if (properties.textAndIconAlignment == "CAknButton::EIconAfterText" && 
cawthron
parents:
diff changeset
    97
		properties.horizTextAlign == "CGraphicsContext::ERight") 
cawthron
parents:
diff changeset
    98
	{
cawthron
parents:
diff changeset
    99
		return new Point(imageDim, 0);	
cawthron
parents:
diff changeset
   100
	}
cawthron
parents:
diff changeset
   101
	// if it's top aligned and image is on top
cawthron
parents:
diff changeset
   102
	if (properties.textAndIconAlignment == "CAknButton::EIconOverText" && 
cawthron
parents:
diff changeset
   103
		properties.vertTextAlign == "CAknButton::ETop") 
cawthron
parents:
diff changeset
   104
	{
cawthron
parents:
diff changeset
   105
		return new Point(0, imageDim);	
cawthron
parents:
diff changeset
   106
	}
cawthron
parents:
diff changeset
   107
	// if it's bottom aligned and image is on bottom
cawthron
parents:
diff changeset
   108
	if (properties.textAndIconAlignment == "CAknButton::EIconUnderText" && 
cawthron
parents:
diff changeset
   109
		properties.vertTextAlign == "CAknButton::EBottom") 
cawthron
parents:
diff changeset
   110
	{
cawthron
parents:
diff changeset
   111
		return new Point(0, imageDim);	
cawthron
parents:
diff changeset
   112
	}
cawthron
parents:
diff changeset
   113
	return new Point(0, 0);
cawthron
parents:
diff changeset
   114
}
cawthron
parents:
diff changeset
   115
cawthron
parents:
diff changeset
   116
function getFontFlagsFromProperties(properties){
cawthron
parents:
diff changeset
   117
cawthron
parents:
diff changeset
   118
		// text can be offset as: center, left hand side, right hand side, top, or bottom
cawthron
parents:
diff changeset
   119
		var fontFlags;
cawthron
parents:
diff changeset
   120
		if (properties.horizTextAlign == "CGraphicsContext::ELeft" || (properties.buttonTextLeft == true) ) {
cawthron
parents:
diff changeset
   121
			fontFlags |= Font.ALIGN_LEFT;
cawthron
parents:
diff changeset
   122
		}else if (properties.horizTextAlign == "CGraphicsContext::ERight") {
cawthron
parents:
diff changeset
   123
			fontFlags |= Font.ALIGN_RIGHT;
cawthron
parents:
diff changeset
   124
		} else {
cawthron
parents:
diff changeset
   125
			fontFlags |= Font.ALIGN_CENTER; // default alignment
cawthron
parents:
diff changeset
   126
		}
cawthron
parents:
diff changeset
   127
		
cawthron
parents:
diff changeset
   128
		if (properties.vertTextAlign == "CAknButton::ETop") {
cawthron
parents:
diff changeset
   129
			fontFlags |= Font.VERTICAL_ALIGN_TOP;
cawthron
parents:
diff changeset
   130
		}else if (properties.vertTextAlign == "CAknButton::EBottom") {
cawthron
parents:
diff changeset
   131
			fontFlags |= Font.VERTICAL_ALIGN_BOTTOM;
cawthron
parents:
diff changeset
   132
		} else {
cawthron
parents:
diff changeset
   133
			fontFlags |= Font.VERTICAL_ALIGN_CENTER;
cawthron
parents:
diff changeset
   134
		}
cawthron
parents:
diff changeset
   135
		return fontFlags;
cawthron
parents:
diff changeset
   136
}
cawthron
parents:
diff changeset
   137
cawthron
parents:
diff changeset
   138
cawthron
parents:
diff changeset
   139
/**
cawthron
parents:
diff changeset
   140
 *	Get the rectangle in which to draw the icon
cawthron
parents:
diff changeset
   141
 */
cawthron
parents:
diff changeset
   142
function getIconRect(properties, laf) {
cawthron
parents:
diff changeset
   143
	var iconSize = laf.getDimension("note.icon.size");
cawthron
parents:
diff changeset
   144
	var padding = laf.getInteger("note.padding", 2);
cawthron
parents:
diff changeset
   145
	var iconRect = new Rectangle(properties.size.width - iconSize.x - padding*2, 
cawthron
parents:
diff changeset
   146
			0,
cawthron
parents:
diff changeset
   147
			iconSize.x, iconSize.y);
cawthron
parents:
diff changeset
   148
	return iconRect;
cawthron
parents:
diff changeset
   149
}
cawthron
parents:
diff changeset
   150
cawthron
parents:
diff changeset
   151
cawthron
parents:
diff changeset
   152
CAknButton.prototype.getViewableSize = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   153
	var	size = instance.properties.size;
cawthron
parents:
diff changeset
   154
	var padding = laf.getInteger("note.padding", 2);
cawthron
parents:
diff changeset
   155
	return new Point(size.height, size.height - padding*2);
cawthron
parents:
diff changeset
   156
}
cawthron
parents:
diff changeset
   157
cawthron
parents:
diff changeset
   158
CAknButton.prototype.isScaling = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   159
	return true;
cawthron
parents:
diff changeset
   160
}
cawthron
parents:
diff changeset
   161
cawthron
parents:
diff changeset
   162
cawthron
parents:
diff changeset
   163
CAknButton.prototype.getAlignmentWeights = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   164
		// If there's no button text align in the center, else align on the left
cawthron
parents:
diff changeset
   165
		var properties = instance.properties;
cawthron
parents:
diff changeset
   166
		
cawthron
parents:
diff changeset
   167
		if (properties.buttonText == "") {
cawthron
parents:
diff changeset
   168
			return new Point(ImageUtils.ALIGN_CENTER_OR_TOP, ImageUtils.ALIGN_CENTER_OR_TOP);
cawthron
parents:
diff changeset
   169
		} else {
cawthron
parents:
diff changeset
   170
			// image and text
cawthron
parents:
diff changeset
   171
				if (properties.textAndIconAlignment == "CAknButton::EIconBeforeText"){
cawthron
parents:
diff changeset
   172
					return new Point(ImageUtils.ALIGN_LEFT, ImageUtils.ALIGN_CENTER_OR_TOP);
cawthron
parents:
diff changeset
   173
				} else if (properties.textAndIconAlignment == "CAknButton::EIconAfterText"){
cawthron
parents:
diff changeset
   174
					return new Point(ImageUtils.ALIGN_RIGHT, ImageUtils.ALIGN_CENTER_OR_TOP);
cawthron
parents:
diff changeset
   175
				} else if (properties.textAndIconAlignment == "CAknButton::EIconUnderText"){
cawthron
parents:
diff changeset
   176
					return new Point(ImageUtils.ALIGN_CENTER, ImageUtils.ALIGN_BOTTOM);
cawthron
parents:
diff changeset
   177
				} else if (properties.textAndIconAlignment == "CAknButton::EIconOverText"){
cawthron
parents:
diff changeset
   178
					return new Point(ImageUtils.ALIGN_CENTER, ImageUtils.ALIGN_TOP);
cawthron
parents:
diff changeset
   179
				} else if (properties.textAndIconAlignment == "CAknButton::EOverlay"){
cawthron
parents:
diff changeset
   180
					return new Point(0, 0);
cawthron
parents:
diff changeset
   181
				}  else {
cawthron
parents:
diff changeset
   182
					return new Point(0, 0);
cawthron
parents:
diff changeset
   183
				}
cawthron
parents:
diff changeset
   184
		}
cawthron
parents:
diff changeset
   185
}
cawthron
parents:
diff changeset
   186
cawthron
parents:
diff changeset
   187
CAknButton.prototype.isPreservingAspectRatio = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   188
	// Preserving aspect ratio only when button is child of toolbar
cawthron
parents:
diff changeset
   189
	if (instance.parent.component.isOfType("com.nokia.sdt.series60.Toolbar")){
cawthron
parents:
diff changeset
   190
		return true;
cawthron
parents:
diff changeset
   191
	} else {
cawthron
parents:
diff changeset
   192
		return false;
cawthron
parents:
diff changeset
   193
	}
cawthron
parents:
diff changeset
   194
}
cawthron
parents:
diff changeset
   195
cawthron
parents:
diff changeset
   196
cawthron
parents:
diff changeset
   197
CAknButton.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
cawthron
parents:
diff changeset
   198
	var properties = instance.properties;
cawthron
parents:
diff changeset
   199
cawthron
parents:
diff changeset
   200
	var width = -1;
cawthron
parents:
diff changeset
   201
	var height = -1;
cawthron
parents:
diff changeset
   202
	if (wHint >= 0)
cawthron
parents:
diff changeset
   203
		width = wHint;
cawthron
parents:
diff changeset
   204
	if (hHint >= 0)
cawthron
parents:
diff changeset
   205
		height = hHint;
cawthron
parents:
diff changeset
   206
cawthron
parents:
diff changeset
   207
	var imgBounds = getImageBounds(instance, properties.images, "normal");
cawthron
parents:
diff changeset
   208
	if (imgBounds) {
cawthron
parents:
diff changeset
   209
		if (imgBounds.width > width)
cawthron
parents:
diff changeset
   210
			width = imgBounds.width;
cawthron
parents:
diff changeset
   211
		if (imgBounds.height > height)
cawthron
parents:
diff changeset
   212
			height = imgBounds.height;
cawthron
parents:
diff changeset
   213
	} else {
cawthron
parents:
diff changeset
   214
		if (width < 0)
cawthron
parents:
diff changeset
   215
			width = 16;
cawthron
parents:
diff changeset
   216
		if (height < 0)
cawthron
parents:
diff changeset
   217
			height = 16;
cawthron
parents:
diff changeset
   218
	}
cawthron
parents:
diff changeset
   219
		
cawthron
parents:
diff changeset
   220
	var bounds = new Point(width, height);
cawthron
parents:
diff changeset
   221
	return bounds;
cawthron
parents:
diff changeset
   222
}
cawthron
parents:
diff changeset
   223
cawthron
parents:
diff changeset
   224
setupCommonDirectImageEditing(CAknButton.prototype, "images", 
cawthron
parents:
diff changeset
   225
	null  	// areafunction
cawthron
parents:
diff changeset
   226
);
cawthron
parents:
diff changeset
   227
cawthron
parents:
diff changeset
   228
cawthron
parents:
diff changeset
   229
function drawButtonTextItem(instance, text, location, size, laf, 
cawthron
parents:
diff changeset
   230
					graphics, textOffsetForImage, fontFlags) {
cawthron
parents:
diff changeset
   231
cawthron
parents:
diff changeset
   232
	var x = location.x;
cawthron
parents:
diff changeset
   233
	var y = location.y;
cawthron
parents:
diff changeset
   234
	var width = size.x;
cawthron
parents:
diff changeset
   235
	var height = size.y;
cawthron
parents:
diff changeset
   236
	var parentIsToolbar = instance.parent.component.isOfType("com.nokia.sdt.series60.Toolbar");
cawthron
parents:
diff changeset
   237
	var font = laf.getFont("ButtonFont");
cawthron
parents:
diff changeset
   238
	graphics.setFont(font);
cawthron
parents:
diff changeset
   239
	
cawthron
parents:
diff changeset
   240
	var textMargin = 1;  
cawthron
parents:
diff changeset
   241
	if (!parentIsToolbar){
cawthron
parents:
diff changeset
   242
		textMargin = laf.getInteger("control.button.text.margin", 0);
cawthron
parents:
diff changeset
   243
	}
cawthron
parents:
diff changeset
   244
	if (size.x <= textMargin) {
cawthron
parents:
diff changeset
   245
		return; // will crash when drawing if no return
cawthron
parents:
diff changeset
   246
	}
cawthron
parents:
diff changeset
   247
	if (textOffsetForImage.x > textMargin){
cawthron
parents:
diff changeset
   248
		textMargin = textOffsetForImage.x
cawthron
parents:
diff changeset
   249
	} else {
cawthron
parents:
diff changeset
   250
		textMargin = textMargin + textOffsetForImage.x
cawthron
parents:
diff changeset
   251
	}
cawthron
parents:
diff changeset
   252
	
cawthron
parents:
diff changeset
   253
	var extent = font.stringExtent(text)
cawthron
parents:
diff changeset
   254
	
cawthron
parents:
diff changeset
   255
	var fontVertOffset = 0;
cawthron
parents:
diff changeset
   256
	if ((fontFlags & Font.VERTICAL_ALIGN_BOTTOM) != 0){
cawthron
parents:
diff changeset
   257
		fontVertOffset = (height - extent.y) - textMargin - textOffsetForImage.y;
cawthron
parents:
diff changeset
   258
	} else if ((fontFlags & Font.VERTICAL_ALIGN_CENTER) != 0){
cawthron
parents:
diff changeset
   259
		fontVertOffset = (height - extent.y) / 2 - (laf.getInteger("control.button.text.margin", 0)/2); // center
cawthron
parents:
diff changeset
   260
	} else {
cawthron
parents:
diff changeset
   261
		// top aligned
cawthron
parents:
diff changeset
   262
		fontVertOffset = textMargin + textOffsetForImage.y;
cawthron
parents:
diff changeset
   263
	}
cawthron
parents:
diff changeset
   264
	
cawthron
parents:
diff changeset
   265
	if (parentIsToolbar){
cawthron
parents:
diff changeset
   266
		// always vertically center text in toolbar
cawthron
parents:
diff changeset
   267
		fontVertOffset = ((height - extent.y) / 2) - 5; // center
cawthron
parents:
diff changeset
   268
	}
cawthron
parents:
diff changeset
   269
	
cawthron
parents:
diff changeset
   270
	if (laf.getBoolean("is.portrait", true)) {
cawthron
parents:
diff changeset
   271
		var fontHorizOffset = 0
cawthron
parents:
diff changeset
   272
		var rect = new Rectangle(x + fontHorizOffset, y + fontVertOffset, 
cawthron
parents:
diff changeset
   273
				width - (2*fontHorizOffset), height );
cawthron
parents:
diff changeset
   274
cawthron
parents:
diff changeset
   275
		rect.y = fontVertOffset;
cawthron
parents:
diff changeset
   276
		rect.height = extent.y + 5;
cawthron
parents:
diff changeset
   277
		rect.x = textMargin;
cawthron
parents:
diff changeset
   278
		rect.width = rect.width - textMargin;
cawthron
parents:
diff changeset
   279
		text = chooseScalableText(text, font, rect.width);
cawthron
parents:
diff changeset
   280
		if (text != ""){
cawthron
parents:
diff changeset
   281
			if (rect.width > 0 && rect.height > 0) {
cawthron
parents:
diff changeset
   282
				graphics.drawFormattedString(text, rect, fontFlags | Font.OVERFLOW_ELLIPSIS, 0);
cawthron
parents:
diff changeset
   283
			}
cawthron
parents:
diff changeset
   284
		}
cawthron
parents:
diff changeset
   285
	}
cawthron
parents:
diff changeset
   286
	else {
cawthron
parents:
diff changeset
   287
		var fontHeight = font.getHeight();
cawthron
parents:
diff changeset
   288
		var sbar1Bounds = laf.getRectangle("status.bar1.bounds");
cawthron
parents:
diff changeset
   289
		var sbar2Bounds = laf.getRectangle("status.bar2.bounds");
cawthron
parents:
diff changeset
   290
		
cawthron
parents:
diff changeset
   291
		var fontOffset = (sbar2Bounds.height - extent.y) / 2
cawthron
parents:
diff changeset
   292
cawthron
parents:
diff changeset
   293
		var rect = new Rectangle(x, y + fontOffset, width, height);
cawthron
parents:
diff changeset
   294
		
cawthron
parents:
diff changeset
   295
		rect.y = fontVertOffset;
cawthron
parents:
diff changeset
   296
		rect.height = extent.y + 5;
cawthron
parents:
diff changeset
   297
		rect.x = textMargin;
cawthron
parents:
diff changeset
   298
		rect.width = rect.width - textMargin*2;
cawthron
parents:
diff changeset
   299
		graphics.fillRectangle(x, y + sbar2Bounds.y, width, sbar2Bounds.height);
cawthron
parents:
diff changeset
   300
		text = chooseScalableText(text, font, rect.width);
cawthron
parents:
diff changeset
   301
		
cawthron
parents:
diff changeset
   302
		if (text != "" && rect.width > 0 && rect.height > 0) {
cawthron
parents:
diff changeset
   303
			graphics.drawFormattedString(text, rect, fontFlags | Font.OVERFLOW_ELLIPSIS, 0);
cawthron
parents:
diff changeset
   304
		}
cawthron
parents:
diff changeset
   305
	}
cawthron
parents:
diff changeset
   306
}
cawthron
parents:
diff changeset
   307
cawthron
parents:
diff changeset
   308
cawthron
parents:
diff changeset
   309
//////////////////////////////
cawthron
parents:
diff changeset
   310
// IDirectLabelEdit
cawthron
parents:
diff changeset
   311
//////////////////////////////
cawthron
parents:
diff changeset
   312
CAknButton.prototype.getPropertyPaths = function(instance) {
cawthron
parents:
diff changeset
   313
	return new Array("buttonText");
cawthron
parents:
diff changeset
   314
}
cawthron
parents:
diff changeset
   315
cawthron
parents:
diff changeset
   316
CAknButton.prototype.getLabelBounds = function(instance, propertyPath, laf) {
cawthron
parents:
diff changeset
   317
	return new Rectangle(0, 0,
cawthron
parents:
diff changeset
   318
		instance.properties.size.width, instance.properties.size.height);
cawthron
parents:
diff changeset
   319
}
cawthron
parents:
diff changeset
   320
cawthron
parents:
diff changeset
   321
CAknButton.prototype.getLabelFont = function(instance, propertyPath, laf) {
cawthron
parents:
diff changeset
   322
	return laf.getFont("ButtonFont");
cawthron
parents:
diff changeset
   323
}
cawthron
parents:
diff changeset
   324
cawthron
parents:
diff changeset
   325
//////////////////////////////////////////
cawthron
parents:
diff changeset
   326
// IComponentEventInfo
cawthron
parents:
diff changeset
   327
//////////////////////////////////////////
cawthron
parents:
diff changeset
   328
CAknButton.prototype.getEventGroups = function(instance) {
cawthron
parents:
diff changeset
   329
	// do not provide Control events when child of Toolbar
cawthron
parents:
diff changeset
   330
	if (instance.parent.component.isOfType("com.nokia.sdt.series60.Toolbar")){
cawthron
parents:
diff changeset
   331
		return ["ToolbarEvent"];
cawthron
parents:
diff changeset
   332
	} else {
cawthron
parents:
diff changeset
   333
		return ["CCoeControl"];
cawthron
parents:
diff changeset
   334
	}
cawthron
parents:
diff changeset
   335
}