Symbian3/SDK/Source/GUID-2D390781-4467-403D-8FFC-8ED5B2319993.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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>