helloviewappcontainer1.cpp

来自「symbianOS第三版开发与实用教程部分源码和部分试验」· C++ 代码 · 共 127 行

CPP
127
字号
/*
============================================================================
 Name        : HelloViewAppContainer1.cpp
 Author      : Lion
 Copyright   : Your copyright notice
 Description : Application view implementation
============================================================================
*/

// INCLUDE FILES
#include <coemain.h>
#include "HelloViewAppContainer1.h"
#include <eiklabel.h> 

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

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

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

// -----------------------------------------------------------------------------
// CHelloViewAppContainer1::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CHelloViewAppContainer1::ConstructL( const TRect& aRect )
    {
    // Create a window for this application view
    CreateWindowL();
	iLabel1 = new (ELeave) CEikLabel;
	iLabel1->SetContainerWindowL(*this);
	iLabel1->SetTextL(_L("View1"));
    // Set the windows size
    SetRect( aRect );

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

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


// -----------------------------------------------------------------------------
// CHelloViewAppContainer1::~CHelloViewAppContainer1()
// Destructor.
// -----------------------------------------------------------------------------
//
CHelloViewAppContainer1::~CHelloViewAppContainer1()
    {
    // No implementation required
    delete iLabel1;
    }


// -----------------------------------------------------------------------------
// CHelloViewAppContainer1::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CHelloViewAppContainer1::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 );
    
  	}

// -----------------------------------------------------------------------------
// CHelloViewAppContainer1::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CHelloViewAppContainer1::SizeChanged()
    {  
    iLabel1->SetExtent(TPoint(10,30),iLabel1->MinimumSize());
    }
TInt CHelloViewAppContainer1::CountComponentControls() const
{
	return 1;
}

CCoeControl* CHelloViewAppContainer1::ComponentControl(TInt aIndex) const
{
	switch (aIndex)
	{
		case 0:
			return iLabel1;
		default:
			return NULL;
	}
}
// End of File

⌨️ 快捷键说明

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