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

📄 multiviewsview2.cpp

📁 演示如何使用Symbian系统的多视图(View)框架。
💻 CPP
字号:
/*
* ==============================================================================
*  Name        : multiviewsview2.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 <aknnotewrappers.h>
#include <MultiViews.rsg>
#include <stringloader.h>

#include "MultiViewsView2.h"
#include "MultiViewsContainer2.h"
#include "MultiViews.hrh"

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

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

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

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

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

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

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

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


// -----------------------------------------------------------------------------
// CMultiViewsView2::DoDeactivate()
// DeActivate an MultiView2
// -----------------------------------------------------------------------------
//
void CMultiViewsView2::DoDeactivate()
    {
    if ( iContainer )
        {
        AppUi()->RemoveFromStack( iContainer );
        delete iContainer;
        iContainer = NULL;
        }
    }

// -----------------------------------------------------------------------------
// CMultiViewsView2::HandleCommandL()
// Takes care of Command handling.
// -----------------------------------------------------------------------------
//
void CMultiViewsView2::HandleCommandL( TInt aCommand )
    {
    if ( aCommand == EMultiViewsCommand1 )
        {
         // Load a string from the resource file.
        HBufC* textResource = StringLoader::LoadLC(  R_MULT_COMMAND1_TEXT  );
        CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
        informationNote->ExecuteLD( *textResource );

        // Pop HBuf from CleanUpStack and Destroy it.
        CleanupStack::PopAndDestroy(  textResource  );

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



// -----------------------------------------------------------------------------
// CMultiViewsView2::HandleSizeChange()
// Called by HandleResourceChangeL() from CMultiViewsAppUi when layout is 
// changed.
// -----------------------------------------------------------------------------
//
void CMultiViewsView2::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 + -