uidesigner/com.nokia.sdt.series60.componentlibrary/components/transient/CAknPreviewPopUp.js
changeset 0 fb279309251b
equal deleted inserted replaced
-1:000000000000 0:fb279309251b
       
     1 /*
       
     2 * Copyright (c) 2009 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 include("../containers/containerLibrary.js")
       
    18 include("../renderLibrary.js")
       
    19 include("../implLibrary.js")
       
    20 include("popupDialogLibrary.js")
       
    21 
       
    22 function CAknPreviewPopUpVisual() {
       
    23 }
       
    24 
       
    25 CAknPreviewPopUpVisual.prototype.draw = function(instance, laf, graphics) {
       
    26 	var properties = instance.properties;
       
    27 	
       
    28 	var rect = new Rectangle(0, 0, properties.size.width, properties.size.height);
       
    29 	
       
    30 	// fill background
       
    31 	graphics.setBackground(getBackgroundColor(instance, laf));
       
    32 	graphics.fillRectangle(rect);
       
    33 
       
    34 	// draw frame
       
    35 	var colorArray = [ null, // no color
       
    36 		Colors.getColor(242,242,242),
       
    37 		Colors.getColor(222,231,247),
       
    38 		Colors.getColor(234,235,234),
       
    39 		Colors.getColor(214,227,239),
       
    40 		Colors.getColor(247,247,255)]
       
    41 	drawFrame(rect, colorArray, graphics);
       
    42 
       
    43 	var contentRect = new Rectangle(6, 6, rect.width - 12, rect.height - 12);
       
    44 	var color = colorFromString(laf, properties.backColor);
       
    45 	if (color != null) {
       
    46 		graphics.setBackground(color);
       
    47 		graphics.fillRectangle(contentRect);
       
    48 	}
       
    49 
       
    50 	if (properties.headingText.length > 0) {
       
    51 		drawPreviewPopUpHeading(instance, graphics, laf);
       
    52 	}
       
    53 }
       
    54 
       
    55 CAknPreviewPopUpVisual.prototype.layout = function(instance, laf) {
       
    56 	var screenSize = laf.getDimension("screen.size");
       
    57 	if (instance.properties.EFixedMode) {
       
    58 		var mainPane = laf.getRectangle("content.pane.bounds");
       
    59 		var portrait = laf.getBoolean("is.portrait", true);
       
    60 		if (portrait) {
       
    61 			instance.properties.location.x = mainPane.x + mainPane.width / 3;
       
    62 		}
       
    63 		else {
       
    64 			instance.properties.location.x = mainPane.x + mainPane.width / 2;
       
    65 		}
       
    66 		instance.properties.location.y = mainPane.y;
       
    67 		instance.properties.size.width = mainPane.width - instance.properties.location.x;
       
    68 		instance.properties.size.height = mainPane.height;
       
    69 	}
       
    70 	else {
       
    71 		// center it if not fixed mode
       
    72 		instance.properties.location.x = (screenSize.x - instance.properties.size.width) / 2;
       
    73 		instance.properties.location.y = (screenSize.y - instance.properties.size.height) / 2;
       
    74 	}
       
    75 }
       
    76 
       
    77 CAknPreviewPopUpVisual.prototype.getPreferredSize = function(instance, laf, wHint, hHint) {
       
    78 	return null;
       
    79 }
       
    80 
       
    81 setupCommonDirectLabelEditing(CAknPreviewPopUpVisual.prototype, 
       
    82 	"headingText", 
       
    83 	null,
       
    84 	function(instance, laf) { return getPreviewPopUpHeadingFont(laf); } 
       
    85 	)
       
    86 
       
    87 //====================================================================================
       
    88 
       
    89 function CAknPreviewPopUpContainment() {
       
    90 }
       
    91 
       
    92 CAknPreviewPopUpContainment.prototype.getAllowedAttribute = function() {
       
    93 	return "is-caknpreviewpopup-content";
       
    94 }
       
    95 
       
    96 setupAttributeBasedQueryContainment(CAknPreviewPopUpContainment.prototype);
       
    97 
       
    98 //====================================================================================
       
    99 
       
   100 function CAknPreviewPopUpInit() {
       
   101 }
       
   102 
       
   103 CAknPreviewPopUpInit.prototype.getClassName = function(instance) {
       
   104 	return "C" + titleCase(instance.properties.name);
       
   105 }
       
   106 
       
   107 CAknPreviewPopUpInit.prototype.initialize = function(instance, isConfigured) {
       
   108 	if (!isConfigured) {
       
   109 		instance.properties.className = this.getClassName(instance);
       
   110 	}
       
   111 }
       
   112 
       
   113 CAknPreviewPopUpInit.prototype.propertyChanged = function(instance, propertyId, laf) {
       
   114 	if (propertyId == "name") {
       
   115 		instance.properties.className = this.getClassName(instance);
       
   116 	}
       
   117 	else if (propertyId == "EFixedMode") {
       
   118 		instance.forceLayout();
       
   119 	}
       
   120 }
       
   121 
       
   122 //====================================================================================
       
   123 
       
   124 function CAknPreviewPopUpEventInfo() {
       
   125 }
       
   126 
       
   127 CAknPreviewPopUpEventInfo.prototype.getEventGroups = function(instance) {
       
   128 	return ["CAknPreviewPopUp"];
       
   129 }
       
   130 
       
   131 CAknPreviewPopUpEventInfo.prototype.getDefaultEventName = function(instance) {
       
   132 	return "handlePointerEvent";
       
   133 }
       
   134 
       
   135 //====================================================================================
       
   136