diff -r b3cee849fa46 -r fad26422216a memspyui/source/MemSpyViewThreadInfoItemActiveObject.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/source/MemSpyViewThreadInfoItemActiveObject.cpp Wed Sep 01 12:30:35 2010 +0100 @@ -0,0 +1,241 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "MemSpyViewThreadInfoItemActiveObject.h" + +// Engine includes +#include +#include +#include +#include +#include +#include +#include + +// User includes +#include "MemSpyContainerObserver.h" + + + +CMemSpyViewThreadInfoItemActiveObjectBase::CMemSpyViewThreadInfoItemActiveObjectBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer ) +: CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeActiveObject ) + { + } + + +TBool CMemSpyViewThreadInfoItemActiveObjectBase::HandleCommandL( TInt aCommand ) + { + TBool handled = ETrue; + // + switch ( aCommand ) + { + case EMemSpyCmdActiveObjectListing: + OnCmdWriteAOListingL(); + break; + default: + handled = CMemSpyViewBase::HandleCommandL( aCommand ); + break; + } + // + return handled; + } + + +void CMemSpyViewThreadInfoItemActiveObjectBase::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) + { + if ( aResourceId == R_MEMSPY_MENUPANE ) + { + aMenuPane->SetItemDimmed( EMemSpyCmdActiveObject, Thread().IsDead() ); + } + } + + +CMemSpyEngineActiveObjectArray& CMemSpyViewThreadInfoItemActiveObjectBase::ActiveObjectArray() const + { + CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( iInfoItem ); + return activeObjectArray->Array(); + } + + +void CMemSpyViewThreadInfoItemActiveObjectBase::OnCmdWriteAOListingL() + { + CMemSpyEngineActiveObjectArray& objects = ActiveObjectArray(); + + // Begin a new data stream + _LIT( KMemSpyContext, "Active Object List - " ); + _LIT( KMemSpyFolder, "Active Objects" ); + iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder ); + + // Set prefix for overall listing + iEngine.Sink().OutputPrefixSetLC( KMemSpyContext ); + + // Create header + CMemSpyEngineActiveObjectArray::OutputDataColumnsL( iEngine ); + + // List items + const TInt count = objects.Count(); + for(TInt i=0; i( iInfoItem ); + TInt selectedIndex = 0; + if ( aSelectionRune ) + { + CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray(); + const TInt index = activeObjectArray.ObjectIndexByAddress( aSelectionRune ); + if ( index >= 0 && index < activeObjectArray.Count() ) + { + selectedIndex = index + 1; + } + } + + // Select item + if ( infoItem->DetailsCount() > 0 ) + { + iListBox->SetCurrentItemIndex( selectedIndex ); + HandleListBoxItemSelectedL( selectedIndex ); + } + } + + +TMemSpyViewType CMemSpyViewThreadInfoItemActiveObject::ViewType() const + { + return EMemSpyViewTypeThreadInfoItemActiveObject; + } + + +CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObject::PrepareChildViewL() + { + CMemSpyViewBase* child = NULL; + + // Get current entry address + TInt index = iListBox->CurrentItemIndex(); + if ( index > 0 ) + { + --index; + CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray(); + // + if ( index >= 0 && index < activeObjectArray.MdcaCount() ) + { + CMemSpyEngineActiveObject& object = activeObjectArray.At( index ); + TAny* aoAddress = object.Address(); + // + child = new(ELeave) CMemSpyViewThreadInfoItemActiveObjectDetails( iEngine, iObserver, iInfoItem->Container(), aoAddress ); + CleanupStack::PushL( child ); + child->ConstructL( Rect(), *Parent(), NULL ); + CleanupStack::Pop( child ); + } + } + // + return child; + } + + + + + + + + + + + +CMemSpyViewThreadInfoItemActiveObjectDetails::CMemSpyViewThreadInfoItemActiveObjectDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, TAny* aObjectAddress ) +: CMemSpyViewThreadInfoItemActiveObjectBase( aEngine, aObserver, aContainer ), iObjectAddress( aObjectAddress ) + { + } + + +void CMemSpyViewThreadInfoItemActiveObjectDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) + { + CMemSpyViewThreadInfoItemActiveObjectBase::ConstructL( aRect, aContainer, aSelectionRune ); + + _LIT( KTitle, "Active Object Details" ); + SetTitleL( KTitle ); + } + + +TMemSpyViewType CMemSpyViewThreadInfoItemActiveObjectDetails::ViewType() const + { + return EMemSpyViewTypeThreadInfoItemActiveObjectDetails; + } + + +CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObjectDetails::PrepareParentViewL() + { + CMemSpyViewThreadInfoItemActiveObject* parent = new(ELeave) CMemSpyViewThreadInfoItemActiveObject( iEngine, iObserver, iInfoItem->Container() ); + CleanupStack::PushL( parent ); + parent->ConstructL( Rect(), *Parent(), iObjectAddress ); + CleanupStack::Pop( parent ); + return parent; + } + + +void CMemSpyViewThreadInfoItemActiveObjectDetails::SetListBoxModelL() + { + // Try to find the right entry + CMemSpyEngineActiveObjectArray& activeObjectArray = ActiveObjectArray(); + const TInt index = activeObjectArray.ObjectIndexByAddress( iObjectAddress ); + User::LeaveIfError( index ); + CMemSpyEngineActiveObject& object = activeObjectArray.At( index ); + // + CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); + listbox->Model()->SetItemTextArray( &object ); + listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); + } + + + + + +