uifw/AvKon/src/aknAnimCtrl.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Anim Ctrl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // AknAnimCtrl.CPP
       
    20 //
       
    21 // Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
       
    22 //
       
    23 
       
    24 // Animation Control
       
    25 
       
    26 
       
    27 #include "aknAnimCtrl.h"
       
    28 #include "aknanimdata.h"
       
    29 #include "AknPanic.h"
       
    30 #include <coemain.h>
       
    31 #include <eikenv.h>
       
    32 #include <eikappui.h>
       
    33 #include <AknLayout.lag>
       
    34 #include <AknUtils.h>
       
    35 #include <aknappui.h>
       
    36 
       
    37 CAknAnimationKeyWatcher* CAknAnimationKeyWatcher::NewL()
       
    38 	{
       
    39 	CAknAnimationKeyWatcher* self = new(ELeave)CAknAnimationKeyWatcher();
       
    40 	CleanupStack::PushL(self);
       
    41 	self->ConstructL();
       
    42 	CleanupStack::Pop();		//self
       
    43 	return self;
       
    44 	}
       
    45 
       
    46 CAknAnimationKeyWatcher::CAknAnimationKeyWatcher()
       
    47 	{
       
    48 	}
       
    49 
       
    50 CAknAnimationKeyWatcher::~CAknAnimationKeyWatcher()
       
    51 	{
       
    52 	iEikonEnv->EikAppUi()->RemoveFromStack(this);
       
    53 	}
       
    54 
       
    55 void CAknAnimationKeyWatcher::ConstructL()
       
    56 	{
       
    57 	iEikonEnv->EikAppUi()->AddToStackL(this,ECoeStackPriorityEnvironmentFilter);
       
    58 	ActivateL();
       
    59 	}
       
    60 
       
    61 TKeyResponse CAknAnimationKeyWatcher::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
    62 	{
       
    63 	// If the animation animation is playing, cancel it but do not consume the key.
       
    64 	// The underlying view then receives the key as normal.
       
    65 	if (iAnimationCtrl)
       
    66 		{
       
    67 		// Animation is playing, so cancel it
       
    68 		iAnimationCtrl->CancelAnimation();
       
    69 		return EKeyWasNotConsumed;
       
    70 		}
       
    71 
       
    72 	// If the view has not yet been drawn, consume the key since this could
       
    73 	// cause the view to change before the animation starts.
       
    74 	return EKeyWasConsumed;
       
    75 	}
       
    76 
       
    77 void CAknAnimationKeyWatcher::SetAnimationControl(CAknAnimationCtrl* aAnimationCtrl)
       
    78 	{
       
    79 	iAnimationCtrl = aAnimationCtrl;
       
    80 	}
       
    81 
       
    82 CAknAnimationCtrl* CAknAnimationCtrl::NewL(CWindowGc& aWindowGc, CFbsBitmap& aViewBitmap, CFbsBitmap& aOriginalBitmap, CAknAnimationData* aData)
       
    83 	{
       
    84 	CAknAnimationCtrl* self = new(ELeave)CAknAnimationCtrl(aWindowGc, aViewBitmap, aOriginalBitmap, aData);
       
    85 	CleanupStack::PushL(self);
       
    86 	self->ConstructL();
       
    87 	CleanupStack::Pop();
       
    88 	return self;
       
    89 	}
       
    90 
       
    91 
       
    92 CAknAnimationCtrl::CAknAnimationCtrl(CWindowGc& aWindowGc, CFbsBitmap& aViewBitmap, CFbsBitmap& aOriginalBitmap, CAknAnimationData* aAnimationData)
       
    93 :iWindowGc(aWindowGc), iViewBitmap(aViewBitmap), iOriginalBitmap(aOriginalBitmap), iAnimationData(aAnimationData)
       
    94 	{
       
    95 	}
       
    96 
       
    97 CAknAnimationCtrl::~CAknAnimationCtrl()
       
    98 	{
       
    99 	}
       
   100 
       
   101 void CAknAnimationCtrl::ConstructL()
       
   102 	{
       
   103 	CreateWindowL();
       
   104 	__ASSERT_DEBUG(iAnimationData, Panic(EAknPanicNoAnimationData));
       
   105     iAnimationData->SetScreenSize(iAvkonAppUi->ApplicationRect().Size());
       
   106 	//iAnimationData->SetScreenSize(TSize(AKN_LAYOUT_WINDOW_screen.iW,AKN_LAYOUT_WINDOW_screen.iH));
       
   107 	iAnimationData->SetViewBitmap(&iViewBitmap);
       
   108 	iAnimationData->SetOldBitmap(&iOriginalBitmap);
       
   109 	}
       
   110 
       
   111 void CAknAnimationCtrl::Draw(const TRect& /*aRect*/) const
       
   112 	{
       
   113 	if (iAnimationData->ClearOldView())
       
   114 		iWindowGc.Clear();
       
   115 	else
       
   116 		iWindowGc.BitBlt(TPoint(0,0), &iOriginalBitmap);
       
   117 	}
       
   118 
       
   119 
       
   120 TBool CAknAnimationCtrl::DrawStep()
       
   121 	{
       
   122 	// Check if the animation has been cancelled
       
   123 	if (iCancelled)
       
   124 		return ETrue;
       
   125 
       
   126 	iWindowGc.Activate(Window());
       
   127 	TBool done = iAnimationData->DrawNextAnimationStep(iWindowGc);
       
   128 	iWindowGc.Deactivate();
       
   129 	return done;
       
   130 	}
       
   131 
       
   132 
       
   133 void CAknAnimationCtrl::CancelAnimation()
       
   134 	{
       
   135 	iCancelled = ETrue;
       
   136 	}
       
   137 
       
   138 // End of File