Symbian3/SDK/Source/GUID-2D390781-4467-403D-8FFC-8ED5B2319993.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-2D390781-4467-403D-8FFC-8ED5B2319993" xml:lang="en"><title>Creating
       
    13 the toolbar extension</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>The toolbar extension is intended for expanding fixed and floating toolbars.
       
    15 It is dependent on the parent toolbar it is located in. </p>
       
    16 <p>You must define the toolbar extension in resource definitions. You can
       
    17 add the extension to your toolbar either in resource definitions or dynamically
       
    18 during program execution like other toolbar items.</p>
       
    19 <p>Use the <codeph>AVKON_TOOLBAR_EXTENSION</codeph> resource structure when
       
    20 defining the toolbar extension. The extension structure should be defined
       
    21 in the actual toolbar’s <codeph>TBAR_CTRL</codeph> structure when defining
       
    22 the toolbar items in the resources. If you add the extension dynamically to
       
    23 the toolbar, use the extension structure resource ID when creating it.</p>
       
    24 <p>The example below shows how to add a toolbar extension as the last item
       
    25 to the view toolbar.</p>
       
    26 <codeblock xml:space="preserve">
       
    27 void CMyAppView::AddExtensionToToolbarL()
       
    28     {
       
    29     CAknToolbar* toolbar = Toolbar();
       
    30     if ( toolbar )
       
    31         {
       
    32         CAknToolbarExtension* toolbarExtension = 
       
    33             CAknToolbarExtension::NewL( R_MYAPP_TOOLBAR_EXTENSION );
       
    34         toolbar-&gt;AddItemL( toolbarExtension, EAknCtToolbarExtension, 0, 0 );
       
    35         }
       
    36     }
       
    37 </codeblock>
       
    38 <p> You can also give the icon bitmap and skin ID information in the resource
       
    39 structure. This way you can change the default extension icon to an application
       
    40 specific icon. You can give separate bitmap or skin ID definitions to normal,
       
    41 pressed, and dimmed states.</p>
       
    42 <p>The example below shows the definition of a toolbar extension with a custom
       
    43 icon and three extension buttons.</p>
       
    44 <codeblock xml:space="preserve">
       
    45 RESOURCE AVKON_TOOLBAR_EXTENSION r_myapp_toolbar_extension
       
    46     {
       
    47     
       
    48     bmpFile = AVKON_BITMAP_FILE;
       
    49     bmpId = EMbmAvkonQgn_indi_navi_arrow_left; 
       
    50     bmpMask = EMbmAvkonQgn_indi_navi_arrow_left_mask;
       
    51     bmpSkinIdMajor = EAknsMajorAvkon;
       
    52     bmpSkinIdMinor = EAknsMinorQgnIndiNaviArrowLeft;
       
    53 
       
    54     items =
       
    55         {
       
    56         TBAR_CTRL
       
    57             {
       
    58             type = EAknCtButton;
       
    59             id = ECmdExtFirst;
       
    60             control = AVKON_BUTTON
       
    61                 {
       
    62                 flags = 0;
       
    63                 states =
       
    64                     {
       
    65                     AVKON_BUTTON_STATE
       
    66                         {
       
    67                         extension = r_myapp_toolbar_ext_first;
       
    68                         }  
       
    69                     };
       
    70                 };
       
    71             },
       
    72         TBAR_CTRL
       
    73             {
       
    74             type = EAknCtButton;
       
    75             id = ECmdExtSecond;
       
    76             control = AVKON_BUTTON
       
    77                 {
       
    78                 flags = 0;
       
    79                 states =
       
    80                     {
       
    81                     AVKON_BUTTON_STATE
       
    82                         {
       
    83                         extension = r_myapp_toolbar_ext_second;
       
    84                         }
       
    85                     };
       
    86                 };
       
    87              },
       
    88          TBAR_CTRL
       
    89             {
       
    90             type = EAknCtButton;
       
    91             id = ECmdExtThird;
       
    92             control = AVKON_BUTTON
       
    93                 {
       
    94                 flags = 0;
       
    95                 states =
       
    96                     {
       
    97                     AVKON_BUTTON_STATE
       
    98                         {
       
    99                         extension = r_myapp_toolbar_ext_third;
       
   100                         }  
       
   101                     };
       
   102                 };
       
   103             }
       
   104         };
       
   105     }
       
   106 </codeblock>
       
   107 <p>The toolbar extension events are provided to the observer of the parent
       
   108 toolbar in the same manner as the actual toolbar events. Therefore you don't
       
   109 need to (or are able to) set an observer to the toolbar extension separately.
       
   110 For more information, see <xref href="GUID-7AE34C8A-50C6-49BA-9E43-AE76873B5E12.dita">Handling
       
   111 toolbar item events</xref>.</p>
       
   112 </conbody></concept>