here is it. the red colored portion is what you've asked...
Code:
CHelloWorldContainer::CHelloWorldContainer()
{
// [[[ begin generated region: do not modify [Generated Contents]
iListBox = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* Destroy child controls.
*/
CHelloWorldContainer::~CHelloWorldContainer()
{
// begin by chen
delete iCallMonitor;
// end by chen
// [[[ begin generated region: do not modify [Generated Contents]
delete iListBox;
iListBox = NULL;
// ]]] end generated region [Generated Contents]
}
CHelloWorldContainer* CHelloWorldContainer::NewL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CHelloWorldContainer* self = CHelloWorldContainer::NewLC(
aRect,
aParent,
aCommandObserver );
CleanupStack::Pop( self );
return self;
}
CHelloWorldContainer* CHelloWorldContainer::NewLC(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
--------
}
void CHelloWorldContainer::ConstructL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
if ( aParent == NULL )
{
CreateWindowL();
}
else
{
SetContainerWindowL( *aParent );
}
iFocusControl = NULL;
iCommandObserver = aCommandObserver;
InitializeControlsL();
SetRect( aRect );
ActivateL();
// [[[ begin generated region: do not modify [Post-ActivateL initializations]
// ]]] end generated region [Post-ActivateL initializations]
// begin by chen
iCallMonitor = CCallMonitor::NewL(*this);
// end by chen
}
void CHelloWorldContainer::InitializeControlsL()
{
iListBox = new ( ELeave ) CAknSingleStyleListBox;
iListBox->SetContainerWindowL( *this );
{
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_HELLO_WORLD_CONTAINER_LIST_BOX );
iListBox->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
// the listbox owns the items in the list and will free them
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
// setup the icon array so graphics-style boxes work
SetupListBoxIconsL();
// add list items
iListBox->SetFocus( ETrue );
iFocusControl = iListBox;
}
// ]]] end generated function
void CHelloWorldContainer::Draw( const TRect& aRect ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
CWindowGc& gc = SystemGc();
gc.Clear( aRect );
// ]]] end generated region [Generated Contents]
}
// [[[ begin generated function: do not modify
void CHelloWorldContainer::AddListBoxItemL(
CEikTextListBox* aListBox,
const TDesC& aString )
{
CTextListBoxModel* model = aListBox->Model();
CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
itemArray->AppendL( aString );
aListBox->HandleItemAdditionL();
}
// ]]] end generated function
// [[[ begin generated function: do not modify
RArray< TInt >* CHelloWorldContainer::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox )
{
CAknFilteredTextListBoxModel* model =
static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
if ( model->NumberOfItems() == 0 )
return NULL;
// get currently selected indices
const CListBoxView::CSelectionIndexArray* selectionIndexes =
aListBox->SelectionIndexes();
TInt selectedIndexesCount = selectionIndexes->Count();
if ( selectedIndexesCount == 0 )
return NULL;
// copy the indices and sort numerically
RArray<TInt>* orderedSelectedIndices =
new (ELeave) RArray< TInt >( selectedIndexesCount );
// push the allocated array
CleanupStack::PushL( orderedSelectedIndices );
// dispose the array resource
CleanupClosePushL( *orderedSelectedIndices );
// see if the search field is enabled
CAknListBoxFilterItems* filter = model->Filter();
if ( filter != NULL )
{
// when filtering enabled, translate indices back to underlying model
for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
{
TInt filteredItem = ( *selectionIndexes ) [ idx ];
TInt actualItem = filter->FilteredItemIndex ( filteredItem );
orderedSelectedIndices->InsertInOrder( actualItem );
}
}
else
{
// the selection indices refer directly to the model
for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] );
}
return orderedSelectedIndices;
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CHelloWorldContainer::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox )
{
CAknFilteredTextListBoxModel* model =
static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
if ( model->NumberOfItems() == 0 )
return;
RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox );
if ( !orderedSelectedIndices )
return;
// Delete selected items from bottom up so indices don't change on us
CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
TInt currentItem = 0;
for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; )
{
currentItem = ( *orderedSelectedIndices )[ idx ];
itemArray->Delete ( currentItem );
}
// dispose the array resources
CleanupStack::PopAndDestroy();
// dispose the array pointer
CleanupStack::PopAndDestroy( orderedSelectedIndices );
// refresh listbox's cursor now that items are deleted
AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
aListBox, currentItem, ETrue );
}
// ]]] end generated function
// [[[ begin generated function: do not modify
CAknSingleStyleListBox* CHelloWorldContainer::ListBox()
{
return iListBox;
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CHelloWorldContainer::CreateListBoxItemL( TDes& aBuffer,
const TDesC& aMainText )
{
_LIT ( KStringHeader, "\t%S" );
aBuffer.Format( KStringHeader(), &aMainText );
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CHelloWorldContainer::AddListBoxResourceArrayItemL( TInt aResourceId )
{
CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId );
CleanupStack::PushL( array );
// This is intended to be large enough, but if you get
// a USER 11 panic, consider reducing string sizes.
TBuf<512> listString;
CreateListBoxItemL( listString, ( *array ) [ 0 ] );
AddListBoxItemL( iListBox, listString );
CleanupStack::PopAndDestroy( array );
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CHelloWorldContainer::SetupListBoxIconsL()
{
CArrayPtr< CGulIcon >* icons = NULL;
if ( icons != NULL )
{
iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
}
}
// ]]] end generated function
/
void CHelloWorldContainer::CallStatusChangedL(CTelephony::TCallStatus& aStatus, TInt aError,TInt aIsInCall,const TDesC& aRemoteCaller,const TDateTime aDateTime,const TTimeIntervalSeconds aDurationInSeconds)
{
TBuf<250> buf;
TBuf<512> listString;
if(aError==KErrNone)
{
buf.AppendNum(TInt(aStatus));
buf.Append(aRemoteCaller);
}
else
{
buf.AppendNum(aError);
}
CreateListBoxItemL( listString, buf );
AddListBoxItemL( iListBox, listString );
iListBox->SetCurrentItemIndexAndDraw(iListBox->Model()->NumberOfItems()-1);
}