Symbian3/PDK/Source/GUID-6113CC3B-F994-4AA8-81E9-50433A3266E2.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Fri, 22 Jan 2010 18:26:19 +0000
changeset 1 25a17d01db0c
child 3 46218c8b8afa
permissions -rw-r--r--
Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608

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