Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?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-BC3207BF-9E9F-4BA0-8F01-B72228110A61" xml:lang="en"><title>Accessing
the toolbar from applications or application views</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-6DF3CACC-8A4F-437E-B4A9-59BA7D8974A3"> <p>To access
the current toolbar (<xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknToolbar.html" format="application/java-archive"><codeph>CAknToolbar</codeph></xref>,
defined in <codeph>akntoolbar.h</codeph>) in applications, use
the methods <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknAppUi.html#3fa2b237b46b9074374e352b912a4210" format="application/java-archive"><codeph>CAknAppUi::CurrentPopupToolbar()</codeph></xref> or <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCEikAppUiFactory.html#3fa2b237b46b9074374e352b912a4210" format="application/java-archive"><codeph>CEikAppUiFactory::CurrentPopupToolbar()</codeph></xref> in the case of a floating toolbar. For a fixed toolbar, use <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknAppUi.html#6542dafaefd94c9903fe12385c65a701" format="application/java-archive"><codeph>CAknAppUi::CurrentFixedToolbar()</codeph></xref> or <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCEikAppUiFactory.html#6542dafaefd94c9903fe12385c65a701" format="application/java-archive"><codeph>CEikAppUiFactory::CurrentFixedToolbar()</codeph></xref>. The methods return a pointer to either the application toolbar or
a view-specific toolbar (if defined). </p><p>To access the application toolbar
directly from applications, you can also call <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknAppUi.html#ed75774769dbeb3d960072e333eaa383" format="application/java-archive"><codeph>CAknAppUi::PopupToolbar()</codeph></xref> and <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCEikAppUiFactory.html#ed75774769dbeb3d960072e333eaa383" format="application/java-archive"><codeph>CEikAppUiFactory::PopupToolbar()</codeph></xref>. To access the view-specific
toolbar as a client, call <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknView.html#183e12214247e0b3ca27ed99b8aab396" format="application/java-archive"><codeph>CAknView::Toolbar()</codeph></xref>. These calls do not transfer the ownership
of the toolbar, so the framework takes care of the toolbar destruction.</p></section>
<section id="GUID-CE4304AF-E891-472E-8B30-46ECFE50276B"><p>The example below
shows how to access the toolbar in the application AppUi class. (You can also
use <codeph>CEikAppUiFactory</codeph> methods.)</p><codeblock xml:space="preserve">void CMyAppUi::DoSomethingToToolbar()
{
// Current fixed toolbar (if view has no fixed toolbar, returns application toolbar)
CAknToolbar* fixedToolbar = CurrentFixedToolbar();
// Current popup toolbar (if view has no popup toolbar, returns application toolbar)
CAknToolbar* popupToolbar = CurrentPopupToolbar();
// Application toolbar
CAknToolbar* appToolbar = PopupToolbar();
…
}</codeblock><p>The example below shows how to access a view specific
toolbar in the application view class.</p><codeblock xml:space="preserve">
void CMyView::DoSomethingToToolbar()
{
// View toolbar
CAknToolbar* toolbar = Toolbar();
…
}
</codeblock></section>
</conbody></concept>