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

📄 longtapdetectorappview.cpp

📁 该程序用于检测手机中的LongTap事件并对该事件进行处理
💻 CPP
字号:
/*
 ============================================================================
 Name		: LongTapDetectorAppView.cpp
 Author	  : Kiran
 Copyright   : Your copyright notice
 Description : Application view implementation
 ============================================================================
 */

// INCLUDE FILES
#include <coemain.h>
#include "LongTapDetectorAppView.h"
#include <aknnotewrappers.h>
// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CLongTapDetectorAppView* CLongTapDetectorAppView::NewL(const TRect& aRect)
	{
	CLongTapDetectorAppView* self = CLongTapDetectorAppView::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CLongTapDetectorAppView* CLongTapDetectorAppView::NewLC(const TRect& aRect)
	{
	CLongTapDetectorAppView* self = new (ELeave) CLongTapDetectorAppView;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CLongTapDetectorAppView::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();

	iLongTapDetector = CAknLongTapDetector::NewL(this);
//	iLongTapDetector->SetLongTapDelay(5000000);
//	iLongTapDetector->SetTimeDelayBeforeAnimation(2000000);
	
	// Set the windows size
	SetRect(aRect);

 // Background context for skinned background
	iBgContext = CAknsBasicBackgroundControlContext::NewL( 
		KAknsIIDSkinBmpMainPaneUsual, TRect( 0, 0, 0, 0 ), ETrue );
	iBgContext->SetRect( Rect() );
	iBgContext->SetParentPos( PositionRelativeToScreen() );
	
	// Activate the window, which makes it ready to be drawn
	ActivateL();
	}

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

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::~CLongTapDetectorAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CLongTapDetectorAppView::~CLongTapDetectorAppView()
	{
		if(iBgContext)
		{
			delete iBgContext;
			iBgContext = NULL;
		}	
		if(iLongTapDetector)
		{
			delete iLongTapDetector;
			iLongTapDetector = NULL;
		}
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CLongTapDetectorAppView::Draw(const TRect& /*aRect*/) const
	{
	  // Draw background
	CWindowGc& gc = SystemGc();
	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
	if ( !AknsDrawUtils::Background( skin, iBgContext, gc, Rect() ) )
		{
		SystemGc().Clear( Rect() );
		}	
	}

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CLongTapDetectorAppView::SizeChanged()
	{
	DrawNow();
	}

// -----------------------------------------------------------------------------
// CLongTapDetectorAppView::HandlePointerEventL()
// Called by framework to handle pointer touch events.
// -----------------------------------------------------------------------------
//
void CLongTapDetectorAppView::HandlePointerEventL(
		const TPointerEvent& aPointerEvent)
	{

	iLongTapDetector->PointerEventL(aPointerEvent);
	
	// Call base class HandlePointerEventL()
	CCoeControl::HandlePointerEventL(aPointerEvent);
	}

void CLongTapDetectorAppView::HandleLongTapEventL(const TPoint& aPenEventLocation, 
                                      const TPoint& aPenEventScreenLocation)
	{
		CAknInformationNote* info = new (ELeave) CAknInformationNote;
		info->ExecuteLD(_L("Really Long one"));
	}
// End of File

⌨️ 快捷键说明

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