Symbian3/PDK/Source/GUID-2D390781-4467-403D-8FFC-8ED5B2319993.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 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". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-2D390781-4467-403D-8FFC-8ED5B2319993" xml:lang="en"><title>Creating
the toolbar extension</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The toolbar extension is intended for expanding fixed and floating toolbars.
It is dependent on the parent toolbar it is located in. </p>
<p>You must define the toolbar extension in resource definitions. You can
add the extension to your toolbar either in resource definitions or dynamically
during program execution like other toolbar items.</p>
<p>Use the <codeph>AVKON_TOOLBAR_EXTENSION</codeph> resource structure when
defining the toolbar extension. The extension structure should be defined
in the actual toolbar’s <codeph>TBAR_CTRL</codeph> structure when defining
the toolbar items in the resources. If you add the extension dynamically to
the toolbar, use the extension structure resource ID when creating it.</p>
<p>The example below shows how to add a toolbar extension as the last item
to the view toolbar.</p>
<codeblock xml:space="preserve">
void CMyAppView::AddExtensionToToolbarL()
    {
    CAknToolbar* toolbar = Toolbar();
    if ( toolbar )
        {
        CAknToolbarExtension* toolbarExtension = 
            CAknToolbarExtension::NewL( R_MYAPP_TOOLBAR_EXTENSION );
        toolbar-&gt;AddItemL( toolbarExtension, EAknCtToolbarExtension, 0, 0 );
        }
    }
</codeblock>
<p> You can also give the icon bitmap and skin ID information in the resource
structure. This way you can change the default extension icon to an application
specific icon. You can give separate bitmap or skin ID definitions to normal,
pressed, and dimmed states.</p>
<p>The example below shows the definition of a toolbar extension with a custom
icon and three extension buttons.</p>
<codeblock xml:space="preserve">
RESOURCE AVKON_TOOLBAR_EXTENSION r_myapp_toolbar_extension
    {
    
    bmpFile = AVKON_BITMAP_FILE;
    bmpId = EMbmAvkonQgn_indi_navi_arrow_left; 
    bmpMask = EMbmAvkonQgn_indi_navi_arrow_left_mask;
    bmpSkinIdMajor = EAknsMajorAvkon;
    bmpSkinIdMinor = EAknsMinorQgnIndiNaviArrowLeft;

    items =
        {
        TBAR_CTRL
            {
            type = EAknCtButton;
            id = ECmdExtFirst;
            control = AVKON_BUTTON
                {
                flags = 0;
                states =
                    {
                    AVKON_BUTTON_STATE
                        {
                        extension = r_myapp_toolbar_ext_first;
                        }  
                    };
                };
            },
        TBAR_CTRL
            {
            type = EAknCtButton;
            id = ECmdExtSecond;
            control = AVKON_BUTTON
                {
                flags = 0;
                states =
                    {
                    AVKON_BUTTON_STATE
                        {
                        extension = r_myapp_toolbar_ext_second;
                        }
                    };
                };
             },
         TBAR_CTRL
            {
            type = EAknCtButton;
            id = ECmdExtThird;
            control = AVKON_BUTTON
                {
                flags = 0;
                states =
                    {
                    AVKON_BUTTON_STATE
                        {
                        extension = r_myapp_toolbar_ext_third;
                        }  
                    };
                };
            }
        };
    }
</codeblock>
<p>The toolbar extension events are provided to the observer of the parent
toolbar in the same manner as the actual toolbar events. Therefore you don't
need to (or are able to) set an observer to the toolbar extension separately.
For more information, see <xref href="GUID-7AE34C8A-50C6-49BA-9E43-AE76873B5E12.dita">Handling
toolbar item events</xref>.</p>
</conbody></concept>