uifw/AvKon/src/aknview.cpp
changeset 0 2f259fa3e83a
child 9 aabf2c525e0f
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 // AknView.cpp
       
    19 //
       
    20 // Copyright (c) 1997-2001 Symbian Ltd.  All rights reserved.
       
    21 //
       
    22 
       
    23 // INCLUDE FILES
       
    24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    25 #include <uikon/eikdefmacros.h>
       
    26 #endif
       
    27 #include "aknview.h"
       
    28 #include "aknViewAppUi.h"
       
    29 #include "AknPanic.h"
       
    30 #include "avkon.hrh"
       
    31 #include "aknenv.h"
       
    32 #include <eikenv.h>
       
    33 #include <eikapp.h>
       
    34 #include <barsread.h>
       
    35 #include <eikmenub.h>
       
    36 #include <eikcba.h>
       
    37 #include <eikmop.h>
       
    38 #include <eikcolib.h>
       
    39 #include <akntoolbar.h>
       
    40 #include <AknPriv.hrh>
       
    41 
       
    42 #ifdef RD_SCALABLE_UI_V2
       
    43 #include <akntouchpane.h>
       
    44 #endif // RD_SCALABLE_UI_V2
       
    45 
       
    46 #include <AknUtils.h>
       
    47 #include "aknitemactionmenuregister.h"
       
    48 
       
    49 // MODULE DATA STRUCTURES
       
    50 enum TAknViewFlags
       
    51 	{
       
    52 	EAknViewForeground
       
    53 	};
       
    54 
       
    55 
       
    56 // CLASS DECLARATION
       
    57 
       
    58 /**
       
    59 * Extension class.
       
    60 */
       
    61 NONSHARABLE_CLASS(CAknViewExtension) : public CBase
       
    62     {
       
    63     public:
       
    64         static CAknViewExtension* NewL(CAknView* aView);
       
    65         ~CAknViewExtension();
       
    66 
       
    67     private:
       
    68         CAknViewExtension(CAknView* aView);
       
    69         void ConstructL();
       
    70         void ChangeToolbar( CAknToolbar* aOldToolbar ); 
       
    71 
       
    72     public:
       
    73         void CreateToolbarL( TInt aResourceId );
       
    74         void PrepareToolbar();
       
    75         void DestroyToolbars();
       
    76         void StopDisplayingToolbar( TBool aAlways );
       
    77         void StopDisplayingFixedToolbar();
       
    78         CAknToolbar* Toolbar() const;
       
    79         void SetToolbar( CAknToolbar* aToolbar ); 
       
    80         void CreateAndSetToolbarL( TInt aResourceId ); 
       
    81         
       
    82     public:
       
    83         TBool iToolbarVisible; 
       
    84         TBool iToolbarFocusing; 
       
    85         TBool iViewActivated;
       
    86     private: // data
       
    87         CAknToolbar* iToolbar;
       
    88         CAknToolbar* iFixedToolbar;
       
    89         CAknView* iView;
       
    90     };
       
    91 
       
    92 // ============================ MEMBER FUNCTIONS ===============================
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CAknViewExtension::CAknViewExtension
       
    96 // C++ default constructor.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CAknViewExtension::CAknViewExtension(CAknView* aView)
       
   100 : iView(aView)
       
   101 	{
       
   102 	}
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CAknViewExtension::~CAknViewExtension
       
   106 // Destructor.
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 CAknViewExtension::~CAknViewExtension()
       
   110     {
       
   111     DestroyToolbars();
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CAknViewExtension::NewL
       
   116 // Symbian two-phased constructor.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 CAknViewExtension* CAknViewExtension::NewL(CAknView* aView)
       
   120 	{
       
   121 	CAknViewExtension* ext = new ( ELeave ) CAknViewExtension(aView);
       
   122 	CleanupStack::PushL( ext );
       
   123 	ext->ConstructL();
       
   124 	CleanupStack::Pop(); // ext
       
   125 	return ext;
       
   126 	}
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CAknViewExtension::ConstructL
       
   130 // Symbian 2nd stage constructor.
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CAknViewExtension::ConstructL()
       
   134 	{
       
   135 	}
       
   136 	
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CAknViewExtension::CreateToolbarL
       
   140 // toolbar is created from the resource files.
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CAknViewExtension::CreateToolbarL( TInt aResourceId )
       
   144     {
       
   145     if ( aResourceId )
       
   146     	{
       
   147     	if ( !iToolbar )
       
   148         	{
       
   149             iToolbar = CAknToolbar::NewL( aResourceId );
       
   150             iToolbar->SetMopParent( iView );
       
   151     
       
   152 #ifdef RD_SCALABLE_UI_V2
       
   153             CAknTouchPane* touchPane = static_cast<CEikAppUiFactory*>( 
       
   154                 CEikonEnv::Static()->AppUiFactory() )->TouchPane(); 
       
   155             if ( touchPane )
       
   156                 {
       
   157                 iToolbar->SetObserver( touchPane );
       
   158                 }
       
   159 
       
   160             // Checking if toolbar is fixed so setting it to iFixedToolbar
       
   161             if ( iToolbar->ToolbarFlags() & KAknToolbarFixed )
       
   162                 {
       
   163                 iFixedToolbar = iToolbar; 
       
   164                 iToolbar = NULL; 
       
   165                 }
       
   166 
       
   167 #endif // RD_SCALABLE_UI_V2
       
   168             }
       
   169     	}
       
   170     }
       
   171     
       
   172 // -----------------------------------------------------------------------------
       
   173 // CAknViewExtension::PrepareToolbar
       
   174 // application informed and the old toolbar is hidden
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 void CAknViewExtension::PrepareToolbar()
       
   178     {
       
   179     CAknToolbar* oldCurrentToolbar = static_cast<CEikAppUiFactory*>( 
       
   180         CEikonEnv::Static()->AppUiFactory() )->CurrentPopupToolbar();
       
   181 
       
   182     // set view specific toolbar	
       
   183     static_cast<CEikAppUiFactory*>( 
       
   184         CEikonEnv::Static()->AppUiFactory() )->SetViewPopupToolbar( iToolbar );
       
   185 
       
   186     CAknToolbar* newToolbar = static_cast<CEikAppUiFactory*>( 
       
   187         CEikonEnv::Static()->AppUiFactory() )->CurrentPopupToolbar();
       
   188 
       
   189     if ( oldCurrentToolbar && oldCurrentToolbar != newToolbar )
       
   190         {
       
   191         oldCurrentToolbar->SetToolbarVisibility( EFalse );
       
   192         }
       
   193     
       
   194     if ( newToolbar )
       
   195         {
       
   196 #ifdef RD_SCALABLE_UI_V2
       
   197         if ( !iToolbarFocusing && iToolbarVisible )
       
   198             {
       
   199             newToolbar->SetToolbarVisibility( ETrue, EFalse ); 
       
   200             }
       
   201         else 
       
   202 #endif //RD_SCALABLE_UI_V2
       
   203             {
       
   204             newToolbar->SetToolbarVisibility( iToolbarVisible ); 
       
   205             }
       
   206         }
       
   207 
       
   208 #ifdef RD_SCALABLE_UI_V2
       
   209         
       
   210     // Here is code for fixed toolbar
       
   211     CAknToolbar* oldFixedToolbar = static_cast<CEikAppUiFactory*>( 
       
   212         CEikonEnv::Static()->AppUiFactory() )->CurrentFixedToolbar();
       
   213 
       
   214     // set view specific fixed toolbar	
       
   215     static_cast<CEikAppUiFactory*>( 
       
   216         CEikonEnv::Static()->AppUiFactory() )->SetViewFixedToolbar( iFixedToolbar );
       
   217 
       
   218     CAknToolbar* newFixedToolbar = static_cast<CEikAppUiFactory*>( 
       
   219         CEikonEnv::Static()->AppUiFactory() )->CurrentFixedToolbar();
       
   220 
       
   221     if ( newFixedToolbar )
       
   222         {
       
   223         newFixedToolbar->HandleResourceChange( KAknToolbarSetVisible );
       
   224         }
       
   225 
       
   226     if ( oldFixedToolbar && oldFixedToolbar != newFixedToolbar )
       
   227         {
       
   228         
       
   229         if ( newFixedToolbar && newFixedToolbar->ToolbarFlags() & KAknToolbarDefault )
       
   230         	{
       
   231         	oldFixedToolbar->HandleResourceChange( KAknToolbarSetHiddenAndDrawBackground );
       
   232         	return;
       
   233         	}
       
   234         
       
   235         oldFixedToolbar->HandleResourceChange( KAknToolbarSetHidden );         
       
   236         }
       
   237 #endif 
       
   238     }
       
   239     
       
   240 // -----------------------------------------------------------------------------
       
   241 // CAknViewExtension::DestroyToolbar
       
   242 // toolbar is created from the resource files.
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 void CAknViewExtension::DestroyToolbars()
       
   246     {
       
   247     delete iToolbar;
       
   248     iToolbar = NULL;
       
   249     
       
   250     static_cast<CEikAppUiFactory*>( 
       
   251         CEikonEnv::Static()->AppUiFactory() )->SetViewPopupToolbar( NULL );
       
   252 
       
   253     delete iFixedToolbar; 
       
   254     iFixedToolbar = NULL; 
       
   255     
       
   256     }
       
   257     
       
   258     
       
   259 // -----------------------------------------------------------------------------
       
   260 // CAknViewExtension::StopDisplayingToolbar
       
   261 // toolbar is hidden.
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 void CAknViewExtension::StopDisplayingToolbar( TBool aAlways )
       
   265     {
       
   266     if ( iToolbar )
       
   267         {
       
   268         if ( aAlways || ( iToolbar->ToolbarFlags() & KAknToolbarFixed ) )
       
   269             {
       
   270             iToolbar->SetToolbarVisibility( EFalse );
       
   271             }
       
   272         }
       
   273     }
       
   274     
       
   275 // -----------------------------------------------------------------------------
       
   276 // CAknViewExtension::TryDisplayToolbar
       
   277 // Toolbar is hidden.
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 void CAknViewExtension::StopDisplayingFixedToolbar()
       
   281     {
       
   282     if ( iFixedToolbar )
       
   283         {
       
   284         iFixedToolbar->SetToolbarVisibility( EFalse );
       
   285         }
       
   286     }
       
   287     
       
   288 // -----------------------------------------------------------------------------
       
   289 // CAknViewExtension::Toolbar
       
   290 // Return toolbar object, either floating of fixed
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 CAknToolbar* CAknViewExtension::Toolbar() const
       
   294     {
       
   295     if ( iToolbar )
       
   296         {
       
   297         return iToolbar;
       
   298         }
       
   299     else
       
   300         {
       
   301         return iFixedToolbar; 
       
   302         }
       
   303     }
       
   304 
       
   305 
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CAknViewExtension::SetToolbar
       
   309 // Sets toolbar for view
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 void CAknViewExtension::SetToolbar( CAknToolbar* aToolbar )
       
   313     {
       
   314     CAknToolbar* oldToolbar = NULL; 
       
   315     if ( iToolbar )
       
   316         {
       
   317         oldToolbar = iToolbar;
       
   318         iToolbar = NULL;
       
   319         }
       
   320     if ( iFixedToolbar )
       
   321         {
       
   322         oldToolbar = iFixedToolbar; 
       
   323         iFixedToolbar = NULL; 
       
   324         }
       
   325     if ( aToolbar && aToolbar->ToolbarFlags() & KAknToolbarFixed )
       
   326         {
       
   327         iFixedToolbar = aToolbar; 
       
   328         }
       
   329     else if ( aToolbar )
       
   330         {
       
   331         iToolbar = aToolbar; 
       
   332         }
       
   333 
       
   334     ChangeToolbar( oldToolbar ); 
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CAknViewExtension::CreateAndSetToolbar
       
   339 // Creates and sets toolbar for the view
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 void CAknViewExtension::CreateAndSetToolbarL( TInt aResourceId )
       
   343     {
       
   344     CAknToolbar* oldToolbar = NULL; 
       
   345     if ( iToolbar )
       
   346         {
       
   347         oldToolbar = iToolbar;
       
   348         iToolbar = NULL;  
       
   349         }
       
   350     if ( iFixedToolbar )
       
   351         {
       
   352         oldToolbar = iFixedToolbar; 
       
   353         iFixedToolbar = NULL; 
       
   354         }
       
   355         
       
   356     CreateToolbarL( aResourceId ); 
       
   357 
       
   358     ChangeToolbar( oldToolbar ); 
       
   359     }
       
   360 
       
   361 
       
   362 // -----------------------------------------------------------------------------
       
   363 // CAknViewExtension::ChangeToolbar
       
   364 // Changes current toolbar. If old toolbar was visible, then the new will 
       
   365 // also be shown. 
       
   366 // -----------------------------------------------------------------------------
       
   367 //
       
   368 void CAknViewExtension::ChangeToolbar( CAknToolbar* aOldToolbar )
       
   369     {
       
   370     TBool shown(EFalse); 
       
   371     if ( aOldToolbar )
       
   372         {
       
   373         if ( aOldToolbar->IsShown() )
       
   374             {
       
   375             shown = ETrue; 
       
   376             }
       
   377         }
       
   378 
       
   379     if ( iToolbar )
       
   380         {
       
   381         static_cast<CEikAppUiFactory*>( 
       
   382             CEikonEnv::Static()->AppUiFactory() )->SetViewPopupToolbar( iFixedToolbar );
       
   383 
       
   384         if ( shown )
       
   385             {
       
   386 #ifdef RD_SCALABLE_UI_V2
       
   387             iToolbar->SetToolbarVisibility( ETrue, iToolbarFocusing ); 
       
   388 #endif //RD_SCALABLE_UI_V2
       
   389             iToolbar->SetToolbarVisibility( ETrue ); 
       
   390             }
       
   391         }
       
   392     if ( iFixedToolbar )
       
   393         {
       
   394         static_cast<CEikAppUiFactory*>( 
       
   395             CEikonEnv::Static()->AppUiFactory() )->SetViewFixedToolbar( iFixedToolbar );
       
   396         if ( shown )
       
   397             {
       
   398             iFixedToolbar->HandleResourceChange( KAknToolbarSetVisible );
       
   399             }
       
   400         }
       
   401 
       
   402     delete aOldToolbar; 
       
   403     aOldToolbar = NULL; 
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CAknView::CAknView
       
   408 // C++ default constructor.
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 EXPORT_C CAknView::CAknView() : iCoeEnv( CCoeEnv::Static() ), 
       
   412   iAppUi( (CAknViewAppUi*)(CEikonEnv::Static()->EikAppUi()) )
       
   413 	{
       
   414 	}
       
   415 
       
   416 // -----------------------------------------------------------------------------
       
   417 // CAknView::~CAknView
       
   418 // Destructor.
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 EXPORT_C CAknView::~CAknView()
       
   422 	{
       
   423 	if ( iMenu )
       
   424 		{
       
   425 		iAppUi->RemoveFromStack( iMenu );
       
   426 		delete iMenu;
       
   427 		}
       
   428 
       
   429 	delete iCba;
       
   430 	delete iExtension;
       
   431 	}
       
   432 
       
   433 // -----------------------------------------------------------------------------
       
   434 // CAknView::BaseConstructL
       
   435 // Second-phase base class constructor. Must be called from a derived classes
       
   436 // second stage construction function.
       
   437 // -----------------------------------------------------------------------------
       
   438 //
       
   439 EXPORT_C void CAknView::BaseConstructL( TInt aResId )
       
   440 	{
       
   441 	iExtension = CAknViewExtension::NewL( this );
       
   442 
       
   443 	if ( aResId )
       
   444 		{
       
   445 		// If this assert fails, you have probably constructed your view twice
       
   446 		ASSERT(!iViewInfo.iMenu && !iViewInfo.iCba && !iViewInfo.iHotKeys);
       
   447 
       
   448         TResourceReader r;
       
   449         iCoeEnv->CreateResourceReaderLC( r, aResId );
       
   450 
       
   451         iViewInfo.iVersion = r.ReadInt8();
       
   452         iViewInfo.iHotKeys = r.ReadInt32();
       
   453         iViewInfo.iMenu = r.ReadInt32();
       
   454         iViewInfo.iCba = r.ReadInt32();
       
   455         iViewInfo.iToolbar = r.ReadInt32();
       
   456         r.ReadInt32(); // extension
       
   457         CleanupStack::PopAndDestroy(); // r
       
   458         }
       
   459         
       
   460     Extension()->CreateToolbarL( iViewInfo.iToolbar );
       
   461 
       
   462     if ( iViewInfo.iMenu )
       
   463         {
       
   464         AknItemActionMenuRegister::SetConstructingMenuBarOwnerL( this );
       
   465         }
       
   466     }
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // CAknView::AppUi
       
   470 // Accessor for the app UI as a CAknViewAppUi.
       
   471 // -----------------------------------------------------------------------------
       
   472 //
       
   473 EXPORT_C CAknViewAppUi* CAknView::AppUi() const
       
   474 	{
       
   475 	return iAppUi;
       
   476 	}
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // CAknView::ActivateViewL
       
   480 // Activates any view in the product.
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 EXPORT_C void CAknView::ActivateViewL( const TVwsViewId& aViewId )
       
   484 	{
       
   485 	// this is here to assert that BaseConstructL has been called properly.
       
   486 	Extension();
       
   487 
       
   488 	iAppUi->ActivateViewL( aViewId );
       
   489 	}
       
   490 
       
   491 // -----------------------------------------------------------------------------
       
   492 // CAknView::ActivateViewL
       
   493 // Activates any view in the product and passes a message.
       
   494 // -----------------------------------------------------------------------------
       
   495 //
       
   496 EXPORT_C void CAknView::ActivateViewL( const TVwsViewId& aViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage )
       
   497 	{
       
   498 	iAppUi->ActivateViewL( aViewId, aCustomMessageId, aCustomMessage );
       
   499 	}
       
   500 
       
   501 // -----------------------------------------------------------------------------
       
   502 // CAknView::StatusPane
       
   503 // Status pane accessor method.
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 EXPORT_C CEikStatusPane* CAknView::StatusPane() const
       
   507 	{
       
   508 	return iAppUi->StatusPane();
       
   509 	}
       
   510 
       
   511 // -----------------------------------------------------------------------------
       
   512 // CAknView::Cba
       
   513 // CBA accessor method. This returns view's CBA if there is one. Otherwise UI's
       
   514 // CBA is returned.
       
   515 // -----------------------------------------------------------------------------
       
   516 //
       
   517 EXPORT_C CEikButtonGroupContainer* CAknView::Cba() const
       
   518 	{
       
   519 	if ( iCba )
       
   520 	    {
       
   521 		return iCba;
       
   522 	    }
       
   523 
       
   524 	return iAppUi->Cba();
       
   525 	}
       
   526 
       
   527 // -----------------------------------------------------------------------------
       
   528 // CAknView::HandleStatusPaneSizeChange
       
   529 // Event handler for status pane size changes. The default implementation is
       
   530 // empty.
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 EXPORT_C void CAknView::HandleStatusPaneSizeChange()
       
   534 	{
       
   535 	}
       
   536 
       
   537 // -----------------------------------------------------------------------------
       
   538 // CAknView::SetEmphasis
       
   539 // Menu emphasis function.
       
   540 // -----------------------------------------------------------------------------
       
   541 //
       
   542 EXPORT_C void CAknView::SetEmphasis( CCoeControl* aMenuControl, TBool aEmphasis )
       
   543 	{
       
   544 	iAppUi->UpdateStackedControlFlags( aMenuControl, aEmphasis? 0: ECoeStackFlagRefusesFocus, ECoeStackFlagRefusesFocus );
       
   545 	iAppUi->HandleStackChanged();
       
   546 	}
       
   547 
       
   548 // -----------------------------------------------------------------------------
       
   549 // CAknView::ViewActivatedL
       
   550 // Handles a view activation event from viewserv.
       
   551 // -----------------------------------------------------------------------------
       
   552 //
       
   553 EXPORT_C void CAknView::ViewActivatedL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage )
       
   554 	{
       
   555 	// this is here to assert that BaseConstructL has been called properly.
       
   556 	Extension();
       
   557 
       
   558 	iAppUi->ViewActivatedL( this, aPrevViewId, aCustomMessageId, aCustomMessage );
       
   559 	}
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // CAknView::ViewDeactivatedL
       
   563 // Handles a view deactivation event from viewserv.
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 EXPORT_C void CAknView::ViewDeactivated()
       
   567 	{
       
   568 	iAppUi->ViewDeactivated(this);
       
   569 	}
       
   570 
       
   571 // -----------------------------------------------------------------------------
       
   572 // CAknView::AknViewActivatedL
       
   573 // Called by the application UI when a view is activated.
       
   574 // -----------------------------------------------------------------------------
       
   575 //
       
   576 EXPORT_C void CAknView::AknViewActivatedL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage )
       
   577 	{
       
   578 	ConstructMenuAndCbaL( ETrue );
       
   579 
       
   580     if ( !iViewInfo.iMenu )
       
   581         {
       
   582         AknItemActionMenuRegister::SetConstructingMenuBarOwnerL( this );
       
   583         }
       
   584     
       
   585 	Extension()->PrepareToolbar();
       
   586 
       
   587 	DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   588 
       
   589     if ( !Extension()->iViewActivated || !iViewInfo.iMenu )
       
   590         {
       
   591         // Reset menu bar owner when view first activated
       
   592         AknItemActionMenuRegister::SetConstructingMenuBarOwnerL( NULL );
       
   593         Extension()->iViewActivated = ETrue;
       
   594         }
       
   595 
       
   596 #ifdef RD_SCALABLE_UI_V2
       
   597     if ( iAvkonAppUi->TouchPane() )
       
   598         {
       
   599         iAvkonAppUi->TouchPane()->RefreshL();
       
   600         }
       
   601 #endif // RD_SCALABLE_UI_V2
       
   602 
       
   603 	ProcessForegroundEventL( ETrue );
       
   604 	}
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CAknView::AknViewActivatedL
       
   608 // Called by the application UI when a view is deactivated.
       
   609 // -----------------------------------------------------------------------------
       
   610 //
       
   611 void CAknView::AknViewDeactivated()
       
   612 	{
       
   613 	TRAP_IGNORE( ProcessForegroundEventL( EFalse ) );
       
   614 
       
   615     Extension()->StopDisplayingToolbar( EFalse );
       
   616 
       
   617 	DoDeactivate();
       
   618 
       
   619 	if ( iCba )
       
   620 		{
       
   621 		iCba->MakeVisible( EFalse );
       
   622 		}
       
   623 	}
       
   624 
       
   625 // -----------------------------------------------------------------------------
       
   626 // CAknView::ViewScreenDeviceChangedL
       
   627 // Screen device changed function from viewserv.
       
   628 // -----------------------------------------------------------------------------
       
   629 //
       
   630 EXPORT_C TVwsViewIdAndMessage CAknView::ViewScreenDeviceChangedL()
       
   631 	{
       
   632 	TVwsViewIdAndMessage r;
       
   633 	return r;
       
   634 	}
       
   635 
       
   636 // -----------------------------------------------------------------------------
       
   637 // CAknView::ViewId
       
   638 // Returns the full view Id for this view.
       
   639 // -----------------------------------------------------------------------------
       
   640 //
       
   641 EXPORT_C TVwsViewId CAknView::ViewId() const
       
   642 	{
       
   643 	return TVwsViewId( iAppUi->Application()->AppDllUid(), Id() );
       
   644 	}
       
   645 
       
   646 // -----------------------------------------------------------------------------
       
   647 // CAknView::MenuBar
       
   648 // Menu bar accessor method. This returns the views menu if available, otherwise
       
   649 // applications menu bar is returned.
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 EXPORT_C CEikMenuBar* CAknView::MenuBar() const
       
   653 	{
       
   654 	if ( iMenu )
       
   655 	    {
       
   656 		return iMenu;
       
   657 	    }
       
   658 
       
   659 	return iEikonEnv->AppUiFactory()->MenuBar();
       
   660 	}
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // CAknView::ClientRect
       
   664 // Calculates the client rectangle of the view, taking the applications client
       
   665 // rectangle and the views CBA into account.
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 EXPORT_C TRect CAknView::ClientRect() const
       
   669 	{
       
   670 #ifdef RD_SPLIT_VIEW
       
   671 	TRect rect( iAppUi->ViewRect( Id() ) );
       
   672 #else
       
   673     TRect rect( iAppUi->ClientRect() );
       
   674 #endif // RD_SPLIT_VIEW
       
   675 	
       
   676 #ifdef RD_SPLIT_VIEW
       
   677 	if ( !iAppUi->SplitViewActive() && iCba )
       
   678 #else
       
   679     if ( iCba )	
       
   680 #endif // RD_SPLIT_VIEW
       
   681         {
       
   682 		iCba->SetBoundingRect( TRect() );
       
   683 		iCba->ReduceRect( rect );
       
   684         }
       
   685 
       
   686 #ifdef RD_SCALABLE_UI_V2
       
   687     // touch pane needs to be reduced here, otherwise cba area is not taken
       
   688     // into account
       
   689 	if ( iAppUi->TouchPane() )
       
   690 	    {
       
   691 	    iAppUi->TouchPane()->ReduceRect( rect );
       
   692 	    }
       
   693 #endif // RD_SCALABLE_UI_V2	    
       
   694             
       
   695 	return rect;
       
   696 	}
       
   697 
       
   698 // -----------------------------------------------------------------------------
       
   699 // CAknView::ProcessCommandL
       
   700 // Handles menu launching command and forwards the rest to HandleCommandL().
       
   701 // -----------------------------------------------------------------------------
       
   702 //
       
   703 EXPORT_C void CAknView::ProcessCommandL( TInt aCommand )
       
   704 	{
       
   705 	// most of the contents are based on CEikAppUi::ProcessCommandL()
       
   706 	if ( iMenu )
       
   707 	    {
       
   708 		iMenu->StopDisplayingMenuBar();
       
   709 	    }
       
   710 	    
       
   711 	// Test for 'options' command
       
   712 	if ( aCommand == EAknSoftkeyOptions )
       
   713 		{
       
   714 		if ( iMenu )
       
   715 		    {
       
   716 			iMenu->TryDisplayMenuBarL();
       
   717 		    }
       
   718 		else
       
   719 		    {
       
   720 			iEikonEnv->AppUiFactory()->MenuBar()->TryDisplayMenuBarL();
       
   721 		    }
       
   722 		    
       
   723 		return;
       
   724 		}
       
   725 	if (aCommand == EAknSoftkeyContextOptions)
       
   726 		{
       
   727 		if ( iMenu )
       
   728             {
       
   729             iMenu->TryDisplayContextMenuBarL();
       
   730             }
       
   731 		else
       
   732             {
       
   733             iEikonEnv->AppUiFactory()->MenuBar()->TryDisplayContextMenuBarL();
       
   734             }
       
   735 		    
       
   736 		return;
       
   737 		}
       
   738 		
       
   739 	if ( aCommand == EAknCmdExit )
       
   740 		{
       
   741 		Extension()->StopDisplayingToolbar( ETrue );
       
   742 		CAknEnv::RunAppShutter();
       
   743 		return;
       
   744 		}
       
   745 		
       
   746 	if ( aCommand != EEikCmdCanceled )
       
   747 	    {
       
   748 		HandleCommandL( aCommand );
       
   749 	    }
       
   750 	}
       
   751 
       
   752 // -----------------------------------------------------------------------------
       
   753 // CAknView::HandleCommandL
       
   754 // Command handling function intended for overriding by derived classes.
       
   755 // -----------------------------------------------------------------------------
       
   756 //
       
   757 EXPORT_C void CAknView::HandleCommandL( TInt /*aCommand*/ )
       
   758 	{
       
   759 	}
       
   760 
       
   761 // -----------------------------------------------------------------------------
       
   762 // CAknView::StopDisplayingMenuBar
       
   763 // Dismisses the menu bar.
       
   764 // -----------------------------------------------------------------------------
       
   765 //
       
   766 EXPORT_C void CAknView::StopDisplayingMenuBar()
       
   767 	{
       
   768 	if ( iMenu )
       
   769 	    {
       
   770 		iMenu->StopDisplayingMenuBar();
       
   771 	    }
       
   772 	}
       
   773 
       
   774 // -----------------------------------------------------------------------------
       
   775 // CAknView::HandleForegroundEventL
       
   776 // Called by the framework when view's foreground status changes. The default
       
   777 // implementation is empty.
       
   778 // -----------------------------------------------------------------------------
       
   779 //
       
   780 EXPORT_C void CAknView::HandleForegroundEventL( TBool /*aForeground*/ )
       
   781 	{
       
   782 	}
       
   783 
       
   784 // -----------------------------------------------------------------------------
       
   785 // CAknView::Reserved_MtsmPosition
       
   786 // -----------------------------------------------------------------------------
       
   787 //
       
   788 EXPORT_C void CAknView::Reserved_MtsmPosition()
       
   789 	{
       
   790 	}
       
   791 
       
   792 // -----------------------------------------------------------------------------
       
   793 // CAknView::Reserved_MtsmObject
       
   794 // -----------------------------------------------------------------------------
       
   795 //
       
   796 EXPORT_C void CAknView::Reserved_MtsmObject()
       
   797 	{
       
   798 	}
       
   799 
       
   800 // -----------------------------------------------------------------------------
       
   801 // CAknView::IsForeground
       
   802 // Checks if the view is on foreground.
       
   803 // -----------------------------------------------------------------------------
       
   804 //
       
   805 EXPORT_C TBool CAknView::IsForeground() const
       
   806 	{
       
   807 	return iFlags[EAknViewForeground];
       
   808 	}
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // CAknView::ProcessForegroundEventL
       
   812 // Called by the application UI when view's foreground status changes.
       
   813 // -----------------------------------------------------------------------------
       
   814 //
       
   815 void CAknView::ProcessForegroundEventL( TBool aForeground )
       
   816 	{
       
   817 	if ( !COMPARE_BOOLS( aForeground, iFlags[EAknViewForeground] ) )
       
   818 		{
       
   819 		iFlags.Assign( EAknViewForeground, aForeground );
       
   820 		HandleForegroundEventL( aForeground );
       
   821 		}
       
   822 	}
       
   823 
       
   824 // -----------------------------------------------------------------------------
       
   825 // CAknView::MopSupplyObject
       
   826 // Retrieves an object of the given type.
       
   827 // -----------------------------------------------------------------------------
       
   828 //
       
   829 EXPORT_C TTypeUid::Ptr CAknView::MopSupplyObject( TTypeUid aId )
       
   830 	{
       
   831 	return SupplyMopObject( aId, iCba, iMenu );
       
   832 	}
       
   833 
       
   834 // -----------------------------------------------------------------------------
       
   835 // CAknView::MopNext
       
   836 // Returns the parent object (application UI).
       
   837 // -----------------------------------------------------------------------------
       
   838 //
       
   839 EXPORT_C MObjectProvider* CAknView::MopNext()
       
   840 	{
       
   841 	return iAppUi;
       
   842 	}
       
   843 
       
   844 // -----------------------------------------------------------------------------
       
   845 // CAknView::ConstructMenuAndCbaEarlyL
       
   846 // Constructs both menu bar and CBA but does not make them visible.
       
   847 // -----------------------------------------------------------------------------
       
   848 //
       
   849 EXPORT_C void CAknView::ConstructMenuAndCbaEarlyL()
       
   850 	{
       
   851 	ConstructMenuAndCbaL( EFalse );
       
   852 	}
       
   853 
       
   854 // -----------------------------------------------------------------------------
       
   855 // CAknView::ConstructMenuAndCbaL
       
   856 // Constructs both menu bar and CBA.
       
   857 // -----------------------------------------------------------------------------
       
   858 //
       
   859 void CAknView::ConstructMenuAndCbaL( TBool aVisible )
       
   860 	{
       
   861 	if ( !iMenu )
       
   862 		{
       
   863 		if ( iViewInfo.iMenu )
       
   864 			{
       
   865 			CEikMenuBar* menu = new ( ELeave ) CEikMenuBar;
       
   866 			CleanupStack::PushL( menu );
       
   867 			menu->ConstructL( this, iViewInfo.iHotKeys, iViewInfo.iMenu );
       
   868 			iAppUi->AddToStackL( *this, menu, ECoeStackPriorityMenu, ECoeStackFlagRefusesFocus );
       
   869 			CleanupStack::Pop(); // menu
       
   870 			iMenu = menu;
       
   871 			}
       
   872 		}
       
   873 
       
   874 	if ( iCba )
       
   875 		{
       
   876 		if ( aVisible )
       
   877 			{
       
   878 			iCba->DrawableWindow()->SetOrdinalPosition( 0 );
       
   879 			iCba->MakeVisible( ETrue );
       
   880 			iCba->DrawNow(); // This is needed because problems if TRANSPARENCY is set, see MTVN-6HXCN4
       
   881 			}
       
   882 		}
       
   883 	else
       
   884 		{
       
   885 		if ( iViewInfo.iCba != 0 )
       
   886 			{
       
   887 				CEikButtonGroupContainer* bgc( CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba,
       
   888 				CEikButtonGroupContainer::EHorizontal, this, iViewInfo.iCba ) );
       
   889 			CleanupStack::PushL( bgc );
       
   890 			bgc->SetBoundingRect( iAppUi->ClientRect() );
       
   891 			// cba needs to be placed on the view stack instead of the application stack
       
   892 			CEikCba* cba( static_cast<CEikCba*>( bgc->ButtonGroup() ) ); // downcast from MEikButtonGroup
       
   893 			iEikonEnv->EikAppUi()->RemoveFromStack( cba ); // remove from the current app ui stack
       
   894 			iAppUi->AddToStackL( *this, cba, ECoeStackPriorityCba, ECoeStackFlagRefusesFocus );
       
   895 			CleanupStack::Pop(); // bgc
       
   896 			iCba = bgc;
       
   897 			iCba->MakeVisible( aVisible );
       
   898 			}
       
   899 		}
       
   900 	}
       
   901 
       
   902 // -----------------------------------------------------------------------------
       
   903 // CAknView::HandleViewRectChange
       
   904 // Called by the framework when view's rectangle changes. The default 
       
   905 // implementation is empty.
       
   906 // -----------------------------------------------------------------------------
       
   907 //
       
   908 EXPORT_C void CAknView::HandleViewRectChange()
       
   909     {
       
   910     }
       
   911     
       
   912 // -----------------------------------------------------------------------------
       
   913 // CAknView::Redraw
       
   914 // Orders the view to redraw its area. The default implementation is empty.
       
   915 // -----------------------------------------------------------------------------
       
   916 //
       
   917 EXPORT_C void CAknView::Redraw() const
       
   918     {
       
   919     }
       
   920 
       
   921 // -----------------------------------------------------------------------------
       
   922 // CAknView::Extension
       
   923 // Asserts that extension object has been created.
       
   924 // -----------------------------------------------------------------------------
       
   925 //
       
   926 CAknViewExtension* CAknView::Extension() const
       
   927     {
       
   928     __ASSERT_ALWAYS( iExtension, Panic( EAknPanicObjectNotFullyConstructed ) );
       
   929     return iExtension;
       
   930     }
       
   931 
       
   932 
       
   933 // -----------------------------------------------------------------------------
       
   934 // CAknView::Toolbar
       
   935 // -----------------------------------------------------------------------------
       
   936 //
       
   937 EXPORT_C CAknToolbar* CAknView::Toolbar() const
       
   938     {
       
   939     return Extension()->Toolbar();
       
   940     }
       
   941 
       
   942 // -----------------------------------------------------------------------------
       
   943 // CAknView::StopDisplayingToolbar
       
   944 // Hides the toolbar if it is visible
       
   945 // -----------------------------------------------------------------------------
       
   946 //  
       
   947 EXPORT_C void CAknView::StopDisplayingToolbar()
       
   948     {
       
   949     Extension()->StopDisplayingToolbar( ETrue );
       
   950     }
       
   951 
       
   952 // -----------------------------------------------------------------------------
       
   953 // CAknView::ToolbarShownOnViewActivation
       
   954 // 
       
   955 // -----------------------------------------------------------------------------
       
   956 //
       
   957 EXPORT_C TBool CAknView::ToolbarShownOnViewActivation() const
       
   958     {
       
   959     return Extension()->iToolbarVisible;
       
   960     }
       
   961 
       
   962 // -----------------------------------------------------------------------------
       
   963 // CAknView::ShowToolbarOnViewActivation
       
   964 // Sets value to determine if toolbar is shown on view activation
       
   965 // -----------------------------------------------------------------------------
       
   966 //
       
   967 EXPORT_C void CAknView::ShowToolbarOnViewActivation( TBool aVisible )
       
   968     {
       
   969     Extension()->iToolbarVisible = aVisible;
       
   970     }
       
   971 
       
   972 // -----------------------------------------------------------------------------
       
   973 // CAknView::SaveToolbarStatus
       
   974 // Saves toolbar visibility and focusing values
       
   975 // -----------------------------------------------------------------------------
       
   976 //
       
   977 void CAknView::SaveToolbarStatus( TBool aVisible, TBool aFocused )
       
   978     {
       
   979     Extension()->iToolbarVisible = aVisible;
       
   980     Extension()->iToolbarFocusing = aFocused;
       
   981     }
       
   982 
       
   983 // -----------------------------------------------------------------------------
       
   984 // CAknView::SetToolbar
       
   985 // Using this the applications can set new toolbar for the view. Old is deleted.
       
   986 // -----------------------------------------------------------------------------
       
   987 //
       
   988 EXPORT_C void CAknView::SetToolbar( CAknToolbar* aToolbar )
       
   989     {
       
   990     Extension()->SetToolbar( aToolbar ); 
       
   991     }
       
   992 
       
   993 
       
   994 // -----------------------------------------------------------------------------
       
   995 // CAknView::CreateAndSetToolbarL
       
   996 // Using this the applications can set new toolbar for the view. Old is deleted.
       
   997 // Creates a toolbar with the resource id and then sets it to view toolbar.
       
   998 // -----------------------------------------------------------------------------
       
   999 //
       
  1000 EXPORT_C void CAknView::CreateAndSetToolbarL( TInt aResourceId )
       
  1001     {
       
  1002     Extension()->CreateAndSetToolbarL( aResourceId ); 
       
  1003     }
       
  1004 
       
  1005 // End of File