windowing/windowserver/test/HNDLODR.CPP
author William Roberts <williamr@symbian.org>
Thu, 03 Jun 2010 17:39:46 +0100
branchNewGraphicsArchitecture
changeset 87 0709f76d91e5
parent 0 5d03bc08d59c
permissions -rw-r--r--
Add MMP files to build libOpenVG_sw.lib which uses LINKAS to redirect to libOpenVG.dll (and the same for libEGL_sw.lib and libOpenVGU_sw.lib). Only the libEGL_sw.lib redirection isn't activated - this can't happen until there is a merged libEGL.dll which supports the OpenWF synchronisation and also implements the graphical support functions. The overall aim is to eliminate the *_sw.dll implementations, at least as a compile-time way of choosing a software-only implementation.The correct way to choose is to put the right set of libraries into a ROM with suitable renaming, and in the emulator to use the "switching DLL" technique to pick the right set. As the Symbian Foundation doesn't have any alternative implementations, we don't need the switching DLLs and we can build directly to the correct name.

// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// Demonstration handwriting class
// 
//

#include "HNDLODR.H"


/*RHandWritingAnim*/

TInt RHandWritingAnim::Construct(const RWsSprite& aDevice)
	{
	TPtrC8 des(NULL,0);
	return RAnim::Construct(aDevice,0,des);
	}

void RHandWritingAnim::Activate()
	{
	Command(EHwOpActivate);
	}

void RHandWritingAnim::Deactivate()
	{
	Command(EHwOpDeactivate);
	}

TInt RHandWritingAnim::SpriteMaskChange(TBool aUsingSeparateMask)
	{
	TPckgBuf<TBool> param;
	param()=aUsingSeparateMask;
	return CommandReply(EHwOpSpriteMask,param);
	}

void RHandWritingAnim::SetDrawData(const THandwritingDrawData& aDrawData)
	{
	TPckgBuf<THandwritingDrawData> param;
	param()=aDrawData;
	Command(EHwOpSetDrawData,param);
	}

TInt RHandWritingAnim::GetLastGeneratedCharacter()
	{
	return CommandReply(EHwOpGetLastChar);
	}


/*CHandWriting*/

CHandWriting::CHandWriting(RWsSession& aSession)
	:iSession(aSession), iAnimDll(aSession), iAnim(iAnimDll), iSprite(aSession)
	{}

void CHandWriting::ConstructL(TSize aScreenSize,RWindowGroup& aGroup,TBool aUseSeparateMask)
	//
	//This function should be called with the correct screen size and 
	//the handle of any group window that will be around as long as the handwriting is required
	//
	{
	CreateSpriteL(aScreenSize,aGroup,aUseSeparateMask);
	LoadDllL();
	}

void CHandWriting::CreateSpriteL(TSize aScreenSize,RWindowGroup& aGroup,TBool aUseSeparateMask)
	{
	TInt color,gray;		//Unused variables
	TDisplayMode mode=iSession.GetDefModeMaxNumColors(color,gray);
	iBitmap=new(ELeave) CFbsBitmap();
	User::LeaveIfError(iBitmap->Create(aScreenSize,mode));
	TSpriteMember member;
	member.iMaskBitmap=iBitmap;
	if (aUseSeparateMask)
		{
		iMaskBitmap=new(ELeave) CFbsBitmap();
		User::LeaveIfError(iMaskBitmap->Create(aScreenSize,mode));
		member.iMaskBitmap=iMaskBitmap;
		}
	User::LeaveIfError(iSprite.Construct(aGroup,TPoint(),ESpriteNoChildClip|ESpriteNoShadows));
	FillInSpriteMember(member);
	iSprite.AppendMember(member);
	}

void CHandWriting::LoadDllL()
	{
	_LIT(DllName,"HandAnim.DLL");
	TInt err=iAnimDll.Load(DllName);
	if (err==KErrNone)
		err=iAnim.Construct(iSprite);
	if (err==KErrNone)
		{
		iAnim.Activate();
		iActive=ETrue;
		}
	User::LeaveIfError(err);
	}

CHandWriting::~CHandWriting()
	{
	delete iBitmap;
	delete iMaskBitmap;
	iSprite.Close();
	iAnimDll.Close();
	}

void CHandWriting::SetMaskL(TBool aUseSeparateMask)
	{
	if ((iMaskBitmap!=NULL)==aUseSeparateMask)
		return;
	TSpriteMember member;
	FillInSpriteMember(member);
	if (aUseSeparateMask)
		{
		iMaskBitmap=new(ELeave) CFbsBitmap();
		member.iMaskBitmap=iMaskBitmap;
		}
	else
		{
		member.iMaskBitmap=iBitmap;
		}
	if (iActive)
		iAnim.Deactivate();
	iSprite.UpdateMember(1,member);
	TInt err=iAnim.SpriteMaskChange(aUseSeparateMask);
	if (err<0)
		{
		if (aUseSeparateMask)
			{
			delete iMaskBitmap;
			iMaskBitmap=NULL;
			member.iMaskBitmap=iBitmap;
			}
		else
			{
			member.iMaskBitmap=iMaskBitmap;
			}
		iSprite.UpdateMember(1,member);
		}
	else if (!aUseSeparateMask)
		{
		delete iMaskBitmap;
		iMaskBitmap=NULL;
		}
	if (iActive)
		iAnim.Activate();
	User::LeaveIfError(err);
	}

void CHandWriting::ToggleStatus()
	{
	if (iActive)
		iAnim.Deactivate();
	else
		iAnim.Activate();
	iActive=!iActive;
	}

void CHandWriting::FillInSpriteMember(TSpriteMember& aMember)
	{
	aMember.iBitmap=iBitmap;
	aMember.iInvertMask=ETrue;		//Must be inverted
	aMember.iDrawMode=CGraphicsContext::EDrawModePEN;		//Ignored when using mask
	aMember.iOffset=TPoint();		//Must be 0,0
	aMember.iInterval=0;		//Not used as only one TSpriteMember in sprite
	}