Leaked source code of windows server 2003
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.

195 lines
4.6 KiB

  1. /*
  2. * _DRAGDRP.H
  3. *
  4. * Purpose:
  5. * class declarations for Richedit's OLE drop target and drop source
  6. * objects.
  7. *
  8. * Author:
  9. * alexgo (4/28/95)
  10. *
  11. */
  12. #ifndef __DRAGDRP_H__
  13. #define __DRAGDRP_H__
  14. #include "_osdc.h"
  15. // DWORD packed flag values. These are assigned values such that they can
  16. // be or'd with DataObjectInfo flags and not conflict. We are, in effect,
  17. // overriding the DataObjectInfo flags.
  18. #define DF_CLIENTCONTROL 0x80000000 // QueryAcceptData says the client
  19. // will handle this drop.
  20. #define DF_CANDROP 0x40000000 // We can handle the drop
  21. #define DF_OVERSOURCE 0x20000000 // Drop target is within source range.
  22. #define DF_RIGHTMOUSEDRAG 0x10000000 // doing a right mouse drag drop
  23. // forward declaration.
  24. class CCallMgr;
  25. #define WIDTH_DROPCARET 2
  26. /*
  27. * CDropCaret
  28. *
  29. * Purpose:
  30. * provides a caret for the location that drop will occur
  31. */
  32. class CDropCaret
  33. {
  34. public:
  35. CDropCaret(CTxtEdit *ped);
  36. ~CDropCaret();
  37. BOOL Init();
  38. void DrawCaret(LONG cpCur);
  39. void ShowCaret(BOOL fShow);
  40. void CancelRestoreCaretArea() {_dvp = -1;}
  41. BOOL NoCaret() const {return -1 == _dvp;}
  42. private:
  43. CTxtEdit * _ped;
  44. HDC _hdcWindow;
  45. LONG _dvp;
  46. POINTUV _ptCaret;
  47. BOOL _fCaretOn;
  48. };
  49. /*
  50. * CDropSource
  51. *
  52. * Purpose:
  53. * provides drag drop feedback
  54. */
  55. class CDropSource : public IDropSource
  56. {
  57. public:
  58. // IUnknown methods
  59. STDMETHOD(QueryInterface)(REFIID riid, void ** ppv);
  60. STDMETHOD_(ULONG, AddRef)();
  61. STDMETHOD_(ULONG, Release)();
  62. // IDropSource methods
  63. STDMETHOD(QueryContinueDrag)(BOOL fEscapePressed, DWORD grfKeyState);
  64. STDMETHOD(GiveFeedback)(DWORD dwEffect);
  65. CDropSource();
  66. private:
  67. // NOTE: private destructor, may not be allocated on the stack as
  68. // this would break OLE's current object liveness rules
  69. ~CDropSource();
  70. ULONG _crefs;
  71. };
  72. /*
  73. * CDropTarget
  74. *
  75. * Purpose:
  76. * an OLE drop-target object; provides a place for text to be "dropped"
  77. *
  78. */
  79. class CDropTarget : public IDropTarget
  80. {
  81. public:
  82. // IUnknown methods
  83. STDMETHOD(QueryInterface)(REFIID riid, void ** ppv);
  84. STDMETHOD_(ULONG, AddRef)();
  85. STDMETHOD_(ULONG, Release)();
  86. // IDropTarget methods
  87. STDMETHOD(DragEnter)(IDataObject *pdo, DWORD grfKeyState,
  88. POINTL pt, DWORD *pdwEffect);
  89. STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  90. STDMETHOD(DragLeave)();
  91. STDMETHOD(Drop)(IDataObject *pdo, DWORD grfKeyState, POINTL pt,
  92. DWORD *pdwEffect);
  93. CDropTarget(CTxtEdit *ped);
  94. // this method is used during drag drop to cache important information
  95. void SetDragInfo( IUndoBuilder *publdr, LONG cpMin, LONG cpMax );
  96. void Zombie(); //@cmember Nulls out the state of this object
  97. BOOL fInDrag(); //@cmember Tells whether another app is dragging
  98. // over us.
  99. private:
  100. // this class is used in CDropTarget::Drop to clean up at the end
  101. // of the call.
  102. class CDropCleanup
  103. {
  104. public:
  105. CDropCleanup( CDropTarget *pdt )
  106. {
  107. _pdt = pdt;
  108. }
  109. ~CDropCleanup()
  110. {
  111. delete _pdt->_pcallmgr;
  112. _pdt->_pcallmgr = NULL;
  113. delete _pdt->_pdrgcrt;
  114. _pdt->_pdrgcrt = NULL;
  115. }
  116. private:
  117. CDropTarget * _pdt;
  118. };
  119. friend class CDropCleanup;
  120. // NOTE: private destructor, may not be allocated on the stack as
  121. // this would break OLE's current object liveness rules
  122. ~CDropTarget();
  123. void UpdateEffect(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  124. void DrawFeedback(void);
  125. void ConvertScreenPtToClientPt( POINTL *pptScreen, POINT *pptClient );
  126. HRESULT HandleRightMouseDrop(IDataObject *pdo, POINTL ptl);
  127. ULONG _crefs;
  128. DWORD _dwFlags; // DataObjectInfo cache (e.g. DOI_CANPASTEPLAIN)
  129. // and other flags.
  130. CTxtEdit * _ped;
  131. CCallMgr * _pcallmgr; // The call manager used during a drag drop operation.
  132. // cached information for drag drop operations
  133. IUndoBuilder *_publdr; // the undo builder for the drag operation
  134. LONG _cpMin; // the min and max cp's for the range that is
  135. LONG _cpMost; // being dragged so we can disable drag-onto-yourself!
  136. LONG _cpSel; // active end and length for selection *before*
  137. LONG _cchSel; // drag drop op occured (so we can restore it)
  138. LONG _cpCur; // the cp that the mouse is currently over
  139. CDropCaret *_pdrgcrt; // Object that implements the drop caret
  140. };
  141. /*
  142. * CDropTarget::fInDrag ()
  143. *
  144. * Purpose:
  145. * Tells interested parties whether a drag operation is occurring
  146. *
  147. */
  148. inline BOOL CDropTarget::fInDrag()
  149. {
  150. return _pcallmgr != NULL;
  151. }
  152. #endif // !__DRAGDRP_H__