Key.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include "config.h"
  3. #include "LabelSet.h"
  4. #include <memory>
  5. class Key
  6. {
  7. public:
  8. virtual bool hitTest(const CPoint& pt) const = 0;
  9. virtual BYTE getState() const = 0;
  10. virtual BYTE getVkey() const = 0;
  11. virtual LPCTSTR getLabel() const = 0;
  12. virtual const CRect& getRect() const = 0;
  13. virtual const LabelSetEx& getLabelSet() const = 0;
  14. virtual void press() = 0;
  15. virtual void release() = 0;
  16. virtual void draw(CDC* pDc) const;
  17. virtual ~Key(void) {}
  18. public:
  19. static COLORREF clrBord[2];
  20. static COLORREF clrFill[2];
  21. static COLORREF clrText[2];
  22. };
  23. class SimpleKey : public Key
  24. {
  25. public:
  26. SimpleKey(LabelSetEx* _pls,const KeyConfig& _kc,int _unit,BYTE _stat);
  27. bool hitTest(const CPoint& pt) const;
  28. BYTE getState() const;
  29. BYTE getVkey() const;
  30. LPCTSTR getLabel() const;
  31. const CRect& getRect() const;
  32. const LabelSetEx& getLabelSet() const;
  33. void press();
  34. void release();
  35. ~SimpleKey();
  36. protected:
  37. SimpleKey();
  38. protected:
  39. LabelSetEx* pls;
  40. short id;
  41. short offset;
  42. CRect rt;
  43. BYTE vk;
  44. BYTE state;
  45. };
  46. class KeyDecorator : public Key
  47. {
  48. public:
  49. KeyDecorator(Key* _pkey);
  50. bool hitTest(const CPoint& pt) const;
  51. BYTE getState() const;
  52. BYTE getVkey() const;
  53. LPCTSTR getLabel() const;
  54. const CRect& getRect() const;
  55. const LabelSetEx& getLabelSet() const;
  56. virtual void press();
  57. virtual void release();
  58. protected:
  59. std::auto_ptr<Key> pkey;
  60. };
  61. class ShiftKey : public KeyDecorator
  62. {
  63. public:
  64. ShiftKey(Key* _pkey,short _id1,short _id2);
  65. void press();
  66. void release();
  67. private:
  68. short id1;
  69. short id2;
  70. };
  71. class LockKey : public KeyDecorator
  72. {
  73. public:
  74. LockKey(Key* _pkey,short _id);
  75. void press();
  76. void release();
  77. private:
  78. short id;
  79. };