windowing/windowserver/Anim/MINANIM.CPP
changeset 0 5d03bc08d59c
child 33 25f95128741d
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1999-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 // MBMANIM.CPP
       
    15 // Template for writing Anim DLL's
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "mincmd.h"
       
    20 #include "minanim.h"
       
    21 
       
    22 
       
    23 GLDEF_C TInt E32Dll(TDllReason)
       
    24 	{
       
    25 	return(KErrNone);
       
    26 	}
       
    27 
       
    28 EXPORT_C CAnimDll *CreateCAnimDllL()
       
    29 	{
       
    30 	return(new(ELeave) CMinAnimDll());
       
    31 	}
       
    32 
       
    33 
       
    34 /*CMinAnimDll*/
       
    35 
       
    36 CAnim *CMinAnimDll::CreateInstanceL(TInt aType)
       
    37 	{
       
    38     switch (aType)
       
    39         {
       
    40     case EMinAnimWindow:
       
    41 	    return new(ELeave) CMinWindowAnim();
       
    42     case EMinAnimHandwriting:
       
    43 	    return new(ELeave) CMinHandAnim();
       
    44     default:;       //To stop a warning
       
    45         }
       
    46 	}
       
    47 
       
    48 
       
    49 /*CMinWindowAnim*/
       
    50 
       
    51 	iAnimator->Animate();
       
    52 	}
       
    53 
       
    54 
       
    55 /*CAnimateMbm*/
       
    56 
       
    57 CAnimateMbm::~CAnimateMbm()
       
    58 	{
       
    59 	delete iTimer;
       
    60 	delete iBitmap;
       
    61 	}
       
    62 
       
    63 void CAnimateMbm::ConstructL(TAny *, TBool )
       
    64 	{
       
    65 	iTimer=new(ELeave) CAnimTimer(this);
       
    66 	iTimer->ConstructL();
       
    67 	CActiveScheduler::Add(iTimer);
       
    68 	iInterval=100000;		//0.1 secs
       
    69 	iBitmap=new(ELeave) CFbsBitmap();
       
    70 	iWindowFunctions->SetRect(TRect(0,0,20,20));
       
    71 	}
       
    72 
       
    73 void CAnimateMbm::Animate()
       
    74 	{
       
    75 	if (!iRunning)
       
    76 		return;
       
    77 	iTimer->After(iInterval);
       
    78 	++iIndex;
       
    79 	while(LoadBitmap()!=KErrNone)
       
    80 		iIndex=0;
       
    81 	iWindowFunctions->ActivateGc();
       
    82 	Redraw();
       
    83 	WindowFunctions()->DeactivateGc();
       
    84 	WindowFunctions()->Update();
       
    85 	}
       
    86 
       
    87 TBool CAnimateMbm::OfferRawEvent(const TRawEvent& /*aRawEvent*/)
       
    88 	{
       
    89 	return EFalse;
       
    90 	}
       
    91 
       
    92 void CAnimateMbm::Animate(TDateTime* /*aDateTime*/)
       
    93 	{
       
    94 	}
       
    95 
       
    96 void CAnimateMbm::Redraw()
       
    97 	{
       
    98 	iGc->BitBlt(TPoint(),iBitmap);
       
    99 	/*if (1>0)
       
   100 		{
       
   101 		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   102 		iGc->SetBrushColor(TRgb::Gray16(iIndex));
       
   103 		iGc->DrawRect(TRect(5,5,300,300));
       
   104 		}*/
       
   105 	}
       
   106 
       
   107 void CAnimateMbm::Command(TInt aOpcode,TAny *aParams)
       
   108 	{
       
   109 	switch (aOpcode)
       
   110 		{
       
   111 	case EMbmOpActivate:
       
   112 		//iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond);
       
   113 		iTimer->After(iInterval);
       
   114 		iRunning=ETrue;
       
   115 		break;
       
   116 	case EMbmOpDeactivate:
       
   117 		//iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone);
       
   118 		iRunning=EFalse;
       
   119 		break;
       
   120 	case EMbmOpFaster:
       
   121 		iInterval=(19*iInterval.Int())/20;
       
   122 		break;
       
   123 	case EMbmOpSlower:
       
   124 		iInterval=(21*iInterval.Int())/20;
       
   125 		break;
       
   126 	case EMbmOpSetFileName:
       
   127 		iName=*STATIC_CAST(TBuf<32>*,aParams);
       
   128 		iIndex=0;
       
   129 		//User::LeaveIfError(LoadBitmap());
       
   130 		break;
       
   131 	default:
       
   132 		iFunctions->Panic();
       
   133 		}
       
   134 	}
       
   135 
       
   136 void CAnimateMbm::FocusChanged(TBool )
       
   137 	{
       
   138 	}
       
   139 
       
   140 TInt CAnimateMbm::CommandReplyL(TInt /*aOpcode*/,TAny* /*aParams*/)
       
   141 	{
       
   142 	/*switch (aOpcode)
       
   143 		{
       
   144 		default:
       
   145 			iFunctions->Panic();
       
   146 		}*/
       
   147 	return KErrNone;
       
   148 	}