Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TNZ_CURSOR_INCLUDED
Toshihiro Shimizu 890ddd
#define TNZ_CURSOR_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "tfilepath.h"
Toshihiro Shimizu 890ddd
#include "tw/tw.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TWIN_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Toshihiro Shimizu 890ddd
#pragma warning(push)
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward decls
Toshihiro Shimizu 890ddd
class TFilePath;
Toshihiro Shimizu 890ddd
class TMouse;
Toshihiro Shimizu 890ddd
class TCursor;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TCursorFactory
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	TCursorFactory() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//typedef vector<tcursor*> CursorList;</tcursor*>
Toshihiro Shimizu 890ddd
	//static CursorList m_cursorList;
Toshihiro Shimizu 890ddd
	typedef TCursor *CursorList[100];
Toshihiro Shimizu 890ddd
	static CursorList m_cursorList;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static bool m_init;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	enum {
Toshihiro Shimizu 890ddd
		CURSOR_NONE,				  // no cursor...
Toshihiro Shimizu 890ddd
		CURSOR_DEFAULT = CURSOR_NONE, // window class cursor...
Toshihiro Shimizu 890ddd
		CURSOR_ARROW,
Toshihiro Shimizu 890ddd
		CURSOR_HAND,
Toshihiro Shimizu 890ddd
		CURSOR_HOURGLASS,
Toshihiro Shimizu 890ddd
		CURSOR_NO,
Toshihiro Shimizu 890ddd
		//#ifdef WIN32
Toshihiro Shimizu 890ddd
		CURSOR_DUMMY,
Toshihiro Shimizu 890ddd
//#endif
Toshihiro Shimizu 890ddd
#ifndef WIN32
Toshihiro Shimizu 890ddd
		CURSOR_DND,
Toshihiro Shimizu 890ddd
		CURSOR_QUESTION,
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
		// ....
Toshihiro Shimizu 890ddd
		NUM_STOCK_CURSORS,
Toshihiro Shimizu 890ddd
		LAST_STOCK_CURSOR = NUM_STOCK_CURSORS - 1
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// public API
Toshihiro Shimizu 890ddd
	static void defineCursor(TWidget::CursorIndex new_cursor_id, const TFilePath &cursor_filename);
Toshihiro Shimizu 890ddd
	static void defineCursorAs(TWidget::CursorIndex new_cursor_id, TWidget::CursorIndex source);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	friend class TMouse;
Toshihiro Shimizu 890ddd
	static TCursor *getCursor(TWidget::CursorIndex cursor_id);
Toshihiro Shimizu 890ddd
	// PD methods
Toshihiro Shimizu 890ddd
	static TCursor *loadCursorFromFile(const TFilePath &cursor_filename);
Toshihiro Shimizu 890ddd
	static void init();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TMouse
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	~TMouse() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// PD methods
Toshihiro Shimizu 890ddd
	void pushCursor(TWidget::CursorIndex id);
Toshihiro Shimizu 890ddd
	void popCursor();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setCursor(TWidget::CursorIndex id);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	enum CursorMode {
Toshihiro Shimizu 890ddd
		MODE_NORMAL,
Toshihiro Shimizu 890ddd
		MODE_HOURGLASS
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
	void setCursorMode(CursorMode mode);
Toshihiro Shimizu 890ddd
	//CursorMode getCursorMode();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	void setCursor(TCursor *);
Toshihiro Shimizu 890ddd
	TWidget::CursorIndex m_currentCursorId;
Toshihiro Shimizu 890ddd
	// to enforce singleton...
Toshihiro Shimizu 890ddd
	TMouse();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	CursorMode m_cursorMode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	static TMouse theMouse;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI THourglassCursor
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	THourglassCursor()
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TMouse::theMouse.setCursorMode(TMouse::MODE_HOURGLASS);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	~THourglassCursor()
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TMouse::theMouse.setCursorMode(TMouse::MODE_NORMAL);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Toshihiro Shimizu 890ddd
#pragma warning(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif