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

📄 soundview.cpp

📁 symbian 可以实现控制声音大小的源码 非常实用!
💻 CPP
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */


// INCLUDE FILES
#include <eikenv.h>
#include <eikdef.h>
#include <eiklabel.h>
#include <gulcolor.h>

#include "sound.pan"
#include "SoundView.h"
#include "SoundDoc.h"


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

// -----------------------------------------------------------------------------
// CSoundView::CSoundView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CSoundView::CSoundView()
    {
    // No implementation required
    }

// -----------------------------------------------------------------------------
// CSoundView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CSoundView* CSoundView::NewL( const TRect& aRect, const TDesC& aMessage )
    {
    CSoundView* self = CSoundView::NewLC( aRect, aMessage );
    CleanupStack::Pop( self );
    return self;
    }

// -----------------------------------------------------------------------------
// CSoundView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CSoundView* CSoundView::NewLC( const TRect& aRect, const TDesC& aMessage )
    {
    CSoundView* self = new ( ELeave ) CSoundView();
    CleanupStack::PushL( self );
    self->ConstructL( aRect, aMessage );
    return self;
    }


// -----------------------------------------------------------------------------
// CSoundView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSoundView::ConstructL( const TRect& aRect, const TDesC& aMessage )
    {

    // Create a window for this application view
    CreateWindowL();

    iBrushStyle = CGraphicsContext::ESolidBrush;

    iBrushColor = iEikonEnv->ControlColor( EColorWindowBackground, *this );

    iLabel = new ( ELeave ) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( aMessage );

    // Set the windows size
    SetRect( aRect );

    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

// -----------------------------------------------------------------------------
// CSoundView::~CSoundView()
// Destructor.
// -----------------------------------------------------------------------------
//
CSoundView::~CSoundView()
    {
    delete iLabel;
    }

// -----------------------------------------------------------------------------
// CSoundView::Draw() 
// Draws the display
// -----------------------------------------------------------------------------
//
void CSoundView::Draw( const TRect& /*aRect*/ ) const
    {
    CWindowGc& gc = SystemGc();
    gc.Clear( Rect() );
    }

// -----------------------------------------------------------------------------
// CSoundView::CountComponentControls()
// returns number of controls inside this container.
// -----------------------------------------------------------------------------
//
TInt CSoundView::CountComponentControls() const
    {
    return 1; 
    }

// -----------------------------------------------------------------------------
// CSoundView::ComponentControl()
// returns pointer of controls inside this container
// -----------------------------------------------------------------------------
//
CCoeControl* CSoundView::ComponentControl( TInt aIndex ) const
    {
    switch ( aIndex )
        {
        case 0:
            return iLabel;

        default:
            User::Panic( KSound, KSoundPanicBadParameter );
            return 0;
        }
    }

// -----------------------------------------------------------------------------
// CSoundView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CSoundView::SizeChanged()
    {
    TRect rect = Rect();

    TSize labelSize = iLabel->MinimumSize();
    rect.iTl.iX += ( rect.Width() - labelSize.iWidth ) / 2;
    rect.iTl.iY += ( rect.Height() - labelSize.iHeight ) / 2;
    rect.iBr = rect.iTl + labelSize;

    iLabel->SetRect( rect );
    }


// -----------------------------------------------------------------------------
// CSoundView::NotifyStatusL()
// Notify Status
// -----------------------------------------------------------------------------
//
void CSoundView::NotifyStatusL( const TDesC& aMessage )
    {
    iLabel->SetTextL( aMessage );
    SizeChanged();
    }


// End of File

⌨️ 快捷键说明

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