Symbian3/PDK/Source/GUID-6113CC3B-F994-4AA8-81E9-50433A3266E2.dita
author Graeme Price <GRAEME.PRICE@NOKIA.COM>
Fri, 15 Oct 2010 14:32:18 +0100
changeset 15 307f4279f433
parent 14 578be2adaf3e
permissions -rw-r--r--
Initial contribution of the Adaptation Documentation.

<?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-6113CC3B-F994-4AA8-81E9-50433A3266E2" xml:lang="en"><title>Adding
and removing toolbar extension items</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The toolbar extension can basically hold the same items as the toolbar
itself. However, the floating toolbar extension can only have focusable buttons.
A fixed toolbar extension does not naturally have focus since its parent toolbar
is not focusing. </p>
<p>The toolbar extension can have a variable number of items. They are located
from the upper left (right in mirrored layout) corner. If all items cannot
fit into the extension, items from the end will be dropped. </p>
<p>You can add items to the toolbar extension in the similar way as to a toolbar,
either by defining <codeph>TBAR_CTRL</codeph> resource structures in the resource
file or adding the items dynamically by using toolbar extension functions.</p>
<p>You can also remove items from the extension.</p>
<p>The example below shows how to add an item to the toolbar extension as
the first item.</p>
<codeblock xml:space="preserve">void CMyAppView::AddItemAsFirstToToolbarExtensionL()
    {
    CAknToolbar* toolbar = Toolbar();
    if ( toolbar )
        {
        CAknToolbarExtension* toolbarExtension = toolbar-&gt;ToolbarExtension();
        if ( toolbarExtension )
            {
            CAknButton* newButton = CAknButton::NewL( R_MYAPP_EXTENSION_BUTTON );
            // Last parameter tells the index at where to add new item
            toolbarExtension-&gt;AddItemL( 
                newButton, EAknCtButton, KExtensionButtonId, 0, 0 );
            }
        }
    }
</codeblock>
<p>The example below shows how to remove an item from the toolbar extension.</p>
<codeblock xml:space="preserve">void CMyAppView::RemoveItemFromToolbarExtensionL()
    {
    CAknToolbar* toolbar = Toolbar();
    if ( toolbar )
        {
        CAknToolbarExtension* toolbarExtension = toolbar-&gt;ToolbarExtension();
        if ( toolbarExtension )
            {
            toolbarExtension-&gt;RemoveItemL( KExtensionButtonId );
            }
        }
    }
</codeblock>
</conbody></concept>