Nokia N97 SDK
Example Applications Guide

CMyViewAppUi Class Reference

#include <MyViewAppUi.h>

Inheritance diagram for CMyViewAppUi:

List of all members.

Detailed Description

Application UI class. CAknViewAppUi derives from CAknAppUi and has view handling methods added. Provides support for the following features:

Definition at line 42 of file MyViewAppUi.h.


Public Member Functions

void  ConstructL ()
  ~CMyViewAppUi ()

Private Member Functions

void  DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane)
void  HandleCommandL (TInt aCommand)
virtual TKeyResponse  HandleKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
void  HandleForegroundEventL (TBool aForeground)
virtual void  HandleResourceChangeL (TInt aType)

Private Attributes

CAknNavigationControlContainer *  iNaviPane
CAknTabGroup *  iTabGroup
CAknNavigationDecorator *  iDecoratedTabGroup
TUid  iViewId1
TUid  iViewId2


Constructor & Destructor Documentation

CMyViewAppUi::~CMyViewAppUi (   ) 
 

Destructor.

Definition at line 95 of file MyViewAppUi.cpp.

References iDecoratedTabGroup.

00096     {
00097     delete iDecoratedTabGroup;
00098     }


Member Function Documentation

void CMyViewAppUi::ConstructL (   ) 
 

EPOC default constructor.

Definition at line 44 of file MyViewAppUi.cpp.

References iDecoratedTabGroup, iNaviPane, iTabGroup, iViewId1, and iViewId2.

00045     {
00046     //Initialises this app UI with standard values.
00047     //The application’s standard resource file will be read unless
00048     //the ENoAppResourceFile or ENonStandardResourceFile flags are passed.
00049     BaseConstructL(0x08 | EAknEnableSkin); // Use ELayoutAwareAppFlag (0x08) to make the application support scalable UI on FP3 devices.
00050 
00051 
00052     // Show tabs for main views from resources
00053     CEikStatusPane* sp = StatusPane();
00054 
00055     // Fetch pointer to the default navi pane control
00056     iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(
00057         TUid::Uid(EEikStatusPaneUidNavi));
00058 
00059     // Tabgroup has been read from resource and it was pushed to the navi pane.
00060     // Get pointer to the navigation decorator with the ResourceDecorator() function.
00061     // Application owns the decorator and it has responsibility to delete the object.
00062     iDecoratedTabGroup = iNaviPane->ResourceDecorator();
00063     if (iDecoratedTabGroup)
00064         {
00065         iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
00066         }
00067 
00068     CMyViewView* view1 = new (ELeave) CMyViewView;
00069 
00070     CleanupStack::PushL( view1 );
00071     view1->ConstructL(iTabGroup);
00072     AddViewL( view1 );        // transfer ownership to CAknViewAppUi
00073     CleanupStack::Pop( view1 );
00074     iViewId1 = view1->Id();   // view id to get view from CAknViewAppUi
00075 
00076 
00077     CMyViewView2* view2 = new (ELeave) CMyViewView2;
00078 
00079     CleanupStack::PushL( view2 );
00080     view2->ConstructL();
00081     AddViewL( view2 );      // transfer ownership to CAknViewAppUi
00082     CleanupStack::Pop( view2 );
00083     iViewId2 = view2->Id(); // view id to get view from CAknViewAppUi
00084 
00085 
00086     SetDefaultViewL( *view1 );
00087     }

void CMyViewAppUi::HandleCommandL (  TInt  aCommand  )  [private]
 

From CEikAppUi, takes care of command handling.

Parameters:
aCommand  command to be handled

Definition at line 187 of file MyViewAppUi.cpp.

00188     {
00189     switch ( aCommand )
00190         {
00191         case EEikCmdExit:
00192             {
00193             Exit();
00194             break;
00195             }
00196         // You can add your all application applying commands here.
00197         // You would handle here menu commands that are valid for all views.
00198         }
00199     }

TKeyResponse CMyViewAppUi::HandleKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
)  [private, virtual]
 

From CEikAppUi, handles key events.

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

Definition at line 140 of file MyViewAppUi.cpp.

References iTabGroup.

00142     {
00143     if ( iTabGroup == NULL )
00144         {
00145         return EKeyWasNotConsumed;
00146         }
00147 
00148     TInt active = iTabGroup->ActiveTabIndex();
00149     TInt count = iTabGroup->TabCount();
00150 
00151     switch ( aKeyEvent.iCode )
00152         {
00153         case EKeyLeftArrow:
00154             if ( active > 0 )
00155                 {
00156                 active--;
00157                 iTabGroup->SetActiveTabByIndex( active );
00158                 // ActivateLocalViewL() is used to change the view.
00159                 // To change view from another application we would use ActivateViewL()
00160                 // Send an empty message
00161                 ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
00162                 }
00163             break;
00164         case EKeyRightArrow:
00165             if( (active + 1) < count )
00166                 {
00167                 active++;
00168                 iTabGroup->SetActiveTabByIndex( active );
00169                 // ActivateLocalViewL() is used to change the view.
00170                 // To change view from another application we would use ActivateViewL()
00171                 ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
00172                 }
00173             break;
00174         default:
00175             return EKeyWasNotConsumed;
00176         }
00177 
00178     return EKeyWasConsumed;
00179     }

void CMyViewAppUi::HandleResourceChangeL (  TInt  aType  )  [private, virtual]
 

From CEikAppUi, handles key events.

Parameters:
aType  The type of resources that have changed

Definition at line 206 of file MyViewAppUi.cpp.

References iViewId1, and iViewId2.

00207     {
00208     CAknAppUi::HandleResourceChangeL( aType );
00209 
00210     // ADDED FOR SCALABLE UI SUPPORT
00211     // *****************************
00212     if ( aType==KEikDynamicLayoutVariantSwitch )
00213         {
00214                 ((CMyViewView*) View( iViewId1) )->HandleClientRectChange(  );
00215                 ((CMyViewView2*) View( iViewId2) )->HandleClientRectChange(  );
00216                 }
00217 
00218     }


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top