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
Shinya Kitaoka 120a6e
class DVAPI TCursorFactory {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TCursorFactory() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // typedef vector<tcursor*> CursorList;</tcursor*>
Shinya Kitaoka 120a6e
  // static CursorList m_cursorList;
Shinya Kitaoka 120a6e
  typedef TCursor *CursorList[100];
Shinya Kitaoka 120a6e
  static CursorList m_cursorList;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static bool m_init;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  enum {
Shinya Kitaoka 120a6e
    CURSOR_NONE,                   // no cursor...
Shinya Kitaoka 120a6e
    CURSOR_DEFAULT = CURSOR_NONE,  // window class cursor...
Shinya Kitaoka 120a6e
    CURSOR_ARROW,
Shinya Kitaoka 120a6e
    CURSOR_HAND,
Shinya Kitaoka 120a6e
    CURSOR_HOURGLASS,
Shinya Kitaoka 120a6e
    CURSOR_NO,
Shinya Kitaoka 120a6e
    //#ifdef WIN32
Shinya Kitaoka 120a6e
    CURSOR_DUMMY,
Toshihiro Shimizu 890ddd
//#endif
Toshihiro Shimizu 890ddd
#ifndef WIN32
Shinya Kitaoka 120a6e
    CURSOR_DND,
Shinya Kitaoka 120a6e
    CURSOR_QUESTION,
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    // ....
Shinya Kitaoka 120a6e
    NUM_STOCK_CURSORS,
Shinya Kitaoka 120a6e
    LAST_STOCK_CURSOR = NUM_STOCK_CURSORS - 1
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // public API
Shinya Kitaoka 120a6e
  static void defineCursor(TWidget::CursorIndex new_cursor_id,
Shinya Kitaoka 120a6e
                           const TFilePath &cursor_filename);
Shinya Kitaoka 120a6e
  static void defineCursorAs(TWidget::CursorIndex new_cursor_id,
Shinya Kitaoka 120a6e
                             TWidget::CursorIndex source);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  friend class TMouse;
Shinya Kitaoka 120a6e
  static TCursor *getCursor(TWidget::CursorIndex cursor_id);
Shinya Kitaoka 120a6e
  // PD methods
Shinya Kitaoka 120a6e
  static TCursor *loadCursorFromFile(const TFilePath &cursor_filename);
Shinya Kitaoka 120a6e
  static void init();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TMouse {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ~TMouse() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // PD methods
Shinya Kitaoka 120a6e
  void pushCursor(TWidget::CursorIndex id);
Shinya Kitaoka 120a6e
  void popCursor();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setCursor(TWidget::CursorIndex id);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  enum CursorMode { MODE_NORMAL, MODE_HOURGLASS };
Shinya Kitaoka 120a6e
  void setCursorMode(CursorMode mode);
Shinya Kitaoka 120a6e
  // CursorMode getCursorMode();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  void setCursor(TCursor *);
Shinya Kitaoka 120a6e
  TWidget::CursorIndex m_currentCursorId;
Shinya Kitaoka 120a6e
  // to enforce singleton...
Shinya Kitaoka 120a6e
  TMouse();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  CursorMode m_cursorMode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static TMouse theMouse;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI THourglassCursor {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  THourglassCursor() { TMouse::theMouse.setCursorMode(TMouse::MODE_HOURGLASS); }
Shinya Kitaoka 120a6e
  ~THourglassCursor() { TMouse::theMouse.setCursorMode(TMouse::MODE_NORMAL); }
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