⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wavegen_appui.cpp

📁 symbian学习音乐播放的源代码
💻 CPP
字号:
//
// wavegen_appui.cpp
//
// Copyright (C) 2005 Nokia Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////

#include <eikmenup.h>           // for CEikMenuPane
#include <avkon.hrh>
#include <akntabgrp.h>          // for CAknTabGroup
#include <aknnavide.h>          // for CAknNavigationDecorator

#include "wavegen_appui.h"
#include "wavegen_view.h"
#include "wavegen.hrh"
#include <wavegen.rsg>

#include "wavegen_engine.h"     // for CStreamAudioEngine

//
// CWaveGenAppUi class - application UI class
//


/*
-------------------------------------------------------------------------------

    CWaveGenAppUi

    Description: Constructor

    Return value: N/A

-------------------------------------------------------------------------------
*/
CWaveGenAppUi::CWaveGenAppUi()
: iEng(0),
  iNaviDec(0),
  iTabGroup(0)
    {      
    }

/*
-------------------------------------------------------------------------------

    ~CWaveGenAppUi

    Description: Destructor

    Return value: N/A

-------------------------------------------------------------------------------
*/
CWaveGenAppUi::~CWaveGenAppUi()
    {
    delete iEng;
    delete iNaviDec;        
    }


/*
-------------------------------------------------------------------------------

    ConstructL

    Description: 2nd phase constructor for the application ui

    Return value: N/A

-------------------------------------------------------------------------------
*/
void CWaveGenAppUi::ConstructL()
    {
    BaseConstructL(EAknEnableSkin);

    iEng = CStreamAudioEngine::NewL();

    // Fetch pointer to the default navigation pane control from status pane
    CAknNavigationControlContainer* naviPane = 
        (CAknNavigationControlContainer*)
            StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
 
    // Get pointer to the navigation decorator
    // Application owns the decorator and is responsible for deleting it
    iNaviDec = naviPane->ResourceDecorator();
    if (iNaviDec)
        {
        iTabGroup = (CAknTabGroup*) iNaviDec->DecoratedControl();
        }

    // construct the two views (generator and file player)
    CWaveGenView* generatorView = CWaveGenView::NewLC(iEng, EGenerator);
    AddViewL( generatorView );          // ownership transferred
    CleanupStack::Pop();                // generatorView

    CWaveGenView* playerView = CWaveGenView::NewLC(iEng, EFilePlayer);
    AddViewL( playerView );             // ownership transferred
    CleanupStack::Pop();                // playerView

    SetDefaultViewL(*generatorView);      
    }


/*
-------------------------------------------------------------------------------

    HandleKeyEventL

    Description: Key event handling (toggle between the two views)

    Return value: TKeyResponse

-------------------------------------------------------------------------------
*/
TKeyResponse CWaveGenAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, 
    TEventCode /*aType*/)
    {
    if ( iTabGroup == NULL )
        {
        return EKeyWasNotConsumed;
        }

    TInt active = iTabGroup->ActiveTabIndex();

    switch (aKeyEvent.iCode)
        {
        case EKeyLeftArrow:
        case EKeyRightArrow:
                {
                // select and activate the new view 
                active = (active + 1) % iTabGroup->TabCount();                    
                SetActiveViewByIndexL(active);
                return EKeyWasConsumed;
                }
        default:
            break;
        } 

    return EKeyWasNotConsumed;
    }

/*
-------------------------------------------------------------------------------

    SetActiveViewByIndexL

    Description: Set the active view and active tab

    Return value: N/A

-------------------------------------------------------------------------------
*/
void CWaveGenAppUi::SetActiveViewByIndexL(TInt aMode)
    {
    iTabGroup->SetActiveTabByIndex(aMode);
    ActivateLocalViewL(TUid::Uid(aMode));
    }


/*
-------------------------------------------------------------------------------

    HandleCommandL

    Description: command handling for the application ui

    Return value: N/A

-------------------------------------------------------------------------------
*/
void CWaveGenAppUi::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
        {
        case EEikCmdExit:		        
        case EAknSoftkeyExit:
            {
            iEng->StopL();
            Exit();
            break;
            }

        case EWaveGenCmdGenerate:
            SetActiveViewByIndexL((TInt)EGenerator);
            break;

        case EWaveGenCmdPlayFile:
            SetActiveViewByIndexL((TInt)EFilePlayer);
            break;

        default:
            break;
        }
    }


/*
-------------------------------------------------------------------------------

    DynInitMenuPaneL

    Description: updates the menu commands dynamically

    Return value: N/A

-------------------------------------------------------------------------------
*/
void CWaveGenAppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
    {
    if (aMenuId == R_WAVEGEN_MENU)        
        UpdateMenuPane(aMenuPane);        
    }


/*
-------------------------------------------------------------------------------

    UpdateMenuPane

    Description: updates the menu Play/Stop commands according to stream
				 status.

    Return value: N/A

-------------------------------------------------------------------------------
*/
void CWaveGenAppUi::UpdateMenuPane(CEikMenuPane* aMenuPane)
    {
    aMenuPane->SetItemDimmed(EWaveGenCmdPlay, ETrue);
	aMenuPane->SetItemDimmed(EWaveGenCmdStop, EFalse);
    
    if(iEng->StreamReady())
		{        
        aMenuPane->SetItemDimmed(EWaveGenCmdPlay, EFalse);
		aMenuPane->SetItemDimmed(EWaveGenCmdStop, ETrue);
		}
    }

// eof

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -