camerauis/cameraapp/generic/common/src/CamCaptureSetupListBox.cpp
changeset 0 1ddebce53859
child 3 8b2d6d0384b0
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:  A list box that displays settings items with radio buttons*
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "CamCaptureSetupListBox.h"
       
    20 #include "CamCaptureSetupListBoxModel.h"
       
    21 #include "CamCaptureSetupListItemDrawer.h"
       
    22 #include "CamSettingValueObserver.h"
       
    23 #include <uikon.hrh>
       
    24 
       
    25 #include "CamUtility.h"
       
    26 
       
    27 #include <aknlayoutscalable_apps.cdl.h>
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CCamCaptureSetupListBox::CCamCaptureSetupListBox
       
    33 // C++ constructor
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CCamCaptureSetupListBox::CCamCaptureSetupListBox( MCamSettingValueObserver* aObserver
       
    37 #ifndef CAMERAAPP_PLUGIN_BUILD
       
    38         						                  ,CCamAppController& aController 
       
    39 #else
       
    40                                                   ,MCamAppController& aController
       
    41 #endif //CAMERAAPP_PLUGIN_BUILD
       
    42                                                  )
       
    43 : iSettingObserver( aObserver ), iController( aController )
       
    44     {
       
    45     iBorder = TGulBorder::ENone;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CCamCaptureSetupListBox::ConstructL
       
    50 // 2nd phase construction
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 void CCamCaptureSetupListBox::ConstructL( const CCoeControl* aParent, 
       
    54                                           TInt aArrayResourceId, 
       
    55                                           TInt aSettingItem,
       
    56                                           TInt aFlags,
       
    57                                           TBool aShootingModeListBox,
       
    58                                           TBool aLocationSettingListBox
       
    59                                           )
       
    60 	{
       
    61 
       
    62 	//Constructing model
       
    63     CCamCaptureSetupListBoxModel* model =
       
    64              CCamCaptureSetupListBoxModel::NewLC( iController,
       
    65              									  aArrayResourceId, 
       
    66              									  aSettingItem,
       
    67              								      aShootingModeListBox,
       
    68                                                   aLocationSettingListBox,
       
    69                                                   Rect()
       
    70              								      );
       
    71     CCamCaptureSetupListItemDrawer* itemDrawer = 
       
    72                                 CCamCaptureSetupListItemDrawer::NewL( *model );
       
    73 
       
    74                                 
       
    75     itemDrawer->SetParentControl( aParent );
       
    76     // CEikListBox takes ownership before anything can leave.
       
    77     // Do not need the model or drawer on the stack when call ConstructL,
       
    78     // because CEikListBox assigns objects as member variables before
       
    79     // ConstructL calls any leaving functions.
       
    80 	CleanupStack::Pop( model ); 
       
    81 	CEikListBox::ConstructL( model, itemDrawer, aParent, aFlags );
       
    82     // The number of items is fixed after the list box has been constructed
       
    83     const TInt KMaxListItems = 5; // This value should come from the LAF
       
    84     // Find the number of items to be displayed in the list box
       
    85     iRequiredHeightInNumOfItems = Min( Model()->NumberOfItems(), KMaxListItems );
       
    86     SetItemHeightL( iItemDrawer->MinimumCellSize().iHeight );
       
    87 	}
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CCamCaptureSetupListBox destructor
       
    91 // 
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 CCamCaptureSetupListBox::~CCamCaptureSetupListBox()
       
    95 	{
       
    96   PRINT( _L("Camera => ~CCamCaptureSetupListBox") );
       
    97   PRINT( _L("Camera <= ~CCamCaptureSetupListBox") );
       
    98 	}
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // CCamCaptureSetupListBox::InitializeL
       
   102 // Initialize the current and selected item in the view
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CCamCaptureSetupListBox::InitializeL( TInt aCurrentValueId )
       
   106     {
       
   107     TInt selectedItemIndex = 
       
   108       static_cast<MCamListboxModel*>( iModel )->ValueIndex( aCurrentValueId );
       
   109 
       
   110     // if the item does not exist select the topmost item
       
   111     selectedItemIndex = Max( selectedItemIndex, 0 );
       
   112     if ( selectedItemIndex < iModel->NumberOfItems() )
       
   113         {
       
   114         iView->SetCurrentItemIndex( selectedItemIndex );
       
   115         iView->SetDisableRedraw( ETrue );
       
   116         iView->SelectItemL( selectedItemIndex );
       
   117         iView->SetDisableRedraw( EFalse );
       
   118         }
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CCamCaptureSetupListBox::OfferKeyEventL
       
   123 // Handle key presses
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TKeyResponse CCamCaptureSetupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )
       
   127     {
       
   128     PRINT( _L("Camera => CCamCaptureSetupListBox::OfferKeyEventL" ))
       
   129     // If the Select or navi key select button is pressed, select the current item
       
   130     if ( ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 && aType == EEventKey )
       
   131         || aKeyEvent.iScanCode == EStdKeyDevice0 ) 
       
   132         {
       
   133         iView->ClearSelection();
       
   134 	    iView->SelectItemL( iView->CurrentItemIndex() );
       
   135         }
       
   136     //TInt oldCurrentItem = CurrentItemIndex();
       
   137     TKeyResponse response = CEikListBox::OfferKeyEventL( aKeyEvent, aType );
       
   138     /*TInt newCurrentItem = CurrentItemIndex();
       
   139     if ( newCurrentItem != oldCurrentItem )
       
   140         {
       
   141         PRINT( _L("Camera => CCamCaptureSetupListBox::OfferKeyEventL set obs" ))
       
   142         MCamListboxModel* model = static_cast<MCamListboxModel*>( iModel );
       
   143         iSettingObserver->HandleSettingValueUpdateL( model->ItemValue( newCurrentItem ) );
       
   144         }*/
       
   145     return response;
       
   146     }
       
   147 
       
   148 
       
   149 
       
   150 
       
   151 
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CCamCaptureSetupListBox::HandlePointerEventL
       
   155 // Handle pointer events
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CCamCaptureSetupListBox::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   159     {   
       
   160     /*TInt oldCurrentItem = CurrentItemIndex();
       
   161     TInt newCurrentItem = CurrentItemIndex();
       
   162     
       
   163     // listbox does default handling
       
   164     CEikListBox::HandlePointerEventL(aPointerEvent);
       
   165     
       
   166     newCurrentItem = CurrentItemIndex();
       
   167       
       
   168     // handle settings update when focus changes  
       
   169 	if ( newCurrentItem != oldCurrentItem )
       
   170 	    {
       
   171 	    MCamListboxModel* model = static_cast<MCamListboxModel*>( iModel );
       
   172 	    iSettingObserver->HandleSettingValueUpdateL( model->ItemValue( newCurrentItem ) );
       
   173 
       
   174 	    }*/
       
   175     iController.StartIdleTimer(); // standby
       
   176     CEikListBox::HandlePointerEventL(aPointerEvent);
       
   177     }
       
   178 
       
   179 
       
   180 //End of file
       
   181