phonebookui/Phonebook2/CommonUI/src/CPbk2TabGroupContainer.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Phonebook 2 tab group container.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2TabGroupContainer.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include <CPbk2ViewGraph.h>
       
    23 #include <CPbk2IconInfoContainer.h>
       
    24 #include <CPbk2IconFactory.h>
       
    25 #include <TPbk2IconId.h>
       
    26 #include <MPbk2ViewExplorer.h>
       
    27 #include <CPbk2AppUiBase.h>
       
    28 #include <CPbk2AppViewBase.h>
       
    29 #include <Pbk2UID.h>
       
    30 #include <MPbk2TabGroupContainerCallback.h>
       
    31 
       
    32 // System includes
       
    33 #include <barsread.h>
       
    34 #include <aknnavide.h>
       
    35 #include <akntabgrp.h>
       
    36 #include <AknsConstants.h>
       
    37 #include <AknsUtils.h>
       
    38 #include <eikspane.h>
       
    39 #include <aknnavide.h>
       
    40 
       
    41 // Debugging headers
       
    42 #include <Pbk2Profile.h>
       
    43 
       
    44 /// Unnamed namespace for local definitions
       
    45 namespace {
       
    46 
       
    47 /**
       
    48  * The maximum amount of visible tabs in the tab group.
       
    49  */
       
    50 const TInt KMaxTabsInTabGroup = 4;
       
    51 
       
    52 /**
       
    53  * Returns the topmost tab group.
       
    54  *
       
    55  * @return  Topmost tab group.
       
    56  */
       
    57 CAknTabGroup* GetTabGroupOnTop()
       
    58     {
       
    59     CAknTabGroup* result = NULL;
       
    60 
       
    61     CAknNavigationControlContainer* naviPane =
       
    62         static_cast<CAknNavigationControlContainer*>
       
    63             ( CEikonEnv::Static()->AppUiFactory()->StatusPane()->ControlL
       
    64                 ( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
    65 
       
    66     if ( naviPane )
       
    67         {
       
    68         CAknNavigationDecorator* topDecorator = naviPane->Top();
       
    69         if ( topDecorator &&  topDecorator->ControlType() ==
       
    70                 CAknNavigationDecorator::ETabGroup )
       
    71             {
       
    72             result = static_cast<CAknTabGroup*>(
       
    73                 topDecorator->DecoratedControl() );
       
    74             }
       
    75         }
       
    76     return result;
       
    77     }
       
    78 
       
    79 } /// namespace
       
    80 
       
    81 
       
    82 /**
       
    83  * Phonebook 2 tab group entry.
       
    84  * Responsible for tab groups. Clients may modify the
       
    85  * tab group through this class.
       
    86  */
       
    87 class CPbk2TabGroupContainer::CPbk2TabGroupEntry : public CBase
       
    88     {
       
    89     public: // Construction and destruction
       
    90 
       
    91         /**
       
    92          * Creates a new instance of this class.
       
    93          *
       
    94          * @param aTabGroupId   Tab group id.
       
    95          * @param aTabGroup     Tab group.
       
    96          * @return  A new instance of this class.
       
    97          */
       
    98         static CPbk2TabGroupEntry* NewL(
       
    99                 TPbk2TabGroupId aTabGroupId,
       
   100                 CAknNavigationDecorator* aTabGroup );
       
   101 
       
   102         /**
       
   103          * Destructor.
       
   104          */
       
   105         ~CPbk2TabGroupEntry();
       
   106 
       
   107     public: // Interface
       
   108 
       
   109         /**
       
   110          * Returns the tab group id.
       
   111          *
       
   112          * @return  Tab group id.
       
   113          */
       
   114         inline TPbk2TabGroupId TabGroupId() const;
       
   115 
       
   116         /**
       
   117          * Returns the tab group.
       
   118          *
       
   119          * @return  Tab group.
       
   120          */
       
   121         inline CAknTabGroup* TabGroup() const;
       
   122 
       
   123         /**
       
   124          * Returns the navigation decorator.
       
   125          *
       
   126          * @return  Navigation decorator.
       
   127          */
       
   128         inline CAknNavigationDecorator* Decorator() const;
       
   129 
       
   130     private: // Implementation
       
   131         CPbk2TabGroupEntry(TPbk2TabGroupId aTabGroupId,
       
   132                 CAknNavigationDecorator* aTabGroup );
       
   133 
       
   134     private: // Data
       
   135         /// Own: Phonebook 2 tab group id
       
   136         TPbk2TabGroupId iTabGroupId;
       
   137         /// Own: Avkon tab group
       
   138         CAknNavigationDecorator* iTabGroup;
       
   139     };
       
   140 
       
   141 
       
   142 // --------------------------------------------------------------------------
       
   143 // CPbk2TabGroupEntry::CPbk2TabGroupEntry
       
   144 // --------------------------------------------------------------------------
       
   145 //
       
   146 CPbk2TabGroupContainer::CPbk2TabGroupEntry::CPbk2TabGroupEntry
       
   147         ( TPbk2TabGroupId aTabGroupId, CAknNavigationDecorator* aTabGroup ) :
       
   148             iTabGroupId( aTabGroupId ),
       
   149             iTabGroup( aTabGroup )
       
   150     {
       
   151     }
       
   152 
       
   153 // --------------------------------------------------------------------------
       
   154 // CPbk2TabGroupContainer::CPbk2TabGroupEntry::~CPbk2TabGroupEntry
       
   155 // --------------------------------------------------------------------------
       
   156 //
       
   157 CPbk2TabGroupContainer::CPbk2TabGroupEntry::~CPbk2TabGroupEntry()
       
   158     {
       
   159     delete iTabGroup;
       
   160     }
       
   161 
       
   162 // --------------------------------------------------------------------------
       
   163 // CPbk2TabGroupContainer::CPbk2TabGroupEntry::CPbk2TabGroupEntry
       
   164 // --------------------------------------------------------------------------
       
   165 //
       
   166 CPbk2TabGroupContainer::CPbk2TabGroupEntry*
       
   167         CPbk2TabGroupContainer::CPbk2TabGroupEntry::NewL
       
   168          ( TPbk2TabGroupId aTabGroupId, CAknNavigationDecorator* aTabGroup )
       
   169     {
       
   170     CPbk2TabGroupEntry* self = new ( ELeave ) CPbk2TabGroupEntry
       
   171         ( aTabGroupId, aTabGroup );
       
   172     return self;
       
   173     }
       
   174 
       
   175 // --------------------------------------------------------------------------
       
   176 // CPbk2TabGroupContainer::CPbk2TabGroupEntry::TabGroupId
       
   177 // --------------------------------------------------------------------------
       
   178 //
       
   179 inline TPbk2TabGroupId
       
   180         CPbk2TabGroupContainer::CPbk2TabGroupEntry::TabGroupId() const
       
   181     {
       
   182     return iTabGroupId;
       
   183     }
       
   184 
       
   185 // --------------------------------------------------------------------------
       
   186 // CPbk2TabGroupContainer::CPbk2TabGroupEntry::TabGroup
       
   187 // --------------------------------------------------------------------------
       
   188 //
       
   189 inline CAknTabGroup*
       
   190         CPbk2TabGroupContainer::CPbk2TabGroupEntry::TabGroup() const
       
   191     {
       
   192     return static_cast<CAknTabGroup*>( iTabGroup->DecoratedControl() );
       
   193     }
       
   194 
       
   195 // --------------------------------------------------------------------------
       
   196 // CPbk2TabGroupEntry::Decorator
       
   197 // --------------------------------------------------------------------------
       
   198 //
       
   199 inline CAknNavigationDecorator*
       
   200         CPbk2TabGroupContainer::CPbk2TabGroupEntry::Decorator() const
       
   201     {
       
   202     return iTabGroup;
       
   203     }
       
   204 
       
   205 // --------------------------------------------------------------------------
       
   206 // CPbk2TabGroupContainer::CPbk2TabGroupContainer
       
   207 // --------------------------------------------------------------------------
       
   208 //
       
   209 CPbk2TabGroupContainer::CPbk2TabGroupContainer(
       
   210         MPbk2ViewExplorer& aViewExplorer,
       
   211         MPbk2TabGroupContainerCallback& aCallback ) :
       
   212     iViewExplorer( aViewExplorer ),
       
   213     iCallback ( aCallback )
       
   214     {
       
   215     }
       
   216 
       
   217 // --------------------------------------------------------------------------
       
   218 // CPbk2TabGroupContainer::~CPbk2TabGroupContainer
       
   219 // --------------------------------------------------------------------------
       
   220 //
       
   221 CPbk2TabGroupContainer::~CPbk2TabGroupContainer()
       
   222     {
       
   223     delete iTabIcons;
       
   224     iViewTabGroups.ResetAndDestroy();
       
   225     }
       
   226 
       
   227 // --------------------------------------------------------------------------
       
   228 // CPbk2TabGroup::ConstructL
       
   229 // --------------------------------------------------------------------------
       
   230 //
       
   231 inline void CPbk2TabGroupContainer::ConstructL()
       
   232     {
       
   233     iTabIcons = CPbk2IconInfoContainer::NewL();
       
   234 
       
   235     PBK2_PROFILE_START(Pbk2Profile::ETabGroupCreateTabGroups);
       
   236     // creates all the tab groups and tabs
       
   237     CreateTabGroupsL();
       
   238     PBK2_PROFILE_END(Pbk2Profile::ETabGroupCreateTabGroups);
       
   239 
       
   240     PBK2_PROFILE_START(Pbk2Profile::ETabGroupSkinTabGroups);
       
   241     // skins the created tabs by looping through all of them
       
   242     SkinTabGroupsL();
       
   243     PBK2_PROFILE_END(Pbk2Profile::ETabGroupSkinTabGroups);
       
   244     }
       
   245 
       
   246 // --------------------------------------------------------------------------
       
   247 // CPbk2TabGroupContainer::NewL
       
   248 // --------------------------------------------------------------------------
       
   249 //
       
   250 EXPORT_C CPbk2TabGroupContainer* CPbk2TabGroupContainer::NewL(
       
   251         MPbk2ViewExplorer& aViewExplorer,
       
   252         MPbk2TabGroupContainerCallback& aCallback )
       
   253     {
       
   254     CPbk2TabGroupContainer* self =
       
   255         new ( ELeave ) CPbk2TabGroupContainer( aViewExplorer, aCallback );
       
   256     CleanupStack::PushL( self );
       
   257     self->ConstructL();
       
   258     CleanupStack::Pop( self );
       
   259     return self;
       
   260     }
       
   261 
       
   262 // --------------------------------------------------------------------------
       
   263 // CPbk2TabGroupContainer::TabGroupFromViewId
       
   264 // --------------------------------------------------------------------------
       
   265 //
       
   266 EXPORT_C CAknNavigationDecorator* CPbk2TabGroupContainer::TabGroupFromViewId
       
   267         ( TInt aId ) const
       
   268     {
       
   269     CAknNavigationDecorator* tabGroupDecorator = NULL;
       
   270 
       
   271     // Loop through the view tab groups array
       
   272     const TInt tabGroupCount = iViewTabGroups.Count();
       
   273     for (TInt i = 0; i < tabGroupCount; ++i)
       
   274         {
       
   275         CAknTabGroup* tabGroup = iViewTabGroups[i]->TabGroup();
       
   276         if (tabGroup->TabIndexFromId(aId) >= 0)
       
   277             {
       
   278             CAknNavigationDecorator* decorator =
       
   279                     iViewTabGroups[i]->Decorator();
       
   280             tabGroupDecorator = decorator;
       
   281             break;
       
   282             }
       
   283         }
       
   284 
       
   285     return tabGroupDecorator;
       
   286     }
       
   287 
       
   288 // --------------------------------------------------------------------------
       
   289 // CPbk2TabGroupContainer::HandleNavigationKeyEventL
       
   290 // --------------------------------------------------------------------------
       
   291 //
       
   292 EXPORT_C TBool CPbk2TabGroupContainer::HandleNavigationKeyEventL
       
   293         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   294     {
       
   295     TBool result = EFalse;
       
   296     CAknTabGroup* topTabGroup = GetTabGroupOnTop();
       
   297 
       
   298     if ( topTabGroup )
       
   299         {
       
   300         // Offer key event to be handled to top most tab
       
   301         result = ( topTabGroup->OfferKeyEventL
       
   302             ( aKeyEvent, aType ) == EKeyWasConsumed );
       
   303         }
       
   304 
       
   305     return result;
       
   306     }
       
   307 
       
   308 // --------------------------------------------------------------------------
       
   309 // CPbk2TabGroupContainer::TabIcons
       
   310 // --------------------------------------------------------------------------
       
   311 //
       
   312 EXPORT_C CPbk2IconInfoContainer& CPbk2TabGroupContainer::TabIcons() const
       
   313     {
       
   314     return *iTabIcons;
       
   315     }
       
   316 
       
   317 // --------------------------------------------------------------------------
       
   318 // CPbk2TabGroupContainer::TabChangedL
       
   319 // --------------------------------------------------------------------------
       
   320 //
       
   321 void CPbk2TabGroupContainer::TabChangedL( TInt aIndex )
       
   322     {
       
   323     CAknTabGroup* topTabGroup = GetTabGroupOnTop();
       
   324     if ( topTabGroup )
       
   325         {
       
   326         // View id is stored in the tab
       
   327         const TInt viewId = topTabGroup->TabIdFromIndex( aIndex );
       
   328 
       
   329         MPbk2AppUi* appUi = Phonebook2::Pbk2AppUi();
       
   330 
       
   331         CPbk2ViewState* activeViewState =
       
   332             appUi->ActiveView()->ViewStateLC();
       
   333         iViewExplorer.ActivatePhonebook2ViewL( TUid::Uid( viewId ),
       
   334             activeViewState );
       
   335         CleanupStack::PopAndDestroy( activeViewState );
       
   336         }
       
   337     }
       
   338 
       
   339 // --------------------------------------------------------------------------
       
   340 // CPbk2TabGroupContainer::HandleNaviDecoratorEventL
       
   341 // --------------------------------------------------------------------------
       
   342 //
       
   343 void CPbk2TabGroupContainer::HandleNaviDecoratorEventL( TInt aEventID )
       
   344     {
       
   345     if ( AknLayoutUtils::PenEnabled() )
       
   346         {
       
   347         CAknTabGroup* topTabGroup = GetTabGroupOnTop();
       
   348         if ( topTabGroup )
       
   349             {
       
   350             topTabGroup->HandleNaviDecoratorEventL( aEventID );
       
   351             }
       
   352         }
       
   353     }
       
   354 
       
   355 // --------------------------------------------------------------------------
       
   356 // CPbk2TabGroupContainer::DoCalculateTabGroupWidth
       
   357 // --------------------------------------------------------------------------
       
   358 //
       
   359 TInt CPbk2TabGroupContainer::DoCalculateTabGroupWidth
       
   360         ( TInt aViewCount ) const
       
   361     {
       
   362     TInt width = EAknTabWidthWithOneTab;
       
   363     switch ( aViewCount )
       
   364         {
       
   365         case 1:
       
   366             width = EAknTabWidthWithOneTab;
       
   367             break;
       
   368         case 2:
       
   369             width = EAknTabWidthWithTwoTabs;
       
   370             break;
       
   371         case 3:
       
   372             width = EAknTabWidthWithThreeTabs;
       
   373             break;
       
   374         case 4:
       
   375             width = EAknTabWidthWithFourTabs;
       
   376             break;
       
   377         }
       
   378     if (aViewCount > KMaxTabsInTabGroup)
       
   379         {
       
   380         // n tabs is the maximum amount visible
       
   381         width = EAknTabWidthWithFourTabs;
       
   382         }
       
   383 
       
   384     return width;
       
   385     }
       
   386 
       
   387 // --------------------------------------------------------------------------
       
   388 // CPbk2TabGroupContainer::DoReadViewNodeTabResourcesL
       
   389 // Reads a PBK2_VIEW_NODE_TAB structure, then based on the amount of
       
   390 // views in the tab selects the correct substructure and adds an avkon
       
   391 // tab from the TAB resource
       
   392 // --------------------------------------------------------------------------
       
   393 //
       
   394 void CPbk2TabGroupContainer::DoReadViewNodeTabResourcesL
       
   395         ( const CPbk2ViewNode& aNode, CAknTabGroup& aAknTabGroup,
       
   396           TInt aViewCount )
       
   397     {
       
   398     // Reads PBK2_VIEW_NODE_TAB structure in the
       
   399     // view graph node
       
   400     TResourceReader resReader;
       
   401     CCoeEnv::Static()->CreateResourceReaderLC
       
   402         ( resReader, aNode.TabResourceId() );
       
   403 
       
   404     // Check how many PBK2_VIEW_NODE_TAB elements there are to read
       
   405     const TInt count = resReader.ReadInt16();
       
   406     TBool found = EFalse;
       
   407     // Loop through the resource elements,
       
   408     for ( TInt i = 0; i < count && !found; ++i )
       
   409         {
       
   410         resReader.ReadInt8(); // read version number
       
   411         TInt tabsInGroup = resReader.ReadInt8();
       
   412         TInt tabResourceId = resReader.ReadInt32();
       
   413         TInt iconResId = resReader.ReadInt32();
       
   414         // Check if this resource structure corresponds
       
   415         // to the amount of tabs previously found in the tab group
       
   416         if ( tabsInGroup == aViewCount ||
       
   417              (aViewCount >= KMaxTabsInTabGroup &&
       
   418               tabsInGroup == KMaxTabsInTabGroup))
       
   419             {
       
   420             // Read a TAB structure
       
   421             TResourceReader tabResReader;
       
   422             CCoeEnv::Static()->CreateResourceReaderLC
       
   423                 ( tabResReader, tabResourceId );
       
   424             // Feed structure to Avkon tab group
       
   425             aAknTabGroup.AddTabL( tabResReader );
       
   426             CleanupStack::PopAndDestroy(); // tabResReader
       
   427 
       
   428             // Read the icons
       
   429             if ( iconResId != 0 )
       
   430                 {
       
   431                 // Add icon infos associated with the TAB to the
       
   432                 // icon info container
       
   433                 iTabIcons->AppendIconsFromResourceL(
       
   434                         iconResId );
       
   435                 }
       
   436             }
       
   437         }
       
   438     CleanupStack::PopAndDestroy(); // resReader
       
   439     }
       
   440 
       
   441 // --------------------------------------------------------------------------
       
   442 // CPbk2TabGroupContainer::CreateTabGroupsL
       
   443 // Initializes the tab group from the view graph
       
   444 // --------------------------------------------------------------------------
       
   445 //
       
   446 void CPbk2TabGroupContainer::CreateTabGroupsL()
       
   447     {
       
   448     RArray<TUid> viewIds;
       
   449     CleanupClosePushL( viewIds );
       
   450 
       
   451     // Get the number of nodes in the view graph
       
   452     const TInt nodeCount = iViewExplorer.ViewGraph().Count();
       
   453 
       
   454     // Travel through all the view graph nodes
       
   455     for ( TInt i = 0; i < nodeCount; ++i )
       
   456         {
       
   457         const CPbk2ViewNode& viewNode = iViewExplorer.ViewGraph()[i];
       
   458 
       
   459         // Check the view nodes tab group id and if it exists with
       
   460         // tab resource id, create tabs unless the view has already
       
   461         // been added to some tab group
       
   462         TPbk2TabGroupId tabGroupId = viewNode.TabGroupId();
       
   463         if ( tabGroupId != 0 &&
       
   464              viewNode.TabResourceId() != 0 &&
       
   465              viewIds.Find( viewNode.ViewId() ) == KErrNotFound )
       
   466             {
       
   467             // Get the view graph nodes in the same tab group
       
   468             RPointerArray<CPbk2ViewNode> viewsInTabGroup =
       
   469                     iViewExplorer.ViewGraph().FindViewsInTabGroupL(
       
   470                             tabGroupId );
       
   471             CleanupClosePushL( viewsInTabGroup );
       
   472 
       
   473             // Set up the tab group width
       
   474             const TInt viewsInTabGroupCount = viewsInTabGroup.Count();
       
   475             const TInt tabWidth =
       
   476                 DoCalculateTabGroupWidth( viewsInTabGroupCount );
       
   477 
       
   478             // Create tab group if it does not already exist
       
   479             CAknTabGroup& aknTabGroup = FindTabGroupWithIdL( tabGroupId );
       
   480             aknTabGroup.SetTabFixedWidthL( tabWidth );
       
   481 
       
   482             // Loop through the tab groups' views
       
   483             for ( TInt view = 0; view < viewsInTabGroupCount; ++view )
       
   484                 {
       
   485                 // Get the tab group view node and add its view id to
       
   486                 // the view id array
       
   487                 const CPbk2ViewNode& node = *viewsInTabGroup[view];
       
   488                 viewIds.AppendL( node.ViewId() );
       
   489 
       
   490                 // If there is no tabs TabResourceId() returns 0.
       
   491                 // tabs -resource defaults to 0. 
       
   492                 if (node.TabResourceId() != 0)
       
   493                     {
       
   494                     // Read the view node tab resource structure and
       
   495                     // adds the tabs to the tab group
       
   496                     DoReadViewNodeTabResourcesL
       
   497                         ( node, aknTabGroup, viewsInTabGroupCount );
       
   498                     }
       
   499                 else
       
   500                     {
       
   501                     // tab group resource doesnt exits, ask callback to create tab
       
   502                     iCallback.CreateViewNodeTabL(
       
   503                         node, aknTabGroup, *iTabIcons, viewsInTabGroupCount );
       
   504                     }
       
   505 
       
   506                 }
       
   507             CleanupStack::PopAndDestroy(); // viewInTabGroup
       
   508             }
       
   509         }
       
   510     CleanupStack::PopAndDestroy(); // viewIds
       
   511     }
       
   512 
       
   513 // --------------------------------------------------------------------------
       
   514 // CPbk2TabGroupContainer::FindTabGroupWithIdL
       
   515 // --------------------------------------------------------------------------
       
   516 //
       
   517 CAknTabGroup& CPbk2TabGroupContainer::FindTabGroupWithIdL
       
   518         ( TPbk2TabGroupId aTabGroupId )
       
   519     {
       
   520     CAknTabGroup* result = NULL;
       
   521 
       
   522     // Find the tab group from the container
       
   523     const TInt tabGroupCount = iViewTabGroups.Count();
       
   524     for ( TInt i=0; i < tabGroupCount; ++i )
       
   525         {
       
   526         if ( iViewTabGroups[i]->TabGroupId() == aTabGroupId )
       
   527             {
       
   528             result = iViewTabGroups[i]->TabGroup();
       
   529             break;
       
   530             }
       
   531         }
       
   532 
       
   533     // If the tab group doesnt exists, it is created
       
   534     if ( !result )
       
   535         {
       
   536         CAknNavigationControlContainer* naviPane =
       
   537             static_cast<CAknNavigationControlContainer*>
       
   538                 ( CEikonEnv::Static()->AppUiFactory()->StatusPane()->ControlL
       
   539                     ( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   540 
       
   541         // Create the new tab group
       
   542         CAknNavigationDecorator* newTabGroup =
       
   543                 naviPane->CreateTabGroupL( this );
       
   544         CleanupStack::PushL( newTabGroup );
       
   545         CPbk2TabGroupEntry* entry = CPbk2TabGroupEntry::NewL
       
   546             ( aTabGroupId, newTabGroup );
       
   547         CleanupStack::Pop( newTabGroup );
       
   548         CleanupStack::PushL(entry);
       
   549         iViewTabGroups.AppendL(entry);
       
   550         CleanupStack::Pop( entry );
       
   551         result = static_cast<CAknTabGroup*>
       
   552             ( newTabGroup->DecoratedControl() );
       
   553         }
       
   554 
       
   555     return *result;
       
   556     }
       
   557 
       
   558 // --------------------------------------------------------------------------
       
   559 // CPbk2TabGroupContainer::SkinTabGroupsL
       
   560 // This function loops all the tabs and overrides then if theres a skin
       
   561 // --------------------------------------------------------------------------
       
   562 //
       
   563 void CPbk2TabGroupContainer::SkinTabGroupsL()
       
   564     {
       
   565     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   566 
       
   567     // Travel all the tab groups that have been created
       
   568     const TInt count = iViewTabGroups.Count();
       
   569     for (TInt i = 0; i < count; ++i)
       
   570         {
       
   571         CAknTabGroup& tabGroup = *iViewTabGroups[i]->TabGroup();
       
   572 
       
   573         // loop through the tabs in the tab group
       
   574         const TInt tabCount = tabGroup.TabCount();
       
   575         for (TInt j = 0; j < tabCount; ++j)
       
   576             {
       
   577             TInt tabId = tabGroup.TabIdFromIndex(j);
       
   578             // tabId is used as icon id
       
   579             TPbk2IconId iconId( TUid::Uid(KPbk2UID3), tabId );
       
   580             // Find the icon info from the tab icon info container
       
   581             const CPbk2IconInfo* iconInfo = iTabIcons->Find(iconId);
       
   582             if (iconInfo)
       
   583                 {
       
   584                 CFbsBitmap* bitmap = NULL;
       
   585                 CFbsBitmap* mask = NULL;
       
   586                 CPbk2IconFactory* factory =
       
   587                     CPbk2IconFactory::NewLC( *iTabIcons );
       
   588                 // Load the icon and mask
       
   589                 factory->CreateIconLC(iconId, *skin, bitmap, mask);
       
   590                 // Replace tab with new bitmaps, skin enabled
       
   591                 tabGroup.ReplaceTabL(tabId, bitmap, mask);
       
   592                 CleanupStack::Pop(2); // mask, bitmap
       
   593                 CleanupStack::PopAndDestroy(factory);
       
   594                 }
       
   595             }
       
   596         }
       
   597     }
       
   598 
       
   599 // End of File