// W32ADLL.H
//
// Copyright (c) 1995-1999 Symbian Ltd.  All rights reserved.
//


//
// Header for writing animated DLL add ons
//

#if !defined(__W32ADLL_H__)
#define __W32ADLL_H__

#if !defined(__W32STD_H__)
#include <w32std.h>
#endif

#if !defined(__BITSTD_H__)
#include <bitstd.h>
#endif

const TUint KWservAnimDllUidValue8=268435858;
const TUid KWservAnimDllUid8={KWservAnimDllUidValue8};
const TUint KWservAnimDllUidValue16=268450594;
const TUid KWservAnimDllUid16={KWservAnimDllUidValue16};
#if defined(_UNICODE)
const TUint KWservAnimDllUidValue=KWservAnimDllUidValue16;
#else
const TUint KWservAnimDllUidValue=KWservAnimDllUidValue8;
#endif
const TUid KWservAnimDllUid={KWservAnimDllUidValue};

//
// Contains functions callable from animated DLL's
//

class CAnimFunctions : public CObject 
	{
public:
	enum TAnimSync	// The animator can be synchronised to any of the below, the Animate() call will take place
		{			// at the start of the new unit (day, hour, etc..)
		ESyncNone,			// Not synchronised
		ESyncFlash,			// Animate() called twice a second, on the second and on seven o'clock
		ESyncSecond,		// Animate() called every second
		ESyncMinute,		// Animate() called every minute
		ESyncDay,			// Animate() called every day
		};
public:
	virtual void ActivateGc()=0;					// Activate the GC to enable drawing in a command or animate function
	virtual void Invalidate(const TRect &aRect)=0;
	virtual void Animate(TDateTime *aDateTime)=0; // Trigger a call to the DLL's Animate function
	virtual void SetSync(TAnimSync aSyncMode)=0;
	virtual void SetInterval(TInt aInterval)=0;		// Set the regular repeat interval, does not affect the current countdown
	virtual void SetNextInterval(TInt aInterval)=0;	// Sets the interval to the next Animate, after that it will fall back to the usual rate
	virtual void SetRect(const TRect &aRect)=0;		// Sets the rect that this instance wants to draw to.
	virtual TDateTime SystemTime() const=0;			// Return the system time as it was when Animate last called
	virtual TBool FlashStateOn() const=0;			// Return ETrue if in the on part of the flash cycle
	virtual const CFbsScreenDevice *ScreenDevice()=0;		// Pointer to screen device
	virtual CFbsBitmap *DuplicateBitmapL(TInt aHandle)=0;	// Create and duplicate a bitmap from a handle
	virtual CFbsFont *DuplicateFontL(TInt aHandle)=0;	// Create and duplicate a font from a handle
	virtual void CloseFont(CFbsFont *)=0;				// Close a font duplicated by DuplicateFontL
	virtual TSize WindowSize() const=0;				// Return the window size
	virtual TBool IsHidden()=0;
	virtual void SetVisible(TBool aState)=0;
	virtual const RThread &Client()=0;					// Return a reference to the calling clients thread
	virtual TAnimSync Sync() const=0;							// Return the current sync mode
	virtual void ReplyBuf(const TDesC8 &aDes)=0;				// Reply a buffer to the client
#if defined(_UNICODE)
	virtual void ReplyBuf(const TDesC16 &aDes)=0;				// Reply a buffer to the client
#endif
	virtual void Panic()=0;							// Trigger a client panic
	};


class CAnimGc : public CBitmapContext
	{
public:
	virtual void SetClippingRegion(const TRegion &aRegion)=0;
	virtual void CancelClippingRegion()=0;
	};

class CWsAnim; // Forward ref for friend declaration
//
//	Base class to derive server side Animated DLL instances from.
//
class CAnim : public CBase
	{
public:
	struct TInterval
		{
		TBool fullUpdate; // If ETrue ignore other values and re-calc time from system time
		TInt days;
		TInt hours;
		TInt minutes;
		TInt seconds;
		TInt halfSeconds;
		};
public:
	virtual void ConstructL(TAny *aArgs, TBool aHasFocus)=0;
	virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs)=0;
	virtual void Command(TInt aOpcode, TAny *aArgs)=0;
	virtual void Animate(TDateTime *aDateTime)=0;
	virtual void Redraw()=0;
	virtual void FocusChanged(TBool aState)=0;
protected:
	CAnimFunctions *iFunctions;
	CAnimGc *iGc;
	friend class CWsAnim;
	};

//
// Base class to derive server side Animated DLL classes from
//
class CAnimDll : public CBase
	{
public:
	virtual CAnim *CreateInstanceL(TInt aType)=0;
	};

#endif
