windowing/windowserver/stdgraphic/BITMAPANIMATIONGRAPHIC.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "W32STDGRAPHIC.H"
       
    17 #include <s32mem.h>
       
    18 
       
    19 LOCAL_C const TUid KStdBitmapAnimationType = {0x10281AAE};
       
    20 
       
    21 // CWsGraphicBitmapAnimation::CFrame  \\\\\\\\\\\\\\\\\\\\\\\\\\
       
    22 
       
    23 EXPORT_C CWsGraphicBitmapAnimation::CFrame* CWsGraphicBitmapAnimation::CFrame::NewL()
       
    24 	{
       
    25 	CFrame* self = new(ELeave) CFrame;
       
    26 	return self;
       
    27 	}
       
    28 
       
    29 CWsGraphicBitmapAnimation::CFrame::CFrame()
       
    30 	{
       
    31 	}
       
    32 
       
    33 EXPORT_C CWsGraphicBitmapAnimation::CFrame::~CFrame()
       
    34 	{
       
    35 	delete iBitmap;
       
    36 	delete iMask;
       
    37 	}
       
    38 
       
    39 // public getters/setters
       
    40 
       
    41 EXPORT_C TFrameInfo CWsGraphicBitmapAnimation::CFrame::FrameInfo() const
       
    42 	{
       
    43 	return iFrameInfo;
       
    44 	}
       
    45 
       
    46 EXPORT_C void CWsGraphicBitmapAnimation::CFrame::SetFrameInfo(const TFrameInfo& aFrameInfo)
       
    47 	{
       
    48 	iFrameInfo = aFrameInfo;
       
    49 	}
       
    50 
       
    51 EXPORT_C const CFbsBitmap* CWsGraphicBitmapAnimation::CFrame::Bitmap() const
       
    52 	{
       
    53 	return iBitmap;
       
    54 	}
       
    55 
       
    56 EXPORT_C void CWsGraphicBitmapAnimation::CFrame::SetBitmap(CFbsBitmap* aBitmap)
       
    57 	{
       
    58 	if(iBitmap != aBitmap)
       
    59 		{
       
    60 		delete iBitmap;
       
    61 		iBitmap = aBitmap;
       
    62 		}
       
    63 	}
       
    64 
       
    65 EXPORT_C const CFbsBitmap* CWsGraphicBitmapAnimation::CFrame::Mask() const
       
    66 	{
       
    67 	return iMask;
       
    68 	}
       
    69 
       
    70 EXPORT_C void CWsGraphicBitmapAnimation::CFrame::SetMask(CFbsBitmap* aMask)
       
    71 	{
       
    72 	if(iMask != aMask)
       
    73 		{
       
    74 		delete iMask;
       
    75 		iMask = aMask;
       
    76 		}
       
    77 	}
       
    78 
       
    79 // CWsGraphicBitmapAnimation  \\\\\\\\\\\\\\\\\\\\\\\\\\
       
    80 
       
    81 CWsGraphicBitmapAnimation::CWsGraphicBitmapAnimation()
       
    82 	{
       
    83 	}
       
    84 
       
    85 EXPORT_C CWsGraphicBitmapAnimation::~CWsGraphicBitmapAnimation()
       
    86 	{
       
    87 	}
       
    88 
       
    89 EXPORT_C CWsGraphicBitmapAnimation* CWsGraphicBitmapAnimation::NewL(const TFrames& aFrames)
       
    90 	{
       
    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);
       
    97 	return self;
       
    98 	}
       
    99 
       
   100 EXPORT_C CWsGraphicBitmapAnimation* CWsGraphicBitmapAnimation::NewL(TUid aUid,const TFrames& aFrames)
       
   101 	{
       
   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);
       
   108 	return self;
       
   109 	}
       
   110 
       
   111 EXPORT_C CWsGraphicBitmapAnimation* CWsGraphicBitmapAnimation::NewL(const TWsGraphicId& aReplace,const TFrames& aFrames)
       
   112 	{
       
   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);
       
   119 	return self;
       
   120 	}
       
   121 
       
   122 // protected virtuals from CWsGraphic promoted to public
       
   123 
       
   124 EXPORT_C TInt CWsGraphicBitmapAnimation::ShareGlobally()
       
   125 	{
       
   126 	return CWsGraphic::ShareGlobally();
       
   127 	}
       
   128 
       
   129 EXPORT_C TInt CWsGraphicBitmapAnimation::UnShareGlobally()
       
   130 	{
       
   131 	return CWsGraphic::UnShareGlobally();
       
   132 	}
       
   133 
       
   134 EXPORT_C TInt CWsGraphicBitmapAnimation::Share(TSecureId aClientId)
       
   135 	{
       
   136 	return CWsGraphic::Share(aClientId);
       
   137 	}
       
   138 
       
   139 EXPORT_C TInt CWsGraphicBitmapAnimation::UnShare(TSecureId aClientId)
       
   140 	{
       
   141 	return CWsGraphic::UnShare(aClientId);
       
   142 	}
       
   143 
       
   144 void CWsGraphicBitmapAnimation::HandleMessage(const TDesC8& /*aData*/)
       
   145 	{
       
   146 	}
       
   147 
       
   148 void CWsGraphicBitmapAnimation::OnReplace()
       
   149 	{
       
   150 	}
       
   151 
       
   152 HBufC8* CWsGraphicBitmapAnimation::PackLC(const TFrames& aFrames)
       
   153 	{
       
   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);
       
   160 	out.PushL();
       
   161 	out.WriteInt32L(count);
       
   162 	for(TInt i=0; i<count; i++)
       
   163 		{
       
   164 		const CFrame* frame = aFrames[i];
       
   165 		if(!frame)
       
   166 			{
       
   167 			User::Leave(KErrArgument);
       
   168 			}
       
   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);
       
   172 		}
       
   173 	out.Pop();
       
   174 	out.CommitL();
       
   175 	return buf;
       
   176 	}