Nokia N97 SDK
Example Applications Guide

ListboxSettingView.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : ListboxSettingView.cpp
00004 *  Part of     : Listbox example
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2007 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #include <listbox.rsg>
00017 #include "ListboxSettingView.h"
00018 #include "ListboxSettingList.h"
00019 #include "Listbox.hrh"
00020 #include "ListboxAppUi.h"
00021 
00022 // ============================ MEMBER FUNCTIONS ===============================
00023 
00024 // ---------------------------------------------------------------------------
00025 // CListboxSettingView::NewL()
00026 // Two-phased constructor.
00027 // ---------------------------------------------------------------------------
00028 //
00029 CListboxSettingView* CListboxSettingView::NewL()
00030     {
00031     CListboxSettingView* self = new (ELeave) CListboxSettingView;
00032     CleanupStack::PushL(self);
00033     self->ConstructL();
00034     CleanupStack::Pop(self);
00035     return self;
00036     }
00037 
00038 // ---------------------------------------------------------------------------
00039 // CListboxSettingView::CListboxSettingView()
00040 // C++ default constructor
00041 // ---------------------------------------------------------------------------
00042 //
00043 CListboxSettingView::CListboxSettingView()
00044     {
00045     }
00046 
00047 // ---------------------------------------------------------------------------
00048 // CListboxSettingView::~CListboxSettingView()
00049 // Destructor
00050 // ---------------------------------------------------------------------------
00051 //
00052 CListboxSettingView::~CListboxSettingView()
00053         {
00054         if ( iContainer )
00055         {
00056         AppUi()->RemoveFromStack( iContainer );
00057         delete iContainer;
00058         }     
00059         }
00060 
00061 // ---------------------------------------------------------------------------
00062 // CListboxSettingView::Id()
00063 // Returns views id.
00064 // ---------------------------------------------------------------------------
00065 //
00066 TUid CListboxSettingView::Id() const 
00067     { 
00068     return TUid::Uid( EListboxSettingView ); 
00069     }
00070 
00071 // ---------------------------------------------------------------------------
00072 // CListboxSettingView::HandleCommandL()
00073 // Handles commands.
00074 // ---------------------------------------------------------------------------
00075 //
00076 void CListboxSettingView::HandleCommandL( TInt aCommand )
00077     {
00078     switch( aCommand )
00079         {
00080         case EListboxCmdChange:
00081             iContainer->EditItemL( 0, ETrue );
00082             break;
00083         default:
00084             AppUi()->HandleCommandL(aCommand);  
00085             break;
00086         }
00087     }
00088 
00089 // ---------------------------------------------------------------------------
00090 // CListboxSettingView::DoActivateL()
00091 // Activates this view.
00092 // ---------------------------------------------------------------------------
00093 //
00094 void CListboxSettingView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
00095                       TUid /*aCustomMessageId*/,
00096                       const TDesC8& /*aCustomMessage*/ )
00097     {    
00098     iContainer = CListboxSettingList::NewL();
00099     
00100     iContainer->SetMopParent( this );
00101     iContainer->ConstructFromResourceL( R_LISTBOX_SETTING_ITEM_LIST );
00102     AppUi()->AddToStackL( *this, iContainer );
00103     
00104     iContainer->MakeVisible( ETrue );
00105     iContainer->SetRect( ClientRect() );
00106     iContainer->ActivateL();
00107     }
00108 
00109 // ---------------------------------------------------------------------------
00110 // CListboxSettingView::DoDeactivate()
00111 // Deactivates this view
00112 // ---------------------------------------------------------------------------
00113 //
00114 void CListboxSettingView::DoDeactivate()
00115     {
00116     if ( iContainer )
00117         {
00118         AppUi()->RemoveFromViewStack( *this, iContainer );
00119         delete iContainer;
00120         iContainer = NULL;
00121         }    
00122     }
00123 
00124 // ---------------------------------------------------------------------------
00125 // CListboxSettingView::ConstructL()
00126 // Symbian 2nd phase constructor can leave.
00127 // ---------------------------------------------------------------------------
00128 //
00129 void CListboxSettingView::ConstructL()
00130     {
00131     BaseConstructL(R_LISTBOX_SETTINGS_VIEW);    
00132     }
00133 
00134 // ---------------------------------------------------------------------------
00135 // CListboxSettingView::DynInitMenuPaneL()
00136 // This function is called by the EIKON framework just before it displays a 
00137 // menu pane.
00138 // ---------------------------------------------------------------------------
00139 //
00140 void CListboxSettingView::DynInitMenuPaneL( TInt aResourceId, 
00141                                            CEikMenuPane* aMenuPane )
00142     {
00143     if( aResourceId == R_LISTBOX_CHANGE_SUBMENU )
00144         {   
00145         aMenuPane->SetItemDimmed( EListboxCommandToSetting, ETrue );  
00146         }
00147     }   
00148 
00149 // -----------------------------------------------------------------------------
00150 // CListboxSettingView::HandleSizeChange()
00151 // Called by HandleResourceChangeL() from CListboxAppUi when layout is 
00152 // changed.
00153 // -----------------------------------------------------------------------------
00154 //
00155 void CListboxSettingView::HandleSizeChange( TInt aType )
00156     {
00157     if( iContainer )
00158         {
00159         iContainer->HandleResourceChange( aType );
00160         
00161         if( aType==KEikDynamicLayoutVariantSwitch )
00162             {        
00163             TRect rect;
00164             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00165             iContainer->SetRect(rect);
00166             }
00167         }         
00168     } 

© Nokia 2009

Back to top