halviewview.cpp

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

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

// INCLUDES

//  Class include
#include "HalViewView.h"

// System includes
#include <aknviewappui.h>    // CAknViewAppUi
#include <akntabgrp.h>        // CAknTabGroup
#include <HalView.rsg>

// User includes
#include "HalViewAppUi.h"
#include "HalViewContainer.h"
#include "HalView.hrh"    // THalViewViewNumber

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

CHalViewView::CHalViewView()
{
}

/** 
* Destructor.  Frees up memory for the container.
*/
CHalViewView::~CHalViewView()
{
    DestroyContainer();
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CHalViewView using the constructor and ConstructL 
* method. the constructed object is popped from the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CHalViewView
*/
CHalViewView* CHalViewView::NewL()
{
    CHalViewView* self = new (ELeave) CHalViewView();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
}

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

void CHalViewView::DestroyContainer()
{
    if (iContainer)
    {
        AppUi()->RemoveFromStack(iContainer);
        delete iContainer;
        iContainer = NULL;
    }
}

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

/**
* Called by the container to allow the tab group to 
* process a key event
*/
TKeyResponse CHalViewView::OfferKeyToTabGroupL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
    CAknTabGroup* tabGroup = static_cast<CHalViewAppUi*>(AppUi())->TabGroup();

    if (tabGroup)
    {
        if (tabGroup->OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
        {
            iContainer->DisplayAttributesByIdL(tabGroup->ActiveTabIndex());
            return EKeyWasConsumed;
        }
    }
    return EKeyWasNotConsumed;
}

/**
* 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 CHalViewView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                   TUid /*aCustomMessageId*/,
                                   const TDesC8& /*aCustomMessage*/)
{
    if (!iContainer)
    {
        iContainer = CHalViewContainer::NewL(*this, ClientRect());
        iContainer->SetMopParent(this);
        AppUi()->AddToStackL(*this, iContainer);
        iContainer->DisplayAttributesByIdL(0);
    }
}

/**
* Called by the framework when the view is deactivated.  
* Removes the container from the control stack and deletes it.
*/
void CHalViewView::DoDeactivate()
{
    DestroyContainer();
}

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

        default:
            AppUi()->HandleCommandL(aCommand);
            break;
    }
}

// End of File

⌨️ 快捷键说明

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