S60 3rd Edition SDK for Symbian OS
Example Applications Guide

CLandmarksAppUi Class Reference

#include <LandmarksAppUi.h>

Inheritance diagram for CLandmarksAppUi:

MLandmarksOperationObserver List of all members.

Public Member Functions

 CLandmarksAppUi ()
void ConstructL ()
 ~CLandmarksAppUi ()
void HandleCommandL (TInt aCommand)
TKeyResponse HandleKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
void NotifyOperationProgressL (TOperation aOperation, TInt aProgress, TInt aErrorCode)
void TabChangedL (TInt aIndex)
void DialogDismissedL (TInt aButtonId)

Private Member Functions

void PostConstructL ()
void LaunchProgressDialogL ()

Private Attributes

CAknNavigationDecorator * iNaviDecorator
 decorates the navi pane (with navigation arrows etc)
CLandmarksApplicationEngine * iEngine
 the application engine
CAknProgressDialog * iProgressDialog
TBool iDelayedExit

Detailed Description

An instance of class CLandmarksAppUi is the UserInterface part of the Eikon application framework for the Landmarks reference application

Definition at line 38 of file LandmarksAppUi.h.


Constructor & Destructor Documentation

CLandmarksAppUi::CLandmarksAppUi (   ) 
 

C++ default constructor. This needs to be public due to the way the framework constructs the AppUi.

Definition at line 40 of file LandmarksAppUi.cpp.

00041     {
00042     }

CLandmarksAppUi::~CLandmarksAppUi (   ) 
 

Destructor.

Definition at line 83 of file LandmarksAppUi.cpp.

References iEngine, and iNaviDecorator.

00084     {
00085     delete iNaviDecorator;
00086 
00087     // Cannot delete iEngine here since it is needed when deactivating views.
00088     iEngine = NULL;
00089     }


Member Function Documentation

void CLandmarksAppUi::ConstructL (   ) 
 

Symbian 2nd phase constructor. This needs to be public due to the way the framework constructs the AppUi.

Definition at line 49 of file LandmarksAppUi.cpp.

References iEngine, iNaviDecorator, LaunchProgressDialogL(), CLandmarksApplicationEngine::NewL(), and CLandmarksApplicationEngine::StartInitializeDbIfNecessaryL().

00050     {
00051     BaseConstructL(EAknEnableSkin);
00052 
00053     // Fetch pointer to the status pane.
00054     CEikStatusPane* statusPane = StatusPane();
00055 
00056     // Fetch pointer to the default navi pane control.
00057     CAknNavigationControlContainer* naviPane = 
00058         (CAknNavigationControlContainer*) statusPane->ControlL(
00059             TUid::Uid(EEikStatusPaneUidNavi));
00060 
00061     // Initialise the nave decorator that visualizes the tabs and navi arrows.
00062     iNaviDecorator = naviPane->ResourceDecorator();
00063     CAknTabGroup* tabGroup =
00064         static_cast<CAknTabGroup*>(iNaviDecorator->DecoratedControl());
00065     tabGroup->SetObserver(this);
00066 
00067     // Create and init the application engine.
00068     iEngine = CLandmarksApplicationEngine::NewL();
00069 
00070     // Initialize the default landmark database if necessary.
00071     if (iEngine->StartInitializeDbIfNecessaryL(this))
00072         {
00073         LaunchProgressDialogL();
00074         }
00075     else
00076         {
00077         // Db is already initialized - OK to construct views.
00078         PostConstructL();
00079         }
00080     }

void CLandmarksAppUi::HandleCommandL (  TInt  aCommand  ) 
 

HandleCommandL handles user menu selections.

Parameters:
aCommand the enumerated code for the option selected

Definition at line 97 of file LandmarksAppUi.cpp.

References iProgressDialog.

00098     {
00099     switch(aCommand)
00100         {
00101         case EEikCmdExit:
00102         case EAknSoftkeyExit:
00103             if (iProgressDialog)
00104                 {
00105                 // The progress dialog has been dismissed but not yet deleted.
00106                 // iProgressDialog->ProcessFinishedL() deletes the progress 
00107                 // dialog asynchronously. If the app is exited before the 
00108                 // dialog is deleted, a Cone 8 panic will occur.
00109                 // Thus, iProgressDialog must be deleted explicitely here.
00110                 delete iProgressDialog;
00111                 iProgressDialog = NULL;
00112                 }
00113             Exit();
00114             break;
00115         default:
00116             break;
00117         }
00118     }

TKeyResponse CLandmarksAppUi::HandleKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
) 
 

HandleKeyEventL handles key events.

Parameters:
aKeyEvent Event to handle.
aType Type of the key event.
Returns:
Reponse code (EKeyWasConsumed, EKeyWasNotConsumed).

Definition at line 126 of file LandmarksAppUi.cpp.

References iNaviDecorator.

00128     {
00129     // Offer arrow keys to CAknTabGroup, it then calculates new active tab
00130     // and later calls our TabChangedL() -method with correct new tab index.
00131 
00132     CAknTabGroup* tabGroup = 
00133         static_cast <CAknTabGroup*> (iNaviDecorator->DecoratedControl());
00134 
00135     if (tabGroup &&
00136         (aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow))
00137         {
00138         return tabGroup->OfferKeyEventL(aKeyEvent, aType);
00139         }
00140 
00141     return EKeyWasNotConsumed;
00142     }

void CLandmarksAppUi::NotifyOperationProgressL (  TOperation  aOperation,
TInt  aProgress,
TInt  aErrorCode
)  [virtual]
 

NotifyOperationProgressL notifies the progress and status of an asynchronous operation.

Parameters:
aOperation the type of operation that is reported.
aProgress the progress of the operation.
aErrorCode the status of the operation.

Implements MLandmarksOperationObserver.

Definition at line 165 of file LandmarksAppUi.cpp.

References iProgressDialog, and PostConstructL().

00169     {
00170     if (aOperation == EInitializeDb)
00171         {
00172         // Update Progressbar
00173         CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL();
00174         progressBar->SetAndDraw(aProgress);
00175 
00176         if (aErrorCode == KErrNone) // Db initialization ready.
00177             {
00178             // Dismiss dialog. 
00179             iProgressDialog->ProcessFinishedL();
00180             
00181             // Continue with construction
00182             PostConstructL();
00183             }
00184         }
00185     }

void CLandmarksAppUi::TabChangedL (  TInt  aIndex  ) 
 

Called by NaviDecorator when tab is changed

Parameters:
aIndex new tab seleected

Definition at line 144 of file LandmarksAppUi.cpp.

00145     {
00146     switch (aIndex)
00147         {
00148         case 0:
00149             ActivateLocalViewL(TUid::Uid(ELandmarksViewId));
00150             break;
00151         case 1:
00152             ActivateLocalViewL(TUid::Uid(ELandmarksCategoriesViewId));
00153             break;
00154         default:
00155             break;    
00156         }
00157     }

void CLandmarksAppUi::DialogDismissedL (  TInt  aButtonId  ) 
 

Called when the dialog has been dismissed.

Parameters:
aButtonId the button that was pressed to dismiss the dialog.

Definition at line 223 of file LandmarksAppUi.cpp.

References iProgressDialog.

00224     {
00225     iProgressDialog = NULL;
00226     }

void CLandmarksAppUi::PostConstructL (   )  [private]
 

Performs the construction phase of this object that is dependent that the application engine is initialized.

Definition at line 193 of file LandmarksAppUi.cpp.

References iEngine, iNaviDecorator, CLandmarksInfoView::NewLC(), CLandmarksCategoriesView::NewLC(), and CLandmarksView::NewLC().

00194     {
00195     // Create landmarks view
00196     CLandmarksView* landmarksView = 
00197         CLandmarksView::NewLC(iNaviDecorator, *iEngine);
00198     AddViewL(landmarksView); // Transfer ownership to base class 
00199     CleanupStack::Pop(landmarksView);
00200 
00201     // Create categories view
00202     CLandmarksCategoriesView* categoriesView = 
00203         CLandmarksCategoriesView::NewLC(iEngine); // ownership is transferred
00204     AddViewL(categoriesView); // Transfer ownership to base class 
00205     CleanupStack::Pop(categoriesView);
00206 
00207     // Create landmark info view
00208     CLandmarksInfoView* infoView = 
00209         CLandmarksInfoView::NewLC(iNaviDecorator, *iEngine);
00210     AddViewL(infoView); // Transfer ownership to base class 
00211     CleanupStack::Pop(infoView);
00212 
00213     // Activate landmarks view
00214     landmarksView->ActivateViewL(landmarksView->ViewId());
00215     }

void CLandmarksAppUi::LaunchProgressDialogL (   )  [private]
 

Launches a progress dialog displayed when the default landmark database is initialized.

Definition at line 234 of file LandmarksAppUi.cpp.

References iProgressDialog.

00235     {
00236     // Initialize dialog
00237     TBool showImmediately(ETrue);
00238     iProgressDialog = new (ELeave) CAknProgressDialog(
00239         reinterpret_cast <CEikDialog**> (&iProgressDialog), showImmediately);
00240     iProgressDialog->PrepareLC(R_LMREFAPP_INIT_DB_PROGRESS_DIALOG);
00241     iProgressDialog->SetCallback(this);
00242 
00243     // Initialize progress bar.
00244     CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL();
00245     const TInt KFinalProgressValue = 100;  // 100% done when ready
00246     progressBar->SetFinalValue(KFinalProgressValue);
00247 
00248     // Launch the prepared dialog.
00249     iProgressDialog->RunLD();
00250 
00251     // Draw the progress bar
00252     progressBar->IncrementAndDraw(0);
00253     }


Member Data Documentation

CAknProgressDialog* CLandmarksAppUi::iProgressDialog [private]
 

displays a progress bar when initializing the default landmark database.

Definition at line 140 of file LandmarksAppUi.h.

TBool CLandmarksAppUi::iDelayedExit [private]
 

indicates if exit has been pressed before the progressDialog is fully deleted

Definition at line 144 of file LandmarksAppUi.h.


© Nokia 2006

Back to top