phonebookui/Phonebook/View/src/CPbkSwapContextPaneIcon.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *         Methods for Class which loads Phonebook's or empty icon into context pane.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkSwapContextPaneIcon.h"  // This class
       
    22 #include "PbkUID.h"
       
    23 #include <eikspane.h>   // CEikStatusPane
       
    24 #include <eikimage.h>   // CEikImage
       
    25 #include <akncontext.h> // CAknContextPane
       
    26 #include <PbkView.rsg>  // Phonebook view dll resource IDs
       
    27 #include <AknsUtils.h>
       
    28 #include <AknsControlContext.h>
       
    29 #include <aknconsts.h>	// Context pane bitmap size
       
    30 #include "PbkIconInfo.h"
       
    31 #include "PbkIconId.hrh"
       
    32 #include <layoutmetadata.cdl.h>
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 inline CPbkSwapContextPaneIcon::CPbkSwapContextPaneIcon() : iState( EPhonebookIcon )
       
    37     {
       
    38     }
       
    39 
       
    40 CPbkSwapContextPaneIcon* CPbkSwapContextPaneIcon::NewL(CEikonEnv& aEikonEnv)
       
    41     {
       
    42     CPbkSwapContextPaneIcon* self = new(ELeave) CPbkSwapContextPaneIcon;
       
    43     CleanupStack::PushL(self);
       
    44     self->ConstructL(aEikonEnv);
       
    45     CleanupStack::Pop(self);
       
    46     return self;
       
    47     }
       
    48 void CPbkSwapContextPaneIcon::ConstructL(CEikonEnv& aEikonEnv)
       
    49     {
       
    50     CEikStatusPane* statusPane = aEikonEnv.AppUiFactory()->StatusPane();
       
    51     if (statusPane &&
       
    52         statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidContext)).IsPresent() &&
       
    53         !Layout_Meta_Data::IsLandscapeOrientation())
       
    54         {
       
    55         iContextPane = static_cast<CAknContextPane*>
       
    56             (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext)));
       
    57         SetPhonebookContextPaneIconL();
       
    58         LoadEmptyContextPaneIconL();
       
    59         }
       
    60     }
       
    61 
       
    62 CPbkSwapContextPaneIcon::~CPbkSwapContextPaneIcon()
       
    63     {
       
    64     delete iContextPaneIcon;
       
    65     }
       
    66 
       
    67 void CPbkSwapContextPaneIcon::SetPhonebookContextPaneIconL()
       
    68     {
       
    69     if (iContextPane)
       
    70         {
       
    71         CFbsBitmap* bitmap = NULL;
       
    72         CFbsBitmap* mask = NULL;
       
    73         AknsUtils::CreateAppIconLC( AknsUtils::SkinInstance(),
       
    74             TUid::Uid(KPbkUID3), EAknsAppIconTypeContext,
       
    75             bitmap, mask );
       
    76 
       
    77         iContextPane->SetPicture(bitmap, mask);        
       
    78         CleanupStack::Pop(2); //bitmap, mask
       
    79         }
       
    80     }
       
    81 void CPbkSwapContextPaneIcon::LoadEmptyContextPaneIconL()
       
    82     {
       
    83     if (iContextPane)
       
    84         {
       
    85         CPbkIconInfoContainer* iconInfoContainer =
       
    86 			CPbkIconInfoContainer::NewL(R_PBK_EMPTY_ICON_INFO_ARRAY, CCoeEnv::Static());
       
    87 		CleanupStack::PushL( iconInfoContainer );
       
    88         const TPbkIconInfo* iconInfo = iconInfoContainer->Find( EPbkqgn_menu_empty_cxt );
       
    89 
       
    90         CFbsBitmap* bitmap = NULL;
       
    91         CFbsBitmap* mask = NULL;
       
    92         PbkIconUtils::CreateIconLC(AknsUtils::SkinInstance(), bitmap, mask, *iconInfo);
       
    93         iContextPaneIcon = new(ELeave)CEikImage;
       
    94         iContextPaneIcon->SetNewBitmaps( bitmap, mask );
       
    95         CleanupStack::Pop(2); //bitmap, mask
       
    96         CleanupStack::PopAndDestroy(); //iconInfoContainer
       
    97         }
       
    98     }
       
    99 void CPbkSwapContextPaneIcon::ShowContextPaneIcon( const TSwapState aState )
       
   100     {
       
   101     if ( iState != aState && iContextPane )
       
   102         {
       
   103         iContextPaneIcon = iContextPane->SwapPicture( iContextPaneIcon );        
       
   104         iState = aState;
       
   105         }
       
   106     }
       
   107 
       
   108 //  End of File