basiclocationinfodisplay/blid/ui/src/CBlidMainView.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2005-2008 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 blid main view class methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDE FILES
       
    20 #include <aknViewAppUi.h>
       
    21 #include <blid.rsg>
       
    22 #include <alf/alfenv.h>
       
    23 #include <alf/alfcontrolgroup.h>
       
    24 #include <alf/alfdisplay.h>
       
    25 #include <alf/alftransformation.h>
       
    26 #include <alf/alfroster.h>
       
    27 // USER INCLUDE FILES
       
    28 #include "CBlidMainView.h"
       
    29 #include "Blid.hrh"
       
    30 #include "CBlidMainControl.h"
       
    31 #include "MBlidLocation.h"
       
    32 #include "CBlidAppUi.h"
       
    33 #include "bliduiconsts.h"
       
    34 #include "Debug.h"
       
    35 
       
    36 //CONSTANTS
       
    37 enum TPanicCode
       
    38     {
       
    39     KBlidNullPointer = 1
       
    40     };
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 // ----------------------------------------------------------------------------
       
    44 // CBlidMainView::NewLC( MKeyProcessor& aKeyProcessor )
       
    45 // Two-phased constructor.
       
    46 // ----------------------------------------------------------------------------
       
    47 //
       
    48 CBlidMainView* CBlidMainView::NewLC( MKeyProcessor& aKeyProcessor,
       
    49 									 CAlfEnv& aEnv  )
       
    50     {
       
    51     CBlidMainView* self = new (ELeave) CBlidMainView( aKeyProcessor,aEnv );
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     return self;
       
    55     }
       
    56 // ----------------------------------------------------------------------------
       
    57 // CBlidMainView::CBlidMainView
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 // ----------------------------------------------------------------------------
       
    61 //
       
    62 CBlidMainView::CBlidMainView( MKeyProcessor& aKeyProcessor ,
       
    63 							  CAlfEnv& aEnv ):
       
    64     CBlidBaseView( aKeyProcessor ),
       
    65     iEnv(aEnv)
       
    66     {
       
    67     }
       
    68 
       
    69 // ----------------------------------------------------------------------------
       
    70 // CBlidMainView::ConstructL
       
    71 // Symbian 2nd phase constructor can leave.
       
    72 // ----------------------------------------------------------------------------
       
    73 //
       
    74 void CBlidMainView::ConstructL()
       
    75     {
       
    76     // Modify the Main view option key
       
    77     BaseConstructL( R_BLID_MAIN_VIEW );
       
    78     
       
    79 	// Create an instance of our list control.
       
    80 	iMainCtrl = CBlidMainControl::NewL(iEnv, ClientRect(), *this );
       
    81 	iMainCtrl->CreateNaviPaneL();
       
    82 
       
    83 	// Create a control group.
       
    84 	iMainCtrlGroup = &( iEnv.NewControlGroupL( KBlidMainGroup ) );
       
    85 
       
    86 	// pass ownership of the list control to the control group
       
    87 	iMainCtrlGroup->AppendL(iMainCtrl);
       
    88 
       
    89     iCtrlDisplay = &( iEnv.NewDisplayL( ClientRect(), CAlfEnv::ENewDisplayAsCoeControl ) );
       
    90 	// Use the Avkon skin background as the display background.
       
    91 	iCtrlDisplay->SetClearBackgroundL(CAlfDisplay::EClearWithSkinBackground);
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CBlidMainView::~CBlidMainView
       
    96 // ----------------------------------------------------------------------------
       
    97 //
       
    98 CBlidMainView::~CBlidMainView()
       
    99     {
       
   100     }
       
   101 
       
   102 // ----------------------------------------------------------------------------
       
   103 // CBlidMainView::ProcessKeyEventL
       
   104 // ----------------------------------------------------------------------------
       
   105 //
       
   106 TBool CBlidMainView::ProcessKeyEventL( const TKeyEvent& aKeyEvent,
       
   107     TEventCode aType )
       
   108     {
       
   109     return CBlidBaseView::ProcessKeyEventL( aKeyEvent,aType );
       
   110     }
       
   111 
       
   112 // ----------------------------------------------------------------------------
       
   113 // TUid CBlidMainView::Id
       
   114 // ----------------------------------------------------------------------------
       
   115 //
       
   116 TUid CBlidMainView::Id() const
       
   117     {
       
   118     return TUid::Uid(EBlidMainView);
       
   119     }
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // CBlidMainView::HandleCommandL
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 void CBlidMainView::HandleCommandL(TInt aCommand)
       
   126     {
       
   127     (static_cast<CBlidAppUi*>(AppUi()))->HandleCommandL( aCommand );
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // CBlidMainView::DoActivateL
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 void CBlidMainView::DoActivateL(
       
   135    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   136    const TDesC8& /*aCustomMessage*/)
       
   137     {
       
   138     #ifdef _DEBUG
       
   139     RDebug::Print(_L("CBlidMainView::DoActivateL() called"));
       
   140     #endif
       
   141 
       
   142     iLocation->SetObserver(*this, EBlidMainView); 
       
   143     iMainCtrl->MakeTitleL( R_BLID_TITLE_MAIN );
       
   144 	
       
   145 	// Show the control group on the display.
       
   146 	iCtrlDisplay->Roster().ShowL( *iMainCtrlGroup );    
       
   147    }
       
   148 
       
   149 // ----------------------------------------------------------------------------
       
   150 // CBlidMainView::DoDeactivate
       
   151 // ----------------------------------------------------------------------------
       
   152 //
       
   153 void CBlidMainView::DoDeactivate()
       
   154     {
       
   155 	// Nothing to do.
       
   156     }
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CBlidMainView::NotifyL
       
   160 // ----------------------------------------------------------------------------
       
   161 //
       
   162 void CBlidMainView::NotifyL( const TBool aOnlineMode )
       
   163     {  
       
   164     if( iMainCtrl &&  aOnlineMode )
       
   165         {
       
   166         iMainCtrl->SetErrorCode( KErrNone );
       
   167         iMainCtrl->SetOnlineMode( aOnlineMode );
       
   168         iMainCtrl->UpdateL();
       
   169         }
       
   170 	DEBUG1(" CBlidMainView::NotifyL called ::%d", aOnlineMode );        
       
   171     CBlidBaseView::NotifyL( aOnlineMode );
       
   172     }
       
   173 
       
   174 // ----------------------------------------------------------------------------
       
   175 // CBlidMainView::NotifyError
       
   176 // ----------------------------------------------------------------------------
       
   177 //
       
   178 void CBlidMainView::NotifyErrorL( TInt aErrorCode )
       
   179     {
       
   180     CBlidBaseView::NotifyErrorL( aErrorCode );    
       
   181     DEBUG1(" CBlidMainView::NotifyErrorL errorcode ::%d", aErrorCode );
       
   182     if( iMainCtrl )
       
   183         {
       
   184         iMainCtrl->SetErrorCode( aErrorCode );
       
   185         iMainCtrl->UpdateL();
       
   186         }
       
   187     }
       
   188 
       
   189 // ----------------------------------------------------------
       
   190 // Handle Resource Change Events: Display orientation switch
       
   191 // ----------------------------------------------------------
       
   192 //
       
   193 void CBlidMainView::HandleResourceChangeL( TInt aType )
       
   194     {
       
   195     if(aType == KEikDynamicLayoutVariantSwitch)
       
   196         {
       
   197         TRect rect;
       
   198         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
   199         
       
   200         // Notify skin of changed display size.
       
   201         iEnv.PrimaryDisplay().SetVisibleArea(rect);
       
   202         iMainCtrl->UpdateDisplayLayoutL();
       
   203         }
       
   204     }
       
   205 
       
   206 CBlidMainControl* CBlidMainView::GetControl()
       
   207     {
       
   208     return iMainCtrl;
       
   209     }
       
   210     
       
   211 #ifdef RD_SCALABLE_UI_V2
       
   212 // ---------------------------------------------------------------------------
       
   213 // CBlidNavigationView::HandleListBoxSelectionL
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void CBlidMainView::HandleListBoxSelectionL()
       
   217     {
       
   218     //Do something if needed
       
   219     }
       
   220 #endif //RD_SCALABLE_UI_V2    
       
   221 // End of File
       
   222 
       
   223