shapedrawergraphicview.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 152 行

CPP
152
字号
/**
 * 
 * @brief Definition of CShapeDrawerGraphicView
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDE FILES
// Class includes
#include "ShapeDrawerGraphicView.h"

// System includes
#include <aknviewappui.h>    // CAknViewAppUi
#include <ShapeDrawer.rsg>    

// User includes
#include "ShapeDrawerGraphicViewContainer.h"    
#include "ShapeDrawer.hrh"    

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

/** 
* Destructor.  Frees up memory for the iLabel.
*/
CShapeDrawerGraphicView::~CShapeDrawerGraphicView()
{
    delete iContainer;
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CShapeDrawerGraphicView using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CShapeDrawerGraphicView
*/
CShapeDrawerGraphicView* CShapeDrawerGraphicView::NewL()
{
    CShapeDrawerGraphicView* self = CShapeDrawerGraphicView::NewLC();
    CleanupStack::Pop(self);
    return self;
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CShapeDrawerGraphicView using the constructor and ConstructL 
* method, leaving the constructed object on the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CShapeDrawerGraphicView
*/
CShapeDrawerGraphicView* CShapeDrawerGraphicView::NewLC()
{
    CShapeDrawerGraphicView* self = new (ELeave) CShapeDrawerGraphicView();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

CShapeDrawerGraphicView::CShapeDrawerGraphicView() 
{
}

CShapeDrawerGraphicViewContainer* CShapeDrawerGraphicView::Container()
{
    return iContainer;
}

CShapeDrawerAppUi& CShapeDrawerGraphicView::GetAppUi()
{
    CAknViewAppUi* aAknViewAppUi = AppUi();
    CShapeDrawerAppUi* aShapeDrawerAppUi = reinterpret_cast<CShapeDrawerAppUi*>(aAknViewAppUi);
    return (*aShapeDrawerAppUi);
}

/**
* Symbian OS 2nd phase constructor.  
* Uses the superclass constructor to construct the view using the 
* R_EMCCVIEWSWITCHED_VIEW1 resource.
*/ 
void CShapeDrawerGraphicView::ConstructL()
{
    BaseConstructL(R_SHAPEDRAWER_GRAPHICVIEW);
}

/**
* Called by the framework
* @return The Uid for this view
*/
TUid CShapeDrawerGraphicView::Id() const
{
    return TUid::Uid(EShapeDrawerGraphicViewId);
}

/**
* Called by the framework when the view is activated.  Constructs the 
* container if necessary, setting this view as its MOP parent, and 
* adding it to the control stack.
*/
void CShapeDrawerGraphicView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                         TUid /*aCustomMessageId*/,
                                         const TDesC8& /*aCustomMessage*/)
{
    if (!iContainer)
    {
        iContainer = CShapeDrawerGraphicViewContainer::NewL(AppUi()->ClientRect(), *this);
        iContainer->SetMopParent(this);
        AppUi()->AddToStackL(*this, iContainer);
    }      
}

/**
* Called by the framework when the view is deactivated.  
* Removes the container from the control stack and deletes it.
*/
void CShapeDrawerGraphicView::DoDeactivate()
{
    if (iContainer)
    {
        AppUi()->RemoveFromStack(iContainer);
        delete iContainer;
        iContainer = NULL;
    }
}

/**
* From CEikAppUi, takes care of command handling for this view.
*
* @param aCommand command to be handled
*/
void CShapeDrawerGraphicView::HandleCommandL(TInt aCommand)
{
    
    switch (aCommand)
    {
        
        case EAknSoftkeyBack:
        {
            AppUi()->HandleCommandL(EEikCmdExit);
            break;
        }
        default:
        {
            AppUi()->HandleCommandL(aCommand);
        }
    }
}

// End of File

⌨️ 快捷键说明

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