os/graphics/windowing/windowserver/nga/SERVER/openwfc/sprite.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2006-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 // CWsSprite and associated classes definitions
    15 // 
    16 //
    17 
    18 #ifndef __SPRITE_H__
    19 #define __SPRITE_H__
    20 
    21 #include "server.h"
    22 #include "window.h"
    23 #include <graphics/wsgraphicscontext.h>
    24 #include <babitflags.h>
    25 
    26 //
    27 // CWsSpriteMember
    28 //
    29 class CWsSpriteMember : public CBase
    30 	{
    31 public:
    32 	CWsSpriteMember();
    33 	~CWsSpriteMember();
    34 	TBool SetL(const TCmdSpriteMember &aCmdSpriteMember);
    35 public:
    36 	CFbsBitmap *iBitmap;
    37 	CFbsBitmap *iMaskBitmap;
    38 	TBool iInvertMask;
    39 	CGraphicsContext::TDrawMode iDrawMode;
    40 	TPoint iOffset;
    41 	TTimeIntervalMicroSeconds32 iInterval;
    42 	};
    43 
    44 //
    45 // CWsSpriteBase
    46 //
    47 class CWsSpriteBase : public CWsScreenObject, public MWsWindowTreeNode, public MWsSprite
    48 	{
    49 protected:
    50 	enum {ENoChildPriorityBoost=1,EPointerPriorityBoost=2};
    51 public:
    52 	friend class CWsSpriteTimer;
    53 	friend class CWsAnim;
    54 	friend class TCursorSprite;
    55 public:
    56 	static void InitStaticsL();
    57 	static void DeleteStatics();
    58 
    59 	CWsSpriteBase(CWsClient *aOwner, WH_HANDLES aType);
    60 	~CWsSpriteBase();
    61 
    62 	//from MWsSprite
    63 	TRect Rect() const;
    64 	TSpriteType SpriteType() const;
    65 	
    66 	TPoint Pos() const;
    67 	void SetPos(const TPoint &Pos);
    68 	void Deactivate();
    69 	void DisconnectGroupWin();
    70 	void TimerExpired();
    71 	void Activate();
    72 	inline TBool IsActive() const;
    73 	inline TBool IsFlashingEnabled() const;
    74 	inline TBool AdvancedPointersEnabled() const;
    75 	TBool CanBeSeen() const;
    76 	CWsSpriteBase * Next() { return iNext; }
    77 	void SetNext(CWsSpriteBase * aNext) { iNext = aNext; }
    78 	void CalcRedrawRegion(const TRegion& aSourceRegion, TRegion& aTarget) const;
    79 	void Redraw(MWsGraphicsContext * aGc, const TRegion& aRegion);
    80 	void ForceRedraw();
    81 	inline const CWsWindow* Win() const;
    82 	inline CWsWindow* Win();
    83 	TBool IsActivated() const;
    84 	inline TBool HasSpriteMember() const { return  iMembers->Count(); }
    85 	void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const;
    86 	
    87 public: // from MWsWindowTreeNode
    88 	MWsWindowTreeNode::TType NodeType() const;
    89 	const MWsWindow* Window() const;
    90 	const MWsSprite* Sprite() const;
    91 	const MWsStandardTextCursor* StandardTextCursor() const;
    92 	const MWsWindowGroup* WindowGroup() const;
    93 	const MWsWindowTreeNode* ParentNode() const;
    94 
    95 protected:
    96 	void ConstructL(TUint aFlags, CWsWindow *aWindow);
    97 	void CommandL(TInt aOpcode, const TAny *aCmdData);
    98 	void AppendMemberL(const TCmdSpriteMember &aCmdSpriteMember);
    99 	virtual void CompleteL();
   100 	void SetMember(TInt aIndex);
   101 	void CheckSizesL();
   102 	TBool UpdateMemberL(CWsSpriteMember *aMember, const TCmdSpriteMember &aCmdSpriteMember);
   103 	void QueueDeltaTimer();
   104 	void NotifyExtentChanged() const;
   105 	enum TInternalFlags 
   106 		{
   107 		EFloating, 
   108 		EClipSprite,
   109 		EHasAnimation,
   110 		EDirty
   111 		};
   112 	inline void SetIsFloating(TBool aIsFloating);
   113 	inline TBool IsFloating() const;
   114 	inline void SetClipSprite(TBool aClipSprite);
   115 	inline TBool ClipSprite() const;
   116 public:	
   117 	inline void SetHasAnimation(TBool aValue);
   118 	inline TBool HasAnimation() const;
   119 	inline void SetDirty(TBool aValue);
   120 	inline TBool IsDirty() const;
   121 
   122 protected:
   123 	CWsWindow *iWin;
   124 	CWsWindowGroup *iGroupWin;
   125 	TPoint iBasePos;
   126 	TPoint iPos;		// Combined position and offset
   127 	TSize iMaxSize;
   128 	TSize iSize;
   129     TUint iFlags;
   130 	TRect iClipRect;
   131 	CArrayPtrFlat<CWsSpriteMember> *iMembers;
   132 	TInt iCurIndex;
   133 	TWsDeltaTimerEntry iDeltaTimerEntry;
   134 	TDisplayMode iDisplayMode;
   135 	TPoint iClipOffset;
   136 	TSize iClipSize;
   137 	CWsSpriteBase * iNext; // linked list per window
   138 	TBitFlags iInternalFlags;
   139 //
   140 // Static data
   141 //
   142 	static CWsDeltaTimer *iDeltaTimer;
   143 	};
   144 
   145 /** Sprite flags.
   146 
   147 These can be combined with each other and TSpriteFlags using a bit-wise OR operation.
   148 
   149 @internalComponent
   150 @released
   151 @see RWsPointerCursor::Construct()
   152 @see RWsSprite::Construct() */
   153 enum TSystemSpriteFlags
   154 	{
   155 	ESpriteNonSystemFlags=0x0000FFFF,
   156 	ESpriteSystemFlags=	  0xFFFF0000,
   157 	ESpritePointer=0x10000,
   158 	ESpriteOOM=0x20000,
   159 	ESpriteDisabled=0x40000,
   160 	ESpriteActive=0x80000,
   161 	ESpriteDirty=0x100000
   162 	};
   163 
   164 //
   165 // CWsSpriteBase inlines
   166 //
   167 inline TBool CWsSpriteBase::IsActive() const
   168 	{
   169 	return (iFlags&ESpriteActive);
   170 	}
   171 inline TBool CWsSpriteBase::IsFlashingEnabled() const
   172 	{
   173 	return (iFlags&ESpriteFlash);
   174 	}
   175 inline const CWsWindow* CWsSpriteBase::Win() const
   176 	{
   177 	return iWin;
   178 	}
   179 inline CWsWindow* CWsSpriteBase::Win()
   180 	{
   181 	return iWin;
   182 	}
   183 /*
   184 @return ETrue if this sprite belongs to window which has Advanced Pointer Support enabled.
   185 */
   186 inline TBool CWsSpriteBase::AdvancedPointersEnabled() const
   187 	{
   188 	return iWin ? iWin->AdvancedPointersEnabled() : EFalse;
   189 	}
   190 
   191 inline void CWsSpriteBase::SetIsFloating(TBool aIsFloating) 
   192 	{ 
   193 	iInternalFlags.Assign(EFloating, aIsFloating); }	
   194 
   195 inline TBool CWsSpriteBase::IsFloating() const 
   196 	{
   197 	return iInternalFlags.IsSet(EFloating);
   198 	}
   199 
   200 inline void CWsSpriteBase::SetClipSprite(TBool aClipSprite) 
   201 	{ 
   202 	iInternalFlags.Assign(EClipSprite, aClipSprite);
   203 	}
   204 
   205 inline TBool CWsSpriteBase::ClipSprite() const 
   206 	{ 
   207 	return iInternalFlags.IsSet(EClipSprite);
   208 	}
   209 
   210 inline void CWsSpriteBase::SetHasAnimation(TBool aValue) 
   211 	{
   212 	iInternalFlags.Assign(EHasAnimation, aValue);
   213 	}
   214 
   215 inline TBool CWsSpriteBase::HasAnimation() const
   216 	{
   217 	return iInternalFlags.IsSet(EHasAnimation);
   218 	}
   219 
   220 inline void CWsSpriteBase::SetDirty(TBool aValue)
   221 	{
   222 	iInternalFlags.Assign(EDirty, aValue);
   223 	}
   224 
   225 inline TBool CWsSpriteBase::IsDirty() const	
   226 	{ 
   227 	return iInternalFlags.IsSet(EDirty);
   228 	}	
   229 	
   230 
   231 //
   232 // CWsSprite
   233 //
   234 class CWsSprite : public CWsSpriteBase
   235 	{
   236 public:
   237 	CWsSprite(CWsClient *aOwner);
   238 	~CWsSprite();
   239 	void ConstructL(const TWsClCmdCreateSprite &aParams);
   240 	void CommandL(TInt aOpcode, const TAny *aCmdData);
   241 	void CompleteL();
   242 	void Update(TInt aMember,TRect aRect,TBool aFullUpdate);
   243 public:
   244 	CWsAnim *iAnim;	// The AnimDLL on this sprite if there is one.
   245 	};
   246 
   247 //
   248 // CWsSpriteManager
   249 //
   250 class CWsSpriteManager : public CBase
   251 	{
   252 public:
   253 	~CWsSpriteManager();
   254 	static CWsSpriteManager* NewL();
   255 	void DrawFloatingSprites(MWsGraphicsContext* aGc,const TRegion& aRegion);
   256 	void AddFloatingSprite(CWsSpriteBase* aSprite);
   257 	void RemoveFloatingSprite(CWsSpriteBase* aSprite);
   258 	void Schedule(CWsSpriteBase* aSprite, TRect* aRect = 0);
   259 	TFlashState CurrentSpriteFlashState(const CWsSpriteBase* aSprite) const;
   260 	TInt SpriteCount() const { return iFloatingSprites.Count(); }
   261 	TTimeIntervalMicroSeconds NextCursorFlashStateChange() const;
   262 	void CalcFloatingSpriteRgn( TRegion& aResultRgn, const TRect& aDefaultRect );
   263 	void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const;
   264 private:
   265 	CWsSpriteManager();
   266 	void ConstructL();
   267 	TTimeIntervalMicroSeconds NextSpriteFlashStateChange(const CWsSpriteBase* aSprite) const;
   268 	TTimeIntervalMicroSeconds CalculateTimeToNextFlash(TTimeIntervalMicroSeconds aTime) const;
   269 private:
   270 	RPointerArray<CWsSpriteBase> iFloatingSprites;
   271 	};
   272 #endif