camerauis/cameraapp/generic/src/CamCaptureSetupMenuListBox.cpp
changeset 0 1ddebce53859
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     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:  Encapsulates the capture setup menu list box.*
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <barsread.h>
       
    20 #include <eikenv.h>
       
    21 
       
    22 #include <cameraapp.rsg>
       
    23 #include <vgacamsettings.rsg>
       
    24 
       
    25 #include "CamCaptureSetupMenuListBox.h"
       
    26 #include "CamCaptureSetupMenuListBoxModel.h"
       
    27 #include "CamCaptureSetupMenuListItemDrawer.h"
       
    28 #include "camlogging.h"
       
    29 
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // NewL
       
    35 // Two-phased constructor.
       
    36 // Returns: CCamCaptureSetupMenuListBox*: Pointer to the created list item.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CCamCaptureSetupMenuListBox* CCamCaptureSetupMenuListBox::NewL( 
       
    40     const CCoeControl* aParent,         // container for this list box
       
    41     TResourceReader& aReader,            // used to populate the list box
       
    42     CCamAppController& aController, // used by the list box model to get list item values
       
    43     TInt aSelectedItemIndex )
       
    44     {
       
    45     CCamCaptureSetupMenuListBox* self = new( ELeave ) CCamCaptureSetupMenuListBox;
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL( aParent, aReader, aController,aSelectedItemIndex );
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // Destructor
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CCamCaptureSetupMenuListBox::~CCamCaptureSetupMenuListBox()
       
    57 	{
       
    58 	}
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // CCamCaptureSetupMenuListBox::ItemSettingsId()
       
    62 // Returns the settings model id that corresponds with the
       
    63 // specified list item index.
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 TInt CCamCaptureSetupMenuListBox::ItemSettingsId( TInt aItemIndex )
       
    67     {
       
    68     return static_cast<CCamCaptureSetupMenuListBoxModel*>( iModel )
       
    69         ->SettingsModelIdAssociatedWithItem( aItemIndex );
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CCamCaptureSetupMenuListBox::MakeViewClassInstanceL()
       
    74 // This method creates instance of CCamCaptureSetupMenuListBoxView
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 CListBoxView* CCamCaptureSetupMenuListBox::MakeViewClassInstanceL()
       
    78 	{
       
    79 	return new( ELeave ) CListBoxView;
       
    80 	}
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CCamCaptureSetupMenuListBox::OfferKeyEventL
       
    84 // Handles a user pressing the key.
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 TKeyResponse CCamCaptureSetupMenuListBox::OfferKeyEventL(
       
    88     const TKeyEvent& aKeyEvent, // The key event
       
    89     TEventCode aType)           // The type of key event
       
    90 	{
       
    91     // If the navikey select has been pressed don't process it.
       
    92     if ( aType == EEventKey && aKeyEvent.iCode == EKeyOK )
       
    93         {
       
    94         return EKeyWasNotConsumed; // indicate that not been processed.
       
    95         }
       
    96 
       
    97 	return CEikListBox::OfferKeyEventL( aKeyEvent, aType );
       
    98 	}
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // Constructor
       
   102 // ---------------------------------------------------------
       
   103 //
       
   104 CCamCaptureSetupMenuListBox::CCamCaptureSetupMenuListBox( )
       
   105 	{
       
   106 	}
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // 2nd phase constructor
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 void CCamCaptureSetupMenuListBox::ConstructL(
       
   113     const CCoeControl* aParent,         // container for this list box
       
   114     TResourceReader& aReader,            // resource reader that will be used to populate the list box
       
   115     CCamAppController& aController, // used by the list box model to get list item values
       
   116     TInt aSelectedItemIndex )
       
   117     {
       
   118     // Set the container window to be the parent.
       
   119     CEikListBox::SetContainerWindowL( *aParent );
       
   120 
       
   121     // Create the model for the list box.
       
   122     CCamCaptureSetupMenuListBoxModel* model = 
       
   123         CCamCaptureSetupMenuListBoxModel::NewLC( aController, aReader );
       
   124 
       
   125     // Create the item drawer for the list box.
       
   126     CCamCaptureSetupMenuListItemDrawer* itemDrawer = 
       
   127         CCamCaptureSetupMenuListItemDrawer::NewL( model, aReader );
       
   128     itemDrawer->SetParentControl( aParent );
       
   129 
       
   130 	// Transfering ownership to CEikListBox.
       
   131     // Do not need the model or drawer on the cleanup stack when call ConstructL,
       
   132     // because CEikListBox assigns objects as member variables before
       
   133     // ConstructL calls any leaving functions.
       
   134     CleanupStack::Pop( model );
       
   135 	CEikListBox::ConstructL( model, itemDrawer, aParent, EAknListBoxMarkableList );
       
   136 
       
   137     // Set the border style.
       
   138     iBorder = TGulBorder::EDeepRaised;
       
   139 
       
   140     // Set the selected item index
       
   141     iView->SetCurrentItemIndex( aSelectedItemIndex );
       
   142 	}
       
   143 
       
   144 
       
   145 
       
   146 
       
   147