S60 3rd Edition SDK for Symbian OS
Example Applications Guide

LandmarksInfoView.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : LandmarksInfoView.cpp
00004 *  Part of     : Landmark Reference Application
00005 *  Interface   : -
00006 *  Description : Implements the CLandmarksInfoView class
00007 *  Version     : 1.0
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <eikmenup.h>
00018 #include <aknviewappui.h>
00019 
00020 #include <LbsPositionInfo.h>
00021 #include <EPos_Landmarks.h>
00022 
00023 #include <LmRefApp.rsg>
00024 #include "LmRefApp.hrh"
00025 #include "LandmarksUtils.h"
00026 #include "LandmarksInfoView.h"
00027 #include "LandmarksApplicationEngine.h"
00028 #include "LandmarksInfoContainer.h"
00029 #include "LandmarksEditDialog.h"
00030 
00031 // ============================ MEMBER FUNCTIONS ===============================
00032 
00033 // -----------------------------------------------------------------------------
00034 // CLandmarksInfoView::CLandmarksInfoView
00035 // C++ constructor can NOT contain any code, that
00036 // might leave.
00037 // -----------------------------------------------------------------------------
00038 //
00039 CLandmarksInfoView::CLandmarksInfoView(
00040     CAknNavigationDecorator* aNaviDecorator,
00041     CLandmarksApplicationEngine& aEngine)
00042 :   iEngine(aEngine), 
00043     iNaviDecorator(aNaviDecorator)
00044     {
00045     // No implementation required
00046     }
00047 
00048 // -----------------------------------------------------------------------------
00049 // CLandmarksInfoView::ConstructL
00050 // Symbian 2nd phase constructor can leave.
00051 // -----------------------------------------------------------------------------
00052 //
00053 void CLandmarksInfoView::ConstructL()
00054     {
00055     BaseConstructL(R_LMREFAPP_INFO_VIEW);
00056     iAppName = iCoeEnv->AllocReadResourceAsDes16L(R_LMREFAPP_APP_TITLE);
00057     }
00058 
00059 // -----------------------------------------------------------------------------
00060 // CLandmarksInfoView::NewLC
00061 // Two-phased constructor.
00062 // -----------------------------------------------------------------------------
00063 //
00064 CLandmarksInfoView* CLandmarksInfoView::NewLC(
00065     CAknNavigationDecorator* aNaviDecorator,
00066     CLandmarksApplicationEngine& aEngine)
00067     {
00068     CLandmarksInfoView* self = new (ELeave) CLandmarksInfoView(
00069         aNaviDecorator, aEngine);
00070     CleanupStack::PushL(self);
00071     self->ConstructL();
00072     return self;
00073     }
00074 
00075 // Destructor
00076 CLandmarksInfoView::~CLandmarksInfoView()
00077     {
00078     delete iContainer;
00079     delete iAppName;
00080     }
00081 
00082 // -----------------------------------------------------------------------------
00083 // CLandmarksInfoView::Id
00084 // 
00085 // (other items were commented in a header).
00086 // -----------------------------------------------------------------------------
00087 //
00088 TUid CLandmarksInfoView::Id() const
00089     {
00090     return TUid::Uid(ELandmarksInfoViewId);
00091     }
00092 
00093 // -----------------------------------------------------------------------------
00094 // CLandmarksInfoView::HandleCommandL
00095 // 
00096 // (other items were commented in a header).
00097 // -----------------------------------------------------------------------------
00098 //
00099 void CLandmarksInfoView::HandleCommandL(TInt aCommand)
00100     {
00101     switch (aCommand)
00102         {
00103         case EAknSoftkeyEdit:
00104             iContainer->EditLandmarkL();
00105             break;
00106 
00107         case EAknSoftkeyBack:
00108             AppUi()->ActivateLocalViewL(TUid::Uid(ELandmarksViewId));
00109             break;
00110 
00111         default:
00112             AppUi()->HandleCommandL(aCommand);
00113             break;
00114         }
00115     }
00116 
00117 // -----------------------------------------------------------------------------
00118 // CLandmarksInfoView::DoActivateL
00119 // 
00120 // (other items were commented in a header).
00121 // -----------------------------------------------------------------------------
00122 //
00123 void CLandmarksInfoView::DoActivateL(
00124     const TVwsViewId& /*aPrevViewId*/,
00125     TUid aCustomMessageId,
00126     const TDesC8& aCustomMessage)
00127     {
00128     __ASSERT_ALWAYS(aCustomMessageId.iUid == ELandmarksViewInfoById,
00129                     LandmarksUtils::Panic(KErrGeneral));
00130     
00131     if (!iContainer)
00132         {
00133         iContainer = new (ELeave) CLandmarksInfoContainer(
00134             *this, iEngine, iNaviDecorator);
00135         iContainer->SetMopParent(this);
00136             iContainer->ConstructL(ClientRect());
00137         }
00138 
00139     iContainer->StoreTitlePaneL();
00140 
00141     // Enable receiving of keyboard events.
00142     AppUi()->AddToStackL(*this, iContainer);
00143 
00144     // custom message contains landmark id
00145     TPckgBuf<TPosLmItemId> lmid;
00146     lmid.Copy(aCustomMessage);
00147     iContainer->LoadLandmarkL(lmid());
00148     
00149     // Make view visible.
00150     iContainer->MakeNaviPaneVisibleL(EFalse);
00151     iContainer->MakeVisible(ETrue);
00152 
00153     // Notify that this view is active
00154     iEngine.NotifyViewActivated(Id(), ETrue);
00155     }
00156 
00157 // -----------------------------------------------------------------------------
00158 // CLandmarksInfoView::DoDeactivate
00159 // 
00160 // (other items were commented in a header).
00161 // -----------------------------------------------------------------------------
00162 //
00163 void CLandmarksInfoView::DoDeactivate()
00164     {
00165     // Hide view.
00166     iContainer->MakeVisible(EFalse);
00167     TInt err = KErrNone;
00168     TRAP(err, iContainer->MakeNaviPaneVisibleL(ETrue));
00169     iContainer->RestoreTitlePane();
00170 
00171     // Notify that this view is inactive
00172     TBool isActive = EFalse;
00173     iEngine.NotifyViewActivated(Id(), isActive);
00174 
00175     // Disable receiving keyboard events.
00176     AppUi()->RemoveFromStack(iContainer);
00177     }
00178 
00179 // End of File
00180 

© Nokia 2006

Back to top