<?xml version="1.0" encoding="UTF-8"?>
<!-- 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 LoadAndScaleIconL SYSTEM "../LoadAndScaleIconL.inc">
]>

<componentDefinition xmlns="http://www.nokia.com/sdt/emf/component" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<enumPropertyDeclaration qualifiedName="com.nokia.sdt.series60.CAknListQueryDialogStyle"
			defaultValue="CAknSinglePopupMenuStyleListBox">
		<enumElement value="CAknSinglePopupMenuStyleListBox"/>
		<enumElement value="CAknSingleGraphicPopupMenuStyleListBox"/>
		<enumElement value="CAknSingleHeadingPopupMenuStyleListBox"/>
		<enumElement value="CAknSingleGraphicHeadingPopupMenuStyleListBox"/>
		<enumElement value="CAknDoublePopupMenuStyleListBox"/>
		<enumElement value="CAknDoubleLargeGraphicPopupMenuStyleListBox"/>
		<enumElement value="CAknDouble2PopupMenuStyleListBox"/>
		
		<!-- <enumElement value="CAknSingleGraphicBtPopupMenuStyleListBox"/> -->
	</enumPropertyDeclaration>

	<component baseComponent="com.nokia.sdt.series60.NonLayoutBase" 
		friendlyName="%friendlyName" 
		qualifiedName="com.nokia.sdt.series60.CAknListQueryDialog" 
		category="NotesDialogs"
		instanceNameRoot="listQuery"
		version="1.0">
		<documentation>
			<information>%information</information>
		</documentation>
		<symbian sdkName="com.nokia.series60" minSDKVersion="2.0" 
			className="CAknListQueryDialog" classHelpTopic=""
			resourceType="AVKON_LIST_QUERY" resourceHelpTopic="" />
		<designerImages smallIconFile="CAknListQueryDialog_sm.png" 
			largeIconFile="CAknListQueryDialog.png"/>
		<attributes>
			<attribute key="is-transient-object">true</attribute>
			<attribute key="is-non-resizable-or-moveable-layout-object">true</attribute>
			<attribute key="list-style-enum-property">com.nokia.sdt.series60.CAknListQueryDialogStyle</attribute>
			<attribute key="is-layout-container">true</attribute>
			<attribute key="layout-type">ordered</attribute>
			<attribute key="ordered-layout-type">vertical-row</attribute>
			<attribute key="vertical-scrollable-container">true</attribute>
			<attribute key="container-background-color">EEikColorWindowBackground</attribute>
		</attributes>
		<properties>
			<compoundProperty category="Hidden" name="location" type="com.nokia.sdt.series60.locationProperty"
				editorClass="com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory"/>
			<compoundProperty category="Hidden" name="size" type="com.nokia.sdt.series60.sizeProperty"
				editorClass="com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory"/>

			<enumProperty category="Appearance" name="style" 
				type="com.nokia.sdt.series60.CAknListQueryDialogStyle"
			 	editorClass="com.nokia.sdt.series60.component.listCustomizer.ListLayoutEditorFactory"
			 	descriptionKey="styleDescription" />
				
			<property category="Data" name="text" type="localizedString"
				descriptionKey="textDescription" default="Question"
				editorClass="com.nokia.sdt.symbian.ui.editors.ScalableTextEditorFactory" />
			<enumProperty category="Data" name="tone" 
				type="com.nokia.sdt.series60.Query.tone"
				descriptionKey="toneDescription" />

<!--
			<property category="Behavior" name="hasSearchField"
				descriptionKey="hasSearchFieldDescription"
				type="boolean"
				default="false" />
-->
			
			<arrayProperty name="extraImages" category="Appearance"
				descriptionKey="extraImagesKey"
				type="com.nokia.sdt.symbian.imageProperty" 
				editorClass="com.nokia.sdt.symbian.ui.editors.ImageArrayEditorFactory"
				
				/>

		</properties>
		<implementations>
			<implementation>
				<interface id="com.nokia.sdt.datamodel.adapter.IVisualAppearance"/>
				<interface id="com.nokia.sdt.datamodel.adapter.IDirectLabelEdit"/>
				<interface id="com.nokia.sdt.datamodel.adapter.ILayout"/>
				<interface id="com.nokia.sdt.datamodel.adapter.IQueryContainment"/>
				<interface id="com.nokia.sdt.datamodel.adapter.IScrollBoundsProvider"/>
				<script file="CAknListQueryDialog.js" prototype="CAknListQueryDialog"/>
			</implementation>
			<implementation>
				<interface id="com.nokia.sdt.datamodel.adapter.IComponentInstancePropertyListener"/> 
				<script file="CAknListQueryDialog.js" prototype="CAknListQueryDialog"/>
			</implementation>
			<implementation>
				<interface id="com.nokia.sdt.datamodel.adapter.IComponentValidator"/> 
				<script file="CAknListQueryDialog.js" prototype="CAknListQueryDialog"/>
			</implementation>
			<implementation>
				<interface id="com.nokia.sdt.datamodel.adapter.IComponentCustomizerUI"/>
				<code class="com.nokia.sdt.series60.component.listCustomizer.ListCustomizerUIImplFactory"/>
			</implementation>
		</implementations>
		
		<sourceMapping>
			<mapResource struct="AVKON_LIST_QUERY" headers="avkon.rh">
				<mapBitmaskMember property="." member="flags" includedProperties="" >
					<!-- initial blank entry forces bits on -->
					<mapBitmaskValue properties="" value="EGeneralQueryFlags" />
				</mapBitmaskMember>
				<mapFixedMember value="R_AVKON_SOFTKEYS_OK_CANCEL" member="softkeys" />
		        <mapResourceMember property="." member="items[0]" 
		        		struct="AVKON_LIST_QUERY_DLG_LINE" headers="avkon.rh"  id="single$items[0]">
		        	<mapResourceMember property="." member="control" 
		        			struct="AVKON_LIST_QUERY_CONTROL" headers="avkon.rh"  id="single$control">
						<mapEnumMember property="style" member="listtype">
							<mapEnum value="CAknSinglePopupMenuStyleListBox" enumerator="EAknCtSinglePopupMenuListBox" />
							<mapEnum value="CAknSingleGraphicPopupMenuStyleListBox" enumerator="EAknCtSingleGraphicPopupMenuListBox"/>
							<mapEnum value="CAknSingleHeadingPopupMenuStyleListBox" enumerator="EAknCtSingleHeadingPopupMenuListBox"/>
							<mapEnum value="CAknSingleGraphicHeadingPopupMenuStyleListBox" enumerator="EAknCtSingleGraphicHeadingPopupMenuListBox"/>
							<mapEnum value="CAknDoublePopupMenuStyleListBox" enumerator="EAknCtMenuDoublePopupMenuListBox"/>
							<mapEnum value="CAknDoubleLargeGraphicPopupMenuStyleListBox" enumerator="EAknCtDoubleLargeGraphicPopupMenuListBox"/>
							<mapEnum value="CAknDouble2PopupMenuStyleListBox" enumerator="EAknCtDouble2PopupMenuListBox"/>
						</mapEnumMember>
						<mapSimpleMember property="text" member="heading" />
						<mapResourceMember property="." member="listbox"
							struct="AVKON_LIST_QUERY_LIST"  id="single$listbox" />
			        </mapResourceMember>
		        </mapResourceMember>
			</mapResource>
		</sourceMapping>
		
		<sourceGen>
			<inline scope="prototype">
include("../listbox/listboxLibrary.js")
			</inline>

			<inline>
// gather all the images used in list items for later emission
if (Engine.formMatches(form, [""])) {
	var listBoxImageInfo = getImageList(instance);
	setupListItemImageInfo(instance, listBoxImageInfo);
	setupExtraListImages(instance, listBoxImageInfo);
}
			</inline>

			<template phase="ClassMethods"><![CDATA[
static void Create${instanceName$title}ItemL( 
		TDes& aBuffer,
		${createParameterizedItemLSignature(instance, "\\t\\t")} );
]]>			</template>
			<template phase="ClassMethods"><![CDATA[
static void Create${instanceName$title}ResourceArrayItemL( 
		TDes& aBuffer, 
		TInt aResourceId${getParameterizedItemLNumericColumnParameter(instance)} );
]]>			</template>

			<defineLocation id="CREATEITEML_METHOD" baseLocation="MAIN_FILE" 
				owned="true"
				location="function(${className}::Create${instanceName$title}ItemL(TDes&amp;,...))">
				<template><![CDATA[
/**
 *	Create a list box item with the given column values.
 */
<% 
	var format = getListItemStringFormat(instance);
	var args = getParameterizedItemLFormatArguments(instance);
%>void ${className}::Create${instanceName$title}ItemL( 
		TDes& aBuffer, 
		${createParameterizedItemLSignature(instance, "\\t\\t")} )
	{
	_LIT ( KStringHeader, "${format}" );

	aBuffer.Format( KStringHeader(), ${args} );
	}
]]>				</template>
			</defineLocation>
			
			<template location="CREATEITEML_METHOD" />

			<defineLocation id="CREATERESOURCEITEML_METHOD" baseLocation="MAIN_FILE" 
				owned="true"
				location="function(${className}::Create${instanceName$title}ResourceArrayItemL(TDes&amp;,TInt,...))">
				<template><![CDATA[
/**
 *	Add an item to the list by reading the text items from resource
 *	and setting a single image property (if available) from an index
 *	in the list box's icon array.
 *	@param aResourceId id of an ARRAY resource containing the textual
 *	items in the columns
 *	${getParameterizedItemLNumericColumnComment(instance)}
 */
void ${className}::Create${instanceName$title}ResourceArrayItemL( 
		TDes& aBuffer, 
		TInt aResourceId${getParameterizedItemLNumericColumnParameter(instance)} )
	{
	CDesCArray* array = CCoeEnv::Static()->ReadDesCArrayResourceL( aResourceId );
	CleanupStack::PushL( array );
<% var args = getParameterizedItemLArguments(instance, "array", getParameterizedItemLNumericColumnParameterName(instance) );
%>	Create${instanceName$title}ItemL( aBuffer, ${args} );
	CleanupStack::PopAndDestroy( array );
	}
]]>				</template>
			</defineLocation>
			
		<template location="CREATERESOURCEITEML_METHOD" />

			<template phase="ClassMethods"><![CDATA[
static CDesCArray* Initialize${instanceName$title}LC();
]]>			</template>

			<defineLocation id="INITLISTBOXL_METHOD" baseLocation="MAIN_FILE" 
				owned="true"
				location="function(${className}::Initialize${instanceName$title}LC())">
				<template>
/**
 * Initialize contents of the popup item list.  This constructs the array
 *	and pushes it on the cleanup stack.
 *	@return item array, never null
 */
CDesCArray* ${className}::Initialize${instanceName$title}LC()
	{
	}
				</template>
			</defineLocation>
			
			<template location="INITLISTBOXL_METHOD"><![CDATA[
const int KNumItems = ${instance.children.length};
CDesCArray* itemArray = new ( ELeave ) CDesCArrayFlat( KNumItems ? KNumItems : 1 );
CleanupStack::PushL( itemArray );

// This is intended to be large enough, but if you get 
// a USER 11 panic, consider reducing string sizes.
TBuf< 512 > des;
<%	// generate list item loading for the dialog
	var itemContribs = Engine.generateChildContributions("AknListQueryDialog");
	var addContribs = Engine.getContributionsForPhase(itemContribs, "AddItems");
	Engine.assignLocationsForPhase(addContribs, "AddItems", "INITLISTBOXL_METHOD");
	contribs.addAll(addContribs);
%>return itemArray;
]]>			</template>

		<!-- icon loading -->

		&LoadAndScaleIconL;

		<template phase="ClassMethods"><![CDATA[
static CArrayPtr< CGulIcon >* Setup${instanceName$title}IconsLC();
]]>		</template>

		<defineLocation id="SETUPLISTICONSLC_METHOD" baseLocation="MAIN_FILE"
			owned="true"
			location="function(${className}::Setup${instanceName$title}IconsLC())">
			<template><![CDATA[
/**
 *	Set up the list query's icon array.  If any icons are used, allocates an
 *	icon array, and places it on the cleanup stack. 
 *	@return icon array, or NULL
 */
CArrayPtr< CGulIcon >* ${className}::Setup${instanceName$title}IconsLC()
	{
	}
	
]]>			</template>
		</defineLocation>

		<template location="SETUPLISTICONSLC_METHOD"><![CDATA[
CArrayPtr< CGulIcon >* icons = NULL;
<% // this sets up an icon array and possibly instantiates the LOADANDSCALEICONL_METHOD
getImageList(instance).generateSetupIconArrayL(
		contribs, "icons", "SETUPLISTICONSLC_METHOD", "LOADANDSCALEICONL_METHOD", 
		instance, isScalingIcons());
%>return icons;
]]>		</template>

		<defineLocation id="IMAGE_ENUMS"
			baseLocation="CLASS"
			owned="false"
			location="enum(T${instanceName$title}Images)">
			<template>
enum T${instanceName$title}Images
	{
	};
			</template>
		</defineLocation>
		
		<template location="IMAGE_ENUMS" />
		
		<defineLocation id="IMAGE_ENUMS_BODY"
			baseLocation="IMAGE_ENUMS"
			owned="true"
			location="region(Generated Enums)" />
			
		<template location="IMAGE_ENUMS_BODY"><![CDATA[
${getImageList(instance).generateImageListEnums()}
]]>		</template>
		

		<!-- END icon loading -->

			<template phase="ClassMethods"><![CDATA[
static TInt Run${instanceName$title}L( 
		const TDesC* aOverrideText = NULL, 
		CDesCArray* aOverrideItemArray = NULL,
		CArrayPtr< CGulIcon >* aOverrideIconArray = NULL );
]]>			</template>
			
			<defineLocation id="RUNL_METHOD" baseLocation="MAIN_FILE" 
				owned="true"
				location="function(${className}::Run${instanceName$title}L(const TDesC*, CDesCArray*, CArrayPtr&lt;CGulIcon&gt;*))">
				<template><![CDATA[
/**
 * Show the popup list query dialog for ${instanceName}.
 * <p>
 * You may override the designer-specified items or icons, though generally
 * both should be overridden together.
 * @param aOverrideText optional override text
 * @param aOverrideItemArray if not NULL, the array of formatted list items to display (passes ownership)
 * @param aOverrideIconArray if not NULL, the array of icons to display (passes ownership)
 * @return selected index (>=0) or -1 for Cancel
 */
TInt ${className}::Run${instanceName$title}L( 
		const TDesC* aOverrideText,
		CDesCArray* aOverrideItemArray,
		CArrayPtr< CGulIcon >* aOverrideIconArray )
	{
	}
]]>	
			</template>
			</defineLocation>

			
			<template location="RUNL_METHOD"><![CDATA[
TInt index = 0;
CAknListQueryDialog* queryDialog = NULL;
queryDialog = new ( ELeave ) CAknListQueryDialog( &index );	
CleanupStack::PushL( queryDialog );

queryDialog->PrepareLC( ${resourceName$upper} );
<% if (properties.tone != "ENoTone") { %>
queryDialog->SetTone( CAknQueryDialog::${properties.tone} );	
<% } 
%>if ( aOverrideText != NULL )
	{
	queryDialog->SetHeaderTextL( *aOverrideText );
	}
	
// initialize list items
CDesCArray* itemArray = NULL;

if ( aOverrideItemArray != NULL ) 
	{
	CleanupStack::PushL( aOverrideItemArray );
	itemArray = aOverrideItemArray;
	}
else
	{
	itemArray = Initialize${instanceName$title}LC();
	}
	
queryDialog->SetItemTextArray( itemArray );
queryDialog->SetOwnershipType( ELbmOwnsItemArray );
CleanupStack::Pop( itemArray );

// initialize list icons
CArrayPtr< CGulIcon >* iconArray = NULL;

if ( aOverrideIconArray != NULL )
	{
	CleanupStack::PushL( aOverrideIconArray );
	iconArray = aOverrideIconArray;
	}
else
	{
	iconArray = Setup${instanceName$title}IconsLC();
	}
	
if ( iconArray != NULL ) 
	{
	queryDialog->SetIconArrayL( iconArray );	// passes ownership
	CleanupStack::Pop( iconArray );
	}

// run dialog
TInt result = queryDialog->RunLD();

// clean up
CleanupStack::Pop( queryDialog );

return result == 0 ? -1 : index;
]]>			</template>

			<template phase="MainSystemIncludes"><![CDATA[
#include <aknlistquerydialog.h>
]]>			</template>
			<template phase="MainSystemIncludes"><![CDATA[
#include <akniconarray.h>
]]>			</template>
		</sourceGen>
	</component>
	
</componentDefinition>
