First public contribution.
1 // Copyright (c) 1996-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 // Base classes used for building window server test code
23 EXPORT_C TSpriteCreateParams::TSpriteCreateParams(TSize aSize,TPoint aOffset,CTSpriteBase::TSpriteDrawFunction aDrawFunc,
24 TAny *aDrawFuncParam,TBool aMask,CGraphicsContext::TDrawMode aDrawMode) :
28 iDrawFuncParam(aDrawFuncParam),
34 EXPORT_C TSpriteCreateParams::TSpriteCreateParams() :
36 iDrawMode(CGraphicsContext::EDrawModePEN),
40 void CTSpriteBase::CreateBitmapL(CFbsBitmap *&aBitmap, CFbsBitmapDevice *&aBitmapDevice, TSpriteCreateParams *aParams, TBool aDoMask)
44 aBitmap=new(ELeave) CFbsBitmap();
45 User::LeaveIfError(aBitmap->Create(aParams->iSize,EGray4));
47 aBitmapDevice=CFbsBitmapDevice::NewL(aBitmap);
48 CFbsBitGc *gc=CFbsBitGc::NewL();
49 gc->Activate(aBitmapDevice);
50 aParams->iDrawFunc(gc,0,aParams->iSize,aDoMask,aParams->iDrawFuncParam);
54 EXPORT_C void CTSpriteBase::RedrawL(CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap, TSpriteCreateParams *aParams)
56 CFbsBitmapDevice *bitmapDevice=NULL;
57 TRAPD(err,CreateBitmapL(aBitmap,bitmapDevice,aParams,EFalse));
64 TRAP(err,CreateBitmapL(aMaskBitmap,bitmapDevice,aParams,ETrue));
67 SpriteBase().UpdateMember(0);
69 User::LeaveIfError(err);
72 EXPORT_C void CTSpriteBase::UpdateL(TInt aIndex, TSpriteCreateParams *aParams)
74 CFbsBitmap *bitmap=NULL;
75 CFbsBitmapDevice *bitmapDevice=NULL;
76 TRAPD(err,CreateBitmapL(bitmap,bitmapDevice,aParams,EFalse));
81 CFbsBitmap *mask=NULL;
83 TRAP(err,CreateBitmapL(mask,bitmapDevice,aParams,ETrue));
87 sprite.iBitmap=bitmap;
88 sprite.iMaskBitmap=mask;
89 sprite.iInvertMask=EFalse;
90 sprite.iDrawMode=aParams->iDrawMode;
91 sprite.iInterval=aParams->iInterval;
92 sprite.iOffset=aParams->iOffset;
93 err=SpriteBase().UpdateMember(aIndex,sprite);
99 User::LeaveIfError(err);
102 EXPORT_C CTSprite::CTSprite(RWsSession &aWs) : iSprite(aWs)
106 EXPORT_C CTSprite::~CTSprite()
111 EXPORT_C RWsSpriteBase &CTSprite::SpriteBase()
116 EXPORT_C RWsSprite &CTSprite::Sprite()
121 EXPORT_C void CTSprite::ConstructL(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount, TSpriteCreateParams *aParams, TInt aFlags)
123 User::LeaveIfError(iSprite.Construct(aWindow,aPos,aFlags));
124 for(TInt index=0;index<aCount;index++,aParams++)
126 CFbsBitmap *bitmap=NULL;
127 CFbsBitmap *mask=NULL;
128 CFbsBitmapDevice *bitmapDevice=NULL;
129 TRAPD(err,CreateBitmapL(bitmap,bitmapDevice,aParams,EFalse));
135 TRAP(err,CreateBitmapL(mask,bitmapDevice,aParams,ETrue));
138 TSpriteMember sprite;
139 sprite.iBitmap=bitmap;
140 sprite.iMaskBitmap=mask;
141 sprite.iInvertMask=EFalse;
142 sprite.iDrawMode=aParams->iDrawMode;
143 sprite.iOffset=aParams->iOffset;
144 sprite.iInterval=aParams->iInterval;
145 err=iSprite.AppendMember(sprite);
151 User::LeaveIfError(err);
153 User::LeaveIfError(iSprite.Activate());
156 EXPORT_C CTPointerCursor::CTPointerCursor(RWsSession &aWs) : iCursor(aWs)
160 EXPORT_C CTPointerCursor::~CTPointerCursor()
165 EXPORT_C RWsSpriteBase &CTPointerCursor::SpriteBase()
170 EXPORT_C RWsPointerCursor &CTPointerCursor::PointerCursor()
175 EXPORT_C void CTPointerCursor::ConstructL(TInt aFlags)
177 User::LeaveIfError(iCursor.Construct(aFlags));
178 TSpriteMember sprite;
180 User::LeaveIfError(iCursor.AppendMember(sprite));
183 EXPORT_C void CTPointerCursor::ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags)
185 CFbsBitmap *bitmap=NULL;
186 CFbsBitmap *mask=NULL;
187 TRAPD(err,ConstructL(aCount, aParams, aFlags, bitmap, mask));
190 User::LeaveIfError(err);
193 EXPORT_C void CTPointerCursor::ConstructL(TInt aCount, TSpriteCreateParams *aParams, TInt aFlags, CFbsBitmap *&aBitmap, CFbsBitmap *&aMaskBitmap)
195 User::LeaveIfError(iCursor.Construct(aFlags));
196 for(TInt index=0;index<aCount;index++,aParams++)
198 CFbsBitmapDevice *bitmapDevice=NULL;
199 TRAPD(err,CreateBitmapL(aBitmap,bitmapDevice,aParams,EFalse));
205 TRAP(err,CreateBitmapL(aMaskBitmap,bitmapDevice,aParams,ETrue));
208 TSpriteMember sprite;
209 sprite.iBitmap=aBitmap;
210 sprite.iMaskBitmap=aMaskBitmap;
211 sprite.iInvertMask=EFalse;
212 sprite.iDrawMode=aParams->iDrawMode;
213 sprite.iInterval=aParams->iInterval;
214 sprite.iOffset=aParams->iOffset;
215 err=iCursor.AppendMember(sprite);
220 User::LeaveIfError(err);
222 User::LeaveIfError(iCursor.Activate());