camerauis/cameraapp/generic/GsCamcorderPlugin/src/CamLocationSettingContainer.cpp
changeset 0 1ddebce53859
child 2 e8773a61782d
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Implements the location settings for image settings*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <gscamerapluginrsc.rsg>
       
    22 #include <barsread.h>
       
    23 #include <AknQueryValue.h>
       
    24 #include <AknIconUtils.h>
       
    25 #include <akntitle.h>  // CAknTitlePane
       
    26 #include <aknappui.h>
       
    27 #include <AknsUtils.h>
       
    28 #include <AknsDrawUtils.h>
       
    29 #include <StringLoader.h>
       
    30 #include <cameraapp.mbg>
       
    31 #include <aknlayoutscalable_apps.cdl.h>
       
    32 #include <layoutmetadata.cdl.h>
       
    33 #include <touchfeedback.h> 
       
    34 
       
    35 #include "CamLocationSettingContainer.h"
       
    36 #include "CamUtility.h"
       
    37 #include "CamCaptureSetupListBox.h"
       
    38 #include "CamCaptureSetupListBoxModel.h"
       
    39 #include "CamPanic.h"
       
    40 #include "camuiconstants.h"
       
    41 #include "camuidconstants.h"
       
    42 #include "CamAppUiBase.h"
       
    43 #include "CamStaticSettingsModel.h"
       
    44 #include "GSCamcorderPlugin.h"
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CCamLocationSettingContainer::CCamLocationSettingContainer
       
    50 // C++ default constructor can NOT contain any code, that
       
    51 // might leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CCamLocationSettingContainer::CCamLocationSettingContainer( MCamAppController& aController,
       
    55                                                             TCamCameraMode aMode,
       
    56                                                             CCoeControl* aParent )
       
    57 :   iParent( aParent ),
       
    58     iController( aController ), 
       
    59     iMode( aMode ),
       
    60     iActivateOnTouchRelease( EFalse )
       
    61     {
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CCamLocationSettingContainer::ConstructL
       
    66 // Symbian 2nd phase constructor can leave.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void CCamLocationSettingContainer::ConstructL()
       
    70     {
       
    71     PRINT(_L("Camera => CCamLocationSettingContainer::ConstructL") )
       
    72 	PRINT(_L("Camera <= CCamLocationSettingContainer::ConstructL") )
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CCamLocationSettingContainer::NewL
       
    77 // Two-phased constructor.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CCamLocationSettingContainer* 
       
    81 CCamLocationSettingContainer::NewL( MCamAppController& aController,
       
    82                                     TCamCameraMode     aMode,
       
    83                                     CCoeControl*       aParent )
       
    84     {
       
    85     CCamLocationSettingContainer* self = 
       
    86         new( ELeave ) CCamLocationSettingContainer( aController, aMode, aParent );
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop();
       
    90     return self;
       
    91     }
       
    92 
       
    93     
       
    94 // -----------------------------------------------------------------------------
       
    95 // CCamLocationSettingContainer::~CCamLocationSettingContainer
       
    96 // Destructor
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CCamLocationSettingContainer::~CCamLocationSettingContainer()
       
   100   {
       
   101   PRINT( _L("Camera => ~CCamLocationSettingContainer") );
       
   102   CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( iEikonEnv->AppUi() );
       
   103   if ( appUi )
       
   104     {
       
   105     TInt resId = ( ECamControllerVideo == iMode )
       
   106                ? R_CAM_VIDEO_SETTINGS_TITLE_NAME
       
   107                : R_CAM_PHOTO_SETTINGS_TITLE_NAME;
       
   108     
       
   109     TRAP_IGNORE( appUi->SetTitleL( resId ) );
       
   110     }
       
   111     iDescArray.ResetAndDestroy();
       
   112     iDescLayoutArray.Close();
       
   113     if ( iCurrentDescLineArray )
       
   114         {
       
   115         iCurrentDescLineArray->Reset();
       
   116         delete iCurrentDescLineArray;
       
   117         } 
       
   118     delete iListBox;
       
   119     
       
   120     if ( iTextTitle )
       
   121         {
       
   122         delete iTextTitle;
       
   123         iTextTitle = NULL;
       
   124         }
       
   125     
       
   126   PRINT( _L("Camera <= ~CCamLocationSettingContainer") );
       
   127   }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CCamLocationSettingContainer::SelectedQuality
       
   131 // Returns the value selected by the listbox
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 TInt CCamLocationSettingContainer::SelectedValue() const
       
   135     {
       
   136     CCamCaptureSetupListBoxModel *model = static_cast<CCamCaptureSetupListBoxModel *>( iListBox->Model() );
       
   137     return model->ItemValue( iListBox->CurrentItemIndex() ); 
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CCamLocationSettingContainer::ConstructFromResourceL
       
   142 // Constructs the container from the resource
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CCamLocationSettingContainer::ConstructFromResourceL( TResourceReader& /*aReader*/ )
       
   146     {
       
   147     CAknViewAppUi* viewAppUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() );
       
   148     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
   149                                ( viewAppUi->View( KGSCamcorderGSPluginUid ) );
       
   150 
       
   151    // set up the container windows here as setting page window
       
   152     // isn't created until CAknSettingPage::ConstructFromResourceL is called
       
   153     SetContainerWindowL( *iParent );
       
   154     
       
   155     TRect mainPaneRect;
       
   156     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   157             mainPaneRect );
       
   158     TRect statusPaneRect;
       
   159     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane,
       
   160             statusPaneRect );
       
   161     
       
   162     // layout area rectangle contains the area, where components need to be 
       
   163     // drawn to. the container size is the whole screen, but the layouts are 
       
   164     // for the client area. aRect is the container size that might include or
       
   165     // might not include statuspane area. calculating area self will
       
   166     // go around the problem
       
   167     TRect layoutAreaRect;
       
   168     layoutAreaRect = mainPaneRect;
       
   169     layoutAreaRect.BoundingRect( statusPaneRect );
       
   170     
       
   171     // set the layouts for the rect containing the description
       
   172     if ( CamUtility::IsNhdDevice() ) 
       
   173         {
       
   174         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   175             {
       
   176             iSummaryRect.LayoutRect( layoutAreaRect, AknLayoutScalable_Apps::main_cset_text2_pane( 0 ) );
       
   177             }
       
   178         else
       
   179             {
       
   180             iSummaryRect.LayoutRect( layoutAreaRect, AknLayoutScalable_Apps::main_cset_text2_pane( 1 ) );
       
   181             }
       
   182         }
       
   183     else
       
   184         {
       
   185         iSummaryRect.LayoutRect( layoutAreaRect, AknLayoutScalable_Apps::main_cset6_text2_pane( 0 ) );
       
   186         }
       
   187     
       
   188 	TRAPD( ignore, 
       
   189 	       ConstructSummaryDetailsFromResourceL( R_CAM_OFF_ON_LOC_TEXT_LIST_SUMMARY ); 
       
   190 	     )
       
   191     if ( ignore )
       
   192         { 
       
   193         // Do nothing ( removes build warning )
       
   194         }
       
   195  
       
   196 	iCurrentDescLineArray  = new( ELeave ) CArrayFixFlat<TPtrC>( 5 );
       
   197 	
       
   198     // set layout for 5 lines of descriptive text
       
   199     iDescLayoutArray.Reset();
       
   200     TAknLayoutText layout;
       
   201     TAknLayoutScalableParameterLimits listLimits = 
       
   202         AknLayoutScalable_Apps::main_cset_text2_pane_t1_copy1_ParamLimits( 0 );
       
   203     TInt lineCount = listLimits.LastRow() + 1;
       
   204     for ( TInt i = 0; i < lineCount; i++ )
       
   205         {
       
   206         if ( CamUtility::IsNhdDevice() ) 
       
   207             {
       
   208             layout.LayoutText( iSummaryRect.Rect(), 
       
   209                 AknLayoutScalable_Apps::main_cset_text2_pane_t1( i ) );
       
   210             }
       
   211         else
       
   212             {
       
   213             layout.LayoutText( iSummaryRect.Rect(), 
       
   214                 AknLayoutScalable_Apps::main_cset_text2_pane_t1_copy1(0,0,i) );
       
   215             }
       
   216         User::LeaveIfError( iDescLayoutArray.Append( layout ) );
       
   217         }
       
   218     
       
   219 	TInt listInt = ECamSettingItemRecLocation;
       
   220 	iListBox =	new( ELeave ) CCamCaptureSetupListBox( this, iController );
       
   221 	iListBox->ConstructL( this, 
       
   222 	                      R_CAM_OFF_ON_LOC_TEXT_LIST, 
       
   223 	                      TInt( ECamSettingItemRecLocation ), 
       
   224 	                      0, 
       
   225 	                      EFalse, 
       
   226 	                      ETrue );
       
   227 	if ( parent )
       
   228 	    {
       
   229 	    iListBox->InitializeL
       
   230 		    ( parent->IntegerSettingValue( listInt ) );
       
   231 		}
       
   232 	iListBox->SetContainerWindowL( *iParent );
       
   233     iListBox->DisableSingleClick( ETrue );
       
   234 	
       
   235 	TRect listboxRect;
       
   236 	ReadListboxLayoutL(listboxRect);
       
   237     
       
   238     // Determine the height of the listbox; Either the height based on the number of items,
       
   239     // or the maximum allowed listbox height.
       
   240     CEikScrollBarFrame::TScrollBarVisibility visibility = CEikScrollBarFrame::EOff;
       
   241     TInt maxListBoxHeight = listboxRect.Height();
       
   242     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   243                                         iListBox->Model()->NumberOfItems() );
       
   244     if ( maxListBoxHeight < listBoxHeight )
       
   245         {
       
   246         // there are more items than would fit to the listbox rectangle
       
   247         
       
   248         // the maximum height is the total height of items 
       
   249         // that can fit to the maxlistboxheight
       
   250         TInt itemHeight = iListBox->ItemHeight();
       
   251         TInt itemsVisible = maxListBoxHeight / itemHeight;
       
   252         listBoxHeight = itemsVisible * itemHeight;
       
   253         
       
   254         // the scrollbar needs to be turned on
       
   255         visibility = CEikScrollBarFrame::EOn;
       
   256         }
       
   257 
       
   258     // get layout for the listbox rect
       
   259     TAknLayoutRect listboxLayoutRect;
       
   260     if ( visibility == CEikScrollBarFrame::EOn )
       
   261         {
       
   262         // if scrollbars are used, use scrollbar layout
       
   263         if ( CamUtility::IsNhdDevice() ) 
       
   264             {
       
   265             listboxLayoutRect.LayoutRect( listboxRect, 
       
   266                 AknLayoutScalable_Apps::main_cset_list_pane( 0 ) );
       
   267             }
       
   268         else
       
   269             {
       
   270             listboxLayoutRect.LayoutRect( listboxRect, 
       
   271                 AknLayoutScalable_Apps::main_cset_list_pane_copy1( 0 ) );
       
   272             }
       
   273         }
       
   274     else
       
   275         {
       
   276         if ( CamUtility::IsNhdDevice() ) 
       
   277             {
       
   278             listboxLayoutRect.LayoutRect( listboxRect, 
       
   279                 AknLayoutScalable_Apps::main_cset_list_pane( 1 ) );
       
   280             }
       
   281         else
       
   282             {
       
   283             listboxLayoutRect.LayoutRect( listboxRect, 
       
   284                 AknLayoutScalable_Apps::main_cset_list_pane_copy1( 1 ) );
       
   285             }
       
   286         }
       
   287     
       
   288     // layout scrollbarpane (will not be visible if not needed)
       
   289     TAknLayoutRect scrollbarLayoutRect;
       
   290     if ( CamUtility::IsNhdDevice() ) 
       
   291         {
       
   292         scrollbarLayoutRect.LayoutRect( listboxRect, 
       
   293             AknLayoutScalable_Apps::scroll_pane_cp028( 0 ) );
       
   294         }
       
   295     else
       
   296         {
       
   297         scrollbarLayoutRect.LayoutRect( listboxRect, 
       
   298             AknLayoutScalable_Apps::scroll_pane_cp028_copy1( 0 ) );
       
   299         }
       
   300     
       
   301     // calculate the layout for the listbox with changed height
       
   302     const AknLayoutUtils::SAknLayoutControl listboxLayout =
       
   303     {   ELayoutEmpty, listboxRect.iTl.iX, listboxRect.iTl.iY, 
       
   304         ELayoutEmpty, ELayoutEmpty, 
       
   305         listboxLayoutRect.Rect().Width(), listBoxHeight };
       
   306     
       
   307     AknLayoutUtils::LayoutControl( iListBox, 
       
   308             layoutAreaRect, listboxLayout);
       
   309     
       
   310     iListBox->CreateScrollBarFrameL( ETrue );
       
   311     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   312                                             CEikScrollBarFrame::EOff, 
       
   313                                             visibility );
       
   314     iListBox->MakeVisible( ETrue );
       
   315     iListBox->SetFocus( EFalse, ENoDrawNow );
       
   316     iListBox->UpdateScrollBarsL();
       
   317     iListBox->ScrollBarFrame()->DrawScrollBarsNow();
       
   318     iListBox->SetListBoxObserver(this);
       
   319     SplitCurrentTextL();
       
   320     
       
   321     // Prevents the system filling invalidated areas with the background colour - 
       
   322     // helps reduce flicker.
       
   323     Window().SetBackgroundColor();
       
   324 
       
   325     ConstructContainerTitleFromResourceL( R_CAM_PHOTO_LOCATION_SETTINGS_TITLE_NAME ); 
       
   326     CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( iEikonEnv->AppUi() );
       
   327     appUi->SetTitleL( iTextTitle->Des() );
       
   328     }
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CCamLocationSettingContainer::CountComponentControls
       
   332 // return the number of component controls
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 TInt CCamLocationSettingContainer::CountComponentControls() const
       
   336     {
       
   337     return 1; // the listbox
       
   338     }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CCamLocationSettingContainer::ComponentControl
       
   342 // return the control at a given index
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 CCoeControl* CCamLocationSettingContainer::ComponentControl( TInt /*aIndex*/ ) const
       
   346     {
       
   347     return iListBox;
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CCamLocationSettingContainer::Draw
       
   352 // Draws the container
       
   353 // -----------------------------------------------------------------------------
       
   354 //
       
   355 void CCamLocationSettingContainer::Draw( const TRect& /*aRect*/ ) const
       
   356     {
       
   357     CWindowGc& gc = SystemGc();
       
   358 
       
   359     // Draw skin background
       
   360     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   361     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   362     AknsDrawUtils::Background( skin, cc, gc, Rect() );
       
   363  
       
   364      // Draw summary text                              
       
   365     DrawSummaryText( gc );
       
   366     }
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CCamLocationSettingContainer::SizeChanged
       
   370 // Handles a change in the size of the control
       
   371 // -----------------------------------------------------------------------------
       
   372 //
       
   373 void CCamLocationSettingContainer::SizeChanged()
       
   374     {
       
   375     // Do this only if the listbox has been created, ie. ConstructFromResourceL() has been called
       
   376     if (iListBox)
       
   377         {
       
   378         TRect listboxRect;
       
   379         TRAPD( ignore, ReadListboxLayoutL(listboxRect) );
       
   380         if ( ignore )
       
   381             { 
       
   382             // Just return if the resource reader fails
       
   383             return;
       
   384             }   
       
   385     
       
   386         TRect mainPaneRect;
       
   387         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   388                 mainPaneRect );
       
   389         TRect statusPaneRect;
       
   390         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane,
       
   391                 statusPaneRect );
       
   392         
       
   393         // layout area rectangle contains the area, where components need to be 
       
   394         // drawn to. the container size is the whole screen, but the layouts are 
       
   395         // for the client area. aRect is the container size that might include or
       
   396         // might not include statuspane area. calculating area self will
       
   397         // go around the problem
       
   398         TRect layoutAreaRect;
       
   399         layoutAreaRect = mainPaneRect;
       
   400         layoutAreaRect.BoundingRect( statusPaneRect );
       
   401     
       
   402         // Determine the height of the listbox; Either the height based on the number of items,
       
   403         // or the maximum allowed listbox height.
       
   404         CEikScrollBarFrame::TScrollBarVisibility visibility = CEikScrollBarFrame::EOff;
       
   405         TInt maxListBoxHeight = listboxRect.Height();
       
   406         TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   407                                             iListBox->Model()->NumberOfItems() );
       
   408         if ( maxListBoxHeight < listBoxHeight )
       
   409             {
       
   410             // there are more items than would fit to the listbox rectangle
       
   411             
       
   412             // the maximum height is the total height of items 
       
   413             // that can fit to the maxlistboxheight
       
   414             TInt itemHeight = iListBox->ItemHeight();
       
   415             TInt itemsVisible = maxListBoxHeight / itemHeight;
       
   416             listBoxHeight = itemsVisible * itemHeight;
       
   417             
       
   418             // the scrollbar needs to be turned on
       
   419             visibility = CEikScrollBarFrame::EOn;
       
   420             }
       
   421     
       
   422         // get layout for the listbox rect
       
   423         TAknLayoutRect listboxLayoutRect;
       
   424         if ( visibility == CEikScrollBarFrame::EOn )
       
   425             {
       
   426             // if scrollbars are used, use scrollbar layout
       
   427             if ( CamUtility::IsNhdDevice() ) 
       
   428                 {
       
   429                 listboxLayoutRect.LayoutRect( listboxRect, 
       
   430                     AknLayoutScalable_Apps::main_cset_list_pane( 0 ) );
       
   431                 }
       
   432             else
       
   433                 {
       
   434                 listboxLayoutRect.LayoutRect( listboxRect, 
       
   435                     AknLayoutScalable_Apps::main_cset_list_pane_copy1( 0 ) );
       
   436                 }
       
   437             }
       
   438         else
       
   439             {
       
   440             if ( CamUtility::IsNhdDevice() ) 
       
   441                 {
       
   442                 listboxLayoutRect.LayoutRect( listboxRect, 
       
   443                     AknLayoutScalable_Apps::main_cset_list_pane( 1 ) );
       
   444                 }
       
   445             else
       
   446                 {
       
   447                 listboxLayoutRect.LayoutRect( listboxRect, 
       
   448                     AknLayoutScalable_Apps::main_cset_list_pane_copy1( 1 ) );
       
   449                 }
       
   450             }
       
   451         
       
   452         // layout scrollbarpane (will not be visible if not needed)
       
   453         TAknLayoutRect scrollbarLayoutRect;
       
   454         if ( CamUtility::IsNhdDevice() ) 
       
   455             {
       
   456             scrollbarLayoutRect.LayoutRect( listboxRect, 
       
   457                 AknLayoutScalable_Apps::scroll_pane_cp028( 0 ) );
       
   458             }
       
   459         else
       
   460             {
       
   461             scrollbarLayoutRect.LayoutRect( listboxRect, 
       
   462                 AknLayoutScalable_Apps::scroll_pane_cp028_copy1( 0 ) );
       
   463             }
       
   464         
       
   465         // calculate the layout for the listbox with changed height
       
   466         const AknLayoutUtils::SAknLayoutControl listboxLayout =
       
   467         {   ELayoutEmpty, listboxRect.iTl.iX, listboxRect.iTl.iY, 
       
   468             ELayoutEmpty, ELayoutEmpty, 
       
   469             listboxLayoutRect.Rect().Width(), listBoxHeight };
       
   470         
       
   471         AknLayoutUtils::LayoutControl( iListBox, 
       
   472                 layoutAreaRect, listboxLayout);
       
   473         }
       
   474     }
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // CCamLocationSettingContainer::OfferKeyEventL
       
   478 // Handles key events
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 TKeyResponse CCamLocationSettingContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   482                                                           TEventCode aType ) 
       
   483     {
       
   484     TKeyResponse keyResponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   485     if ( keyResponse == EKeyWasConsumed )
       
   486         {
       
   487         ReportEventL( MCoeControlObserver::EEventStateChanged );
       
   488         }
       
   489     return keyResponse;
       
   490     }
       
   491 
       
   492 // -----------------------------------------------------------------------------
       
   493 // CCamLocationSettingContainer::HandleSettingValueUpdateL
       
   494 // Handles a change to the setting value
       
   495 // -----------------------------------------------------------------------------
       
   496 //
       
   497 void CCamLocationSettingContainer::HandleSettingValueUpdateL( TInt /*aNewValue*/ )
       
   498     {
       
   499     SplitCurrentTextL();
       
   500     ActivateGc();
       
   501     Window().Invalidate( iSummaryRect.Rect() );
       
   502     DeactivateGc();
       
   503     }
       
   504 
       
   505 // -----------------------------------------------------------------------------
       
   506 // CCamLocationSettingContainer::ReadListboxLayoutL
       
   507 // Reads the listbox layout
       
   508 // -----------------------------------------------------------------------------
       
   509 //
       
   510 void CCamLocationSettingContainer::ReadListboxLayoutL( TRect& aRect )
       
   511     {
       
   512     TRect mainPaneRect;
       
   513     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   514             mainPaneRect );
       
   515     TRect statusPaneRect;
       
   516     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane,
       
   517             statusPaneRect );
       
   518         
       
   519     // layout area rectangle contains the area, where components need to be 
       
   520     // drawn to. the container size is the whole screen, but the layouts are 
       
   521     // for the client area. aRect is the container size that might include or
       
   522     // might not include statuspane area. calculating area self will
       
   523     // go around the problem
       
   524     TRect layoutAreaRect;
       
   525     layoutAreaRect = mainPaneRect;
       
   526     layoutAreaRect.BoundingRect( statusPaneRect );
       
   527     
       
   528     // get the rect size for listbox in the layout
       
   529     TAknLayoutRect listboxLayoutRect;
       
   530     if ( CamUtility::IsNhdDevice() ) 
       
   531         {
       
   532         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   533             {
       
   534             listboxLayoutRect.LayoutRect( layoutAreaRect, 
       
   535                 AknLayoutScalable_Apps::main_cset_listscroll_pane( 4 ) );
       
   536             }
       
   537         else
       
   538             {
       
   539             listboxLayoutRect.LayoutRect( layoutAreaRect, 
       
   540                 AknLayoutScalable_Apps::main_cset_listscroll_pane( 5 ) );
       
   541             }
       
   542         }
       
   543     else
       
   544         {
       
   545         listboxLayoutRect.LayoutRect( layoutAreaRect, 
       
   546             AknLayoutScalable_Apps::main_cset6_listscroll_pane( 4 ) );
       
   547         }
       
   548     aRect.SetRect(listboxLayoutRect.Rect().iTl, listboxLayoutRect.Rect().Size() );
       
   549     }
       
   550 
       
   551 // -----------------------------------------------------------------
       
   552 // CCamLocationSettingContainer::ConstructSummaryDetailsFromResourceL
       
   553 // Sets up the layouts of the summary items
       
   554 // -----------------------------------------------------------------
       
   555 void CCamLocationSettingContainer::ConstructSummaryDetailsFromResourceL(TInt aResourceId)
       
   556     {
       
   557     TResourceReader reader;                                                                                     
       
   558     iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); 
       
   559     const TInt count = reader.ReadInt16();
       
   560 
       
   561     TInt i              = -1;
       
   562     // bitmapID and SummarySceneId are needed since we are using
       
   563     // a resource that requires fetching those values also.
       
   564     // The reason why the resource itself is not changed is
       
   565     // that we are using a CamCaptureSetupListBox that needs those.
       
   566     // This requires much less work if not creating own listbox type that
       
   567     // would otherwise have to be created. CamCaptureSetupListBox is now
       
   568     // used here in such a way that the listbox icon are is set to zero width
       
   569     // and no bitmap icon is showed.
       
   570     TInt bitmapId = -1;
       
   571     // To remove warning about setting variable but never using it
       
   572     TInt summarySceneId = bitmapId;
       
   573     // made to remove warning. (explained above comments)
       
   574     bitmapId = summarySceneId;
       
   575      
       
   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         descr          = reader.ReadHBufC16L();
       
   584 
       
   585 	    // This hack because an empty resource string which comes as NULL from the resource reader.
       
   586 	    // This would create crash later on.
       
   587 	    if ( NULL == descr )
       
   588 	        {
       
   589 	        _LIT(KText,"");
       
   590 	        HBufC* buf;
       
   591 	        buf = HBufC::NewL(0);
       
   592 	        *buf = KText;
       
   593 	        User::LeaveIfError( iDescArray.Append( buf ) );
       
   594 	        }
       
   595 	    else 
       
   596 	        {
       
   597 	        User::LeaveIfError( iDescArray.Append( descr ) );
       
   598 	        }
       
   599         }    
       
   600     CleanupStack::PopAndDestroy(); // reader       
       
   601     }
       
   602 
       
   603 
       
   604 // -----------------------------------------------------------------
       
   605 // CCamLocationModeContainer::DrawSummaryText
       
   606 // Draws summary title and description text
       
   607 // -----------------------------------------------------------------
       
   608 void CCamLocationSettingContainer::DrawSummaryText( CWindowGc& aGc ) const
       
   609     {
       
   610 //    aGc.SetBrushColor( KRgbShadedWhite );
       
   611 //    aGc.Clear( iSummaryRect.Rect() );
       
   612 
       
   613     TInt count = iCurrentDescLineArray->Count();
       
   614     TInt layoutCount = iDescLayoutArray.Count();
       
   615     TRgb color; 
       
   616     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   617     AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 );    
       
   618 
       
   619     if ( layoutCount < count )
       
   620         {
       
   621         count = layoutCount;
       
   622         }
       
   623     TInt i;        
       
   624     for ( i = 0; i < count; i++ )
       
   625         {
       
   626         iDescLayoutArray[i].DrawText( aGc, ( *iCurrentDescLineArray )[i], ETrue, color );
       
   627         }
       
   628     }
       
   629     
       
   630 // -----------------------------------------------------------------
       
   631 // CCamLocationModeContainer::SplitCurrentTextL
       
   632 // Splits the summary title and description text into multiple lines that fit the status layouts
       
   633 // -----------------------------------------------------------------
       
   634 void CCamLocationSettingContainer::SplitCurrentTextL()
       
   635     {
       
   636     // Use the layout info from the first line for width and font
       
   637     TAknLayoutText layout = iDescLayoutArray[0];
       
   638    	AknTextUtils::WrapToArrayL( *iDescArray[iListBox->CurrentItemIndex()],
       
   639                                 layout.TextRect().Width(),
       
   640                                 *( layout.Font() ),
       
   641                                 *iCurrentDescLineArray );
       
   642     }
       
   643 
       
   644 
       
   645 // --------------------------------------------------------------------------
       
   646 // CCamLocationSettingContainer::ConstructContainerTitleFromResourceL
       
   647 // --------------------------------------------------------------------------
       
   648 //
       
   649 void CCamLocationSettingContainer::ConstructContainerTitleFromResourceL( TInt aResourceId )
       
   650     {
       
   651     TResourceReader reader;
       
   652     iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); // cleanupstack
       
   653     
       
   654     iTextTitle = reader.ReadHBufC16L();    
       
   655     
       
   656     CleanupStack::PopAndDestroy(); // reader
       
   657     }
       
   658 
       
   659 // --------------------------------------------------------------------------
       
   660 // CCamLocationSettingContainer::HandlePointerEventL
       
   661 // --------------------------------------------------------------------------
       
   662 //    
       
   663 void CCamLocationSettingContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) 
       
   664     {
       
   665     RDebug::Print(_L("CCamLocationSettingContainer::HandlePointerEventL iType=%d iPosition=(%d, %d)"),
       
   666             aPointerEvent.iType,
       
   667             aPointerEvent.iPosition.iX,
       
   668             aPointerEvent.iPosition.iY );
       
   669     iListBox->HandlePointerEventL( aPointerEvent );
       
   670     /*TInt oldListItemIndex = -1;
       
   671     TInt newListItemIndex = -1;
       
   672     TBool handleItemActivation = EFalse;
       
   673    
       
   674     if ( iListBox )
       
   675         {
       
   676         oldListItemIndex = iListBox->CurrentItemIndex();
       
   677         }
       
   678   
       
   679     CCoeControl::HandlePointerEventL( aPointerEvent );       
       
   680        
       
   681     if ( iListBox )
       
   682         {
       
   683         newListItemIndex = iListBox->CurrentItemIndex();
       
   684         }
       
   685        
       
   686     if ( oldListItemIndex != -1 && newListItemIndex != -1 )
       
   687         {
       
   688         
       
   689         // figure out if item was activated by touch down + release combination on same item
       
   690         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   691             {
       
   692             if ( newListItemIndex != oldListItemIndex )
       
   693                 {
       
   694                 iActivateOnTouchRelease = EFalse;
       
   695                 }
       
   696             else 
       
   697                 {
       
   698                 // set the current item to be activated on touch release
       
   699                 iActivateOnTouchRelease = ETrue;
       
   700                 }
       
   701             }
       
   702         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   703             {
       
   704             if ( iActivateOnTouchRelease && ( newListItemIndex == oldListItemIndex ) )
       
   705                 {
       
   706                 TInt pointedItemIndex;
       
   707                 TBool focusableItemPointed = iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointedItemIndex );
       
   708                 // check that pointer is in focusable area
       
   709                 if ( focusableItemPointed )
       
   710                     {
       
   711                     // only if list item index has not changed during event and iActivateOnTouchRelease is true
       
   712                     handleItemActivation = ETrue;
       
   713                     iActivateOnTouchRelease = EFalse;                       
       
   714                     }
       
   715                 else
       
   716                     {
       
   717                     iActivateOnTouchRelease = EFalse;                       
       
   718                     }
       
   719                 }
       
   720             }
       
   721         else 
       
   722             {
       
   723             // aPointerEvent.iType == TPointerEvent::EDrag
       
   724             
       
   725             if ( newListItemIndex != oldListItemIndex )
       
   726                 {
       
   727                 // change only when drag event changes the listitem index
       
   728                 iActivateOnTouchRelease = EFalse;
       
   729                 }
       
   730             }
       
   731     
       
   732         } // end if ( oldListItemIndex != -1 && newListItemIndex != -1 )
       
   733     
       
   734     if ( handleItemActivation )
       
   735         {
       
   736         TKeyEvent key;
       
   737         key.iRepeats = 0;
       
   738         key.iCode = EKeyOK;
       
   739         key.iModifiers = 0;
       
   740         iEikonEnv->SimulateKeyEventL( key, EEventKey );
       
   741         }*/
       
   742         
       
   743     } // end of HandlePointerEventL
       
   744 // ---------------------------------------------------------------------------
       
   745 // CCamLocationSettingContainer::HandleListBoxEventL
       
   746 // Handles Listbox events
       
   747 // ---------------------------------------------------------------------------
       
   748 //
       
   749 void CCamLocationSettingContainer::HandleListBoxEventL( CEikListBox* aListBox, 
       
   750                                                     TListBoxEvent aEventType )
       
   751     {
       
   752     
       
   753     switch( aEventType )
       
   754         {
       
   755         
       
   756         case EEventEnterKeyPressed:
       
   757         case EEventItemDoubleClicked:
       
   758               {
       
   759                TKeyEvent key;
       
   760                key.iRepeats = 0;
       
   761                key.iCode = EKeyOK;
       
   762                key.iModifiers = 0;
       
   763                iEikonEnv->SimulateKeyEventL( key, EEventKey );
       
   764               }
       
   765               break;  
       
   766         case EEventItemClicked:
       
   767             {
       
   768             HandleSettingValueUpdateL( iListBox->CurrentItemIndex() );          
       
   769             }
       
   770             break;
       
   771         default:
       
   772             break;
       
   773         }
       
   774     }
       
   775 //  End of File