📄 soundview.cpp
字号:
// Copyright (c) 2003, Nokia Mobile Phones. All rights reserved.
#include <eikenv.h>
#include <eikdef.h>
#include <eiklabel.h>
#include <gulcolor.h>
#include "sound.pan"
#include "SoundView.h"
#include "SoundDoc.h"
CSoundView* CSoundView::NewL(const TRect& aRect, const TDesC& aMessage)
{
CSoundView* self = CSoundView::NewLC(aRect, aMessage);
CleanupStack::Pop(self);
return self;
}
CSoundView* CSoundView::NewLC(const TRect& aRect, const TDesC& aMessage)
{
CSoundView* self = new (ELeave) CSoundView();
CleanupStack::PushL(self);
self->ConstructL(aRect, aMessage);
return self;
}
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()
{
delete iLabel;
iLabel = NULL;
}
CSoundView::CSoundView()
{
// No implementation required
}
void CSoundView::Draw(const TRect& /*aRect*/) const
{
CWindowGc& gc = SystemGc();
gc.Clear(Rect());
}
TInt CSoundView::CountComponentControls() const
{
return 1;
}
CCoeControl* CSoundView::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return iLabel;
default:
User::Panic(KSound, KSoundPanicBadParameter);
return 0;
}
}
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);
}
void CSoundView::NotifyStatusL(const TDesC& aMessage)
{
iLabel->SetTextL(aMessage);
SizeChanged();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -