windowing/windowserver/Anim/MINANIM.CPP
changeset 0 5d03bc08d59c
child 33 25f95128741d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/windowing/windowserver/Anim/MINANIM.CPP	Tue Feb 02 01:47:50 2010 +0200
@@ -0,0 +1,148 @@
+// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// MBMANIM.CPP
+// Template for writing Anim DLL's
+// 
+//
+
+#include "mincmd.h"
+#include "minanim.h"
+
+
+GLDEF_C TInt E32Dll(TDllReason)
+	{
+	return(KErrNone);
+	}
+
+EXPORT_C CAnimDll *CreateCAnimDllL()
+	{
+	return(new(ELeave) CMinAnimDll());
+	}
+
+
+/*CMinAnimDll*/
+
+CAnim *CMinAnimDll::CreateInstanceL(TInt aType)
+	{
+    switch (aType)
+        {
+    case EMinAnimWindow:
+	    return new(ELeave) CMinWindowAnim();
+    case EMinAnimHandwriting:
+	    return new(ELeave) CMinHandAnim();
+    default:;       //To stop a warning
+        }
+	}
+
+
+/*CMinWindowAnim*/
+
+	iAnimator->Animate();
+	}
+
+
+/*CAnimateMbm*/
+
+CAnimateMbm::~CAnimateMbm()
+	{
+	delete iTimer;
+	delete iBitmap;
+	}
+
+void CAnimateMbm::ConstructL(TAny *, TBool )
+	{
+	iTimer=new(ELeave) CAnimTimer(this);
+	iTimer->ConstructL();
+	CActiveScheduler::Add(iTimer);
+	iInterval=100000;		//0.1 secs
+	iBitmap=new(ELeave) CFbsBitmap();
+	iWindowFunctions->SetRect(TRect(0,0,20,20));
+	}
+
+void CAnimateMbm::Animate()
+	{
+	if (!iRunning)
+		return;
+	iTimer->After(iInterval);
+	++iIndex;
+	while(LoadBitmap()!=KErrNone)
+		iIndex=0;
+	iWindowFunctions->ActivateGc();
+	Redraw();
+	WindowFunctions()->DeactivateGc();
+	WindowFunctions()->Update();
+	}
+
+TBool CAnimateMbm::OfferRawEvent(const TRawEvent& /*aRawEvent*/)
+	{
+	return EFalse;
+	}
+
+void CAnimateMbm::Animate(TDateTime* /*aDateTime*/)
+	{
+	}
+
+void CAnimateMbm::Redraw()
+	{
+	iGc->BitBlt(TPoint(),iBitmap);
+	/*if (1>0)
+		{
+		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
+		iGc->SetBrushColor(TRgb::Gray16(iIndex));
+		iGc->DrawRect(TRect(5,5,300,300));
+		}*/
+	}
+
+void CAnimateMbm::Command(TInt aOpcode,TAny *aParams)
+	{
+	switch (aOpcode)
+		{
+	case EMbmOpActivate:
+		//iFunctions->SetSync(MAnimGeneralFunctions::ESyncSecond);
+		iTimer->After(iInterval);
+		iRunning=ETrue;
+		break;
+	case EMbmOpDeactivate:
+		//iFunctions->SetSync(MAnimGeneralFunctions::ESyncNone);
+		iRunning=EFalse;
+		break;
+	case EMbmOpFaster:
+		iInterval=(19*iInterval.Int())/20;
+		break;
+	case EMbmOpSlower:
+		iInterval=(21*iInterval.Int())/20;
+		break;
+	case EMbmOpSetFileName:
+		iName=*STATIC_CAST(TBuf<32>*,aParams);
+		iIndex=0;
+		//User::LeaveIfError(LoadBitmap());
+		break;
+	default:
+		iFunctions->Panic();
+		}
+	}
+
+void CAnimateMbm::FocusChanged(TBool )
+	{
+	}
+
+TInt CAnimateMbm::CommandReplyL(TInt /*aOpcode*/,TAny* /*aParams*/)
+	{
+	/*switch (aOpcode)
+		{
+		default:
+			iFunctions->Panic();
+		}*/
+	return KErrNone;
+	}