⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scalablescreendrawingengine.h

📁 一个界面绘图的例子
💻 H
字号:
////////////////////////////////////////////////////////////////////////
//
// CScalableScreenDrawingEngine.h
//
////////////////////////////////////////////////////////////////////////


#ifndef __SCALABLESCREENDRAWINGENGINE_H
#define __SCALABLESCREENDRAWINGENGINE_H

#include <w32std.h>
#include <aknViewAppUi.h>
#include <eikappui.h>
#include <aknappui.h>
#include <AknIconUtils.h>

// Constants

// delay in microseconds, i.e. interval between frames
#define DELAY 30000
#define NUMBER_OF_FLAKES 20
#define WINDSPEED 1
#define GRAVITY 1

#define PERIOD_FPS 1000000
#define OFFSCREEN_DISPLAYMODE EColor64K

// Menu items
const TInt KNumberOfMenuLines = 8;
_LIT(KMenuText, "--- Game Menu ---");
_LIT(KMenuTextToggleDoubleBuffer, "Toggle Dbl Buffer");
_LIT(KMenuTextToggleIcons, "Toggle Icons");
_LIT(KMenuTextToggleAnchor, "Toggle Anchor");
_LIT(KMenuTextToggleBackground, "Toggle Background");
_LIT(KMenuTextToggleScroll, "Scroll");
_LIT(KMenuTextToggleOrientation, "Toggle Orientation");
_LIT(KMenuTextToggleSnow, "Toggle Snow");


// TSnowFlake
class TSnowFlake
{
public:
	TPoint iPos;
	TInt iSpeed;
	TBool iSize;
};

#ifdef EKA2
class CIconFileProvider : public CBase, public MAknIconFileProvider 
{	
public:
	CIconFileProvider(RFs aSession);
	static CIconFileProvider* NewL(RFs aSession, const TDesC& aFilename);
	void ConstructL( const TDesC& aFilename);
	~CIconFileProvider();
private:
	//from MAknIconFileProvider
	void RetrieveIconFileHandleL( RFile& aFile, const TIconFileType aType );
    void Finished();
    
    RFs iSession;
    HBufC* iFilename;
};
#endif//EKA2

class CScalableScreenDrawingEngine : public CBase, public MDirectScreenAccess//, public MAknIconFileProvider
    {
    enum THandlerPhase
		{
		EBackgroundScale,
		EBackgroundFlakesScale,
		ELargeScale,
		ELargeMskScale,
		ESmallScale,
		ESmallMskScale,
		EScaleSelector,
		EScaleSelectorMask,
		EAllDone
		};

	enum TMenuChoice
		{
		EDoubleBuffer,
		EIcons,
		EAnchor,
		EBackground,
		EScroll,
		EOrienation,
		ESnow
		};

public:
    // Constructor and destructors
	CScalableScreenDrawingEngine(RWsSession& aClient, CAknViewAppUi* aAppUi);
	~CScalableScreenDrawingEngine();
    void ConstructL(RWindow& aWindow,CWsScreenDevice* aScreenDevice);

public:
    void ScaleImage();

	void ArrowUp();
	void ArrowDown();
	void EnterPress();
	void ToggleDecorators();

private:
	void SnowGenerator();
	void MoveFlakes();
	void DrawScreen(CBitmapContext* aBc) const;
	void DrawScreenDoubleBuffer() const;
	void DoFrame();
	static TInt Animate(TAny* aObj);
	static TInt Fps(TAny* aObj);
	void CustomBitBlit(TPoint aDestPoint, CFbsBitmap* aDest, CFbsBitmap* aSource, CFbsBitmap* aMask = NULL) const;
    void DoCopyPixel(TUint8*& aDest, TUint8*& aSource, TInt aBpp, TBool aCopy = ETrue) const;
private:
	// Implement MDirectScreenAccess
	void Restart(RDirectScreenAccess::TTerminationReasons aReason);
	void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
	
private:

	// OWNED
	CFbsBitmap* iBackground;
	CFbsBitmap* iBackground2;
 	CFbsBitmap*	iSnowflakeSmall;
	CFbsBitmap*	iSnowflakeSmall_mask;
	CFbsBitmap*	iSnowflakeBig;
	CFbsBitmap*	iSnowflakeBig_mask;
	CFbsBitmap*	iIconSelector;
	CFbsBitmap*	iIconSelector_mask;
	CFbsBitmap*	iIconSelector2;
	CFbsBitmap*	iIconSelector2_mask;
	CFbsBitmap*	iIconExit;
	CFbsBitmap*	iIconMenu;

    TSnowFlake iSnowflakes[NUMBER_OF_FLAKES];

	CAknViewAppUi* iAppUi;						// BYREF
    CWsScreenDevice* iScreenDevice;				// BYREF

	// Periodic for drawing graphics
    CPeriodic* iPeriodic;						// OWNED

    // Direct Screen Access
    CDirectScreenAccess* iDirectScreenAccess;	// OWNED
	CFbsBitGc* iGc;								// BYREF, from DSA
	RRegion* iRegion;							// BYREF, from DSA
	RWsSession& iClient;

	// Offscreen bitmap for double-buffering
    CFbsBitmap* iVirtualScreen;					// OWNED
    CBitmapContext* iBC;						// OWNED
	CFbsBitmapDevice* iBitmapDevice;			// OWNED

	TPixelsTwipsAndRotation iPixTwipsRot;

	TInt iScrollOffset;
	TInt iScrollOffsetStars;

	CPeriodic* iPeriodicFps;					// OWNED
	TInt iFpsCounter;
	TBuf<5> iFpsText;

	// User-changeable settings (from the menu)
	TInt iIxSelection;			            	// Currently selected menu item
	TBool iUseDoubleBuffer;
	TBool iUseBitmapIcons;
	TBool iUseAnchors;
	TBool iUseVectorBackground;
	TBool iUseScrolling;

	// from keypad
	TBool iHideMenu;
	TBool iHideSnow;
	TBool iHideStars;
	TBool iHideCBA;
	
	TBuf<100> completefilename;
	RFs iFsSession;
#ifdef EKA2
	CIconFileProvider* iIconProvider; 
#endif
    };

#endif // __SCALABLESCREENDRAWINGENGINE_H

// End of file.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -