⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multiviewsview1.cpp

📁 演示如何使用Symbian系统的多视图(View)框架。
💻 CPP
字号:
/*
* ==============================================================================
*  Name        : multiviewsview1.cpp
*  Part of     : MultiViews
*  Interface   :
*  Description :
*  Version     :
*
Copyright (c) 2004 - 2006 Nokia Corporation.
*  This material, including documentation and any related
*  computer programs, is protected by copyright controlled by
*  Nokia Corporation.
* ==============================================================================
*/


// INCLUDE FILES
#include <aknviewappui.h>
#include <aknconsts.h>
#include <aknutils.h> 
#include <MultiViews.rsg>

#include "MultiViewsView1.h"
#include "MultiViewsContainer1.h"
#include "MultiViews.hrh"


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

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


// -----------------------------------------------------------------------------
// CMultiViewsView1::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CMultiViewsView1* CMultiViewsView1::NewL()
    {
    CMultiViewsView1* self = CMultiViewsView1::NewLC();
    CleanupStack::Pop( self );
    return self;
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CMultiViewsView1* CMultiViewsView1::NewLC()
    {
    CMultiViewsView1* self = new ( ELeave ) CMultiViewsView1();
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CMultiViewsView1::ConstructL()
    {
    BaseConstructL( R_MULTIVIEWS_VIEW1 );
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::~CMultiViewsView1()
// Destructor.
// -----------------------------------------------------------------------------
//
CMultiViewsView1::~CMultiViewsView1()
    {
    // No implementation required
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::Id()
// Returns View's ID.
// -----------------------------------------------------------------------------
//
TUid CMultiViewsView1::Id() const
    {
    return TUid::Uid( EMultiViewsView1Id );
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::DoActivateL()
// Activate an MultiView1
// -----------------------------------------------------------------------------
//
void CMultiViewsView1::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
                                    TUid /*aCustomMessageId*/,
                                    const TDesC8& /*aCustomMessage*/)
    {
    iContainer = CMultiViewsContainer1::NewL( ClientRect() );
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::DoDeactivate()
// DeActivate an MultiView1
// -----------------------------------------------------------------------------
//
void CMultiViewsView1::DoDeactivate()
    {

    if ( iContainer )
        {
        // Remove View1's container form controllStack
        AppUi()->RemoveFromStack( iContainer );
        delete iContainer;
        iContainer = NULL;
        }
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::HandleCommandL()
// Takes care of Command handling.
// -----------------------------------------------------------------------------
//
void CMultiViewsView1::HandleCommandL( TInt aCommand )
    {

    if ( aCommand == EMultiViewsSwitchToView2 )
        {
        AppUi()->ActivateLocalViewL( TUid::Uid( EMultiViewsView2Id ) );
        }
    else
        {
        AppUi()->HandleCommandL( aCommand );
        }
    }

// -----------------------------------------------------------------------------
// CMultiViewsView1::HandleSizeChange()
// Called by HandleResourceChangeL() from CMultiViewsAppUi when layout is 
// changed.
// -----------------------------------------------------------------------------
//
void CMultiViewsView1::HandleSizeChange( TInt aType )
    {
    if( iContainer )
        {
        iContainer->HandleResourceChange( aType );
        
        if ( aType==KEikDynamicLayoutVariantSwitch )
            {        
            TRect rect;
            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
            iContainer->SetRect(rect);
            }
        }         
    }
    
// End of File

⌨️ 快捷键说明

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