voicerecorder/RecViewSrc/CVRRecViewContainer.cpp
changeset 0 845549f293a7
child 8 49233e24b2ab
equal deleted inserted replaced
-1:000000000000 0:845549f293a7
       
     1 /*
       
     2 * Copyright (c) 2002 - 2006 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 *     A compound control class. It is responsible for owning CVRButtonPanel
       
    16 *     and CVRStateInfoPanel. It also handles the changing of softkeys, menubar
       
    17 *     and volume control.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 
       
    24 #include <eikenv.h>
       
    25 #include <bldvariant.hrh>
       
    26 
       
    27 #include <aknnavi.h>
       
    28 #include <aknnavide.h>
       
    29 #include <eikspane.h>
       
    30 #include <avkon.rsg>
       
    31 #include <avkon.hrh>
       
    32 #include <aknappui.h>
       
    33 #include <aknsoundsystem.h>
       
    34 #include <aknview.h>
       
    35 #include <eikbtgpc.h>
       
    36 #include <eikmenub.h>
       
    37 #include <AknUtils.h>
       
    38 #include <AknsUtils.h>
       
    39 #include <AknsDrawUtils.h>
       
    40 #include <AknsBasicBackgroundControlContext.h>
       
    41 #include <akncontext.h>
       
    42 #include <applayout.cdl.h>
       
    43 #include <voicerecorder.rsg>
       
    44 #include <AknDef.h>		// For layout change event definitions
       
    45 #include <AknVolumePopup.h>
       
    46 #include <featmgr.h>	// Feature manager
       
    47 
       
    48 #include "CVRRecViewContainer.h"
       
    49 #include "CVRButtonPanel.h"
       
    50 #include "CVRStateInfoPanel.h"
       
    51 #include "MVRDecoratorModel.h"
       
    52 #include "MVRVolumeChangeObserver.h"
       
    53 #include "CVRRecView.h"
       
    54 #include "MVRKeyObserver.h"
       
    55 #include "CVRRemConObserver.h"
       
    56 #include "VRConsts.h"
       
    57 
       
    58 #include <VoiceRecorderUID.h>
       
    59 
       
    60 #include "VRUtils.h"
       
    61 
       
    62 // ================= MEMBER FUNCTIONS =========================================
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // CVRRecViewContainer::CVRRecViewContainer
       
    66 //
       
    67 // ----------------------------------------------------------------------------
       
    68 //
       
    69 CVRRecViewContainer::CVRRecViewContainer()
       
    70 	{
       
    71 	}
       
    72 
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // CVRRecViewContainer::~CVRRecViewContainer
       
    76 //
       
    77 // ----------------------------------------------------------------------------
       
    78 //
       
    79 CVRRecViewContainer::~CVRRecViewContainer()
       
    80 	{
       
    81 	if ( iModel )
       
    82 		{
       
    83 		iModel->SetDecoratorObserver( NULL );
       
    84 		}
       
    85 	delete iButtonPanel;
       
    86 	delete iStateInfoPanel;
       
    87 	delete iIhfVolumeControl;
       
    88 	delete iEarPieceVolumeControl;
       
    89 
       
    90 	delete iBackgroundSkinContext;
       
    91 	
       
    92 	delete iRemConObserver;
       
    93 
       
    94 	}
       
    95 
       
    96 
       
    97 // ----------------------------------------------------------------------------
       
    98 // CVRRecViewContainer::ConstructL
       
    99 //
       
   100 // ----------------------------------------------------------------------------
       
   101 //
       
   102 void CVRRecViewContainer::ConstructL( const TRect& aRect,
       
   103 									  MVRButtonPanelModel* aButtonModel,
       
   104 									  MVRDecoratorModel* aDecoratorModel,
       
   105 									  MVRStateInfoModel* aStateInfoModel,
       
   106 									  CVRRecView* aOwningView )
       
   107 	{
       
   108 	CreateWindowL();
       
   109 
       
   110 	iRemConObserver = CVRRemConObserver::NewL( this );
       
   111 
       
   112 	// Get the skin instance
       
   113 	iSkinInstance = AknsUtils::SkinInstance();
       
   114 	if ( !iSkinInstance )
       
   115 	    {
       
   116 	    User::Leave( KErrNoMemory );
       
   117 	    }
       
   118 
       
   119 	// Create background control context for skinning the background
       
   120 	iBackgroundSkinContext = CAknsBasicBackgroundControlContext::NewL( 
       
   121 			KAknsIIDQsnBgAreaMain, aRect, ETrue );
       
   122 
       
   123 	// Refer to Series 60 European Application LAF for coordinate descriptions
       
   124 	iButtonPanel = new( ELeave ) CVRButtonPanel( aButtonModel, 
       
   125 												 aOwningView->Id() );
       
   126 	iButtonPanel->SetContainerWindowL( *this );
       
   127 	iButtonPanel->ConstructL();
       
   128 	iButtonPanel->SetMopParent( this );
       
   129 	TAknWindowLineLayout buttonPanelLayout = AppLayout::grid_vorec_pane();   
       
   130     AknLayoutUtils::LayoutControl( iButtonPanel, Rect(), buttonPanelLayout );
       
   131 
       
   132 	// Refer to Series 60 European Application LAF for coordinate descriptions
       
   133 	iStateInfoPanel = new( ELeave ) CVRStateInfoPanel( aStateInfoModel, 
       
   134 													   aOwningView->Id() );
       
   135 	iStateInfoPanel->SetContainerWindowL( *this );
       
   136 	iStateInfoPanel->ConstructL();
       
   137     iStateInfoPanel->SetRect( TRect( TPoint( 0,0 ), aRect.Size() ) );
       
   138 
       
   139 	// Set state info panel's MOP-parent so that it can get hold of the bg 
       
   140 	// control context
       
   141 	iStateInfoPanel->SetMopParent( this );
       
   142 
       
   143 	iNaviPane = static_cast< CAknNavigationControlContainer* >(
       
   144 				iEikonEnv->AppUiFactory()->StatusPane()->ControlL(
       
   145 				TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   146 
       
   147 
       
   148 	// Volume indicator with IHF icon
       
   149 	iIhfVolumeControl = iNaviPane->CreateVolumeIndicatorL(
       
   150 										 R_AVKON_NAVI_PANE_VOLUME_INDICATOR );
       
   151     // when touch UI is enabled
       
   152     if ( AknLayoutUtils::PenEnabled() )
       
   153         {
       
   154         static_cast<CAknVolumeControl*>
       
   155                   ( iIhfVolumeControl->DecoratedControl() )->SetObserver( this );     
       
   156         }
       
   157 										     
       
   158     iEarPieceVolumeControl = iNaviPane->CreateVolumeIndicatorL(
       
   159 	                            R_AVKON_NAVI_PANE_EARPIECE_VOLUME_INDICATOR );
       
   160 
       
   161     // when touch UI is enabled
       
   162     if ( AknLayoutUtils::PenEnabled() )
       
   163         {
       
   164         static_cast<CAknVolumeControl*>
       
   165                   ( iEarPieceVolumeControl->DecoratedControl() )->SetObserver( this );     
       
   166         }
       
   167 
       
   168     iIhfVolumeControl->MakeVisible( ETrue );
       
   169     iEarPieceVolumeControl->MakeVisible( ETrue );
       
   170 
       
   171 	iModel = aDecoratorModel;
       
   172 	iModel->SetDecoratorObserver( this );
       
   173 
       
   174 	iOwningView = aOwningView;
       
   175 
       
   176     SetRect( aRect );
       
   177 	// Update child control rects and other co-ordinates for current
       
   178 	// layout ( Euro/APAC/Arabic&Hebrew )
       
   179 	UpdateLayoutL();
       
   180 	} 
       
   181 
       
   182 
       
   183 // ----------------------------------------------------------------------------
       
   184 // CVRRecViewContainer::GetHelpContext
       
   185 //
       
   186 // ----------------------------------------------------------------------------
       
   187 //
       
   188 void CVRRecViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   189 	{
       
   190 	aContext.iMajor = TUid::Uid( KVoiceRecorderAppUID3 );
       
   191 	if ( iModel )
       
   192 		{
       
   193 		iModel->GetHelpContext( aContext );
       
   194 		}
       
   195 	}
       
   196 
       
   197 
       
   198 // ----------------------------------------------------------------------------
       
   199 // CVRRecViewContainer::CountComponentControls
       
   200 //
       
   201 // ----------------------------------------------------------------------------
       
   202 //
       
   203 TInt CVRRecViewContainer::CountComponentControls() const
       
   204 	{
       
   205 	return 2;
       
   206 
       
   207 	}
       
   208 
       
   209 
       
   210 // ----------------------------------------------------------------------------
       
   211 // CVRRecViewContainer::ComponentControl
       
   212 //
       
   213 // ----------------------------------------------------------------------------
       
   214 //
       
   215 CCoeControl* CVRRecViewContainer::ComponentControl( TInt aIndex ) const
       
   216 	{
       
   217 	switch ( aIndex )
       
   218 		{
       
   219 		case 0:
       
   220 			{
       
   221 			return iButtonPanel;
       
   222 			}
       
   223 		case 1:
       
   224 			{
       
   225 			return iStateInfoPanel;
       
   226 			}
       
   227 
       
   228 		case 2:
       
   229 			{
       
   230 			return iIhfVolumeControl->DecoratedControl();
       
   231 			}
       
   232 		case 3:
       
   233 			{
       
   234             return iEarPieceVolumeControl->DecoratedControl();
       
   235 			} 
       
   236 
       
   237 		default:
       
   238 			{
       
   239 			return NULL;
       
   240 			}
       
   241 		}
       
   242 	}
       
   243 
       
   244 
       
   245 
       
   246 // ----------------------------------------------------------------------------
       
   247 // CVRRecViewContainer::OfferKeyEventL
       
   248 //
       
   249 // ----------------------------------------------------------------------------
       
   250 //
       
   251 TKeyResponse CVRRecViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   252 												  TEventCode aType )
       
   253 	{
       
   254 	TBool consumed( EFalse );
       
   255 
       
   256 			if ( aType == EEventKeyDown )
       
   257 				{
       
   258 				aType = aType;
       
   259 				}
       
   260 
       
   261 	if ( iKeyObserver )
       
   262 		{
       
   263 		consumed = iKeyObserver->ProcessKeyEventL( aKeyEvent, aType );
       
   264 		}
       
   265 
       
   266 	if ( !consumed )
       
   267 		{
       
   268 		if ( iActiveVolumeControl && iVolumeChangeObserver->CanSetVolume() && 
       
   269 			   !FeatureManager::FeatureSupported( KFeatureIdSideVolumeKeys ) )
       
   270 			{
       
   271 			if ( ( aKeyEvent.iCode == EKeyLeftArrow ) ||
       
   272 				 ( aKeyEvent.iCode == EKeyRightArrow ) )
       
   273 				{
       
   274 				HandleVolumeChangeL( aKeyEvent, aType );
       
   275 				}
       
   276 			}
       
   277 
       
   278 		return iButtonPanel->OfferKeyEventL( aKeyEvent, aType );
       
   279 		}
       
   280 
       
   281 	return EKeyWasNotConsumed;
       
   282 
       
   283 	}
       
   284 
       
   285 
       
   286 // ----------------------------------------------------------------------------
       
   287 // CVRRecViewContainer::SizeChanged
       
   288 //
       
   289 // ----------------------------------------------------------------------------
       
   290 //
       
   291 void CVRRecViewContainer::SizeChanged()
       
   292 	{
       
   293 	iStateInfoPanel->SetRect( Rect() );
       
   294 
       
   295 	TRect bgRect;
       
   296 	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, bgRect);
       
   297 	iBackgroundSkinContext->SetRect( bgRect );	
       
   298 
       
   299 	TAknWindowLineLayout buttonPanelLayout = AppLayout::grid_vorec_pane();   
       
   300     AknLayoutUtils::LayoutControl( iButtonPanel, Rect(), buttonPanelLayout );
       
   301 
       
   302 	TAknWindowLineLayout statusPaneLayout = 
       
   303 								AknLayout::status_pane( Rect(), 0 );
       
   304 								
       
   305     TAknLayoutRect statusPanelRect;
       
   306     statusPanelRect.LayoutRect( Rect(), statusPaneLayout );
       
   307 
       
   308 	TAknWindowLineLayout verticalLineLayout = 
       
   309 								AppLayout::Voice_Recorder_elements_Line_2();
       
   310 								
       
   311 	iVerticalLineRect.LayoutRect( statusPanelRect.Rect(), verticalLineLayout );
       
   312 
       
   313 	TAknWindowLineLayout horizontalLineLayout = 
       
   314 								AppLayout::Voice_Recorder_elements_Line_3();
       
   315 								
       
   316 	iHorizontalLineRect.LayoutRect( statusPanelRect.Rect(), 
       
   317 									horizontalLineLayout );
       
   318 	}
       
   319 
       
   320 
       
   321 
       
   322 // ----------------------------------------------------------------------------
       
   323 // CVRRecViewContainer::Draw
       
   324 //
       
   325 // ----------------------------------------------------------------------------
       
   326 //
       
   327 void CVRRecViewContainer::Draw( const TRect& /*aRect*/ ) const
       
   328 	{
       
   329 	CWindowGc& gc = SystemGc();
       
   330 
       
   331 	// Fill the background with the background bitmap from the skin
       
   332 	// Note: if the skin doesn't define a background the area is simply
       
   333 	// cleared (which is OK for us).
       
   334 	AknsDrawUtils::Background( iSkinInstance, iBackgroundSkinContext,
       
   335 			this, gc, Rect() );
       
   336 
       
   337 	iVerticalLineRect.DrawRect( gc );
       
   338 	iHorizontalLineRect.DrawRect( gc );
       
   339 	}
       
   340 
       
   341 
       
   342 // ----------------------------------------------------------------------------
       
   343 // CVRRecViewContainer::SetKeyObserver
       
   344 //
       
   345 // ----------------------------------------------------------------------------
       
   346 //
       
   347 void CVRRecViewContainer::SetKeyObserver( MVRKeyObserver* aObserver )
       
   348 	{
       
   349 	iKeyObserver = aObserver;
       
   350 	}
       
   351 
       
   352 
       
   353 // ----------------------------------------------------------------------------
       
   354 // CVRRecViewContainer::SetVolumeChangeObserver
       
   355 //
       
   356 // ----------------------------------------------------------------------------
       
   357 //
       
   358 void CVRRecViewContainer::SetVolumeChangeObserver(
       
   359 										  MVRVolumeChangeObserver* aObserver )
       
   360 	{
       
   361 	iVolumeChangeObserver = aObserver;
       
   362 	}
       
   363 
       
   364 
       
   365 // ----------------------------------------------------------------------------
       
   366 // CVRRecViewContainer::Update
       
   367 //
       
   368 // ----------------------------------------------------------------------------
       
   369 //
       
   370 void CVRRecViewContainer::Update( TVRUpdateCommand aCommand )
       
   371 	{
       
   372 	
       
   373 	if ( aCommand == EVRUpdateCBA )
       
   374 		{
       
   375 		UpdateCBA();
       
   376 		return;
       
   377 		}
       
   378 		
       
   379 	// Change menubar
       
   380 	iOwningView->MenuBar()->SetMenuTitleResourceId(
       
   381 												iModel->MenuBarResourceId() );
       
   382 	
       
   383 	// error ignored, this rarely leaves but just to make sure
       
   384 	TRAP_IGNORE( iNaviPane = static_cast< CAknNavigationControlContainer* >(iEikonEnv->AppUiFactory()->StatusPane()->ControlL( // CSI: 42 #
       
   385 				TUid::Uid( EEikStatusPaneUidNavi ) ) ) ); 
       
   386 
       
   387 	iNaviPane->DrawNow();
       
   388 	
       
   389 	UpdateCBA();
       
   390 
       
   391 	TRAP_IGNORE( UpdateVolumeControlL() );
       
   392 	}
       
   393 
       
   394 
       
   395 // ----------------------------------------------------------------------------
       
   396 // CVRRecViewContainer::UpdateCBA
       
   397 // Updates the CBA buttons (LSK, MSK & RSK) according to the current state and 
       
   398 // draws them
       
   399 // ----------------------------------------------------------------------------
       
   400 //
       
   401 void CVRRecViewContainer::UpdateCBA()
       
   402 	{
       
   403 	// Change CBA buttons
       
   404 	// Ignore any errors. SetCommandSetL() will leave if there is
       
   405 	// not enough memory
       
   406 	CEikButtonGroupContainer* cba = iOwningView->Cba();
       
   407 	
       
   408 	// e.g. recording is about to start and options menu shouldn't be opened
       
   409 	if ( iModel->CbaResourceId() == R_VR_SOFTKEYS_OPTIONS_EXIT_SELECT &&
       
   410 			!iModel->CBAEnabled() )
       
   411 		{
       
   412 		// Same texts remain but disables LSK and RSK use
       
   413 		TRAP_IGNORE( cba->SetCommandSetL( 
       
   414 						R_VR_SOFTKEYS_OPTIONS_EXIT_SELECT_NO_COMMAND ) );
       
   415 		}
       
   416 	
       
   417 	// jeffery: added for CR to disable "Pause" key, will remove it later when plugin is updatedd
       
   418 
       
   419 #ifdef  __AAC_ENCODER_PLUGIN   
       
   420 	if (!iOwningView->IsEmbedded() && (iOwningView->Quality() == EQualityHigh) && (iOwningView->GetStateId() == EStateRecording ))
       
   421 
       
   422     	{
       
   423     	TRAP_IGNORE(cba->SetCommandSetL(R_VR_SOFTKEYS_STOP_SELECT));    	 
       
   424     	} 
       
   425 #endif
       
   426 	
       
   427 	else
       
   428 		{
       
   429 		// Normal behaviour
       
   430 		TRAP_IGNORE( cba->SetCommandSetL( iModel->CbaResourceId() ) );	
       
   431 		}	
       
   432 	
       
   433 	cba->DrawNow();
       
   434 	}
       
   435 
       
   436 
       
   437 // ----------------------------------------------------------------------------
       
   438 // CVRRecViewContainer::UpdateVolumeControlL
       
   439 //
       
   440 // ----------------------------------------------------------------------------
       
   441 //
       
   442 void CVRRecViewContainer::UpdateVolumeControlL()
       
   443 	{
       
   444     TVRVolumeControlState state; 	
       
   445     TInt volume;
       
   446 
       
   447     // Get volume control data from model
       
   448     iModel->GetVolumeControlState( state, volume );
       
   449 
       
   450     if ( iActiveVolumeControl )
       
   451 	    {
       
   452 	    // pop the previous volume control if there was one
       
   453 	    iNaviPane->Pop();
       
   454 	    }
       
   455 
       
   456     switch ( state )
       
   457 	    {
       
   458 	    case EDisabled:
       
   459 		    {
       
   460 		    iActiveVolumeControl = NULL;
       
   461 		    break;
       
   462 		    }
       
   463 
       
   464 	    case EIhf:
       
   465 		    {
       
   466 
       
   467 		    iActiveVolumeControl = iIhfVolumeControl;
       
   468 
       
   469 		    break;
       
   470 		    }
       
   471 
       
   472 	    case EEarPiece:
       
   473 		    {
       
   474 
       
   475 		    iActiveVolumeControl = iEarPieceVolumeControl;
       
   476 		    break;
       
   477 		    }
       
   478         }
       
   479 
       
   480     if ( state != EDisabled )
       
   481 	    {
       
   482 	    iNaviPane->PushL( *iActiveVolumeControl );
       
   483 	    CAknVolumeControl* control = static_cast< CAknVolumeControl* >(
       
   484 								    iActiveVolumeControl->DecoratedControl() );
       
   485 	    
       
   486 	    
       
   487 	    control->SetValue( volume );
       
   488 	    }
       
   489 	}
       
   490 
       
   491 
       
   492 // ----------------------------------------------------------------------------
       
   493 // CVRRecViewContainer::UpdateLayoutL
       
   494 //
       
   495 // ----------------------------------------------------------------------------
       
   496 //
       
   497 void CVRRecViewContainer::UpdateLayoutL()
       
   498 	{
       
   499 	SizeChanged();
       
   500 	}
       
   501 
       
   502 
       
   503 // ----------------------------------------------------------------------------
       
   504 // CVRRecViewContainer::MopSupplyObject
       
   505 //
       
   506 // ----------------------------------------------------------------------------
       
   507 //
       
   508 TTypeUid::Ptr CVRRecViewContainer::MopSupplyObject(TTypeUid aId)
       
   509 	{
       
   510 	if ( aId.iUid == MAknsControlContext::ETypeId )
       
   511 		{
       
   512 		// Return the control context for the childs
       
   513 		return MAknsControlContext::SupplyMopObject( aId, iBackgroundSkinContext );
       
   514 		}
       
   515 	return CCoeControl::MopSupplyObject( aId );
       
   516 	}
       
   517 
       
   518 
       
   519 // ----------------------------------------------------------------------------
       
   520 // CVRRecViewContainer::HandleResourceChangeL
       
   521 //
       
   522 // ----------------------------------------------------------------------------
       
   523 //
       
   524 void CVRRecViewContainer::HandleResourceChangeL( TInt aType )
       
   525 	{
       
   526 	CCoeControl::HandleResourceChange( aType );
       
   527 	
       
   528 	if ( aType == KEikDynamicLayoutVariantSwitch )
       
   529 		{
       
   530 		UpdateLayoutL();
       
   531 		}
       
   532 	else if ( aType == KAknsMessageSkinChange )
       
   533 		{
       
   534 		// New skin instance is loaded
       
   535 		iSkinInstance = AknsUtils::SkinInstance();
       
   536 		}
       
   537 	
       
   538 	// Inform other controls	
       
   539 	iButtonPanel->HandleResourceChangeL( aType );
       
   540 	iStateInfoPanel->HandleResourceChangeL( aType );	
       
   541 		
       
   542 	}
       
   543 
       
   544 
       
   545 // ----------------------------------------------------------------------------
       
   546 // CVRRecViewContainer::HandleVolumeChangeL
       
   547 //
       
   548 // ----------------------------------------------------------------------------
       
   549 //
       
   550 TInt CVRRecViewContainer::HandleVolumeChangeL( const TKeyEvent& aKeyEvent,
       
   551 											   TEventCode aType )
       
   552 	{
       
   553 	
       
   554 	if( !iActiveVolumeControl || !iVolumeChangeObserver->CanSetVolume() )
       
   555 		{
       
   556 		// Can't process volume change yet
       
   557 		return KErrNotReady;
       
   558 		}
       
   559 	
       
   560 	CAknAppUi* appUi = static_cast< CAknAppUi* >(
       
   561 										  iEikonEnv->EikAppUi() );
       
   562 	CAknVolumeControl* control = static_cast< CAknVolumeControl* >
       
   563 					( iActiveVolumeControl->DecoratedControl() );
       
   564 
       
   565 	TInt prevLevel( control->Value() );
       
   566 	
       
   567 	control->OfferKeyEventL( aKeyEvent, aType );
       
   568 
       
   569 	// Values range from 1 to 10 so the cast is ok
       
   570 	TUint8 newValue( ( TUint8 ) control->Value() );
       
   571 
       
   572 	if ( iVolumeChangeObserver )
       
   573 		{
       
   574 		iVolumeChangeObserver->SetVolume( newValue,
       
   575 										  KVRMaxVolumeSteps );
       
   576 		}
       
   577 
       
   578 	// determine if the volume was already at either end
       
   579 	// (of the scale)
       
   580 	// play a system sound in that case.
       
   581 	if ( prevLevel == control->Value() )
       
   582 		{
       
   583 		TInt sid( EAvkonSIDVolumeMaxTone );
       
   584 		if ( prevLevel == 1 )
       
   585 			{
       
   586 			sid = EAvkonSIDVolumeMinTone;
       
   587 			}
       
   588 		appUi->KeySounds()->PlaySound( sid );
       
   589 		return KErrTooBig;
       
   590 		}	
       
   591 		
       
   592 	return KErrNone;
       
   593 	}
       
   594 	
       
   595 
       
   596 // ---------------------------------------------------------------------------
       
   597 // CVRRecViewContainer::HandlePointerEventL
       
   598 // Handles pointer events by passing them on to controls
       
   599 // ---------------------------------------------------------------------------
       
   600 //		
       
   601 void CVRRecViewContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   602 	{
       
   603 	if( AknLayoutUtils::PenEnabled() )
       
   604 		{
       
   605 		CCoeControl::HandlePointerEventL(aPointerEvent);	
       
   606 		iButtonPanel->HandlePointerEventL(aPointerEvent);
       
   607 
       
   608 		if ( iActiveVolumeControl && iVolumeChangeObserver->CanSetVolume() )
       
   609 	    	{
       
   610 	    	if ( (iOwningView->GetStateId() == EStatePlayingPaused ) || (iOwningView->GetStateId() == EStatePlaying ) )
       
   611 	    		{
       
   612 	    		// pop the previous volume control if there was one
       
   613 	    		CAknVolumeControl* control = static_cast< CAknVolumeControl* >
       
   614 	    						( iActiveVolumeControl->DecoratedControl() );
       
   615 	    		CAknVolumePopup* popup = static_cast<CAknVolumePopup*> ( control->Parent() );
       
   616 	    		TRect volumePopupRect( popup->Rect() );
       
   617 	    		volumePopupRect.Move( popup->Position() );
       
   618 	    		if( volumePopupRect.Contains(aPointerEvent.iParentPosition) )
       
   619 	    			{
       
   620 	    			TRAP_IGNORE( popup->ShowVolumePopupL() );
       
   621 	    			}
       
   622 		    	}
       
   623 	    	}
       
   624 		}
       
   625 	}
       
   626 
       
   627 // ---------------------------------------------------------------------------
       
   628 // CVRRecViewContainer::FocusedButton
       
   629 // Returns the currently focused button in Button Panel
       
   630 // ---------------------------------------------------------------------------
       
   631 //		
       
   632 TInt CVRRecViewContainer::FocusedButton() const
       
   633 	{
       
   634 	return iButtonPanel->FocusedButton();
       
   635 	}
       
   636 
       
   637 
       
   638 // ---------------------------------------------------------------------------
       
   639 // CVRRecViewContainer::UpdateButtonPanel
       
   640 // Gives the update command to Button Panel
       
   641 // ---------------------------------------------------------------------------
       
   642 //
       
   643 void CVRRecViewContainer::UpdateButtonPanel( TVRUpdateCommand aCommand )
       
   644 	{
       
   645 	iButtonPanel->Update( aCommand );
       
   646 	}
       
   647 
       
   648 	
       
   649 // ----------------------------------------------------------------------------
       
   650 // void CVRRecViewContainer::HandleControlEventL
       
   651 // ----------------------------------------------------------------------------
       
   652 //
       
   653 void CVRRecViewContainer::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType )
       
   654 	{
       
   655     // Added for touch UI to adjust volume
       
   656 	if( AknLayoutUtils::PenEnabled() )
       
   657 		{			
       
   658 		switch( aEventType )
       
   659 			{
       
   660 			case EEventStateChanged:
       
   661 				{
       
   662 				if ( aControl == static_cast< CAknVolumeControl*>(iActiveVolumeControl->DecoratedControl()))
       
   663  				    {
       
   664 						if( !iActiveVolumeControl || !iVolumeChangeObserver->CanSetVolume() )
       
   665 						{
       
   666 						// Can't process volume change yet
       
   667 						User::Leave(KErrNotReady);
       
   668 						}
       
   669 	
       
   670 						CAknAppUi* appUi = static_cast< CAknAppUi* >(iEikonEnv->EikAppUi() );
       
   671 						CAknVolumeControl* control = static_cast< CAknVolumeControl* >(iActiveVolumeControl->DecoratedControl() );
       
   672 
       
   673 						TInt prevLevel( control->Value() );
       
   674 	
       
   675 						// Values range from 1 to 10 so the cast is ok
       
   676 						TUint8 newValue( ( TUint8 ) control->Value() );
       
   677 
       
   678 						if ( iVolumeChangeObserver )
       
   679 							{
       
   680 							iVolumeChangeObserver->SetVolume( newValue, KVRMaxVolumeSteps );
       
   681 							}
       
   682 
       
   683 						// determine if the volume was already at either end
       
   684 						// (of the scale)
       
   685 						// play a system sound in that case.
       
   686 						if ( prevLevel == control->Value() )
       
   687 							{
       
   688 							TInt sid( EAvkonSIDVolumeMaxTone );
       
   689 							if ( prevLevel == 1 )
       
   690 								{
       
   691 								sid = EAvkonSIDVolumeMinTone;
       
   692 								}
       
   693 							appUi->KeySounds()->PlaySound( sid );
       
   694 							User::Leave(KErrTooBig);
       
   695 							}	
       
   696  				    }
       
   697                 }
       
   698 			default:
       
   699 				break;                
       
   700             }
       
   701         }
       
   702     }