lafagnosticuifoundation/animation/src/AnimationFrame.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2004-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 <fbs.h>
       
    17 
       
    18 #include "AnimationFrame.h"
       
    19 
       
    20 /** Destructor.*/
       
    21 EXPORT_C CAnimationFrame::~CAnimationFrame()
       
    22 	{
       
    23 	delete iBitmap;
       
    24 	delete iMask;
       
    25 	}
       
    26 
       
    27 /**
       
    28 Two stage constructor.
       
    29 
       
    30 After construction, the frame contains empty bitmaps.
       
    31 
       
    32 @return The new object
       
    33 */
       
    34 EXPORT_C CAnimationFrame* CAnimationFrame::NewL()
       
    35 	{
       
    36 	CAnimationFrame * self = new (ELeave) CAnimationFrame();
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop(self);
       
    40 	return self;
       
    41 	}
       
    42 	
       
    43 /**
       
    44 Two stage constructor.
       
    45 
       
    46 After construction, the frame contains the bitmaps specified in the handles
       
    47 argument.
       
    48 
       
    49 @see GetHandles()
       
    50 @param aHandles An internal data type used for transferring the contents
       
    51 @return The new object
       
    52 */
       
    53 EXPORT_C CAnimationFrame* CAnimationFrame::NewL(const THandles& aHandles)
       
    54 	{
       
    55 	CAnimationFrame * self = NewL();
       
    56 	CleanupStack::PushL(self);
       
    57 	self->SetHandlesL(aHandles);
       
    58 	CleanupStack::Pop(self);
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 void CAnimationFrame::ConstructL()
       
    63 	{
       
    64 	iBitmap = new (ELeave) CFbsBitmap;
       
    65 	iMask = new (ELeave) CFbsBitmap;
       
    66 	}
       
    67 
       
    68 /**
       
    69 Initialises the internal bitmaps to the correct sizes for the frame.
       
    70 @param aFrameInfo A TFrameInfo object indicating the required size
       
    71 of the bitmaps.
       
    72 */
       
    73 EXPORT_C void CAnimationFrame::CreateL(const TFrameInfo& aFrameInfo)
       
    74 	{
       
    75 	iFrameInfo = aFrameInfo;
       
    76 	iBitmap->Reset();
       
    77 	iMask->Reset();
       
    78 	User::LeaveIfError(iBitmap->Create(iFrameInfo.iFrameCoordsInPixels.Size(), iFrameInfo.iFrameDisplayMode));
       
    79 	User::LeaveIfError(iMask->Create(iFrameInfo.iFrameCoordsInPixels.Size(), EGray256));
       
    80 	}
       
    81 	
       
    82 /**
       
    83 Obtains an alternative representation of the frame suitable for transferring
       
    84 over most interfaces (a THandle uses handles instead of pointers).
       
    85 
       
    86 @see SetHandlesL()
       
    87 @param aHandles A handles object to populate
       
    88 */
       
    89 EXPORT_C void CAnimationFrame::GetHandles(THandles & aHandles) const
       
    90 	{
       
    91 	aHandles.iBitmapHandle = iBitmap->Handle();
       
    92 	aHandles.iMaskHandle = iMask->Handle();
       
    93 	aHandles.iFrameInfo = iFrameInfo;
       
    94 	}
       
    95 	
       
    96 /**
       
    97 Sets the contents of the internal bitmaps to those represented by the handles.
       
    98 
       
    99 @see GetHandles()
       
   100 @param aHandles A handles object obtained from a call to GetHandles
       
   101 */
       
   102 EXPORT_C void CAnimationFrame::SetHandlesL(const THandles & aHandles)
       
   103 	{
       
   104 	iBitmap->Duplicate(aHandles.iBitmapHandle);
       
   105 	iMask->Duplicate(aHandles.iMaskHandle);
       
   106 	iFrameInfo = aHandles.iFrameInfo;
       
   107 	}
       
   108 
       
   109 /** Reserved for future use */
       
   110 EXPORT_C void CAnimationFrame::CAnimationFrame_Reserved1() { }
       
   111 
       
   112 /** Reserved for future use */
       
   113 EXPORT_C void CAnimationFrame::CAnimationFrame_Reserved2() { }
       
   114