Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
2.9 KiB

  1. #ifndef __SPRITE_H__
  2. #define __SPRITE_H__
  3. // Draggers are graphical objects that typicaly overlay windows and
  4. // can be shown, hidden, and moved. A default dragger is simply a
  5. // dotted rectangle XOR'd over the contents of it's window.
  6. //
  7. // For bitmap draggers, use the CSprite class.
  8. //
  9. // CDragger() creates hidden draggers.
  10. //
  11. // ~CDragger() will hide a dragger before it is destroyed.
  12. //
  13. // Move() and SetSize() will make sure a dragger gets erased from
  14. // it's old position and if it was visible, it will be drawn in
  15. // it's new position.
  16. //
  17. class CDragger : public CObject
  18. {
  19. public:
  20. enum STATE
  21. {
  22. hidden,
  23. shown,
  24. obscured
  25. };
  26. CDragger () : m_rect(), m_pWnd() { m_state = hidden; };
  27. CDragger ( CWnd* pWnd, CRect* pRect = NULL );
  28. virtual ~CDragger ();
  29. virtual void Hide ();
  30. virtual void Show ();
  31. virtual void Obscure(BOOL bObscure);
  32. virtual void Draw ();
  33. virtual void Erase ();
  34. virtual void Move ( const CRect& newRect, BOOL bForceShow = FALSE );
  35. virtual void Move ( const CPoint& newTopLeft, BOOL bForceShow = FALSE );
  36. void MoveBy ( int cx, int cy, BOOL bForceShow = FALSE );
  37. void SetSize( const CSize& newSize, BOOL bForceShow = FALSE );
  38. virtual CObList* GetDraggerList() { return NULL; }
  39. virtual CRect GetRect() const;
  40. inline BOOL IsShown() const { return m_state == shown; }
  41. CRect m_rect;
  42. STATE m_state;
  43. CWnd* m_pWnd;
  44. #ifdef _DEBUG
  45. DECLARE_DYNAMIC( CDragger )
  46. #endif
  47. };
  48. class CMultiDragger : public CDragger
  49. {
  50. public:
  51. CMultiDragger();
  52. CMultiDragger(CWnd* pWnd);
  53. virtual ~CMultiDragger();
  54. virtual void Hide();
  55. virtual void Show();
  56. virtual void Draw();
  57. virtual void Erase();
  58. virtual void Move(const CPoint& newTopLeft, BOOL bForceShow = FALSE);
  59. virtual CRect GetRect() const;
  60. void Add (CDragger *pDragger);
  61. void Remove(CDragger *pDragger);
  62. virtual CObList* GetDraggerList() { return &m_draggerList; }
  63. CObList m_draggerList;
  64. #ifdef _DEBUG
  65. DECLARE_DYNAMIC( CMultiDragger )
  66. #endif
  67. };
  68. class CSprite : public CDragger
  69. {
  70. public:
  71. CSprite();
  72. CSprite(CWnd* pWnd, CRect* pRect = NULL);
  73. virtual ~CSprite();
  74. virtual void Move(const CRect&, BOOL = FALSE);
  75. inline void Move(const CPoint& newTopLeft)
  76. { CDragger::Move(newTopLeft); }
  77. virtual void Draw() = 0;
  78. virtual void SaveBits();
  79. virtual void Erase();
  80. CBitmap m_saveBits;
  81. #ifdef _DEBUG
  82. DECLARE_DYNAMIC( CSprite )
  83. #endif
  84. };
  85. class CHighlight : public CDragger
  86. {
  87. public:
  88. CHighlight();
  89. CHighlight(CWnd *pWnd, CRect* pRect = NULL, int bdrSize = 2);
  90. ~CHighlight();
  91. int m_bdrSize;
  92. virtual void Draw();
  93. virtual void Erase();
  94. };
  95. #endif