// ---------------------------------------------------------------------------
// CBCTestMix50Case::TestCEikCbaCaseL()
// ( menu item -6.1- )
// ---------------------------------------------------------------------------
//
void CBCTestMix50Case::TestCEikCbaCaseL()
{
    CEikButtonGroupContainer* btnGroupContainer =
                                 CEikButtonGroupContainer::Current();
    

    CEikCba *eikcba = static_cast<CEikCba*>( btnGroupContainer->ButtonGroup() );
    eikcba->HandleControlEventL(eikcba, MCoeControlObserver::EEventStateChanged);
    _LIT(KHandleControlEvent, "CCoeControl::HandleControlEventL");
    AssertTrueL(ETrue, KHandleControlEvent);

}
// ---------------------------------------------------------------------------
// CAknMemorySelectionDialogMultiDrive::ExecuteL
// ---------------------------------------------------------------------------
//
EXPORT_C CAknCommonDialogsBase::TReturnKey
    CAknMemorySelectionDialogMultiDrive::ExecuteL(
        TDriveNumber& aSelectedDrive, TDes* aRootPath, TDes* aDefaultFolder )
    {
    __ASSERT_DEBUG( iTitle && iLeftSoftkey && iRightSoftkey,
        User::Panic( KCFDPanicText, ECFDPanicTitleOrSoftkeyNotSet ) );

    iModel->UpdateItemsL();
    TBool doubleStyle( AknCFDUtility::DirectoriesOnly( iDialogType ) );
    CEikFormattedCellListBox* listBox = NULL;
    if( doubleStyle )
        {
        listBox = new( ELeave ) CAknDoubleLargeGraphicPopupMenuStyleListBox();
        }
    else
        {
        listBox = new( ELeave ) CAknSingleGraphicPopupMenuStyleListBox();
        }
    CleanupStack::PushL( listBox );

    AknPopupLayouts::TAknPopupLayouts layout( doubleStyle ?
        AknPopupLayouts::EMenuDoubleLargeGraphicWindow :
        AknPopupLayouts::EMenuGraphicWindow );
    TBool isEndKeyPress = EFalse;
    CAknCommonDialogsPopupList* popupList =
        CAknCommonDialogsPopupList::NewL(
            *iEventHandler, listBox, layout, isEndKeyPress );
    CleanupStack::PushL( popupList );

    listBox->ConstructL( popupList, 0 );
    listBox->CreateScrollBarFrameL( ETrue ); // Create scroll indicator
    listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

    listBox->Model()->SetItemTextArray( iModel );
    // Set model ownership type
    listBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );

    // Icons:
    // Granularity, 5 icons
    CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 5 );
    CleanupStack::PushL( iconArray );
    LoadIconsL( iconArray, doubleStyle );
    listBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( iconArray );
    CleanupStack::Pop(); // iconArray

    popupList->SetTitleL( *iTitle ); // Set title
    CEikButtonGroupContainer* cba = popupList->ButtonGroupContainer();
    MEikButtonGroup* buttonGroup = cba->ButtonGroup();
    cba->SetCommandL( buttonGroup->CommandId( 0 ), *iLeftSoftkey );
    cba->SetCommandL( buttonGroup->CommandId( 2 ), *iRightSoftkey );

    // Set listener for popuplist anytime.
    TBool hasRemoteDrive =
        ( iIncludedMedias & AknCommonDialogsDynMem::EMemoryTypeRemote );
    iEventHandler->StartNotifyDisk( popupList, hasRemoteDrive );

    TInt selectedIndex = FindIndexByDrive( aSelectedDrive );
    if( selectedIndex == KErrNotFound )
        {
        selectedIndex = 0; // The first index
        }
        
    listBox->View()->SetCurrentItemIndex( selectedIndex );

    // Update CAB show.
    iEventHandler->HandleEventL(
    		MAknCommonDialogsEventObserver::EFocusChange,
    		selectedIndex,
    		selectedIndex,
    		popupList->ButtonGroupContainer() );
    
    CleanupStack::Pop(); // popupList (deleted in ExecuteLD)
    // Execute the popup dialog
    TBool returnValue = EFalse;
    TRAPD( err, returnValue = popupList->ExecuteLD() );
    
    if ( iEventHandler )
        {        
        iEventHandler->StopNotifyDisk();
        }
    
    if( returnValue )
        {
        selectedIndex = listBox->CurrentItemIndex();
        GetDrivePaths( selectedIndex, aRootPath, aDefaultFolder );
        aSelectedDrive = FindDriveByIndex( selectedIndex );
        }
    else if ( err )
        {
        User::Leave( err );
        }
    
    CleanupStack::PopAndDestroy(); // listBox
    return TReturnKey( returnValue );
    }