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

📄 basicsoundcontainer.cpp

📁 《基于symbian手机开发与应用》一书的源代码
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CBasicSoundContainer from BasicSoundContainer.h
*  Part of  : BasicSound
*  Created  : 2006-2-7 by 
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: 
* ============================================================================
*/

// INCLUDE FILES
#include "BasicSoundContainer.h"
#include <stringloader.h>
#include "basicsound.rsg"



// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CBasicSoundContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CBasicSoundContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
	SetRect(aRect);

	iLabel=new(ELeave)CEikLabel();
	iLabel->SetContainerWindowL(*this);
	iLabel->SetRect(Rect());
	iLabel->SetMopParent(this);
	iLabel->SetAlignment(EHCenterVCenter);
	iLabel->SetTextL(_L("No sound!"));
    
	ActivateL();
	iSound=CMyToneClass::NewL(*this);
	
    }

// Destructor
CBasicSoundContainer::~CBasicSoundContainer()
    {
	delete iSound;
	delete iLabel;
    }

// ---------------------------------------------------------
// CBasicSoundContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CBasicSoundContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
   }

// ---------------------------------------------------------
// CBasicSoundContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CBasicSoundContainer::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CBasicSoundContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CBasicSoundContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
			return iLabel;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CBasicSoundContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CBasicSoundContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

void CBasicSoundContainer::DynInitMenuPaneL(TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
	
}
void CBasicSoundContainer::PlayL()
{
	HBufC* textPlaying=StringLoader::LoadLC(R_TEXT_SOUND_PLAYING);
	iLabel->SetTextL(*textPlaying);
	iLabel->DrawDeferred();
	CleanupStack::PopAndDestroy(textPlaying);
	iSound->PlayToneL();
}
void CBasicSoundContainer::StopL()
{
	iSound->StopL();
}
void CBasicSoundContainer::PlayClipL()
{
	iSound->PlayClipL();
}
void CBasicSoundContainer::playStreamL()
{
	iSound->PlayStreamL();
}

void CBasicSoundContainer::HandelPlayStopL()
{
		HBufC* LabelTextStop;
		LabelTextStop=StringLoader::LoadLC(R_TEXT_SOUND_STOP);
		iLabel->SetTextL(*LabelTextStop);
		iLabel->DrawDeferred();
		CleanupStack::PopAndDestroy(LabelTextStop);
}

// End of File  

⌨️ 快捷键说明

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