camerauis/cameraapp/generic/src/CamShootingModeContainer.cpp
changeset 0 1ddebce53859
child 12 8c55c525d5d7
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  Setting page for Image/Video quality.*
       
    15 */
       
    16 
       
    17 #include <AknBidiTextUtils.h>
       
    18 #include <AknsUtils.h>
       
    19 #include <AknsDrawUtils.h>
       
    20 #include <AknUtils.h>
       
    21 #include <barsread.h>    // resource reader
       
    22 #include <aknview.h> 
       
    23 #include <touchfeedback.h> 
       
    24 #include <StringLoader.h>
       
    25 
       
    26 #include <cameraapp.rsg>
       
    27 #include <vgacamsettings.rsg>  
       
    28 
       
    29 #include "CamShootingModeContainer.h"
       
    30 #include "CamUtility.h"
       
    31 #include "CamAppUi.h"
       
    32 #include "CameraUiConfigManager.h"
       
    33 #include "CamSceneListBox.h"
       
    34 #include "CamSceneListBoxModel.h"
       
    35 #include "CamPanic.h"
       
    36 #include "camactivepalettehandler.h"
       
    37 
       
    38 #include <aknlayoutscalable_apps.cdl.h>
       
    39 #include "akntoolbar.h"
       
    40 
       
    41 // CONSTANTS
       
    42 
       
    43 const TInt KInfoTooltipDelay = 0; // time (milliseconds) delay when showing the tooltip
       
    44 const TInt KInfoTooltipDisplayTime = 5000; // maximum time (milliseconds) the tooltip is displayed
       
    45 const TInt KExplTxtGranularity = 6;
       
    46 
       
    47 // ================= MEMBER FUNCTIONS =======================
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CCamShootingModeContainer::NewL
       
    51 // Symbian OS two-phased constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CCamShootingModeContainer* 
       
    55 CCamShootingModeContainer::NewL( const TRect&             aRect, 
       
    56                                        CAknView&          aView,
       
    57                                        TCamCameraMode     aMode,
       
    58                                        CCamAppController& aController,
       
    59                                        TBool              aUserBaseScenes )
       
    60   {
       
    61   CCamShootingModeContainer* self = 
       
    62       new( ELeave ) CCamShootingModeContainer( aMode, 
       
    63                                                aController,
       
    64                                                aView, 
       
    65                                                aUserBaseScenes );
       
    66   CleanupStack::PushL( self );
       
    67   self->ConstructL( aRect );
       
    68   CleanupStack::Pop( self );
       
    69   return self;
       
    70   }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CCamShootingModeContainer::~CCamShootingModeContainer
       
    74 // Destructor
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CCamShootingModeContainer::~CCamShootingModeContainer()
       
    78   {
       
    79   PRINT( _L( "Camera => ~CCamShootingModeContainer" ) );
       
    80   
       
    81   iSummaryBitmapArray.ResetAndDestroy();
       
    82   iTitleArray.ResetAndDestroy();
       
    83   iDescArray.ResetAndDestroy();
       
    84   iExplTxtLinesLayout.Close();  
       
    85    
       
    86   if ( iFeedback ) 
       
    87     {
       
    88     iFeedback->RemoveFeedbackForControl( iListBox );
       
    89     }
       
    90 
       
    91   if ( iListBox )
       
    92 	  {
       
    93 	  delete iListBox;
       
    94 	  iListBox = NULL;
       
    95 	  }
       
    96   
       
    97     if ( iTooltipController )
       
    98         {
       
    99         delete iTooltipController;
       
   100         iTooltipController = NULL;
       
   101         }
       
   102         
       
   103   if ( iListboxTitle )
       
   104     {
       
   105     delete iListboxTitle;
       
   106     iListboxTitle = NULL;
       
   107     }
       
   108   
       
   109   if ( iCurrentDescLineArray ) 
       
   110     {
       
   111     iCurrentDescLineArray->Reset();
       
   112     delete iCurrentDescLineArray;
       
   113     }
       
   114 
       
   115   PRINT( _L( "Camera <= ~CCamShootingModeContainer" ) );    
       
   116   }
       
   117   
       
   118 // ---------------------------------------------------------
       
   119 // CCamShootingModeContainer::ConstructL
       
   120 // Symbian OS 2nd phase constructor
       
   121 // ---------------------------------------------------------
       
   122 //
       
   123 void 
       
   124 CCamShootingModeContainer::ConstructL( const TRect& aRect )
       
   125     {
       
   126 	PRINT(_L("Camera => CCamShootingModeContainer::ConstructL") )
       
   127     
       
   128     CCamContainerBase::BaseConstructL( aRect );
       
   129 
       
   130     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   131                                        iLayoutAreaRect );
       
   132     // layout area rectangle contains the area, where components need to be 
       
   133     // drawn to. the container size is the whole screen, but the layouts are 
       
   134     // for the client area. aRect is the container size that might include or
       
   135     // might not include statuspane area. calculating area self will
       
   136     // go around the problem
       
   137     TInt resource = SelectSummaryResourceL();
       
   138     if( 0 <= resource )
       
   139       {
       
   140       ConstructSummaryDetailsFromResourceL( resource );
       
   141       }
       
   142 
       
   143     TInt scene = 0;
       
   144     if ( iUserBaseScenes )
       
   145         {
       
   146         scene = ECamSettingItemUserSceneBasedOnScene;
       
   147         }
       
   148     else if ( ECamControllerImage == iMode )
       
   149         {
       
   150         scene = ECamSettingItemDynamicPhotoScene;
       
   151         }
       
   152     else
       
   153         {
       
   154         scene = ECamSettingItemDynamicVideoScene;
       
   155         }                      
       
   156 
       
   157     // construct the listbox
       
   158 	iListBox =	new( ELeave ) CCamSceneListBox( iMode, this, iController );                           
       
   159 	iListBox->ConstructL( iController, this, iTitleArray, iDescArray, 
       
   160 	                      iUserBaseScenes  );	
       
   161 	iListBox->InitializeL( iController.IntegerSettingValue( scene ) );
       
   162 	iListBox->SetContainerWindowL( *this );
       
   163 	iListBox->CreateScrollBarFrameL( ETrue ); 
       
   164     iListBox->DisableSingleClick( ETrue );
       
   165    
       
   166 	TRect listboxRect;
       
   167     if ( CamUtility::IsNhdDevice() ) 
       
   168         {
       
   169         listboxRect = TouchLayout();
       
   170         }
       
   171     else
       
   172         {
       
   173         iCurrentDescLineArray  = 
       
   174                      new( ELeave ) CArrayFixFlat<TPtrC>( KExplTxtGranularity );
       
   175         listboxRect = NonTouchLayout();
       
   176         }
       
   177 	
       
   178     // Determine the height of the listbox; 
       
   179     // Height needs to be based on the number of items, because the layout
       
   180     // height (maxListBoxHeight )might be different 
       
   181     // than combined height of the max visible listbox items
       
   182     
       
   183     CEikScrollBarFrame::TScrollBarVisibility visibility = 
       
   184                                                       CEikScrollBarFrame::EOff;
       
   185     TInt maxListBoxHeight = listboxRect.Height();
       
   186     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   187                                           iListBox->Model()->NumberOfItems() );
       
   188     if ( maxListBoxHeight < listBoxHeight )
       
   189         {
       
   190         // there are more items than would fit to the listbox rectangle
       
   191         
       
   192         // the maximum height is the total height of items 
       
   193         // that can fit to the maxlistboxheight
       
   194         TInt itemHeight = iListBox->ItemHeight();
       
   195         TInt itemsVisible = maxListBoxHeight / itemHeight;
       
   196         listBoxHeight = itemsVisible * itemHeight;
       
   197         
       
   198         // the scrollbar needs to be turned on
       
   199         visibility = CEikScrollBarFrame::EOn;        
       
   200         }
       
   201    
       
   202     // calculate the layout for the listbox with changed height
       
   203     const AknLayoutUtils::SAknLayoutControl listboxLayout =
       
   204     {   ELayoutEmpty, iListboxLayoutRect.Rect().iTl.iX, listboxRect.iTl.iY,
       
   205         ELayoutEmpty, ELayoutEmpty, 
       
   206         iListboxLayoutRect.Rect().Width(), listBoxHeight };
       
   207    
       
   208     AknLayoutUtils::LayoutControl( iListBox, 
       
   209             iLayoutAreaRect, listboxLayout);
       
   210 
       
   211     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   212                                         CEikScrollBarFrame::EOff, visibility );
       
   213     iListBox->MakeVisible( ETrue );
       
   214     iListBox->SetFocus( EFalse, ENoDrawNow );
       
   215     iListBox->UpdateScrollBarsL();
       
   216     iListBox->ScrollBarFrame()->DrawScrollBarsNow();
       
   217     iListBox->SetListBoxObserver(this);
       
   218     CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
   219     appUi->SetActivePaletteVisibility( EFalse );
       
   220 
       
   221     // Prevents the system filling invalidated areas with the background 
       
   222     // colour - helps reduce flicker.
       
   223     Window().SetBackgroundColor();
       
   224     
       
   225     if ( iMode == ECamControllerImage )
       
   226         {
       
   227         ConstructContainerTitleFromResourceL( R_CAM_STILL_SCENE_SETTING_TITLE ); 
       
   228         }
       
   229     else 
       
   230         {
       
   231         ConstructContainerTitleFromResourceL( R_CAM_VIDEO_SCENE_SETTING_TITLE );
       
   232         }
       
   233      
       
   234     if ( ! iTooltipController )
       
   235         {
       
   236         iTooltipController = CAknInfoPopupNoteController::NewL();
       
   237         }
       
   238         
       
   239     iTooltipController->SetTimeDelayBeforeShow( KInfoTooltipDelay );
       
   240     iTooltipController->SetTimePopupInView( KInfoTooltipDisplayTime );
       
   241     
       
   242     // Position the tooltip
       
   243     TPoint position;
       
   244     if ( AknsUtils::GetControlPosition( this, position ) != KErrNone )
       
   245         {
       
   246         position = PositionRelativeToScreen();
       
   247         }
       
   248     TRect rect( position, Size() );
       
   249     TPoint center = rect.Center();
       
   250     iTooltipController->SetPositionAndAlignment( 
       
   251                              TPoint( center.iX, rect.iTl.iY ), EHLeftVBottom );
       
   252      
       
   253     iTooltipController->SetTimeDelayBeforeShow( KInfoTooltipDelay );
       
   254     iTooltipController->SetTimePopupInView( KInfoTooltipDisplayTime );
       
   255     
       
   256     iFeedback = MTouchFeedback::Instance();  
       
   257     if ( iFeedback )  
       
   258         {
       
   259         iFeedback->SetFeedbackArea( iListBox, 0, iListBox->Rect(), 
       
   260                                     ETouchFeedbackBasic, ETouchEventStylusDown );
       
   261         }
       
   262 
       
   263 	PRINT(_L("Camera <= CCamShootingModeContainer::ConstructL") )    
       
   264     }
       
   265    
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // SelectSummaryResourceL
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 TInt 
       
   272 CCamShootingModeContainer::SelectSummaryResourceL()
       
   273   {
       
   274   TInt  resourceId = KErrNotSupported;
       
   275   TBool secondCameraOn = 
       
   276     static_cast<CCamAppUi*>( iEikonEnv->AppUi() )->IsSecondCameraEnabled();
       
   277   // -------------------------------------------------------
       
   278   // Photo mode  
       
   279   if ( ECamControllerImage == iMode )
       
   280     {
       
   281     if ( secondCameraOn )
       
   282       {
       
   283       //Product does not currently support shooting modes for secondary camera photo mode
       
   284       }
       
   285     else
       
   286       {
       
   287       resourceId = R_CAM_CAPTURE_SETUP_LIST_PHOTO_SHOOTING_MODE_SUMMARY;
       
   288       }
       
   289     }
       
   290   // -------------------------------------------------------
       
   291   // Video mode  
       
   292   else
       
   293     {
       
   294     if ( secondCameraOn )
       
   295       {
       
   296       //Products do not currently support shooting modes for secondary camera video mode           
       
   297       }
       
   298     else
       
   299       {
       
   300       resourceId = R_CAM_CAPTURE_SETUP_LIST_VIDEO_SHOOTING_MODE_SUMMARY;
       
   301       }
       
   302     }
       
   303   // -------------------------------------------------------
       
   304 
       
   305   return resourceId;
       
   306   }
       
   307 
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // CCamShootingModeContainer::CCamShootingModeContainer
       
   311 // C++ constructor
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 CCamShootingModeContainer::CCamShootingModeContainer( 
       
   315         TCamCameraMode aMode,
       
   316         CCamAppController& aController,
       
   317         CAknView& aView,
       
   318         TBool aUserBaseScenes )
       
   319 : CCamContainerBase( aController, aView ),
       
   320     iListBox( NULL ),
       
   321     iMode( aMode ), 
       
   322     iUserBaseScenes( aUserBaseScenes ),
       
   323     iTooltipController( NULL ),
       
   324     iListboxTitle( NULL ),
       
   325     iTooltipIndex( -1 ),
       
   326     iActivateOnTouchRelease( EFalse )
       
   327     {
       
   328     }
       
   329 
       
   330 // ----------------------------------------------------------------
       
   331 // CCamShootingModeContainer::UserSceneHighlighted
       
   332 // Returns ETrue if the current selected scene is User
       
   333 // ----------------------------------------------------------------
       
   334 //
       
   335 TBool CCamShootingModeContainer::UserSceneHighlighted()
       
   336     {
       
   337     return (CurrentSettingItemValue() == ECamSceneUser );
       
   338     }
       
   339 
       
   340 // ----------------------------------------------------------------
       
   341 // CCamShootingModeContainer::SaveSceneSettingIfChangedL
       
   342 // Stores the currently selected scene in the dynamic settings model
       
   343 // if it differs from current scene mode
       
   344 // ----------------------------------------------------------------
       
   345 //
       
   346 TBool CCamShootingModeContainer::SaveSceneSettingIfChangedL()
       
   347     {
       
   348     TInt scene = 0;
       
   349     if ( iUserBaseScenes )
       
   350       {
       
   351       scene = ECamSettingItemUserSceneBasedOnScene;
       
   352       }
       
   353     else if ( ECamControllerImage == iMode )
       
   354       {
       
   355       scene = ECamSettingItemDynamicPhotoScene;
       
   356       }
       
   357     else
       
   358       {
       
   359       scene = ECamSettingItemDynamicVideoScene;
       
   360       }
       
   361 
       
   362     TInt currentSceneMode = iController.IntegerSettingValue( scene );
       
   363     if ( currentSceneMode != CurrentSettingItemValue() )
       
   364         {
       
   365         // The scene mode selection has changed, store new mode
       
   366         return SaveSceneSettingL();
       
   367         }
       
   368     else
       
   369         {
       
   370         // No change, no need to save
       
   371         return EFalse;
       
   372         }
       
   373     }
       
   374 
       
   375 // ----------------------------------------------------------------
       
   376 // CCamShootingModeContainer::SaveSceneSetting
       
   377 // Stores the currently selected scene in the dynamic settings model
       
   378 // ----------------------------------------------------------------
       
   379 //
       
   380 TBool CCamShootingModeContainer::SaveSceneSettingL()
       
   381   {
       
   382   TInt scene = 0;
       
   383   if ( iUserBaseScenes )
       
   384     {
       
   385     scene = ECamSettingItemUserSceneBasedOnScene;
       
   386     }
       
   387   else if ( ECamControllerImage == iMode )
       
   388     {
       
   389     scene = ECamSettingItemDynamicPhotoScene;
       
   390     }
       
   391   else
       
   392     {
       
   393     scene = ECamSettingItemDynamicVideoScene;
       
   394     }
       
   395   
       
   396   iController.SetIntegerSettingValueL( scene,
       
   397               CurrentSettingItemValue() );
       
   398   static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() )->APHandler()->UpdateActivePaletteL();        
       
   399               
       
   400 
       
   401   // If user selected sports scene from list.
       
   402   if ( CurrentSettingItemValue() == ECamSceneSports )
       
   403     {
       
   404     // if the selection was for user scene base scene, and user 
       
   405     // scene is active, but request was cancelled, return false.
       
   406     if ( ( iController.IntegerSettingValue( ECamSettingItemDynamicPhotoScene )
       
   407          == ECamSceneUser ) &&
       
   408          ( iController.IntegerSettingValue( ECamSettingItemUserSceneBasedOnScene )
       
   409          != ECamSceneSports ) )
       
   410         {
       
   411         return EFalse;
       
   412         }
       
   413     // if the selection was for the photo/video scene, but request was 
       
   414     // cancelled, return false.
       
   415     if ( ( iController.IntegerSettingValue( ECamSettingItemDynamicPhotoScene )
       
   416          != ECamSceneUser )  && 
       
   417          ( iController.IntegerSettingValue( scene ) != ECamSceneSports ) )
       
   418         {
       
   419         return EFalse;
       
   420         }
       
   421     }
       
   422   // Otherwise, if the user selected user scene from the list, but request
       
   423   // was cancelled, return false.
       
   424   else if ( ( CurrentSettingItemValue() 
       
   425             == ECamSceneUser ) &&
       
   426             ( iController.IntegerSettingValue( ECamSettingItemDynamicPhotoScene )
       
   427            != ECamSceneUser ) )
       
   428       {
       
   429       return EFalse;
       
   430       }
       
   431 
       
   432   // Remove lint warning.
       
   433   else
       
   434       {
       
   435       }
       
   436 
       
   437   // In all other cases, return true.
       
   438   return ETrue;
       
   439   }
       
   440      
       
   441 // -----------------------------------------------------------------------------
       
   442 // CCamShootingModeContainer::CurrentSettingItemValue
       
   443 // Returns the Current item's setting value ID
       
   444 // -----------------------------------------------------------------------------
       
   445 TInt CCamShootingModeContainer::CurrentSettingItemValue() const
       
   446     {
       
   447     return (static_cast<CCamSceneListBoxModel *>(iListBox->Model())->ItemValue(iListBox->CurrentItemIndex()));
       
   448     }
       
   449     
       
   450 // -----------------------------------------------------------------------------
       
   451 // CCamShootingModeContainer::IndexForValueId() const
       
   452 // Returns the index of the item in the array with the specified ValueId
       
   453 // -----------------------------------------------------------------------------   
       
   454 TInt CCamShootingModeContainer::IndexForValueId( TInt aValueId ) const
       
   455     {
       
   456     return static_cast<MCamListboxModel*>( iListBox->Model() )->ValueIndex( aValueId );
       
   457     } 
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // CCamShootingModeContainer::HandleSettingValueUpdateL
       
   461 // Handles a change to the setting value of the slider
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 void CCamShootingModeContainer::HandleSettingValueUpdateL( TInt /*aNewValue*/ )
       
   465     {   
       
   466     }
       
   467     
       
   468 
       
   469 // ---------------------------------------------------------
       
   470 // CCamShootingModeContainer::CountComponentControls 
       
   471 // Returns the number of controls owned
       
   472 // ---------------------------------------------------------
       
   473 //
       
   474 TInt CCamShootingModeContainer::CountComponentControls() const
       
   475     {
       
   476     return 1;
       
   477     }
       
   478 
       
   479 // ---------------------------------------------------------
       
   480 // CCamShootingModeContainer::ComponentControl
       
   481 // Returns the requested component control
       
   482 // ---------------------------------------------------------
       
   483 //
       
   484 CCoeControl* CCamShootingModeContainer::ComponentControl( TInt /*aIndex*/ ) const
       
   485     {
       
   486     return iListBox;
       
   487     }
       
   488 
       
   489 // ---------------------------------------------------------
       
   490 // CCamShootingModeContainer::Draw
       
   491 // Draw control
       
   492 // ---------------------------------------------------------
       
   493 //
       
   494 void CCamShootingModeContainer::Draw( const TRect& aRect ) const
       
   495     {
       
   496 	PRINT(_L("Camera => CCamShootingModeContainer::Draw") )
       
   497 
       
   498     CWindowGc& gc = SystemGc();
       
   499     if ( CamUtility::IsNhdDevice() )
       
   500         {
       
   501         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   502         AknsDrawUtils::Background( skin, iBgContext, gc, aRect );
       
   503         TRgb color;
       
   504         AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
       
   505                                                 EAknsCIQsnTextColorsCG6 );  
       
   506         iTitleTextRectLayout.DrawText( gc, *iListboxTitle, ETrue, color ); 
       
   507         }
       
   508     else
       
   509         {  
       
   510         TRAP_IGNORE( DrawSummaryTextL( gc ) );
       
   511         }
       
   512 
       
   513  
       
   514 	PRINT(_L("Camera <= CCamShootingModeContainer::Draw") )
       
   515     }
       
   516 
       
   517 // ----------------------------------------------------------------
       
   518 // CCamShootingModeContainer::OfferKeyEventL
       
   519 // Handles this application view's command keys. Forwards other
       
   520 // keys to child control(s).
       
   521 // ----------------------------------------------------------------
       
   522 //
       
   523 TKeyResponse CCamShootingModeContainer::OfferKeyEventL( 
       
   524     const TKeyEvent& aKeyEvent,
       
   525     TEventCode aType )
       
   526     {
       
   527    
       
   528     iController.StartIdleTimer();
       
   529 
       
   530     // If the Ok button is pressed, select the current item
       
   531     if ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 && aType == EEventKey )
       
   532         {
       
   533         TKeyResponse response = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   534         iView.HandleCommandL( EAknSoftkeySelect );
       
   535         return response;
       
   536         }
       
   537     TKeyResponse returnvalue = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   538 
       
   539     // for non touch, we use key presses to scroll thru the scene modes
       
   540     // for touch with keyboard, key pressing can also scroll thru the scene modes
       
   541     // after every up and down key presses we display the tool tip
       
   542     if ( EStdKeyUpArrow == aKeyEvent.iScanCode ||
       
   543          EStdKeyDownArrow == aKeyEvent.iScanCode )
       
   544         {
       
   545         if ( CamUtility::IsNhdDevice() )  
       
   546             {
       
   547             ShowTooltipL(); 
       
   548             }
       
   549         else
       
   550             {
       
   551             DrawDeferred(); // Update explanation text
       
   552             }
       
   553         }
       
   554         
       
   555     return returnvalue;
       
   556     }
       
   557 
       
   558 // -----------------------------------------------------------------
       
   559 // CCamShootingModeContainer::ConstructSummaryDetailsFromResourceL
       
   560 // Sets up the layouts of the summary items
       
   561 // -----------------------------------------------------------------
       
   562 void CCamShootingModeContainer::ConstructSummaryDetailsFromResourceL(TInt aResourceId)
       
   563     {
       
   564      // Find the name and path of the MBM file for bitmaps
       
   565     TFileName mbmFileName;
       
   566     CamUtility::ResourceFileName( mbmFileName );
       
   567      
       
   568     TResourceReader reader;                                                                                     
       
   569     iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); 
       
   570     const TInt count = reader.ReadInt16();
       
   571 
       
   572     TInt i              = -1;
       
   573     TInt bitmapId 	    = -1;
       
   574     TInt summarySceneId = -1;
       
   575     HBufC16* title = NULL;
       
   576     HBufC16* descr = NULL;
       
   577     
       
   578     // Read all of the summary entries from the resource file
       
   579     for ( i = 0; i < count; i++ )
       
   580         {
       
   581         summarySceneId = reader.ReadInt16();
       
   582         bitmapId       = reader.ReadInt32();
       
   583         title          = reader.ReadHBufC16L();
       
   584         descr          = reader.ReadHBufC16L();
       
   585 
       
   586         // Only add supported scenes.
       
   587         if( IsSupportedScene(summarySceneId) )
       
   588           {
       
   589           CFbsBitmap* icon = AknIconUtils::CreateIconL( mbmFileName, bitmapId );
       
   590           CleanupStack::PushL( icon );
       
   591           User::LeaveIfError( iSummaryBitmapArray.Append( icon ) );
       
   592           CleanupStack::Pop( icon );
       
   593 
       
   594           User::LeaveIfError( iTitleArray.Append( title ) );
       
   595           if ( summarySceneId == ECamSceneScenery )
       
   596             {
       
   597             CCamAppUi* appUi   = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
   598             if ( appUi && appUi->AppController().UiConfigManagerPtr()
       
   599                  && appUi->AppController().UiConfigManagerPtr()->IsAutoFocusSupported() )
       
   600                 {
       
   601                 // the description of the icon
       
   602                 HBufC* Description;
       
   603                 TInt description = R_CAM_SCENE_DESCRIPTION_LANDSCAPE_AUTOFOCUS;
       
   604                 Description = StringLoader::LoadL( description );
       
   605                 User::LeaveIfError( iDescArray.Append( Description ) );
       
   606                 }
       
   607             else 
       
   608                 {
       
   609                 User::LeaveIfError( iDescArray.Append( descr ) );
       
   610                 }
       
   611             }
       
   612           else 
       
   613             {
       
   614             User::LeaveIfError( iDescArray.Append( descr ) );
       
   615             }
       
   616           }
       
   617         else
       
   618           {
       
   619           delete title;
       
   620           title = NULL;
       
   621           delete descr;
       
   622           descr = NULL;
       
   623           }          
       
   624         }    
       
   625     CleanupStack::PopAndDestroy(); // reader       
       
   626     }
       
   627 
       
   628 
       
   629 
       
   630 
       
   631 
       
   632 // -----------------------------------------------------------------
       
   633 // IsSupportedScene
       
   634 //
       
   635 // Get whether the given scene is supported.
       
   636 // -----------------------------------------------------------------
       
   637 //
       
   638 TBool 
       
   639 CCamShootingModeContainer::IsSupportedScene( TInt aSceneId ) const
       
   640   {
       
   641   // NOTE: 
       
   642   //   CamUtility in product changed to return also user scene
       
   643   //   as one of supported scenes.
       
   644 
       
   645   CCamAppUi* appUi   = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
   646   TBool      imageMode = (ECamControllerImage == iMode);
       
   647   
       
   648   // Scene must be in supported scenes list.
       
   649   TBool supported = iController.IsSceneSupported( aSceneId, imageMode );
       
   650   
       
   651   // Still, user scene is never supported in user scene base list.
       
   652   TBool userException = (ECamSceneUser == aSceneId && iUserBaseScenes );
       
   653 
       
   654   if( supported && !userException )
       
   655     {
       
   656     return ETrue;
       
   657     }
       
   658   else
       
   659     {
       
   660     return EFalse;
       
   661     }
       
   662   }
       
   663 
       
   664  // --------------------------------------------------------------------------
       
   665 // CCamShootingModeContainer::HandlePointerEventL
       
   666  // --------------------------------------------------------------------------
       
   667  //    
       
   668  void CCamShootingModeContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) 
       
   669     {
       
   670     
       
   671     RDebug::Print(_L("CCamShootingModeContainer::HandlePointerEventL iType=%d iPosition=(%d, %d)"),
       
   672         aPointerEvent.iType,
       
   673         aPointerEvent.iPosition.iX,
       
   674         aPointerEvent.iPosition.iY );
       
   675     iListBox->HandlePointerEventL(aPointerEvent);
       
   676     /*TInt oldListItemIndex = -1;
       
   677     TInt newListItemIndex = -1;
       
   678     TBool handleItemActivation = EFalse;
       
   679    
       
   680     if ( iListBox )
       
   681     	{
       
   682     	oldListItemIndex = iListBox->CurrentItemIndex();
       
   683     	}
       
   684    
       
   685     // send to coecontrol -> will inform controls in this container about pointer events
       
   686     // (listbox will handle focus changes and scrolling)
       
   687     CCoeControl::HandlePointerEventL( aPointerEvent );       
       
   688        
       
   689     if ( iListBox )
       
   690     	{
       
   691     	newListItemIndex = iListBox->CurrentItemIndex();
       
   692     	}
       
   693        
       
   694     // figure out if item was activated by touch down + release combination on same item
       
   695     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   696     	{
       
   697 
       
   698     	if ( iListBox->Rect().Contains( aPointerEvent.iPosition )  ) 
       
   699     	    {
       
   700         	if ( newListItemIndex != oldListItemIndex )
       
   701         	    {
       
   702         	    iActivateOnTouchRelease = EFalse;
       
   703         	    }
       
   704         	else 
       
   705         	    {
       
   706         	    // set the current item to be activated on touch release
       
   707         	    iActivateOnTouchRelease = ETrue;
       
   708         	    }
       
   709         	 
       
   710         	// show tooltip always when touch event down happens inside listbox
       
   711         	ShowTooltipL();
       
   712         	}
       
   713     	else
       
   714     	    {
       
   715     	    iActivateOnTouchRelease = EFalse;
       
   716     	    }
       
   717     	
       
   718     	
       
   719     	}
       
   720     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   721     	{
       
   722     	if ( iActivateOnTouchRelease && ( newListItemIndex == oldListItemIndex ) )
       
   723     		{
       
   724     		// only if list item index has not changed during event 
       
   725     		// and iActivateOnTouchRelease is true
       
   726     		TInt pointedItemIndex = 0;
       
   727             TBool focusableItemPointed = 
       
   728                 iListBox->View()->XYPosToItemIndex( aPointerEvent.iPosition, 
       
   729                                                     pointedItemIndex );
       
   730             // check that pointer is in focusable area
       
   731             if ( focusableItemPointed )
       
   732                 {
       
   733                 handleItemActivation = ETrue;
       
   734                 iActivateOnTouchRelease = EFalse;                       
       
   735                 }
       
   736             else
       
   737                 {
       
   738                 iActivateOnTouchRelease = EFalse;                       
       
   739                 }
       
   740     		}
       
   741     	}
       
   742     else 
       
   743     	{
       
   744     	// aPointerEvent.iType == TPointerEvent::EDrag
       
   745     	
       
   746     	if ( newListItemIndex != oldListItemIndex )
       
   747     		{
       
   748     		// change only when drag event changes the listitem index
       
   749     		iActivateOnTouchRelease = EFalse;
       
   750 
       
   751     		// with drag always update the tooltip
       
   752     		ShowTooltipL();
       
   753     		}
       
   754 
       
   755     	}
       
   756 
       
   757 
       
   758     if ( handleItemActivation )
       
   759     	{
       
   760    	
       
   761     	// no need for tooltips anymore
       
   762     	HideCurrentTooltipL();
       
   763     	
       
   764     	if ( UserSceneHighlighted() )
       
   765     		{
       
   766     		iView.HandleCommandL( ECamCmdUserSceneSelected );
       
   767     		}
       
   768     	else 
       
   769     		{
       
   770     		iView.HandleCommandL( EAknSoftkeySelect );
       
   771     		}
       
   772     	}
       
   773    
       
   774     */
       
   775     } // end of HandlePointerEventL
       
   776     
       
   777 
       
   778 // --------------------------------------------------------------------------
       
   779 // CCamShootingModeContainer::ShowTooltipL
       
   780 // --------------------------------------------------------------------------
       
   781 //
       
   782 void CCamShootingModeContainer::ShowTooltipL()
       
   783     {
       
   784 
       
   785     if ( !iTooltipController || ( iDescArray[iListBox->CurrentItemIndex()]->Length() <= 0 ) )
       
   786         {
       
   787         return;
       
   788         }
       
   789     
       
   790     if ( iTooltipIndex != iListBox->CurrentItemIndex() )
       
   791         {
       
   792         // make sure that possible already open tooltip is hidden
       
   793         iTooltipController->HideInfoPopupNote();
       
   794         iTooltipController->SetTextL( *iDescArray[iListBox->CurrentItemIndex()] );     
       
   795         iTooltipController->SetPositionByHighlight( iListBox->HighlightRect() );
       
   796 
       
   797         iTooltipIndex = iListBox->CurrentItemIndex();
       
   798         }
       
   799     
       
   800     iTooltipController->ShowInfoPopupNote();   
       
   801     }
       
   802 
       
   803 
       
   804 // --------------------------------------------------------------------------
       
   805 // CCamShootingModeContainer::HideCurrentTooltipL
       
   806 // Hides tooltip for the selected listbox item, if one is visible
       
   807 // --------------------------------------------------------------------------
       
   808 //
       
   809 void CCamShootingModeContainer::HideCurrentTooltipL()
       
   810     {
       
   811     
       
   812     if ( !iTooltipController || ( iDescArray[iListBox->CurrentItemIndex()]->Length() <= 0 ) )
       
   813         {
       
   814         return;
       
   815         }
       
   816     
       
   817     iTooltipController->HideInfoPopupNote();
       
   818     
       
   819     }
       
   820 
       
   821  
       
   822 // --------------------------------------------------------------------------
       
   823 // CCamShootingModeContainer::ConstructContainerTitleFromResourceL
       
   824 // --------------------------------------------------------------------------
       
   825 //
       
   826 void CCamShootingModeContainer::ConstructContainerTitleFromResourceL( TInt aResourceId )
       
   827     {
       
   828     TResourceReader reader;
       
   829     iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); // cleanupstack
       
   830     
       
   831     iListboxTitle = reader.ReadHBufC16L();    
       
   832     
       
   833     CleanupStack::PopAndDestroy(); // reader
       
   834     }
       
   835 
       
   836 // --------------------------------------------------------------------------
       
   837 // CCamShootingModeContainer::SelectItem
       
   838 // --------------------------------------------------------------------------
       
   839 //
       
   840 TBool CCamShootingModeContainer::SelectItem( TInt aItemIndex )
       
   841 	{
       
   842 	
       
   843     TInt oldListItemIndex = -1;
       
   844     TBool returnSelectionSuccess = EFalse;
       
   845    
       
   846     if ( iListBox )
       
   847     	{
       
   848     	oldListItemIndex = iListBox->CurrentItemIndex();
       
   849 	
       
   850 	    if ( oldListItemIndex != aItemIndex )
       
   851 	    	{
       
   852 	    	iListBox->SetCurrentItemIndex( aItemIndex );
       
   853 	       	}
       
   854 	    else
       
   855 	    	{
       
   856 	    	// already selected
       
   857 	    	returnSelectionSuccess = EFalse;
       
   858 	    	}
       
   859     	}
       
   860     else
       
   861     	{
       
   862     	// iListBox == NULL
       
   863     	returnSelectionSuccess = EFalse;
       
   864     	}
       
   865 	
       
   866     return returnSelectionSuccess;
       
   867 	}
       
   868 
       
   869 // -----------------------------------------------------------------
       
   870 // CCamShootingModeContainer::DrawSummaryText (Scene settings)
       
   871 // Draws summary title and description text
       
   872 // -----------------------------------------------------------------
       
   873 
       
   874 void CCamShootingModeContainer::DrawSummaryTextL( CWindowGc& aGc ) const  
       
   875     {
       
   876     CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
   877     appUi->SetTitleL( *iListboxTitle );     
       
   878     
       
   879     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   880     AknsDrawUtils::Background( skin, iBgContext, aGc, Rect() );
       
   881   
       
   882     // Draw summary frame 
       
   883     TRect explTxtRect = iExplanationRect;
       
   884     TInt border = iExplIconLayout.Rect().iTl.iX - iExplanationRect.iTl.iX;
       
   885     explTxtRect.Shrink( border/2 , border/2 ); //Magic: half of frame
       
   886     AknsDrawUtils::DrawFrame( skin, aGc, iExplanationRect, explTxtRect,
       
   887                               KAknsIIDQsnFrInput, KAknsIIDNone );   //frame
       
   888     
       
   889     AknIconUtils::SetSize( iSummaryBitmapArray[iListBox->CurrentItemIndex()], 
       
   890                            iExplIconLayout.Rect().Size() ); 
       
   891     iExplIconLayout.DrawImage( aGc, 
       
   892                    iSummaryBitmapArray[ iListBox->CurrentItemIndex() ], NULL );
       
   893     
       
   894     TRgb explTitleTxtColor; // same as list highlight text
       
   895     TRgb explTxtColor;      // same as main area text
       
   896     AknsUtils::GetCachedColor( skin, explTitleTxtColor, KAknsIIDQsnTextColors,
       
   897                                EAknsCIQsnTextColorsCG10 ); 
       
   898     AknsUtils::GetCachedColor( skin, explTxtColor, KAknsIIDQsnTextColors, 
       
   899                                EAknsCIQsnTextColorsCG6 );
       
   900     iExplTitleLayout.DrawText( aGc, 
       
   901                             iTitleArray[ iListBox->CurrentItemIndex() ]->Des(), 
       
   902                             ETrue, explTitleTxtColor ); 
       
   903     AknTextUtils::WrapToArrayL( *iDescArray[iListBox->CurrentItemIndex()],
       
   904                                 iExplTxtLinesLayout[0].TextRect().Width(),
       
   905                                 *iExplTxtLinesLayout[0].Font(), 
       
   906                                 *iCurrentDescLineArray );
       
   907     TInt lCount = Min( iExplLineCount, iCurrentDescLineArray->Count() );                               
       
   908     for ( TInt i = 0; i < lCount; i++ )  
       
   909         {
       
   910         iExplTxtLinesLayout[i].DrawText( aGc, (*iCurrentDescLineArray)[i], 
       
   911                                          ETrue, explTxtColor ); 
       
   912         }     
       
   913     }
       
   914 
       
   915 
       
   916 
       
   917 // --------------------------------------------------------------------------
       
   918 // CCamShootingModeContainer::TouchLayout
       
   919 // --------------------------------------------------------------------------
       
   920 //
       
   921 TRect CCamShootingModeContainer::TouchLayout()
       
   922     {
       
   923     TRect statusPaneRect;
       
   924     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane,
       
   925                                        statusPaneRect );
       
   926     iLayoutAreaRect.BoundingRect( statusPaneRect );
       
   927     
       
   928     // get the rect size for listbox in the layout
       
   929     TAknLayoutRect wholeListboxLayoutRect;
       
   930     wholeListboxLayoutRect.LayoutRect( iLayoutAreaRect, 
       
   931                       AknLayoutScalable_Apps::main_cset_listscroll_pane( 3 ) );
       
   932     
       
   933     // get layout for the listbox rect
       
   934     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   935                                           iListBox->Model()->NumberOfItems() );
       
   936     if ( wholeListboxLayoutRect.Rect().Height() < listBoxHeight )
       
   937         {
       
   938         // if scrollbars are used, use scrollbar layout
       
   939         iListboxLayoutRect.LayoutRect( wholeListboxLayoutRect.Rect(), 
       
   940                             AknLayoutScalable_Apps::main_cset_list_pane( 0 ) );
       
   941         AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(), 
       
   942                             wholeListboxLayoutRect.Rect(),
       
   943                             AknLayoutScalable_Apps::scroll_pane_cp028( 0 ) );
       
   944         }
       
   945     else
       
   946         {
       
   947         iListboxLayoutRect.LayoutRect( wholeListboxLayoutRect.Rect(), 
       
   948                             AknLayoutScalable_Apps::main_cset_list_pane( 1 ) ); 
       
   949         }
       
   950     
       
   951     // text for the listbox title
       
   952     iTitleTextRectLayout.LayoutText( iLayoutAreaRect, 
       
   953                            AknLayoutScalable_Apps::main_cam_set_pane_t1( 3 ) );
       
   954     
       
   955     return wholeListboxLayoutRect.Rect();
       
   956     }
       
   957 
       
   958 // --------------------------------------------------------------------------
       
   959 // CCamShootingModeContainer::NonTouchLayout (Scene mode)
       
   960 // --------------------------------------------------------------------------
       
   961 //
       
   962 TRect CCamShootingModeContainer::NonTouchLayout()
       
   963     {
       
   964     TAknLayoutRect wholeListboxLayoutRect;
       
   965     wholeListboxLayoutRect.LayoutRect( iLayoutAreaRect, 
       
   966                      AknLayoutScalable_Apps::main_cset6_listscroll_pane( 3 ) );
       
   967     TAknLayoutRect listLayoutRect;
       
   968     listLayoutRect.LayoutRect( iLayoutAreaRect, 
       
   969                      AknLayoutScalable_Apps::main_cset6_listscroll_pane( 4 ) );
       
   970     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   971                                           iListBox->Model()->NumberOfItems() );
       
   972     if ( wholeListboxLayoutRect.Rect().Height() < listBoxHeight )
       
   973         {
       
   974         // if scrollbars are used, use scrollbar layout
       
   975         iListboxLayoutRect.LayoutRect( listLayoutRect.Rect(),
       
   976                       AknLayoutScalable_Apps::main_cset_list_pane_copy1( 0 ) );
       
   977         AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(), 
       
   978                         listLayoutRect.Rect(),
       
   979                         AknLayoutScalable_Apps::scroll_pane_cp028_copy1( 0 ) );
       
   980         }
       
   981     else
       
   982         {
       
   983         iListboxLayoutRect.LayoutRect( listLayoutRect.Rect(), 
       
   984                       AknLayoutScalable_Apps::main_cset_list_pane_copy1( 1 ) );  
       
   985         }
       
   986     
       
   987     // Explanation ikon, title, and text layout
       
   988     TAknLayoutRect explParent;
       
   989     explParent.LayoutRect( iLayoutAreaRect,
       
   990                           AknLayoutScalable_Apps::main_cset6_text2_pane( 0 ) );
       
   991     TAknLayoutRect explLayoutRect;
       
   992     explLayoutRect.LayoutRect( explParent.Rect(), 
       
   993               AknLayoutScalable_Apps::bg_popup_preview_window_pane_cp03( 0 ) );
       
   994     iExplanationRect = explLayoutRect.Rect();
       
   995 
       
   996     iExplIconLayout.LayoutRect( iExplanationRect, 
       
   997             AknLayoutScalable_Apps::main_cset6_text2_pane_g1( 0 ) );  
       
   998     iExplTitleLayout.LayoutText( iExplanationRect, 
       
   999             AknLayoutScalable_Apps::main_cset6_text2_pane_t1( 0 ) ); 
       
  1000     iExplTitleLayout.LayoutText( iExplanationRect, 
       
  1001             AknLayoutScalable_Apps::main_cset6_text2_pane_t1( 0 ) ); 
       
  1002 
       
  1003     TAknLayoutRect explTxtParent;
       
  1004     explTxtParent.LayoutRect( iExplanationRect,
       
  1005                              AknLayoutScalable_Apps::list_cset_text2_pane(0) );
       
  1006     TAknLayoutScalableParameterLimits listLimits = 
       
  1007               AknLayoutScalable_Apps::list_cset_text2_pane_t1_ParamLimits( 0 );
       
  1008     iExplLineCount = listLimits.LastRow() + 1;
       
  1009     for ( TInt i = 0; i < iExplLineCount; i++ )
       
  1010         {
       
  1011         TAknLayoutText layoutText;
       
  1012         layoutText.LayoutText( explTxtParent.Rect(), 
       
  1013                   AknLayoutScalable_Apps::list_cset_text2_pane_t1( 0, 0, i ) );
       
  1014         (void) iExplTxtLinesLayout.Append( layoutText ); // Errors are ignored
       
  1015         } 
       
  1016     
       
  1017     TRect ret = wholeListboxLayoutRect.Rect();
       
  1018     // Non-touch has a visible title & status panes
       
  1019     TRect titlePaneRect;
       
  1020     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, 
       
  1021                                        titlePaneRect );
       
  1022     ret.Move( 0, -titlePaneRect.Height() );
       
  1023     return ret;
       
  1024     }
       
  1025 
       
  1026 // --------------------------------------------------------------------------
       
  1027 // CCamShootingModeContainer::HandleListBoxEventL 
       
  1028 // Handles Listbox events
       
  1029 // --------------------------------------------------------------------------
       
  1030 //
       
  1031 
       
  1032 void CCamShootingModeContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType )
       
  1033     {
       
  1034     switch( aEventType )
       
  1035         {
       
  1036         case EEventEnterKeyPressed:
       
  1037         case EEventItemDoubleClicked:
       
  1038         case EEventItemSingleClicked:
       
  1039               {
       
  1040               HideCurrentTooltipL();
       
  1041               if ( UserSceneHighlighted() )
       
  1042                   {
       
  1043                   iView.HandleCommandL( ECamCmdUserSceneSelected );
       
  1044                   }
       
  1045               else 
       
  1046                   {
       
  1047                   iView.HandleCommandL( EAknSoftkeySelect );
       
  1048                   }
       
  1049               }
       
  1050               break;  
       
  1051         
       
  1052         case EEventItemClicked:
       
  1053             {
       
  1054             ShowTooltipL();
       
  1055             }
       
  1056             break;
       
  1057         default:
       
  1058             break;
       
  1059         }
       
  1060     }
       
  1061 // End of File