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

📄 sprite.h

📁 虚拟打印机
💻 H
字号:
/* * * sprite.h * *   Copyright (C) 2006 Michael H. Overlin   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Contact at poster_printer@yahoo.com */#ifndef SPRITE_H#define SPRITE_H#include <windows.h>#include <vector>class Sprite {public:	virtual ~Sprite() {}	virtual void Draw(OUT HDC hdc) = 0;	virtual void Save(IN HDC hdc, HRGN hrgnClip) = 0;	virtual void Update(IN OUT HDC hdc, OUT HRGN hrgnUpdate) = 0;	// 7/6	virtual void Scroll(IN const POINT& ptDelta) = 0;	virtual HRGN GetUpdateRegion(void) = 0;};class NextStateRegionSprite : public Sprite {public:	virtual ~NextStateRegionSprite() {}	virtual void Update(IN OUT HDC hdc, OUT HRGN hrgnUpdate);	struct UpdateRegions {		UpdateRegions(void) { hrgnErase = hrgnDraw = hrgnSave = NULL; }		~UpdateRegions() { 			if (hrgnErase != NULL) ::DeleteObject(hrgnErase); 			if (hrgnDraw != NULL) ::DeleteObject(hrgnDraw);			if (hrgnSave != NULL) ::DeleteObject(hrgnSave);		}		HRGN hrgnErase;		HRGN hrgnDraw;		HRGN hrgnSave;	};	virtual void Erase(OUT HDC hdc) = 0;	virtual void Next(void) = 0;	virtual void CalculateRegions(OUT UpdateRegions& ur) = 0;	// 7/6	virtual HRGN GetUpdateRegion(void) {		UpdateRegions ur;		this->CalculateRegions(ur);		::CombineRgn(ur.hrgnDraw, ur.hrgnDraw, ur.hrgnErase, RGN_OR);		HRGN hrgn = ur.hrgnDraw;		ur.hrgnDraw = NULL;		return hrgn;	}};typedef NextStateRegionSprite *PNextStateRegionSprite;class CompositeNextStateRegionSprite : public NextStateRegionSprite {public:	CompositeNextStateRegionSprite(const std::vector<PNextStateRegionSprite>& vSprite);;	virtual ~CompositeNextStateRegionSprite() ;	virtual void Erase(OUT HDC hdc) ;	virtual void Draw(OUT HDC hdc) ;	virtual void Save(IN HDC hdc, HRGN hrgnClip) ;	virtual void Next(void) ;	virtual void CalculateRegions(OUT UpdateRegions& ur) ;	// 7/6	virtual void Scroll(IN const POINT& ptDelta) ;	virtual void SetClipRgn(HRGN hrgnClip);protected:	CompositeNextStateRegionSprite(void) {}	std::vector<PNextStateRegionSprite> m_vSprite;	HRGN m_hrgnClip;};class SolidColorSprite : public NextStateRegionSprite {public:	struct State {		RECT r;		COLORREF clr;		BOOL bVisible;		BOOL operator ==(const State& state) const { return memcmp(this, &state, sizeof(*this)) == 0; }		BOOL operator !=(const State& state) const { return ! (*this == state); }	};	SolidColorSprite(const SIZE& szMax);	virtual ~SolidColorSprite();	void SetNextState(const State& state);	const State& GetState(void) const { return m_state; }	BOOL HitTest(const POINT& pt) const;	virtual void Erase(OUT HDC hdc);	virtual void Draw(OUT HDC hdc) ;	virtual void Save(IN HDC hdc, IN HRGN hrgnClip) ;	virtual void Next(void) ;	virtual void CalculateRegions(OUT UpdateRegions& ur) ;	//7/6	virtual void Scroll(IN const POINT& ptDelta) ;private:	State m_state;	State m_stateNext;	const SIZE m_szMax;	HBITMAP m_hbmpSave;};// DEBUG#if 0class DebugBounceSprite : public SolidColorSprite {public:	DebugBounceSprite(const SIZE& sz, const POINT& pt, COLORREF clr, const RECT& rBounce, const POINT& ptV) ;	void Next(void) ;private:	RECT m_rBounce;	POINT m_ptV;};#endif#endif

⌨️ 快捷键说明

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