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

📄 richtexttestcontainerview.cpp

📁 symbian code developemnt
💻 CPP
字号:
/*
========================================================================
 Name        : RichtextTestContainerView.cpp
 Author      : 
 Copyright   : Your copyright notice
 Description : 
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <barsread.h>
#include <stringloader.h>
#include <gdi.h>
#include <eikgted.h>
#include <eikenv.h>
#include <eiklabel.h>
#include <akncontext.h>
#include <akntitle.h>
#include <eikbtgpc.h>
#include <RichtextTest.rsg>
// ]]] end generated region [Generated System Includes]

// [[[ begin generated region: do not modify [Generated User Includes]

#include "RichtextTest.hrh"
#include "RichtextTestContainerView.h"
#include "RichtextTestContainer.hrh"
#include "RichtextTestContainer.h"
// ]]] end generated region [Generated User Includes]

#include <AknUtils.h>

// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]

/**
 * First phase of Symbian two-phase construction. Should not contain any
 * code that could leave.
 */
CRichtextTestContainerView::CRichtextTestContainerView()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	iRichtextTestContainer = NULL;
	// ]]] end generated region [Generated Contents]
	
	}

/** 
 * The view's destructor removes the container from the control
 * stack and destroys it.
 */
CRichtextTestContainerView::~CRichtextTestContainerView()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	delete iRichtextTestContainer;
	iRichtextTestContainer = NULL;
	// ]]] end generated region [Generated Contents]
	
	}

/**
 * Symbian two-phase constructor.
 * This creates an instance then calls the second-phase constructor
 * without leaving the instance on the cleanup stack.
 * @return new instance of CRichtextTestContainerView
 */
CRichtextTestContainerView* CRichtextTestContainerView::NewL()
	{
	CRichtextTestContainerView* self = CRichtextTestContainerView::NewLC();
	CleanupStack::Pop( self );
	return self;
	}

/**
 * Symbian two-phase constructor.
 * This creates an instance, pushes it on the cleanup stack,
 * then calls the second-phase constructor.
 * @return new instance of CRichtextTestContainerView
 */
CRichtextTestContainerView* CRichtextTestContainerView::NewLC()
	{
	CRichtextTestContainerView* self = new ( ELeave ) CRichtextTestContainerView();
	CleanupStack::PushL( self );
	self->ConstructL();
	return self;
	}


/**
 * Second-phase constructor for view.  
 * Initialize contents from resource.
 */ 
void CRichtextTestContainerView::ConstructL()
	{
	// [[[ begin generated region: do not modify [Generated Code]
	BaseConstructL( R_RICHTEXT_TEST_CONTAINER_RICHTEXT_TEST_CONTAINER_VIEW );
				
	// ]]] end generated region [Generated Code]
	
	// add your own initialization code here
	
	}

/**
 * @return The UID for this view
 */
TUid CRichtextTestContainerView::Id() const
	{
	return TUid::Uid( ERichtextTestContainerViewId );
	}

/**
 * Handle a command for this view (override)
 * @param aCommand command id to be handled
 */
void CRichtextTestContainerView::HandleCommandL( TInt aCommand )
	{
	// [[[ begin generated region: do not modify [Generated Code]
	TBool commandHandled = EFalse;
	switch ( aCommand )
		{	// code to dispatch to the AknView's menu and CBA commands is generated here
		case ERichtextTestContainerViewBIG_SIZEMenuItemCommand:
			commandHandled = HandleBIG_SIZEMenuItemSelectedL( aCommand );
			break;
		case ERichtextTestContainerViewSmall_sizeMenuItemCommand:
			commandHandled = HandleSmall_sizeMenuItemSelectedL( aCommand );
			break;
		case ERichtextTestContainerViewPrimaryMenuItemCommand:
			commandHandled = HandlePrimaryMenuItemSelectedL( aCommand );
			break;
		case ERichtextTestContainerViewRedMenuItemCommand:
			commandHandled = HandleRedMenuItemSelectedL( aCommand );
			break;
		case ERichtextTestContainerViewBlueMenuItemCommand:
			commandHandled = HandleBlueMenuItemSelectedL( aCommand );
			break;
		case ERichtextTestContainerViewGreenMenuItemCommand:
			commandHandled = HandleGreenMenuItemSelectedL( aCommand );
			break;
		default:
			break;
		}
	
		
	if ( !commandHandled ) 
		{
	
		if ( aCommand == EAknSoftkeyExit )
			{
			AppUi()->HandleCommandL( EEikCmdExit );
			}
	
		}
	// ]]] end generated region [Generated Code]
	
	}

/**
 *	Handles user actions during activation of the view, 
 *	such as initializing the content.
 */
void CRichtextTestContainerView::DoActivateL( 
		const TVwsViewId& /*aPrevViewId*/,
		TUid /*aCustomMessageId*/,
		const TDesC8& /*aCustomMessage*/ )
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	SetupStatusPaneL();
	
				
				
	
	if ( iRichtextTestContainer == NULL )
		{
		iRichtextTestContainer = CreateContainerL();
		iRichtextTestContainer->SetMopParent( this );
		AppUi()->AddToStackL( *this, iRichtextTestContainer );
		} 
	// ]]] end generated region [Generated Contents]
	
	}

/**
 */
void CRichtextTestContainerView::DoDeactivate()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	CleanupStatusPane();
	
	if ( iRichtextTestContainer != NULL )
		{
		AppUi()->RemoveFromViewStack( *this, iRichtextTestContainer );
		delete iRichtextTestContainer;
		iRichtextTestContainer = NULL;
		}
	// ]]] end generated region [Generated Contents]
	
	}

/** 
 * Handle status pane size change for this view (override)
 */
void CRichtextTestContainerView::HandleStatusPaneSizeChange()
	{
	CAknView::HandleStatusPaneSizeChange();
	
	// this may fail, but we're not able to propagate exceptions here
	TVwsViewId view;
	AppUi()->GetActiveViewId( view );
	if ( view.iViewUid == Id() )
		{
		TInt result;
		TRAP( result, SetupStatusPaneL() );
		}
	
	// [[[ begin generated region: do not modify [Generated Code]
	// ]]] end generated region [Generated Code]
	
	}



/**
 *	Creates the top-level container for the view.  You may modify this method's
 *	contents and the CRichtextTestContainer::NewL() signature as needed to initialize the
 *	container, but the signature for this method is fixed.
 *	@return new initialized instance of CRichtextTestContainer
 */
CRichtextTestContainer* CRichtextTestContainerView::CreateContainerL()
	{
	return CRichtextTestContainer::NewL( ClientRect(), NULL, this );
	}

/** 
 * Handle the selected event.
 * @param aCommand the command id invoked
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CRichtextTestContainerView::HandleBIG_SIZEMenuItemSelectedL( TInt aCommand )
	{
	// TODO: implement selected event handle
	
	iRichtextTestContainer->SetFont(LatinBold19());
	return ETrue;
	}
	

void CRichtextTestContainerView::SetupStatusPaneL()
	{
	// reset the context pane
	TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
	CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
		StatusPane()->PaneCapabilities( contextPaneUid );
	if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
		{
		CAknContextPane* context = static_cast< CAknContextPane* > ( 
			StatusPane()->ControlL( contextPaneUid ) );
		context->SetPictureToDefaultL();
		}
	
	// setup the title pane
	TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
	CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
		StatusPane()->PaneCapabilities( titlePaneUid );
	if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
		{
		CAknTitlePane* title = static_cast< CAknTitlePane* >( 
			StatusPane()->ControlL( titlePaneUid ) );
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_RICHTEXT_TEST_CONTAINER_TITLE_RESOURCE );
		title->SetFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
				
	}





// [[[ begin generated function: do not modify
void CRichtextTestContainerView::CleanupStatusPane()
	{
	}

// ]]] end generated function

/** 
 * Handle the selected event.
 * @param aCommand the command id invoked
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CRichtextTestContainerView::HandleSmall_sizeMenuItemSelectedL( TInt aCommand )
	{
	// TODO: implement selected event handler
	iRichtextTestContainer->SetFont(LatinBold12());
	return ETrue;
	}
				
/** 
 * Handle the selected event.
 * @param aCommand the command id invoked
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CRichtextTestContainerView::HandlePrimaryMenuItemSelectedL( TInt aCommand )
	{
	// TODO: implement selected event handler
	iRichtextTestContainer->SetFont(LatinPlain12());
	return ETrue;
	}
				
/** 
 * Handle the selected event.
 * @param aCommand the command id invoked
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CRichtextTestContainerView::HandleRedMenuItemSelectedL( TInt aCommand )
	{
	// TODO: implement selected event handler
	iRichtextTestContainer->SetColor(KRgbRed);
	return ETrue;
	}
				
/** 
 * Handle the selected event.
 * @param aCommand the command id invoked
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CRichtextTestContainerView::HandleBlueMenuItemSelectedL( TInt aCommand )
	{
	// TODO: implement selected event handler
	iRichtextTestContainer->SetColor(KRgbBlue);
	return ETrue;
	}
				
/** 
 * Handle the selected event.
 * @param aCommand the command id invoked
 * @return ETrue if the command was handled, EFalse if not
 */
TBool CRichtextTestContainerView::HandleGreenMenuItemSelectedL( TInt aCommand )
	{
	// TODO: implement selected event handler
	iRichtextTestContainer->SetColor(KRgbGreen);
	return ETrue;
	}
				

⌨️ 快捷键说明

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