helloviewappcontainer2.cpp
来自「symbianOS第三版开发与实用教程部分源码和部分试验」· C++ 代码 · 共 127 行
CPP
127 行
/*
============================================================================
Name : HelloViewAppContainer2.cpp
Author : Lion
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/
// INCLUDE FILES
#include <coemain.h>
#include "HelloViewAppContainer2.h"
#include <eiklabel.h>
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CHelloViewAppContainer2* CHelloViewAppContainer2::NewL( const TRect& aRect )
{
CHelloViewAppContainer2* self = CHelloViewAppContainer2::NewLC( aRect );
CleanupStack::Pop( self );
return self;
}
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CHelloViewAppContainer2* CHelloViewAppContainer2::NewLC( const TRect& aRect )
{
CHelloViewAppContainer2* self = new ( ELeave ) CHelloViewAppContainer2;
CleanupStack::PushL( self );
self->ConstructL( aRect );
return self;
}
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CHelloViewAppContainer2::ConstructL( const TRect& aRect )
{
// Create a window for this application view
CreateWindowL();
iLabel2 = new (ELeave) CEikLabel;
iLabel2->SetContainerWindowL(*this);
iLabel2->SetTextL(_L("View2"));
// Set the windows size
SetRect( aRect );
// Activate the window, which makes it ready to be drawn
ActivateL();
}
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::CHelloViewAppContainer2()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CHelloViewAppContainer2::CHelloViewAppContainer2()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::~CHelloViewAppContainer2()
// Destructor.
// -----------------------------------------------------------------------------
//
CHelloViewAppContainer2::~CHelloViewAppContainer2()
{
// No implementation required
delete iLabel2;
}
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CHelloViewAppContainer2::Draw( const TRect& /*aRect*/ ) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect( Rect());
// Clears the screen
gc.Clear( drawRect );
}
// -----------------------------------------------------------------------------
// CHelloViewAppContainer2::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CHelloViewAppContainer2::SizeChanged()
{
iLabel2->SetExtent(TPoint(10,90),iLabel2->MinimumSize());
}
TInt CHelloViewAppContainer2::CountComponentControls() const
{
return 1;
}
CCoeControl* CHelloViewAppContainer2::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iLabel2;
default:
return NULL;
}
}
// End of File
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?