psln/Src/PslnBaseView.cpp
branchRCL_3
changeset 20 d48ab3b357f1
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Provides Psln Application Base view methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "PslnBaseView.h"
       
    22 
       
    23 #include <mpslnfwmsklabelobserver.h>
       
    24 
       
    25 #include <aknnavi.h>
       
    26 #include <aknnavide.h>
       
    27 #include <aknViewAppUi.h>
       
    28 #include <akntitle.h>
       
    29 #include <barsread.h>
       
    30 #include <StringLoader.h>
       
    31 #include <eikbtgpc.h>
       
    32 #include <eikmenup.h>
       
    33 #include <avkon.rsg>
       
    34 
       
    35 #include <psln.rsg>
       
    36 
       
    37 #include "PslnFeatures.h"
       
    38 #include "PslnUi.h"
       
    39 #include "PslnBaseContainer.h"
       
    40 #include "PslnConst.h"
       
    41 
       
    42 // ========================= MEMBER FUNCTIONS ================================
       
    43 // ---------------------------------------------------------------------------
       
    44 // Constructor
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CPslnBaseView::CPslnBaseView()
       
    48     {
       
    49     iPslnUi = static_cast<CPslnUi*>( AppUi() );
       
    50 
       
    51     if ( !iModel )
       
    52         {
       
    53         iModel = iPslnUi->Model();
       
    54         }
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Destructor
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CPslnBaseView::~CPslnBaseView()
       
    62     {
       
    63     if ( iContainer )
       
    64         {
       
    65         if( iPslnUi )
       
    66             {
       
    67             iPslnUi->RemoveFromStack( iContainer );
       
    68             }
       
    69         delete iContainer;
       
    70         }
       
    71     if ( iNaviPaneContext &&
       
    72          iNaviPaneContext != iPslnUi->PslnTabGroup() )
       
    73         {
       
    74         delete iNaviPaneContext;
       
    75         }
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CPslnBaseView::HandleListBoxEventL
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CPslnBaseView::HandleListBoxEventL(
       
    83     CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
    84     {
       
    85     switch ( aEventType )
       
    86         {
       
    87         case EEventEnterKeyPressed:
       
    88         case EEventItemSingleClicked:
       
    89             HandleListBoxSelectionL();
       
    90             break;
       
    91         default:
       
    92            break;
       
    93         }
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CPslnBaseView::DoActivateL
       
    98 // Activates the view.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CPslnBaseView::DoActivateL( const TVwsViewId& aPrevViewId,
       
   102     TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/ )
       
   103     {
       
   104     if( aPrevViewId.iViewUid == Id() &&
       
   105         aPrevViewId.iAppUid == KUidPsln )//same view?
       
   106         {
       
   107         //if continuous activate same view twice,direct return,do nothing
       
   108         return;   
       
   109         }
       
   110         
       
   111     if( iContainer )
       
   112         {
       
   113         RemoveContainer();
       
   114         }
       
   115 
       
   116     CreateContainerL();
       
   117     iPslnUi->AddToStackL( *this, iContainer );
       
   118     iContainer->SetListBoxObserver( this );
       
   119 
       
   120     SetNaviPaneL();
       
   121     TInt titlePaneResourceID = KErrNone;
       
   122     SetTitlePaneL( titlePaneResourceID );
       
   123     // Retrieve title pane and set it.
       
   124     CEikStatusPane* sp = iAvkonAppUi->StatusPane();
       
   125     if ( sp )
       
   126         {
       
   127         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>(
       
   128             sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   129         if ( ( titlePaneResourceID > KErrNone ) && titlePane )
       
   130             {
       
   131             HBufC* titlePaneText = NULL;
       
   132             titlePaneText = StringLoader::LoadLC( titlePaneResourceID );
       
   133             titlePane->SetTextL( titlePaneText->Des() );
       
   134             CleanupStack::PopAndDestroy( titlePaneText );
       
   135             }
       
   136         }
       
   137         
       
   138     CEikButtonGroupContainer* cba = Cba();
       
   139     if (cba)
       
   140         {
       
   141         TInt id = CbaResourceId( aPrevViewId, aCustomMessageId );
       
   142         cba->SetCommandSetL( id );
       
   143         cba->DrawDeferred();
       
   144         }
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CPslnBaseView::DoDeactivate
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CPslnBaseView::DoDeactivate()
       
   152     {
       
   153     if ( iContainer )
       
   154         {
       
   155         iCurrentItem = iContainer->CurrentItemIndex();
       
   156         RemoveContainer();
       
   157         }
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CPslnBaseView::CreateContainerL()
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CPslnBaseView::CreateContainerL()
       
   165     {
       
   166     NewContainerL();
       
   167     iContainer->SetMopParent( this );
       
   168 
       
   169     CPslnBaseContainer* container = iContainer;
       
   170     iContainer = NULL;
       
   171     CleanupStack::PushL( container );
       
   172     container->ConstructL( ClientRect() );
       
   173     CleanupStack::Pop( container );
       
   174     iContainer = container;
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // CPslnBaseView::SetNaviPaneL
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CPslnBaseView::SetNaviPaneL()
       
   182     {
       
   183 #ifndef RD_CONTROL_PANEL
       
   184     CAknNavigationControlContainer* naviPane = iPslnUi->NaviContainer();
       
   185     if ( !naviPane )
       
   186         {
       
   187         return;
       
   188         }
       
   189     if ( iNaviPaneContext )
       
   190         {
       
   191         iPslnUi->NaviContainer()->PushL( *iNaviPaneContext );
       
   192 
       
   193         if ( iNaviPaneContext == iPslnUi->PslnTabGroup() )
       
   194             {
       
   195             iPslnUi->UpdateTabIndex();
       
   196             }
       
   197         }
       
   198     else
       
   199         {
       
   200         iPslnUi->NaviContainer()->PushDefaultL();
       
   201         }
       
   202 #else
       
   203     iPslnUi->NaviContainer()->PushDefaultL();
       
   204 #endif //RD_CONTROL_PANEL
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // Sets middle softkey label.
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 void CPslnBaseView::SetMiddleSoftKeyLabelL(
       
   212     const TInt aResourceId, const TInt aCommandId )
       
   213     {
       
   214     CEikButtonGroupContainer* cbaGroup = Cba();
       
   215     if ( cbaGroup )
       
   216         {
       
   217         HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
       
   218         TPtr mskPtr = middleSKText->Des();
       
   219         cbaGroup->AddCommandToStackL(
       
   220             KPslnMSKControlID,
       
   221             aCommandId,
       
   222             mskPtr );
       
   223         CleanupStack::PopAndDestroy( middleSKText );
       
   224         }
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------------------------
       
   228 // Removes Help if it is not supported.
       
   229 // ---------------------------------------------------------------------------
       
   230 //
       
   231 void CPslnBaseView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   232     {
       
   233     if ( aResourceId == R_PSLN_BASIC_MENUPANE )
       
   234         {
       
   235         if( !PslnFeatures::IsHelpSupported() )
       
   236             {
       
   237             // Disable help if not supported
       
   238             aMenuPane->SetItemDimmed( EPslnCmdAppHelp, ETrue );
       
   239             }
       
   240         }
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // Whether to set right softkey as exit
       
   245 // ---------------------------------------------------------------------------
       
   246 //        
       
   247 TInt CPslnBaseView::CbaResourceId(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/  )
       
   248     {
       
   249     return R_AVKON_SOFTKEYS_OPTIONS_BACK;
       
   250     }
       
   251     
       
   252 // ---------------------------------------------------------------------------
       
   253 // Removes container.
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 void CPslnBaseView::RemoveContainer()
       
   257     {
       
   258     if ( iPslnUi )
       
   259         {
       
   260         iPslnUi->RemoveFromStack( iContainer );
       
   261         }
       
   262     delete iContainer;
       
   263     iContainer = NULL;
       
   264     }
       
   265 
       
   266 //End of File