Update contrib.
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Demonstration handwriting class
23 TInt RHandWritingAnim::Construct(const RWsSprite& aDevice)
26 return RAnim::Construct(aDevice,0,des);
29 void RHandWritingAnim::Activate()
31 Command(EHwOpActivate);
34 void RHandWritingAnim::Deactivate()
36 Command(EHwOpDeactivate);
39 TInt RHandWritingAnim::SpriteMaskChange(TBool aUsingSeparateMask)
41 TPckgBuf<TBool> param;
42 param()=aUsingSeparateMask;
43 return CommandReply(EHwOpSpriteMask,param);
46 void RHandWritingAnim::SetDrawData(const THandwritingDrawData& aDrawData)
48 TPckgBuf<THandwritingDrawData> param;
50 Command(EHwOpSetDrawData,param);
53 TInt RHandWritingAnim::GetLastGeneratedCharacter()
55 return CommandReply(EHwOpGetLastChar);
61 CHandWriting::CHandWriting(RWsSession& aSession)
62 :iSession(aSession), iAnimDll(aSession), iAnim(iAnimDll), iSprite(aSession)
65 void CHandWriting::ConstructL(TSize aScreenSize,RWindowGroup& aGroup,TBool aUseSeparateMask)
67 //This function should be called with the correct screen size and
68 //the handle of any group window that will be around as long as the handwriting is required
71 CreateSpriteL(aScreenSize,aGroup,aUseSeparateMask);
75 void CHandWriting::CreateSpriteL(TSize aScreenSize,RWindowGroup& aGroup,TBool aUseSeparateMask)
77 TInt color,gray; //Unused variables
78 TDisplayMode mode=iSession.GetDefModeMaxNumColors(color,gray);
79 iBitmap=new(ELeave) CFbsBitmap();
80 User::LeaveIfError(iBitmap->Create(aScreenSize,mode));
82 member.iMaskBitmap=iBitmap;
85 iMaskBitmap=new(ELeave) CFbsBitmap();
86 User::LeaveIfError(iMaskBitmap->Create(aScreenSize,mode));
87 member.iMaskBitmap=iMaskBitmap;
89 User::LeaveIfError(iSprite.Construct(aGroup,TPoint(),ESpriteNoChildClip|ESpriteNoShadows));
90 FillInSpriteMember(member);
91 iSprite.AppendMember(member);
94 void CHandWriting::LoadDllL()
96 _LIT(DllName,"HandAnim.DLL");
97 TInt err=iAnimDll.Load(DllName);
99 err=iAnim.Construct(iSprite);
105 User::LeaveIfError(err);
108 CHandWriting::~CHandWriting()
116 void CHandWriting::SetMaskL(TBool aUseSeparateMask)
118 if ((iMaskBitmap!=NULL)==aUseSeparateMask)
120 TSpriteMember member;
121 FillInSpriteMember(member);
122 if (aUseSeparateMask)
124 iMaskBitmap=new(ELeave) CFbsBitmap();
125 member.iMaskBitmap=iMaskBitmap;
129 member.iMaskBitmap=iBitmap;
133 iSprite.UpdateMember(1,member);
134 TInt err=iAnim.SpriteMaskChange(aUseSeparateMask);
137 if (aUseSeparateMask)
141 member.iMaskBitmap=iBitmap;
145 member.iMaskBitmap=iMaskBitmap;
147 iSprite.UpdateMember(1,member);
149 else if (!aUseSeparateMask)
156 User::LeaveIfError(err);
159 void CHandWriting::ToggleStatus()
168 void CHandWriting::FillInSpriteMember(TSpriteMember& aMember)
170 aMember.iBitmap=iBitmap;
171 aMember.iInvertMask=ETrue; //Must be inverted
172 aMember.iDrawMode=CGraphicsContext::EDrawModePEN; //Ignored when using mask
173 aMember.iOffset=TPoint(); //Must be 0,0
174 aMember.iInterval=0; //Not used as only one TSpriteMember in sprite