Symbian3/SDK/Source/GUID-6113CC3B-F994-4AA8-81E9-50433A3266E2.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

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