camerauis/cameraapp/generic/GsCamcorderPlugin/src/CamLocationSettingPage.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 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 location setting in Image&Video Settings.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <gscamerapluginrsc.rsg>
       
    21 #include <aknsettingitemlist.h>
       
    22 #include <barsread.h>
       
    23 #include "CamUtility.h"
       
    24 #include "CamLocationSettingPage.h"
       
    25 #include "MCamAppController.h"
       
    26 #include "CamLocationSettingContainer.h"
       
    27 #include <aknlayoutscalable_apps.cdl.h>
       
    28 #include <layoutmetadata.cdl.h>
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 // ---------------------------------------------------------------------------
       
    35 // CCamLocationSettingPage::CCamLocationSettingPage
       
    36 // C++ constructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CCamLocationSettingPage::CCamLocationSettingPage( 
       
    40     TCamCameraMode aMode, 
       
    41     TDesC& aSettingTitleText,
       
    42     TInt aSettingNumber, 
       
    43     TInt aControlType,
       
    44     TInt aEditorResourceId, 
       
    45     TInt aSettingPageResourceId,
       
    46     MAknQueryValue& aQueryValue,
       
    47     MCamAppController& aController )
       
    48     : CAknSettingPage(	&aSettingTitleText, 
       
    49 						aSettingNumber, 
       
    50 						aControlType,
       
    51 						aEditorResourceId, 
       
    52 						aSettingPageResourceId ),
       
    53       iQueryValue( aQueryValue ),
       
    54       iController( aController ),
       
    55       iMode( aMode )
       
    56     {
       
    57     }
       
    58 // ---------------------------------------------------------------------------
       
    59 // CCamLocationSettingPage::~CCamLocationSettingPage
       
    60 // C++ destructor
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CCamLocationSettingPage::~CCamLocationSettingPage()
       
    64   {
       
    65   PRINT( _L("Camera => ~CCamLocationSettingPage") );
       
    66   delete iLocationContainer;
       
    67   
       
    68   if ( iTimer && iTimer->IsActive() )
       
    69     {
       
    70     iTimer->Cancel();
       
    71     }
       
    72   delete iTimer;
       
    73   
       
    74   TRAP_IGNORE( iController.CancelPreviewChangesL() );
       
    75   PRINT( _L("Camera <= ~CCamLocationSettingPage") );
       
    76   }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CCamLocationSettingPage::ConstructL
       
    80 // Construct the setting page
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CCamLocationSettingPage::ConstructL()
       
    84 	{
       
    85     // create the timer used for callbacks
       
    86     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    87     // this needs to be created before BaseConstructL as it sets the
       
    88     // size of the setting page which will result in SizeChanged being called
       
    89     iLocationContainer = CCamLocationSettingContainer::NewL( iController, 
       
    90                                                              iMode, 
       
    91                                                              this );
       
    92 	BaseConstructL();
       
    93 	}
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CCamLocationSettingPage::UpdateSettingL
       
    97 // Called when the state of location setting changes
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CCamLocationSettingPage::UpdateSettingL()
       
   101     {
       
   102     TBool settingValueEnabled = ETrue;
       
   103     iCurrentVal = iLocationContainer->SelectedValue();
       
   104     iSettingItemId = ECamSettingItemRecLocation;
       
   105     // Inform the base setting page class
       
   106 	SetDataValidity( settingValueEnabled );
       
   107     UpdateCbaL();
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CCamLocationSettingPage::ProcessCommandL
       
   112 // Processes events from the softkeys.
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CCamLocationSettingPage::ProcessCommandL( TInt aCommandId )
       
   116 	{
       
   117 	HideMenu();
       
   118 
       
   119 	// Respond to softkey events
       
   120 	switch ( aCommandId )
       
   121 		{
       
   122 		case EAknSoftkeyOk:
       
   123 		case EAknSoftkeySelect:  
       
   124 			SelectCurrentItemL(); 
       
   125 			AttemptExitL( ETrue );
       
   126             iController.CommitPreviewChanges();
       
   127 			break;
       
   128 		case EAknSoftkeyCancel:
       
   129 			AttemptExitL( EFalse );
       
   130             iController.CancelPreviewChangesL();
       
   131 			break;
       
   132 		default:
       
   133 			break;
       
   134 		}
       
   135 	}
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CCamLocationSettingPage::PostDisplayCheckL
       
   139 // Customises some of the functionality so that the custom control
       
   140 // is used instead of the base classes editor control
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 TBool CCamLocationSettingPage::PostDisplayCheckL()
       
   144     {
       
   145     // don't use the editor control in the base class
       
   146     // use the custom control instead.
       
   147     iLocationContainer->SetObserver( this );
       
   148     return CAknSettingPage::PostDisplayCheckL();
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // CCamLocationSettingPage::SelectCurrentItemL
       
   153 // Uses the query value to inform the setting item that
       
   154 // a new value has been selected
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CCamLocationSettingPage::SelectCurrentItemL()
       
   158 	{
       
   159 	iQueryValue.SetCurrentValueIndex( iLocationContainer->SelectedValue() );
       
   160 	} 
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CCamLocationSettingPage::ConstructFromResourceL
       
   164 // Constructs the quality container from the resource file
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void CCamLocationSettingPage::ConstructFromResourceL( TResourceReader& aReader )
       
   168     {
       
   169     // setting page window is created in the base class
       
   170     CAknSettingPage::ConstructFromResourceL( aReader );
       
   171 
       
   172     TResourceReader reader;
       
   173 	iLocationContainer->ConstructFromResourceL( reader );
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CCamLocationSettingPage::CountComponentControls
       
   178 // Returns the number of component controls
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 TInt CCamLocationSettingPage::CountComponentControls() const
       
   182     {
       
   183     return 1; // the location container
       
   184     }
       
   185  
       
   186 // ---------------------------------------------------------------------------
       
   187 // CCamLocationSettingPage::ComponentControl
       
   188 // Returns the control at the given index
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 CCoeControl* CCamLocationSettingPage::ComponentControl( TInt /*aIndex*/ ) const
       
   192     {
       
   193     return iLocationContainer;
       
   194     }
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // CCamLocationSettingPage::Draw
       
   198 // Draws the setting page
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CCamLocationSettingPage::Draw( const TRect& /*aRect*/ ) const
       
   202     {
       
   203     CWindowGc& gc = SystemGc();
       
   204     gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   205     gc.SetBrushColor( KRgbWhite );
       
   206     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   207     gc.DrawRect( Rect() );
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CCamLocationSettingPage::SizeChanged
       
   212 // Handles a change in the size of the page
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 void CCamLocationSettingPage::SizeChanged()
       
   216     {
       
   217     CAknSettingPage::SizeChanged();
       
   218 
       
   219     if ( CamUtility::IsNhdDevice() ) 
       
   220         {
       
   221         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   222             {
       
   223             AknLayoutUtils::LayoutControl( iLocationContainer, Rect(), AknLayoutScalable_Apps::main_cam_set_pane_g1( 7 ) );
       
   224             }
       
   225         else
       
   226             {
       
   227             AknLayoutUtils::LayoutControl( iLocationContainer, Rect(), AknLayoutScalable_Apps::main_cam_set_pane_g1( 8 ) );
       
   228             }
       
   229         }
       
   230     else
       
   231         {
       
   232         AknLayoutUtils::LayoutControl( iLocationContainer, Rect(), AknLayoutScalable_Apps::main_cam6_set_pane( 0 ) );
       
   233         }
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CCamLocationSettingPage::OfferKeyEventL
       
   238 // Handles the key event
       
   239 // ---------------------------------------------------------------------------
       
   240 //
       
   241 TKeyResponse CCamLocationSettingPage::OfferKeyEventL( 
       
   242                                             const TKeyEvent& aKeyEvent, 
       
   243                                             TEventCode aType 
       
   244                                             ) 
       
   245     {
       
   246     // Always react to Escape key by cancelling the setting page
       
   247 	if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape)
       
   248 		{
       
   249 		ProcessCommandL( EAknSoftkeyCancel );
       
   250 		return EKeyWasConsumed;
       
   251 		}
       
   252 
       
   253 	// Only handle other key events if we're focused
       
   254 	if ( IsFocused() )
       
   255 		{
       
   256 		// Abstraction of key events: Escape is handled like Cancel 
       
   257 		// OK key is handled like the Select softkey by default
       
   258 		if ( aType == EEventKey && aKeyEvent.iCode == EKeyOK )
       
   259 			{
       
   260 			if ( aKeyEvent.iRepeats != 0 ) 
       
   261                 {
       
   262                 return EKeyWasConsumed;
       
   263                 }
       
   264 			if ( DataValidity() )
       
   265                 {
       
   266                 ProcessCommandL( EAknSoftkeySelect );
       
   267                 }
       
   268             return EKeyWasConsumed;
       
   269             }
       
   270 		}
       
   271 
       
   272     // offer the key to the quality container class
       
   273     // if not handled by the setting page
       
   274     return iLocationContainer->OfferKeyEventL( aKeyEvent, aType );
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CCamLocationSettingPage::PreviewSettingChangeL
       
   279 // Previews the setting value
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 TInt CCamLocationSettingPage::PreviewSettingChange( TAny* aAny )
       
   283     {
       
   284     CCamLocationSettingPage* settingPage = 
       
   285         static_cast<CCamLocationSettingPage*>( aAny );
       
   286     // preview the setting value - will 
       
   287     // update the engine and the navi couner
       
   288     TRAPD( ignore, settingPage->iController.PreviewSettingChangeL( 
       
   289                                                 settingPage->iSettingItemId, 
       
   290                                                 settingPage->iCurrentVal ) );       
       
   291 	if(ignore)
       
   292 		{
       
   293 		// Lint error removal
       
   294 		}
       
   295 		
       
   296     // cancel the timer
       
   297     settingPage->iTimer->Cancel();
       
   298 
       
   299     return KErrNone;
       
   300     }
       
   301 //End of File