uidesigner/com.nokia.carbide.cpp.uiq.components/components/embeddedControlImplLibrary.js
author tzelaw
Tue, 14 Apr 2009 15:03:19 -0500
changeset 94 d74b720418db
parent 2 d760517a8095
permissions -rw-r--r--
Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
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
 /** Helpers for controls embedded in forms or setting item lists */
cawthron
parents:
diff changeset
    20
cawthron
parents:
diff changeset
    21
var DRAW_BOUNDING_RECTS = false;
cawthron
parents:
diff changeset
    22
cawthron
parents:
diff changeset
    23
include("formLibrary.js") // for isForm function
cawthron
parents:
diff changeset
    24
include("settingsListLibrary.js")// for isSettingItemList
cawthron
parents:
diff changeset
    25
include("transient_dialog/popupDialogLibrary.js")//isDataQuery
cawthron
parents:
diff changeset
    26
cawthron
parents:
diff changeset
    27
/**
cawthron
parents:
diff changeset
    28
 * Implement IVisualAppearance routines with form/setting item support.
cawthron
parents:
diff changeset
    29
 * This automatically handles reducing the content area for
cawthron
parents:
diff changeset
    30
 * a component when it is displayed in a form/setting item list 
cawthron
parents:
diff changeset
    31
 * and returning a preferred size.
cawthron
parents:
diff changeset
    32
 *
cawthron
parents:
diff changeset
    33
 * @param prototype the prototype to modify<p>
cawthron
parents:
diff changeset
    34
 * 	This must provide these routines:	<br>
cawthron
parents:
diff changeset
    35
 * <p>
cawthron
parents:
diff changeset
    36
 *		drawContent(instance, laf, graphics, rect)	<br>
cawthron
parents:
diff changeset
    37
 *			Draw content into 'rect' (x, y are 0 and GC is shifted)	<br>
cawthron
parents:
diff changeset
    38
 *<p>
cawthron
parents:
diff changeset
    39
 *		getContentSize(instance, laf, size)	<br>
cawthron
parents:
diff changeset
    40
 *			Get the required size of the content, given the nominal constraints
cawthron
parents:
diff changeset
    41
 *			in 'size'.  For instance, a text field may increase the height
cawthron
parents:
diff changeset
    42
 *			due to wrapping.<p>
cawthron
parents:
diff changeset
    43
 *			The content bounds calculation is usually independent of whether the
cawthron
parents:
diff changeset
    44
 *			parent is a form, unless the rendering is significantly
cawthron
parents:
diff changeset
    45
 *			different.  The calculation <i>is</i> different for a setting
cawthron
parents:
diff changeset
    46
 *			item list, which uses a different font.  Returns a Point.	<br>
cawthron
parents:
diff changeset
    47
 */
cawthron
parents:
diff changeset
    48
function setupEmbeddedRendering(prototype) {
cawthron
parents:
diff changeset
    49
	prototype.draw = function(instance, laf, graphics) {
cawthron
parents:
diff changeset
    50
		var properties = instance.properties;
cawthron
parents:
diff changeset
    51
		if (isForm(instance.parent)) {
cawthron
parents:
diff changeset
    52
			var rects = getFormItemRectangles(instance, laf);
cawthron
parents:
diff changeset
    53
			var promptRect = rects[FORM_PROMPT_RECT_INDEX];
cawthron
parents:
diff changeset
    54
			var contentRect = rects[FORM_CONTENT_RECT_INDEX];
cawthron
parents:
diff changeset
    55
			
cawthron
parents:
diff changeset
    56
			drawFormPrompt(prototype, instance, laf, graphics, rects);
cawthron
parents:
diff changeset
    57
			if (DRAW_BOUNDING_RECTS) {
cawthron
parents:
diff changeset
    58
				graphics.setForeground(Colors.getColor(255, 0, 0));
cawthron
parents:
diff changeset
    59
				graphics.setXORMode(true);
cawthron
parents:
diff changeset
    60
				graphics.drawRectangle(promptRect.x, promptRect.y, promptRect.width-1, promptRect.height-1 );
cawthron
parents:
diff changeset
    61
				graphics.setXORMode(false);
cawthron
parents:
diff changeset
    62
			}
cawthron
parents:
diff changeset
    63
						
cawthron
parents:
diff changeset
    64
			var oldX = graphics.getOffX();
cawthron
parents:
diff changeset
    65
			var oldY = graphics.getOffY();
cawthron
parents:
diff changeset
    66
			graphics.setOffX(contentRect.x);
cawthron
parents:
diff changeset
    67
			graphics.setOffY(contentRect.y);
cawthron
parents:
diff changeset
    68
			contentRect.x = 0;
cawthron
parents:
diff changeset
    69
			contentRect.y = 0;
cawthron
parents:
diff changeset
    70
			this.drawContent(instance, laf, graphics, contentRect);
cawthron
parents:
diff changeset
    71
cawthron
parents:
diff changeset
    72
			if (DRAW_BOUNDING_RECTS) {
cawthron
parents:
diff changeset
    73
				graphics.setForeground(Colors.getColor(255, 0, 0));
cawthron
parents:
diff changeset
    74
				graphics.setXORMode(true);
cawthron
parents:
diff changeset
    75
				graphics.drawRectangle(contentRect.x, contentRect.y, contentRect.width-1, contentRect.height-1 );
cawthron
parents:
diff changeset
    76
				graphics.setXORMode(false);
cawthron
parents:
diff changeset
    77
			}
cawthron
parents:
diff changeset
    78
						
cawthron
parents:
diff changeset
    79
			graphics.setOffX(oldX);
cawthron
parents:
diff changeset
    80
			graphics.setOffY(oldY);
cawthron
parents:
diff changeset
    81
cawthron
parents:
diff changeset
    82
		} else if (isSettingItemList(instance.parent)) {
cawthron
parents:
diff changeset
    83
cawthron
parents:
diff changeset
    84
			var rects = getSettingItemRectangles(instance, laf);
cawthron
parents:
diff changeset
    85
			var numberRect = rects[SIL_NUMBER_RECT_INDEX];
cawthron
parents:
diff changeset
    86
			var titleRect = rects[SIL_TITLE_RECT_INDEX];
cawthron
parents:
diff changeset
    87
			var contentRect = rects[SIL_CONTENT_RECT_INDEX];
cawthron
parents:
diff changeset
    88
			
cawthron
parents:
diff changeset
    89
			drawSettingItemPrompt(prototype, instance, laf, graphics, rects);
cawthron
parents:
diff changeset
    90
			if (DRAW_BOUNDING_RECTS) {
cawthron
parents:
diff changeset
    91
				graphics.setForeground(Colors.getColor(255, 0, 0));
cawthron
parents:
diff changeset
    92
				graphics.setXORMode(true);
cawthron
parents:
diff changeset
    93
				graphics.drawRectangle(numberRect.x, numberRect.y, numberRect.width-1, numberRect.height-1 );
cawthron
parents:
diff changeset
    94
				graphics.drawRectangle(titleRect.x, titleRect.y, titleRect.width-1, titleRect.height-1 );
cawthron
parents:
diff changeset
    95
				graphics.setXORMode(false);
cawthron
parents:
diff changeset
    96
			}
cawthron
parents:
diff changeset
    97
						
cawthron
parents:
diff changeset
    98
			var oldX = graphics.getOffX();
cawthron
parents:
diff changeset
    99
			var oldY = graphics.getOffY();
cawthron
parents:
diff changeset
   100
			graphics.setOffX(contentRect.x);
cawthron
parents:
diff changeset
   101
			graphics.setOffY(contentRect.y);
cawthron
parents:
diff changeset
   102
			contentRect.x = 0;
cawthron
parents:
diff changeset
   103
			contentRect.y = 0;
cawthron
parents:
diff changeset
   104
			this.drawContent(instance, laf, graphics, contentRect);
cawthron
parents:
diff changeset
   105
cawthron
parents:
diff changeset
   106
			if (DRAW_BOUNDING_RECTS) {
cawthron
parents:
diff changeset
   107
				graphics.setForeground(Colors.getColor(128, 0, 0));
cawthron
parents:
diff changeset
   108
				graphics.setXORMode(true);
cawthron
parents:
diff changeset
   109
				graphics.drawRectangle(contentRect.x, contentRect.y, contentRect.width-1, contentRect.height-1 );
cawthron
parents:
diff changeset
   110
				graphics.setXORMode(false);
cawthron
parents:
diff changeset
   111
			}
cawthron
parents:
diff changeset
   112
						
cawthron
parents:
diff changeset
   113
			graphics.setOffX(oldX);
cawthron
parents:
diff changeset
   114
			graphics.setOffY(oldY);
cawthron
parents:
diff changeset
   115
cawthron
parents:
diff changeset
   116
		} else if (isDataQuery(instance.parent)) {
cawthron
parents:
diff changeset
   117
			// draw inner shadows
cawthron
parents:
diff changeset
   118
			var width = properties.size.width;
cawthron
parents:
diff changeset
   119
			var height = properties.size.height;
cawthron
parents:
diff changeset
   120
			graphics.setForeground(laf.getColor("control.shadow.inner"));
cawthron
parents:
diff changeset
   121
			graphics.drawRectangle(0, 0, width - 1, height - 1);
cawthron
parents:
diff changeset
   122
			
cawthron
parents:
diff changeset
   123
			
cawthron
parents:
diff changeset
   124
			graphics.setForeground(laf.getColor("control.shadow.outer"));
cawthron
parents:
diff changeset
   125
			graphics.drawLine(1, 1, width - 1, 1);
cawthron
parents:
diff changeset
   126
			graphics.drawLine(1, 1, 1, height - 1);
cawthron
parents:
diff changeset
   127
			
cawthron
parents:
diff changeset
   128
			// draw content
cawthron
parents:
diff changeset
   129
			var rect = new Rectangle(3, 3,
cawthron
parents:
diff changeset
   130
					properties.size.width - 6, properties.size.height - 6);
cawthron
parents:
diff changeset
   131
			this.drawContent(instance, laf, graphics, rect);
cawthron
parents:
diff changeset
   132
		} else {
cawthron
parents:
diff changeset
   133
			var rect = new Rectangle(0, 0,
cawthron
parents:
diff changeset
   134
					properties.size.width, properties.size.height);
cawthron
parents:
diff changeset
   135
			this.drawContent(instance, laf, graphics, rect);
cawthron
parents:
diff changeset
   136
		}
cawthron
parents:
diff changeset
   137
	}
cawthron
parents:
diff changeset
   138
	
cawthron
parents:
diff changeset
   139
	prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
cawthron
parents:
diff changeset
   140
		var properties = instance.properties;
cawthron
parents:
diff changeset
   141
		
cawthron
parents:
diff changeset
   142
		// [[[ ordinary calculations
cawthron
parents:
diff changeset
   143
		
cawthron
parents:
diff changeset
   144
		// get current size
cawthron
parents:
diff changeset
   145
		width = properties.size.width;
cawthron
parents:
diff changeset
   146
		height = properties.size.height;
cawthron
parents:
diff changeset
   147
		
cawthron
parents:
diff changeset
   148
		// if either of these are empty, use the parent's bounds as starting point
cawthron
parents:
diff changeset
   149
		if ((width == 0) || (height == 0)) {
cawthron
parents:
diff changeset
   150
			width = instance.parent.properties.size.width;
cawthron
parents:
diff changeset
   151
			height = instance.parent.properties.size.height;
cawthron
parents:
diff changeset
   152
		}
cawthron
parents:
diff changeset
   153
		
cawthron
parents:
diff changeset
   154
		// use hints if provided
cawthron
parents:
diff changeset
   155
		if (wHint >= 0)
cawthron
parents:
diff changeset
   156
			width = wHint;
cawthron
parents:
diff changeset
   157
		if (hHint >= 0)
cawthron
parents:
diff changeset
   158
			height = hHint;
cawthron
parents:
diff changeset
   159
			
cawthron
parents:
diff changeset
   160
		// ]]]
cawthron
parents:
diff changeset
   161
		
cawthron
parents:
diff changeset
   162
		var rect = new Rectangle(0, 0, width, height);
cawthron
parents:
diff changeset
   163
cawthron
parents:
diff changeset
   164
		if (isForm(instance.parent)) {
cawthron
parents:
diff changeset
   165
			var rects = getFormItemRectanglesInRect(instance, laf, rect);
cawthron
parents:
diff changeset
   166
			var promptRect = rects[FORM_PROMPT_RECT_INDEX];
cawthron
parents:
diff changeset
   167
			var contentRect = rects[FORM_CONTENT_RECT_INDEX];
cawthron
parents:
diff changeset
   168
			
cawthron
parents:
diff changeset
   169
			// ensure size is big enough for content
cawthron
parents:
diff changeset
   170
			size = this.getContentSize(instance, laf, 
cawthron
parents:
diff changeset
   171
						new Point(contentRect.width, contentRect.height));
cawthron
parents:
diff changeset
   172
			
cawthron
parents:
diff changeset
   173
			// for double-space mode, add height for the prompt
cawthron
parents:
diff changeset
   174
			if (isDoubleSpaced(instance.parent)) {
cawthron
parents:
diff changeset
   175
				size.y += promptRect.height + getFormLineGap(laf);
cawthron
parents:
diff changeset
   176
			} else {
cawthron
parents:
diff changeset
   177
				size.y += getFormLineGap(laf);
cawthron
parents:
diff changeset
   178
			
cawthron
parents:
diff changeset
   179
			}
cawthron
parents:
diff changeset
   180
		} else if (isSettingItemList(instance.parent)) {
cawthron
parents:
diff changeset
   181
			var rects = getSettingItemRectanglesInRect(instance, laf, rect);
cawthron
parents:
diff changeset
   182
			var contentRect = rects[SIL_CONTENT_RECT_INDEX];
cawthron
parents:
diff changeset
   183
			
cawthron
parents:
diff changeset
   184
			// ensure size is big enough for content
cawthron
parents:
diff changeset
   185
			size = this.getContentSize(instance, laf, 
cawthron
parents:
diff changeset
   186
						new Point(contentRect.width, contentRect.height));
cawthron
parents:
diff changeset
   187
			
cawthron
parents:
diff changeset
   188
			//size.y += getLineGap(laf);
cawthron
parents:
diff changeset
   189
		} else {
cawthron
parents:
diff changeset
   190
			size = this.getContentSize(instance, laf, new Point(width, height));
cawthron
parents:
diff changeset
   191
		}
cawthron
parents:
diff changeset
   192
		
cawthron
parents:
diff changeset
   193
		return size;
cawthron
parents:
diff changeset
   194
	}
cawthron
parents:
diff changeset
   195
	
cawthron
parents:
diff changeset
   196
	// drawPrompt needs these routines
cawthron
parents:
diff changeset
   197
	setupEmbeddedImagePropertyInfo(prototype);
cawthron
parents:
diff changeset
   198
}
cawthron
parents:
diff changeset
   199
cawthron
parents:
diff changeset
   200
cawthron
parents:
diff changeset
   201
/**
cawthron
parents:
diff changeset
   202
 *	Set up direct label editing implementation for a component with
cawthron
parents:
diff changeset
   203
 *	one editable label
cawthron
parents:
diff changeset
   204
 *	@param prototype the impl prototype to update
cawthron
parents:
diff changeset
   205
 *	@param property the name of the edited property
cawthron
parents:
diff changeset
   206
 *	@param areafunction a function, taking (instance, laf, rect), which returns the
cawthron
parents:
diff changeset
   207
 *		editable area of the label (or null).  If null, the default behavior is
cawthron
parents:
diff changeset
   208
 *		to use the entire rendered area.  Otherwise, the area should be a subset
cawthron
parents:
diff changeset
   209
 *		of rect (which is adjusted to the content area in a form if necessary).
cawthron
parents:
diff changeset
   210
 *	@param fontfunction a function, taking an instance and laf, which returns the
cawthron
parents:
diff changeset
   211
 *		IFont to edit with (or null).  If null, the default behavior is to return
cawthron
parents:
diff changeset
   212
 *		null, indicating a default system font.
cawthron
parents:
diff changeset
   213
 */
cawthron
parents:
diff changeset
   214
function setupCommonEmbeddedDirectLabelEditing(prototype, property,
cawthron
parents:
diff changeset
   215
	areafunction, fontfunction) {
cawthron
parents:
diff changeset
   216
	
cawthron
parents:
diff changeset
   217
	prototype.getPropertyPaths = function(instance) {
cawthron
parents:
diff changeset
   218
		if (property) {
cawthron
parents:
diff changeset
   219
			if (isForm(instance.parent))
cawthron
parents:
diff changeset
   220
				return [ "prompt", property ];
cawthron
parents:
diff changeset
   221
			else if (isSettingItemList(instance.parent))
cawthron
parents:
diff changeset
   222
				return [ "itemTitle", "compulsoryLabel", property ];
cawthron
parents:
diff changeset
   223
			else
cawthron
parents:
diff changeset
   224
				return [ property ];
cawthron
parents:
diff changeset
   225
		} else {
cawthron
parents:
diff changeset
   226
			if (isForm(instance.parent))
cawthron
parents:
diff changeset
   227
				return [ "prompt" ];
cawthron
parents:
diff changeset
   228
			else if (isSettingItemList(instance.parent))
cawthron
parents:
diff changeset
   229
				return [ "itemTitle", "compulsoryLabel" ];
cawthron
parents:
diff changeset
   230
			else
cawthron
parents:
diff changeset
   231
				return [ ];
cawthron
parents:
diff changeset
   232
		}
cawthron
parents:
diff changeset
   233
	}
cawthron
parents:
diff changeset
   234
cawthron
parents:
diff changeset
   235
	prototype.getLabelBounds = function(instance, propertyPath, laf) {
cawthron
parents:
diff changeset
   236
cawthron
parents:
diff changeset
   237
		if (isForm(instance.parent)) {
cawthron
parents:
diff changeset
   238
			var rects = getFormItemRectangles(instance, laf);
cawthron
parents:
diff changeset
   239
			var promptLabelRect = rects[FORM_PROMPT_LABEL_RECT_INDEX];
cawthron
parents:
diff changeset
   240
			var contentRect = rects[FORM_CONTENT_RECT_INDEX];
cawthron
parents:
diff changeset
   241
		
cawthron
parents:
diff changeset
   242
			if (propertyPath == "prompt") {
cawthron
parents:
diff changeset
   243
				return promptLabelRect;
cawthron
parents:
diff changeset
   244
			}
cawthron
parents:
diff changeset
   245
			else if (property && propertyPath == property) {
cawthron
parents:
diff changeset
   246
				rect = contentRect;
cawthron
parents:
diff changeset
   247
				if (areafunction)
cawthron
parents:
diff changeset
   248
					rect = areafunction(instance, laf, rect);
cawthron
parents:
diff changeset
   249
				return rect;
cawthron
parents:
diff changeset
   250
			}
cawthron
parents:
diff changeset
   251
			else /* fall through */ ;
cawthron
parents:
diff changeset
   252
		} else if (isSettingItemList(instance.parent)) {
cawthron
parents:
diff changeset
   253
			var rects = getSettingItemRectangles(instance, laf);
cawthron
parents:
diff changeset
   254
			var titleLabelRect = rects[SIL_TITLE_RECT_INDEX];
cawthron
parents:
diff changeset
   255
			var contentRect = rects[SIL_CONTENT_RECT_INDEX];
cawthron
parents:
diff changeset
   256
		
cawthron
parents:
diff changeset
   257
			if (propertyPath == "itemTitle") {
cawthron
parents:
diff changeset
   258
				return titleLabelRect;
cawthron
parents:
diff changeset
   259
			}
cawthron
parents:
diff changeset
   260
			if (propertyPath == "compulsoryLabel") {
cawthron
parents:
diff changeset
   261
				return rects[SIL_INDICATOR_RECT_INDEX];
cawthron
parents:
diff changeset
   262
			}
cawthron
parents:
diff changeset
   263
			if (property && propertyPath == property) {
cawthron
parents:
diff changeset
   264
				rect = contentRect;
cawthron
parents:
diff changeset
   265
				if (areafunction)
cawthron
parents:
diff changeset
   266
					rect = areafunction(instance, laf, rect);
cawthron
parents:
diff changeset
   267
				return rect;
cawthron
parents:
diff changeset
   268
			}
cawthron
parents:
diff changeset
   269
			/* fall through */
cawthron
parents:
diff changeset
   270
		
cawthron
parents:
diff changeset
   271
		}
cawthron
parents:
diff changeset
   272
cawthron
parents:
diff changeset
   273
		var rect = new Rectangle(0, 0, 
cawthron
parents:
diff changeset
   274
			instance.properties.size.width, instance.properties.size.height);
cawthron
parents:
diff changeset
   275
		
cawthron
parents:
diff changeset
   276
		if (property && propertyPath == property) {
cawthron
parents:
diff changeset
   277
			if (areafunction)
cawthron
parents:
diff changeset
   278
				rect = areafunction(instance, laf, rect);
cawthron
parents:
diff changeset
   279
		
cawthron
parents:
diff changeset
   280
			return rect;
cawthron
parents:
diff changeset
   281
		}
cawthron
parents:
diff changeset
   282
		
cawthron
parents:
diff changeset
   283
		return null;
cawthron
parents:
diff changeset
   284
	}
cawthron
parents:
diff changeset
   285
cawthron
parents:
diff changeset
   286
	prototype.getLabelFont = function(instance, propertyPath, laf) {
cawthron
parents:
diff changeset
   287
		if (propertyPath == "prompt")
cawthron
parents:
diff changeset
   288
			return getPromptFont(laf);
cawthron
parents:
diff changeset
   289
		if (propertyPath == "itemTitle")
cawthron
parents:
diff changeset
   290
			return getTitleFont(laf);
cawthron
parents:
diff changeset
   291
			
cawthron
parents:
diff changeset
   292
		if (property && propertyPath) {
cawthron
parents:
diff changeset
   293
			if (fontfunction)
cawthron
parents:
diff changeset
   294
				return fontfunction(instance, laf);
cawthron
parents:
diff changeset
   295
		}
cawthron
parents:
diff changeset
   296
			
cawthron
parents:
diff changeset
   297
		return null;
cawthron
parents:
diff changeset
   298
	}
cawthron
parents:
diff changeset
   299
}
cawthron
parents:
diff changeset
   300
cawthron
parents:
diff changeset
   301
/**
cawthron
parents:
diff changeset
   302
 *	Support image validation for a form-provided promptImage property.
cawthron
parents:
diff changeset
   303
 */
cawthron
parents:
diff changeset
   304
function setupCommonEmbeddedDirectImageEditing(prototype) {
cawthron
parents:
diff changeset
   305
	setupCommonDirectImageEditing(prototype, "promptImage", 
cawthron
parents:
diff changeset
   306
	
cawthron
parents:
diff changeset
   307
	/* areafunction */
cawthron
parents:
diff changeset
   308
	function (instance, laf, propertyId) {
cawthron
parents:
diff changeset
   309
		if (isForm(instance.parent) &&
cawthron
parents:
diff changeset
   310
			instance.parent.properties.EEikFormShowBitmaps) {
cawthron
parents:
diff changeset
   311
			var rects = getFormItemRectangles(instance, laf);
cawthron
parents:
diff changeset
   312
			return rects[FORM_PROMPT_IMAGE_RECT_INDEX];
cawthron
parents:
diff changeset
   313
		} else {
cawthron
parents:
diff changeset
   314
			return null;
cawthron
parents:
diff changeset
   315
		}
cawthron
parents:
diff changeset
   316
	}
cawthron
parents:
diff changeset
   317
	);
cawthron
parents:
diff changeset
   318
}
cawthron
parents:
diff changeset
   319
cawthron
parents:
diff changeset
   320
/**
cawthron
parents:
diff changeset
   321
 *	Support image property info support for form
cawthron
parents:
diff changeset
   322
 */
cawthron
parents:
diff changeset
   323
function setupEmbeddedImagePropertyInfo(prototype) {
cawthron
parents:
diff changeset
   324
	// IImagePropertyInfo
cawthron
parents:
diff changeset
   325
	prototype.getViewableSize = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   326
		if (propertyId == "promptImage") {
cawthron
parents:
diff changeset
   327
			if (isForm(instance.parent)) {
cawthron
parents:
diff changeset
   328
				// return rect even if prompt is invisible
cawthron
parents:
diff changeset
   329
				var rects = getFormItemRectangles(instance, laf);
cawthron
parents:
diff changeset
   330
				var rect = rects[FORM_PROMPT_IMAGE_RECT_INDEX];
cawthron
parents:
diff changeset
   331
				if (rect != null)
cawthron
parents:
diff changeset
   332
					return new Point(rect.width, rect.height);
cawthron
parents:
diff changeset
   333
			}
cawthron
parents:
diff changeset
   334
		}
cawthron
parents:
diff changeset
   335
		return null;
cawthron
parents:
diff changeset
   336
	}
cawthron
parents:
diff changeset
   337
cawthron
parents:
diff changeset
   338
	prototype.isScaling = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   339
		if (propertyId == "promptImage") {
cawthron
parents:
diff changeset
   340
			return isScalingIcons();
cawthron
parents:
diff changeset
   341
		}
cawthron
parents:
diff changeset
   342
		return true;
cawthron
parents:
diff changeset
   343
	}
cawthron
parents:
diff changeset
   344
	
cawthron
parents:
diff changeset
   345
	prototype.getAlignmentWeights = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   346
		if (propertyId == "promptImage") {
cawthron
parents:
diff changeset
   347
			return new Point(ImageUtils.ALIGN_CENTER_OR_LEFT, ImageUtils.ALIGN_CENTER_OR_TOP);
cawthron
parents:
diff changeset
   348
		}
cawthron
parents:
diff changeset
   349
		return null;
cawthron
parents:
diff changeset
   350
	}
cawthron
parents:
diff changeset
   351
	
cawthron
parents:
diff changeset
   352
	prototype.isPreservingAspectRatio = function(instance, propertyId, laf) {
cawthron
parents:
diff changeset
   353
		if (propertyId == "promptImage") {
cawthron
parents:
diff changeset
   354
			return true;
cawthron
parents:
diff changeset
   355
		}
cawthron
parents:
diff changeset
   356
		return true;
cawthron
parents:
diff changeset
   357
	}
cawthron
parents:
diff changeset
   358
cawthron
parents:
diff changeset
   359
}