photosgallery/viewframework/views/gridview/src/glxgridviewimp.cpp
changeset 0 4e91876724a2
child 9 6b87b143d312
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Implementation of Grid view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <aknbutton.h>
       
    24 #include <StringLoader.h>
       
    25 #include <AknsBasicBackgroundControlContext.h>
       
    26 
       
    27 //Gallery Headers
       
    28 #include <glxactivemedialistregistry.h>                 // For medialist registry
       
    29 #include <glxcommandhandlers.hrh>                       // For EGlxCmdFullScreenBack                   
       
    30 #include <glxgridviewdata.rsg>                          // Gridview resource
       
    31 
       
    32 #include <mglxmedialist.h>                              // CGlxMedialist
       
    33 #include <glxsetappstate.h>
       
    34 #include <glxtracer.h>                                  // For Tracer
       
    35 
       
    36 
       
    37 // User Includes
       
    38 #include "glxgridviewimp.h"                         
       
    39 #include "glxgridviewmlobserver.h"                      // medialist observer for Hg Grid                
       
    40 #include "glxgridviewcontainer.h"
       
    41 
       
    42 const TInt KGlxToolbarButtonUnLatched = 0;              // Toolbar mark button's unlatched state defined in the rss file
       
    43 
       
    44 // ======== MEMBER FUNCTIONS ========
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Two-phased constructor.
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CGlxGridViewImp* CGlxGridViewImp::NewL(
       
    51 		MGlxMediaListFactory* aMediaListFactory,
       
    52 		const TGridViewResourceIds& aResourceIds,
       
    53 		TInt aViewUID,
       
    54 		const TDesC& aTitle)
       
    55 	{
       
    56 	TRACER("CGlxGridViewImp::NewL");
       
    57 	CGlxGridViewImp* self = CGlxGridViewImp::NewLC(aMediaListFactory, 
       
    58 			aResourceIds,
       
    59 			aViewUID,
       
    60 			aTitle);
       
    61 	CleanupStack::Pop(self);
       
    62 	return self;
       
    63 	}
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Two-phased constructor.
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CGlxGridViewImp* CGlxGridViewImp::NewLC(
       
    70 		MGlxMediaListFactory* aMediaListFactory,
       
    71 		const TGridViewResourceIds& aResourceIds,
       
    72 		TInt aViewUID,
       
    73 		const TDesC& aTitle)
       
    74 	{
       
    75 	TRACER("CGlxGridViewImp::NewLC()");
       
    76 	CGlxGridViewImp* self = 
       
    77 	new (ELeave) CGlxGridViewImp(aResourceIds, aViewUID);
       
    78 	CleanupStack::PushL(self);
       
    79 	self->ConstructL(aMediaListFactory, aTitle);
       
    80 	return self;
       
    81 	}
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // C++ default constructor can NOT contain any code, that
       
    85 // might leave.
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CGlxGridViewImp::CGlxGridViewImp(const TGridViewResourceIds& aResourceIds,
       
    89 		TInt aViewUID) :
       
    90 		iResourceIds(aResourceIds),
       
    91 		iViewUID(aViewUID),
       
    92 		iPreviousFocusChangeType(NGlxListDefs::EUnknown)
       
    93     	{
       
    94     	TRACER("CGlxGridViewImp::CGlxGridViewImp()");
       
    95     	}
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Symbian 2nd phase constructor can leave.
       
    99 // ---------------------------------------------------------------------------
       
   100 //  
       
   101 void CGlxGridViewImp::ConstructL(MGlxMediaListFactory* aMediaListFactory,
       
   102 		const TDesC& aTitle)
       
   103 	{
       
   104 	TRACER("CGlxGridViewImp::ConstructL()");
       
   105 	BaseConstructL(iResourceIds.iViewId);
       
   106 	ViewBaseConstructL();
       
   107 	MLViewBaseConstructL(aMediaListFactory, aTitle);   
       
   108 
       
   109 	//Register the view to recieve toolbar events. ViewBase handles the events
       
   110 	SetToolbarObserver(this);
       
   111 	ShowToolbarOnViewActivation(ETrue);
       
   112     
       
   113 	// Get object that stores the active media list registry
       
   114 	iActiveMediaListRegistry = CGlxActiveMediaListRegistry::InstanceL();
       
   115 	}
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // From CAknView
       
   119 // Handles a view activation.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CGlxGridViewImp::DoMLViewActivateL(
       
   123 		const TVwsViewId& /* aPrevViewId */, 
       
   124 		TUid /* aCustomMessageId */,
       
   125 		const TDesC8& /*aCustomMessage*/)
       
   126 	{
       
   127 	TRACER("CGlxGridViewImp::DoMLViewActivateL()");
       
   128 
       
   129 	if(StatusPane())
       
   130 		{
       
   131 		StatusPane()->MakeVisible(ETrue);
       
   132 		CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   133 		CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL(
       
   134 				TUid::Uid( EEikStatusPaneUidTitle ));     
       
   135 		const TDesC* titleText = titlePane->Text();
       
   136 		HBufC* tempTitle = titleText->AllocLC();
       
   137 		TPtr titleptr = tempTitle->Des();
       
   138 		titleptr.Trim();
       
   139 		if(!tempTitle->Length())
       
   140 			{
       
   141 			if( iTitletext )
       
   142 				{
       
   143 				// Set the required Title
       
   144 				titlePane->SetTextL( *iTitletext );
       
   145 				}
       
   146 			}
       
   147 		CleanupStack::PopAndDestroy(tempTitle);        
       
   148 		}
       
   149 
       
   150 	GlxSetAppState::SetState(EGlxInCarouselView);
       
   151 	// Setting the Context sensitive menu id
       
   152 	MenuBar()->SetContextMenuTitleResourceId( iResourceIds.iOkOptionsMenuId );
       
   153 	iActiveMediaListRegistry->RegisterActiveMediaList(iMediaList);
       
   154 
       
   155 	//Create HG Grid, medialist observer, FS thumbnailcontext
       
   156 	iGlxGridViewContainer = CGlxGridViewContainer::NewL(iMediaList,iUiUtility,*this);
       
   157 	iEikonEnv->AppUi()->AddToStackL(*this,iGlxGridViewContainer);
       
   158 	}
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // From CAknView
       
   162 // View deactivation function.
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CGlxGridViewImp::DoMLViewDeactivate()
       
   166 	{
       
   167 	TRACER("CGlxGridViewImp::DoMLViewDeactivate");
       
   168 	if(StatusPane())
       
   169 		{
       
   170 		if(iTitletext)
       
   171 			{
       
   172 			delete iTitletext;
       
   173 			iTitletext = NULL;
       
   174 			}
       
   175 		CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   176 		TRAP_IGNORE(CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL(
       
   177 				TUid::Uid( EEikStatusPaneUidTitle ));        
       
   178 		iTitletext = titlePane->Text()->AllocL());
       
   179 		}
       
   180 	// Deregister active media list pointer
       
   181 	iActiveMediaListRegistry->DeregisterActiveMediaList(iMediaList);
       
   182 
       
   183 	// Destroy Grid widget before going to next view
       
   184 	DestroyGridWidget();
       
   185 	}
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // DestroyGridWidget
       
   189 // ---------------------------------------------------------------------------
       
   190 //  
       
   191 void CGlxGridViewImp::DestroyGridWidget()
       
   192 	{
       
   193 	TRACER("CGlxGridViewImp::DestroyGridWidget()");
       
   194 	//while view deactivating need to remove from the control stack.
       
   195 	iEikonEnv->AppUi()->RemoveFromViewStack(*this,iGlxGridViewContainer);        
       
   196 	delete iGlxGridViewContainer;
       
   197     iGlxGridViewContainer = NULL;
       
   198 	}
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // Destructor
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 CGlxGridViewImp::~CGlxGridViewImp()
       
   205 	{
       
   206 	TRACER("CGlxGridViewImp::~CGlxGridViewImp");
       
   207 	delete iTitletext;
       
   208     
       
   209 	if (iActiveMediaListRegistry)
       
   210 		{
       
   211 		iActiveMediaListRegistry->Close();
       
   212 		}    
       
   213 	}
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // From CAknView
       
   217 // Returns views id.
       
   218 // ---------------------------------------------------------------------------
       
   219 TUid CGlxGridViewImp::Id() const
       
   220 {
       
   221 TRACER("CGlxGridViewImp::Id()");
       
   222 return TUid::Uid(iViewUID);
       
   223 }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // From CAknView
       
   227 // Command handling function.
       
   228 // ---------------------------------------------------------------------------
       
   229 TBool CGlxGridViewImp::HandleViewCommandL(TInt aCommand)
       
   230 	{
       
   231 	TRACER("CGlxGridViewImp::HandleViewCommandL()");
       
   232     GLX_LOG_INFO1( "CGlxGridViewImp::HandleViewCommandL(%x) entering", aCommand );
       
   233     return iGlxGridViewContainer->HandleViewCommandL(aCommand);
       
   234 	}
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // From CAknView
       
   238 // HandleForegroundEventL
       
   239 // Foreground event handling function.
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 void CGlxGridViewImp::HandleForegroundEventL(TBool aForeground)
       
   243 	{
       
   244     TRACER("CGlxGridViewImp::HandleForegroundEventL()");
       
   245 	CAknView::HandleForegroundEventL(aForeground);
       
   246 	}
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // From MGlxHandleGridEvents
       
   250 // HandleGridEventsL()
       
   251 // handles processcommandL related commands
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 void CGlxGridViewImp::HandleGridEventsL(TInt aCmd)
       
   255 	{
       
   256 	TRACER("CGlxGridViewImp::HandleGridEventsL()");
       
   257 	//do processcmd related event handling
       
   258 	ProcessCommandL(aCmd);
       
   259 	}
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // From MGlxHandleButtonMark
       
   263 // HandleLatchToolbar()
       
   264 // sets toolbar mark unmark status
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 void CGlxGridViewImp::HandleLatchToolbar()
       
   268 	{
       
   269 	TRACER("CGlxGridViewImp::HandleLatchToolbarL()");
       
   270 	CAknButton* markButton = static_cast<CAknButton*>
       
   271 									(Toolbar()->ControlOrNull( EGlxCmdStartMultipleMarking ));
       
   272 
       
   273 	if(markButton)
       
   274 		{
       
   275 		markButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue );
       
   276 		}	
       
   277 	}
       
   278 //  End of File