Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef SHORTCUTMANAGER_INCLUDED
Toshihiro Shimizu 890ddd
#define SHORTCUTMANAGER_INCLUDED
Toshihiro Shimizu 890ddd
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
Shinya Kitaoka 120a6e
// forward declarations
Toshihiro Shimizu 890ddd
class TKeyListener;
Toshihiro Shimizu 890ddd
class TFilePath;
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// Shortcut
Toshihiro Shimizu 890ddd
//
Shinya Kitaoka 120a6e
class DVAPI TShortcut {
Shinya Kitaoka 120a6e
  string m_id;
Shinya Kitaoka 120a6e
  wstring m_name;
Shinya Kitaoka 120a6e
  TKeyListener *m_listener;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TShortcut(string id);
Shinya Kitaoka 120a6e
  virtual ~TShortcut();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  string getId() const { return m_id; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setName(wstring name) { m_name = name; }
Shinya Kitaoka 120a6e
  wstring getName() const { return m_name; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  string getKeyName() const;
Shinya Kitaoka 120a6e
  void setKeyName(string keyName);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void onKeyDown() = 0;
Shinya Kitaoka 120a6e
  virtual void onKeyUp(bool mouseEventReceived) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual string getType() const = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TShortcut(const TShortcut &);
Shinya Kitaoka 120a6e
  TShortcut &operator=(const TShortcut &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// Shortcut controller
Toshihiro Shimizu 890ddd
//
Shinya Kitaoka 120a6e
class DVAPI TShortcutManager {  // singleton
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  class Imp;
Shinya Kitaoka 120a6e
  Imp *m_imp;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TShortcutManager();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ~TShortcutManager();
Shinya Kitaoka 120a6e
  static TShortcutManager *instance();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setKeyName(string id, string keyName);
Shinya Kitaoka 120a6e
  string getKeyName(string id);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TShortcut *getShortcutByKeyName(string keyName);
Shinya Kitaoka 120a6e
  TShortcut *getShortcutById(string keyName);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void getShortcuts(std::vector<const *="" tshortcut=""> &shortcuts);</const>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // get ownership
Shinya Kitaoka 120a6e
  void add(TShortcut *shortcut);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setPath(const TFilePath &path);
Shinya Kitaoka 120a6e
  const TFilePath &getPath() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void load();
Shinya Kitaoka 120a6e
  void save();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif