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

📄 xwjjvxflcontainer.cpp

📁 如何在S60 3rd上使用系统默认背景!
💻 CPP
字号:
/*
========================================================================
 Name        : XwjjvxflContainer.cpp
 Author      : 
 Copyright   : Your copyright notice
 Description : 
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <barsread.h>
#include <stringloader.h>
#include <gdi.h>
#include <eikedwin.h>
#include <eikenv.h>
#include <aknviewappui.h>
#include <eikappui.h>
#include <Xwjjvxfl.rsg>
// ]]] end generated region [Generated System Includes]

// [[[ begin generated region: do not modify [Generated User Includes]
#include "XwjjvxflContainer.h"
#include "XwjjvxflContainerView.h"
#include "Xwjjvxfl.hrh"
// ]]] end generated region [Generated User Includes]

#include <AknsDrawUtils.h>
#include <AknsBasicBackgroundControlContext.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.
 */
CXwjjvxflContainer::CXwjjvxflContainer()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	iEdit1 = NULL;
	// ]]] end generated region [Generated Contents]
	
	}
/** 
 * Destroy child controls.
 */
CXwjjvxflContainer::~CXwjjvxflContainer()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	delete iEdit1;
	iEdit1 = NULL;
	// ]]] end generated region [Generated Contents]
	
	delete iBgContext;
	}
				
/**
 * Construct the control (first phase).
 *  Creates an instance and initializes it.
 *  Instance is not left on cleanup stack.
 * @param aRect bounding rectangle
 * @param aParent owning parent, or NULL
 * @param aCommandObserver command observer
 * @return initialized instance of CXwjjvxflContainer
 */
CXwjjvxflContainer* CXwjjvxflContainer::NewL( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver )
	{
	CXwjjvxflContainer* self = CXwjjvxflContainer::NewLC( 
			aRect, 
			aParent, 
			aCommandObserver );
	CleanupStack::Pop( self );
	return self;
	}

/**
 * Construct the control (first phase).
 *  Creates an instance and initializes it.
 *  Instance is left on cleanup stack.
 * @param aRect The rectangle for this window
 * @param aParent owning parent, or NULL
 * @param aCommandObserver command observer
 * @return new instance of CXwjjvxflContainer
 */
CXwjjvxflContainer* CXwjjvxflContainer::NewLC( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver )
	{
	CXwjjvxflContainer* self = new ( ELeave ) CXwjjvxflContainer();
	CleanupStack::PushL( self );
	self->ConstructL( aRect, aParent, aCommandObserver );
	return self;
	}
			
/**
 * Construct the control (second phase).
 *  Creates a window to contain the controls and activates it.
 * @param aRect bounding rectangle
 * @param aCommandObserver command observer
 * @param aParent owning parent, or NULL
 */ 
void CXwjjvxflContainer::ConstructL( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver )
	{
	if ( aParent == NULL )
	    {
		CreateWindowL();
	    }
	else
	    {
	    SetContainerWindowL( *aParent );
	    }
	iFocusControl = NULL;
	iCommandObserver = aCommandObserver;
	InitializeControlsL();
	SetRect( aRect );
	ActivateL();
	// [[[ begin generated region: do not modify [Post-ActivateL initializations]
	// ]]] end generated region [Post-ActivateL initializations]

	iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,ETrue);
	//	iEdit1->SetSkinBackgroundControlContextL(NULL);
	}
			
/**
* Return the number of controls in the container (override)
* @return count
*/
TInt CXwjjvxflContainer::CountComponentControls() const
	{
	return ( int ) ELastControl;
	}
				
/**
* Get the control with the given index (override)
* @param aIndex Control index [0...n) (limited by #CountComponentControls)
* @return Pointer to control
*/
CCoeControl* CXwjjvxflContainer::ComponentControl( TInt aIndex ) const
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	switch ( aIndex )
		{
		case EEdit1:
			return iEdit1;
		}
	// ]]] end generated region [Generated Contents]
	
	// handle any user controls here...
	
	return NULL;
	}
				
/**
 *	Handle resizing of the container. This implementation will lay out
 *  full-sized controls like list boxes for any screen size, and will layout
 *  labels, editors, etc. to the size they were given in the UI designer.
 *  This code will need to be modified to adjust arbitrary controls to
 *  any screen size.
 */				
void CXwjjvxflContainer::SizeChanged()
	{
	CCoeControl::SizeChanged();
	LayoutControls();
	// [[[ begin generated region: do not modify [Generated Contents]
			
	// ]]] end generated region [Generated Contents]
	 if(iBgContext)
		 {
		   iBgContext->SetRect(Rect());
		                if ( &Window() )
		                {
		                        iBgContext->SetParentPos( PositionRelativeToScreen() );
		                }
		 }
	}
				
// [[[ begin generated function: do not modify
/**
 * Layout components as specified in the UI Designer
 */
void CXwjjvxflContainer::LayoutControls()
	{
	iEdit1->SetExtent( TPoint( 0, 0 ), TSize( 176, 144 ) );
	}
// ]]] end generated function

/**
 *	Handle key events.
 */				
TKeyResponse CXwjjvxflContainer::OfferKeyEventL( 
		const TKeyEvent& aKeyEvent, 
		TEventCode aType )
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	
	// ]]] end generated region [Generated Contents]
	
	if ( iFocusControl != NULL
		&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
		{
		return EKeyWasConsumed;
		}
	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
	}
				
// [[[ begin generated function: do not modify
/**
 *	Initialize each control upon creation.
 */				
void CXwjjvxflContainer::InitializeControlsL()
	{
	iEdit1 = new ( ELeave ) CEikEdwin;
	iEdit1->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_XWJJVXFL_CONTAINER_EDIT1 );
		iEdit1->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
		{
		HBufC* text = StringLoader::LoadLC( R_XWJJVXFL_CONTAINER_EDIT1_2 );
		iEdit1->SetTextL( text );
		CleanupStack::PopAndDestroy( text );
		}
	
	iEdit1->SetFocus( ETrue );
	iFocusControl = iEdit1;
	
	}
// ]]] end generated function

/** 
 * Handle global resource changes, such as scalable UI or skin events (override)
 */
void CXwjjvxflContainer::HandleResourceChange( TInt aType )
	{
	CCoeControl::HandleResourceChange( aType );
	SetRect( iAvkonViewAppUi->View( TUid::Uid( EXwjjvxflContainerViewId ) )->ClientRect() );
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	}
				
/**
 *	Draw container contents.
 */				
void CXwjjvxflContainer::Draw( const TRect& aRect ) const
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	CWindowGc& gc = SystemGc();
	gc.Clear( aRect );
	
	// ]]] end generated region [Generated Contents]

	 // Redraw the background using the default skin
	 MAknsSkinInstance* skin = AknsUtils::SkinInstance();
	 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
	 AknsDrawUtils::Background( skin, cc, this, gc, aRect );
	}
				
TTypeUid::Ptr CXwjjvxflContainer::MopSupplyObject(TTypeUid aId)
	{
	 if (iBgContext )
	 {
	   return MAknsControlContext::SupplyMopObject( aId, iBgContext );
	 }
	 return CCoeControl::MopSupplyObject(aId);
	}

⌨️ 快捷键说明

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