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

📄 window.h

📁 3D游戏展示程序
💻 H
字号:
//--------------------------------------------------
//  Desc: Base Window UI
//  Date: 2006.11.15 /update
//  Author: artsylee
//
//  Copyright (C) 2006 artsylee
//
//--------------------------------------------------

#ifndef _WINDOW_
#define _WINDOW_

#include <list>
#include "../Core/GPoint.h"

// Type Define
class CWindow;
typedef std::list<CWindow*>			WndList;
typedef WndList::iterator			WndItor;
typedef WndList::reverse_iterator	WndRItor;

// UI Attribute
#define GUI_ACTIVE			0x00000001L
#define GUI_VISIBLE			0x00000002L
#define GUI_DRAGABLE		0x00000004L
#define GUI_ENABLE			0x00000008L

// UI Type define
#define GUI_WINDOW			0x00000001L
#define GUI_BUTTON			0x00000002L
#define GUI_STATIC			0x00000003L
#define GUI_CHECKBOX		0x00000004L
#define GUI_RADIOGROUP		0x00000005L
#define GUI_SLIDER			0x00000006L
#define GUI_SCROLLBAR		0x00000007L
#define GUI_LISTBOX			0x00000008L

// WOW UI Type
#define GUI_COOLBUTTON		0x00000100L
#define GUI_COOLSCROLL		0x00000101L
#define GUI_COOLLISTBOX		0x00000102L
#define GUI_COOLNUMBERINPUT	0x00000103L
#define GUI_COOLSTATIC		0x00000104L

enum DRAG_STATE
{
	DRAG_NONE = 0,
	DRAG_START,
	DRAG_MOVING,
	DRAG_DROP,
};

#define INVALID_ID	0x00000000L

//---------------------------------------------------
// GUI的消息
// m_dwType = MSG_SYS_GUI
// m_dwSource = ID
// m_dwParam1 = GUI消息子类型
// m_dwParam2 = GUI type/状态值/选中的控件ID/..(根据GUI类型有所不同)
// m_pParam3 = this指针(使用此值必须确保此对象有效, 删除对象时删除该对象的所有消息?)
//---------------------------------------------------

// GUI消息子类型
#define GUI_MOUSE_OVER		0x00000001L
#define GUI_MOUSE_LDOWN		0x00000002L
#define GUI_MOUSE_LUP		0x00000003L
#define GUI_LOST_FOCUS		0x00000004L
#define GUI_VALUE_CHANGE	0x00000005L

class ASE_DLL CWindow
{
public:
	CWindow(CWindow* pParent = NULL);
	virtual ~CWindow();
	virtual void	Release();
	virtual void	Render();
	virtual DWORD	ProcessEvent();
	virtual bool	LoadFromIni(char* pfilename, char* pIndex);

	// Identity
	DWORD	GetID()							{	return m_dwID;		}
	void	SetID(DWORD id)					{	m_dwID = id;	}
	DWORD	GetType()						{	return m_dwGUIType;	}
	// 暂不提供外部设置的接口
	//virtual	void	SetTexture(TextureHandle hTex)	{ m_hTexture = hTex;	}
	// Coordinates
	virtual	void	MoveTo(int x, int y);
	virtual	void	OffSet(int x, int y);
	virtual GPoint	GetPosition()	{   return m_ptPos;		}
	virtual GRect	GetRect();	
	virtual void	SetHeight(int height)	{	m_Height = height;	}
	virtual int		GetHeight(void)			{	return m_Height;	}
	virtual void	SetWidth(int width)		{	m_Width = width;	}
	virtual int		GetWidth(void)			{	return m_Width;		}
	// Attribute
	virtual bool	IsShow()		{	return (m_dwAttrib & GUI_VISIBLE)?true:false;	}
	virtual bool	IsEnable()		{	return (m_dwAttrib & GUI_ENABLE)?true:false;		}
	virtual bool	IsDragable()	{	return (m_dwAttrib & GUI_DRAGABLE)?true:false;	}
	virtual bool	IsActive()		{	return (m_dwAttrib & GUI_ACTIVE)?true:false;		}
	virtual void	Show(bool c = true);
	virtual void	Enable();
	virtual void	Disable();
	virtual void	SetDragable(bool c = true);
	virtual void	SetActive(bool c = true);
	virtual DWORD	GetColor()				{	return m_dwColor;	}
	virtual void	SetColor(DWORD color)	{	m_dwColor = color;	}
	virtual bool	GetFastDraw()			{	return m_bFastDraw;	}
	virtual void	SetFastDraw(bool c)		{	m_bFastDraw = c;	}
	// Parent
	virtual	CWindow*		GetParent();
	virtual	void			SetParent(CWindow* pParent);
	// SubWindows
	virtual void	AddWindow(CWindow* pWnd);
	virtual void	RemoveWindow(CWindow* pWnd, bool bDel = true);
	virtual void	RemoveWindow(DWORD WndID, bool bDel = true);
	virtual	int		GetSubWindowsCount();
	virtual	CWindow*	GetSubWindow(DWORD WndID);

protected:
	void			RenderNewStyle(unsigned long hTex, const RECT &rc, DWORD color, int border);	// WOW方式
	void			RenderExpand();			// 
	void			RenderExpandEx();		// 快速
	void			CreateRGN(GRect *rc);	// 生成不规则RGN
	virtual bool	CheckInRGN(GRect rc, POINT *pt = NULL);	// 检查是否在RGN内
	POINT			GetRGNCenter(void);
	
protected:
	DWORD			m_dwAttrib;
	DWORD			m_dwGUIType;
	DWORD			m_dwColor;
	GPoint			m_ptPos;
	GRect			m_rcSrc;
	int				m_Width;
	int				m_Height;

	DWORD			m_hTexture;
	DWORD			m_hBackground;
	DWORD			m_hHeader;

	DWORD			m_dwID;
	char			m_szCaption[256];
	bool			m_bFastDraw;		// 快速绘图(仅对合成绘图方式有效)
	bool			m_ComplexDraw;		// 是否使用合成绘图方式
	bool*			m_pRgnInfo;
	bool			m_bUseRgn;

	CWindow*		m_pParent;
	WndList			m_SubWindows;

	DRAG_STATE		m_DragState;
	GPoint			m_ptDragStart;
	// Border
	int				m_WindowBorder;
	int				m_WindowCull;
	char			m_szUIPath[256];
};

#endif // _WINDOW_

⌨️ 快捷键说明

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