<?xml version="1.0" encoding="UTF-8"?>
<!-- START_USECASES: CU7 END_USECASES -->
<!-- Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -->
<!-- All rights reserved. -->
<!-- This component and the accompanying materials are made available -->
<!-- under the terms of the License "Eclipse Public License v1.0" -->
<!-- which accompanies this distribution, and is available -->
<!-- at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!DOCTYPE componentDefinition [
<!ENTITY CommonMacros SYSTEM "../../CommonMacros.inc">
<!ENTITY FileAndClassMacros SYSTEM "../../FileAndClassMacros.inc">
] >
<componentDefinition xmlns="http://www.nokia.com/sdt/emf/component" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<!-- This component is the abstract base component for
	     all UIQ components
	 -->
	 
	 <!-- TEMPORARY, see below -->

<compoundPropertyDeclaration qualifiedName="com.nokia.sdt.series60.locationProperty">
	<property name="x" type="integer" minValue="-1000" maxValue="1000"
		descriptionKey="xDescription" />
	<property name="y" type="integer" minValue="-1000" maxValue="1000"
		descriptionKey="yDescription" />
</compoundPropertyDeclaration>

<compoundPropertyDeclaration qualifiedName="com.nokia.sdt.series60.sizeProperty">
	<property name="width" type="integer" minValue="0" maxValue="1000"
		descriptionKey="widthDescription" />
	<property name="height" type="integer" minValue="0" maxValue="1000"
		descriptionKey="heightDescription" />
</compoundPropertyDeclaration>

	<component friendlyName="%friendlyName" 
		qualifiedName="com.nokia.carbide.uiq.CommonBase"
		abstract="true"
		version="1.0">

		<symbian sdkName="com.uiq" minSDKVersion="3.0"></symbian>
		
	    <attributes>
	    	<attribute key="not-in-toolbox">true</attribute>
	    </attributes>
		
		<properties>
			<property name="name" type="uniqueName" descriptionKey="nameDescription" category="%category.design"></property>
		</properties>

		<sourceGen>
			&CommonMacros;
			&FileAndClassMacros;

		<inline scope="prototype"><![CDATA[	
			${jsObject}.prototype.getCppClassName = function(instance) {
        return instance.component.attributes["cpp-class-name"];
}
]]>		</inline>
		<inline scope="prototype"><![CDATA[
		 ${jsObject}.prototype.findOrCreateControlUidConstant = function(instance) {

// the algorithm can deal with either CAknView or AvkonViewReference

return Engine.findOrCreateEnumeratorForAlgorithm(instance, ".", 

//"com.nokia.sdt.component.symbian.NAME_ALG_VIEW_UID");
"com.nokia.carbide.uiq.NAME_ALG_CONTROL_ID");
}
		]]>	
		</inline>			
		<inline scope="prototype"><![CDATA[	
			${jsObject}.prototype.isRegistered = function(instance) {
				if (instance.properties.control) {
					var ret = Engine.getGlobalDictionary().get("InstanceGenRegistry").contains(instance.properties.control);
					return ret;					
				}
				return false;
			}
]]>		</inline>
		<inline scope="prototype"><![CDATA[	
			${jsObject}.prototype.register = function(instance) {
				if (instance.properties.control)
					Engine.getGlobalDictionary().get("InstanceGenRegistry").add(instance.properties.control);
			}
]]>		</inline>

		<inline scope="file">
			include("../../srcgenLibrary.js")

			function isSimpleDialog(instance){
				return instance.isInstanceOf("com.nokia.carbide.uiq.CQikSimpleDialog");			
			}				
		</inline>

	<!--Macro for control components source gen -->

		<defineMacro id="SetupControlInstanceVariable">
			<!-- Type of control  -->
			<macroArgument name="Type" />

			<!-- Name of instance member -->
			<macroArgument name="InstanceMemberName" />

			<!-- Name of instance member -->
			<macroArgument name="InstanceTitle" />

			<!-- Importing macro for includes-->
            <importArguments macroName="AddCppIncludes" arguments="Headers Phase"/>			

		    <template form="InstanceGen" phase="ClassPrivateInstanceVariables">
$(Type)* $(InstanceMemberName);
			</template>	

		    <template form="InstanceGen" phase="Initialize"><![CDATA[
$(InstanceMemberName) = LocateControlByUniqueHandle<$(Type)>( ${this.findOrCreateControlUidConstant(instance)} );
if ( $(InstanceMemberName) != NULL )
	{
	$(InstanceMemberName)->SetObserver( this );
	}
]]>
			</template>

			<template form="InstanceGen" phase="Destroy">
<!--<![CDATA[
delete $(InstanceMemberName);-->
<![CDATA[$(InstanceMemberName) = NULL;]]>
			</template>
			<template form="InstanceGen" phase="ForwardDeclarations">
<![CDATA[
class $(Type);
]]>				
			</template>
			
			<template form="InstanceGen" phase="Hrhinclude" ifExpr="isSimpleDialog(instance.parent.parent)">
<![CDATA[#include "${instance.parent.parent.name}.hrh"]]>
			</template>


			<expandMacro name="AddCppIncludes" passArguments="Headers" Phase="MainSystemIncludes"/>																

		</defineMacro>

			<inline>
var childContribs = Engine.generateChildContributions(form);				
contribs.addAll(childContribs);
			</inline>

			
		</sourceGen>
		
	</component>
</componentDefinition>
