First public contribution.
     1 // Copyright (c) 1995-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.
 
    16 #include "W32STDGRAPHIC.H"
 
    19 LOCAL_C const TUid KStdBitmapAnimationType = {0x10281AAE};
 
    21 // CWsGraphicBitmapAnimation::CFrame  \\\\\\\\\\\\\\\\\\\\\\\\\\
 
    23 EXPORT_C CWsGraphicBitmapAnimation::CFrame* CWsGraphicBitmapAnimation::CFrame::NewL()
 
    25 	CFrame* self = new(ELeave) CFrame;
 
    29 CWsGraphicBitmapAnimation::CFrame::CFrame()
 
    33 EXPORT_C CWsGraphicBitmapAnimation::CFrame::~CFrame()
 
    39 // public getters/setters
 
    41 EXPORT_C TFrameInfo CWsGraphicBitmapAnimation::CFrame::FrameInfo() const
 
    46 EXPORT_C void CWsGraphicBitmapAnimation::CFrame::SetFrameInfo(const TFrameInfo& aFrameInfo)
 
    48 	iFrameInfo = aFrameInfo;
 
    51 EXPORT_C const CFbsBitmap* CWsGraphicBitmapAnimation::CFrame::Bitmap() const
 
    56 EXPORT_C void CWsGraphicBitmapAnimation::CFrame::SetBitmap(CFbsBitmap* aBitmap)
 
    58 	if(iBitmap != aBitmap)
 
    65 EXPORT_C const CFbsBitmap* CWsGraphicBitmapAnimation::CFrame::Mask() const
 
    70 EXPORT_C void CWsGraphicBitmapAnimation::CFrame::SetMask(CFbsBitmap* aMask)
 
    79 // CWsGraphicBitmapAnimation  \\\\\\\\\\\\\\\\\\\\\\\\\\
 
    81 CWsGraphicBitmapAnimation::CWsGraphicBitmapAnimation()
 
    85 EXPORT_C CWsGraphicBitmapAnimation::~CWsGraphicBitmapAnimation()
 
    89 EXPORT_C CWsGraphicBitmapAnimation* CWsGraphicBitmapAnimation::NewL(const TFrames& aFrames)
 
    91 	CWsGraphicBitmapAnimation* self = new(ELeave) CWsGraphicBitmapAnimation;
 
    92 	CleanupStack::PushL(self);
 
    93 	HBufC8* data = PackLC(aFrames);
 
    94 	self->BaseConstructL(KStdBitmapAnimationType,*data);
 
    95 	CleanupStack::PopAndDestroy(data);
 
    96 	CleanupStack::Pop(self);
 
   100 EXPORT_C CWsGraphicBitmapAnimation* CWsGraphicBitmapAnimation::NewL(TUid aUid,const TFrames& aFrames)
 
   102 	CWsGraphicBitmapAnimation* self = new(ELeave) CWsGraphicBitmapAnimation;
 
   103 	CleanupStack::PushL(self);
 
   104 	HBufC8* data = PackLC(aFrames);
 
   105 	self->BaseConstructL(aUid,KStdBitmapAnimationType,*data);
 
   106 	CleanupStack::PopAndDestroy(data);	
 
   107 	CleanupStack::Pop(self);
 
   111 EXPORT_C CWsGraphicBitmapAnimation* CWsGraphicBitmapAnimation::NewL(const TWsGraphicId& aReplace,const TFrames& aFrames)
 
   113 	CWsGraphicBitmapAnimation* self = new(ELeave) CWsGraphicBitmapAnimation;
 
   114 	CleanupStack::PushL(self);
 
   115 	HBufC8* data = PackLC(aFrames);
 
   116 	self->BaseConstructL(aReplace,KStdBitmapAnimationType,*data);
 
   117 	CleanupStack::PopAndDestroy(data);	
 
   118 	CleanupStack::Pop(self);
 
   122 // protected virtuals from CWsGraphic promoted to public
 
   124 EXPORT_C TInt CWsGraphicBitmapAnimation::ShareGlobally()
 
   126 	return CWsGraphic::ShareGlobally();
 
   129 EXPORT_C TInt CWsGraphicBitmapAnimation::UnShareGlobally()
 
   131 	return CWsGraphic::UnShareGlobally();
 
   134 EXPORT_C TInt CWsGraphicBitmapAnimation::Share(TSecureId aClientId)
 
   136 	return CWsGraphic::Share(aClientId);
 
   139 EXPORT_C TInt CWsGraphicBitmapAnimation::UnShare(TSecureId aClientId)
 
   141 	return CWsGraphic::UnShare(aClientId);
 
   144 void CWsGraphicBitmapAnimation::HandleMessage(const TDesC8& /*aData*/)
 
   148 void CWsGraphicBitmapAnimation::OnReplace()
 
   152 HBufC8* CWsGraphicBitmapAnimation::PackLC(const TFrames& aFrames)
 
   154 	__ASSERT_COMPILE(sizeof(TInt) == sizeof(TInt32));
 
   155 	const TInt count = aFrames.Count();
 
   156 	HBufC8* buf = HBufC8::NewL(sizeof(TInt) + ((sizeof(TFrameInfo)+sizeof(TInt)+sizeof(TInt))*count));
 
   157 	CleanupStack::PushL(buf);
 
   158 	TPtr8 des = buf->Des();
 
   159 	RDesWriteStream out(des);
 
   161 	out.WriteInt32L(count);
 
   162 	for(TInt i=0; i<count; i++)
 
   164 		const CFrame* frame = aFrames[i];
 
   167 			User::Leave(KErrArgument);
 
   169 		out.WriteL(reinterpret_cast<const TUint8*>(&(frame->iFrameInfo)),sizeof(TFrameInfo));
 
   170 		out.WriteInt32L(frame->Bitmap()? frame->Bitmap()->Handle(): 0);
 
   171 		out.WriteInt32L(frame->Mask()? frame->Mask()->Handle(): 0);