uidesigner/com.nokia.sdt.series60.componentlibrary/components/controls/CAknPopupFieldText.js
changeset 2 d760517a8095
equal deleted inserted replaced
-1:000000000000 2:d760517a8095
       
     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 
       
    20 include("../embeddedControlImplLibrary.js")
       
    21 include("editors/editorLibrary.js")
       
    22 
       
    23 function CAknPopupFieldText() {
       
    24 }
       
    25 
       
    26 CAknPopupFieldText.prototype.getFlags = function(instance, laf) {
       
    27 	return Font.ALIGN_LEFT; 
       
    28 }
       
    29 
       
    30 CAknPopupFieldText.prototype.getFont = function(instance, laf) {
       
    31 	var fontName = instance.properties.font;
       
    32 	return laf.getFont(fontName);
       
    33 }
       
    34 
       
    35 CAknPopupFieldText.prototype.getDisplayText = function(instance) {
       
    36 	var text = "";
       
    37 	var items = instance.properties.items;
       
    38 	if ((items != null) && (items.length > 0)) {
       
    39 		var active = instance.properties.active;
       
    40 		if (items.length > active) {
       
    41 			text = items[active];
       
    42 			if (text == null)
       
    43 				text = "empty";
       
    44 		}
       
    45 		else {
       
    46 			text = instance.properties.invalidText;
       
    47 			if (text == "")
       
    48 				text = "(invalid)";
       
    49 		}
       
    50 	}
       
    51 	else {
       
    52 		var emptyText = instance.properties.emptyText;
       
    53 		if (emptyText != null)
       
    54 			text = emptyText;
       
    55 	}
       
    56 
       
    57 	return text;
       
    58 }
       
    59 
       
    60 CAknPopupFieldText.prototype.getDisplayColor = function(instance, laf) {
       
    61 	var text = "";
       
    62 	var items = instance.properties.items;
       
    63 	if ((items != null) && (items.length > 0)) {
       
    64 		var active = instance.properties.active;
       
    65 		if (active >= items.length) {
       
    66 			return laf.getColor("EEikColorControlDimmedText");
       
    67 		}
       
    68 	}
       
    69 	return null;
       
    70 }
       
    71 
       
    72 CAknPopupFieldText.prototype.getMaxLength = function(instance) {
       
    73 	var items = instance.properties.items;
       
    74 	if ((items != null) && (items.length > 0)) {
       
    75 		var active = instance.properties.active;
       
    76 		if (items.length > active) {
       
    77 			return instance.properties.maxLength;
       
    78 		}
       
    79 	}
       
    80 	return 0;
       
    81 }
       
    82 
       
    83 
       
    84 setupEditorRendering(CAknPopupFieldText.prototype);
       
    85 
       
    86 // no direct label editing, just form prompt editing
       
    87 setupCommonEmbeddedDirectLabelEditing(CAknPopupFieldText.prototype,
       
    88 	null,
       
    89 	null, // areafunction
       
    90 	null
       
    91 );
       
    92 
       
    93 setupCommonEmbeddedDirectImageEditing(CAknPopupFieldText.prototype);
       
    94 setupEmbeddedImagePropertyInfo(CAknPopupFieldText.prototype);
       
    95 
       
    96 //////////////////////
       
    97 
       
    98 		// note that laf will be null if a display model was not created
       
    99 CAknPopupFieldText.prototype.validate = function(instance, laf) {
       
   100 	var properties = instance.properties;
       
   101 
       
   102 	var messages = null;
       
   103 	if (properties.items.length == 0) {
       
   104 		messages = new java.util.ArrayList();	
       
   105 		messages.add(createSimpleModelError(instance, 
       
   106 			"items", 
       
   107 			lookupString("ErrorEmptyList"), 
       
   108 				[instance.name]));
       
   109 	} 
       
   110 	return messages;
       
   111 }
       
   112 
       
   113 	// note that laf will be null if a display model was not created
       
   114 CAknPopupFieldText.prototype.queryPropertyChange = function(instance, propertyPath,
       
   115 				newVal, laf) {
       
   116 				
       
   117 	var properties = instance.properties;
       
   118 	var message = null;
       
   119 
       
   120 	// Don't toss away any changes at this point; otherwise,
       
   121 	// the user will endure a dialog and have it all thrown away.
       
   122 	// Better to let them go back and re-edit.
       
   123 
       
   124 	return message;		
       
   125 }
       
   126 
       
   127 CAknPopupFieldText.prototype.initialize = function(instance, isConfigured) {
       
   128 	if (isConfigured) return;
       
   129 	// make at least one text entry
       
   130 	instance.properties.items[0] = lookupString("InitialItemText");
       
   131 }