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.

234 lines
5.1 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 1
  26. #define DEFAULT_DROPCARET_MAXHEIGHT 32
  27. /*
  28. * CDropCaret
  29. *
  30. * Purpose:
  31. * provides a caret for the location that drop will occur
  32. */
  33. class CDropCaret
  34. {
  35. public:
  36. CDropCaret(CTxtEdit *ped);
  37. ~CDropCaret();
  38. BOOL Init();
  39. void DrawCaret(LONG cpCur);
  40. void HideCaret();
  41. void ShowCaret();
  42. void CancelRestoreCaretArea();
  43. BOOL NoCaret();
  44. private:
  45. CTxtEdit * _ped;
  46. HDC _hdcWindow;
  47. LONG _yPixelsPerInch;
  48. LONG _yHeight;
  49. LONG _yHeightMax;
  50. POINT _ptCaret;
  51. COffScreenDC _osdc;
  52. };
  53. /*
  54. * CDropCaret::CancelRestoreCaretArea
  55. *
  56. * Purpose:
  57. * Tell object not to restore area where caret was.
  58. *
  59. * @devnote:
  60. * When we drop we don't want to restore the old caret area
  61. * since that is no longer correct.
  62. *
  63. */
  64. inline void CDropCaret::CancelRestoreCaretArea()
  65. {
  66. _yHeight = -1;
  67. }
  68. /*
  69. * CDropCaret::NoCaret
  70. *
  71. * Purpose:
  72. * Tell whether caret has been turned off
  73. *
  74. */
  75. inline BOOL CDropCaret::NoCaret()
  76. {
  77. return -1 == _yHeight;
  78. }
  79. /*
  80. * CDropSource
  81. *
  82. * Purpose:
  83. * provides drag drop feedback
  84. */
  85. class CDropSource : public IDropSource
  86. {
  87. public:
  88. // IUnknown methods
  89. STDMETHOD(QueryInterface)(REFIID riid, void ** ppv);
  90. STDMETHOD_(ULONG, AddRef)();
  91. STDMETHOD_(ULONG, Release)();
  92. // IDropSource methods
  93. STDMETHOD(QueryContinueDrag)(BOOL fEscapePressed, DWORD grfKeyState);
  94. STDMETHOD(GiveFeedback)(DWORD dwEffect);
  95. CDropSource();
  96. private:
  97. // NOTE: private destructor, may not be allocated on the stack as
  98. // this would break OLE's current object liveness rules
  99. ~CDropSource();
  100. ULONG _crefs;
  101. };
  102. /*
  103. * CDropTarget
  104. *
  105. * Purpose:
  106. * an OLE drop-target object; provides a place for text to be "dropped"
  107. *
  108. */
  109. class CDropTarget : public IDropTarget
  110. {
  111. public:
  112. // IUnknown methods
  113. STDMETHOD(QueryInterface)(REFIID riid, void ** ppv);
  114. STDMETHOD_(ULONG, AddRef)();
  115. STDMETHOD_(ULONG, Release)();
  116. // IDropTarget methods
  117. STDMETHOD(DragEnter)(IDataObject *pdo, DWORD grfKeyState,
  118. POINTL pt, DWORD *pdwEffect);
  119. STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  120. STDMETHOD(DragLeave)();
  121. STDMETHOD(Drop)(IDataObject *pdo, DWORD grfKeyState, POINTL pt,
  122. DWORD *pdwEffect);
  123. CDropTarget(CTxtEdit *ped);
  124. // this method is used during drag drop to cache important information
  125. void SetDragInfo( IUndoBuilder *publdr, LONG cpMin, LONG cpMax );
  126. void Zombie(); //@cmember Nulls out the state of this object
  127. BOOL fInDrag(); //@cmember Tells whether another app is dragging
  128. // over us.
  129. private:
  130. // this class is used in CDropTarget::Drop to clean up at the end
  131. // of the call.
  132. class CDropCleanup
  133. {
  134. public:
  135. CDropCleanup( CDropTarget *pdt )
  136. {
  137. _pdt = pdt;
  138. }
  139. ~CDropCleanup()
  140. {
  141. delete _pdt->_pcallmgr;
  142. _pdt->_pcallmgr = NULL;
  143. delete _pdt->_pdrgcrt;
  144. _pdt->_pdrgcrt = NULL;
  145. }
  146. private:
  147. CDropTarget * _pdt;
  148. };
  149. friend class CDropCleanup;
  150. // NOTE: private destructor, may not be allocated on the stack as
  151. // this would break OLE's current object liveness rules
  152. ~CDropTarget();
  153. void UpdateEffect(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  154. void DrawFeedback(void);
  155. void ConvertScreenPtToClientPt( POINTL *pptScreen, POINT *pptClient );
  156. HRESULT HandleRightMouseDrop(IDataObject *pdo, POINTL ptl);
  157. ULONG _crefs;
  158. DWORD _dwFlags; // DataObjectInfo cache (e.g. DOI_CANPASTEPLAIN)
  159. // and other flags.
  160. CTxtEdit * _ped;
  161. CCallMgr * _pcallmgr; // The call manager used during a drag drop operation.
  162. // cached information for drag drop operations
  163. IUndoBuilder *_publdr; // the undo builder for the drag operation
  164. LONG _cpMin; // the min and max cp's for the range that is
  165. LONG _cpMost; // being dragged so we can disable drag-onto-yourself!
  166. LONG _cpSel; // active end and length for selection *before*
  167. LONG _cchSel; // drag drop op occured (so we can restore it)
  168. LONG _cpCur; // the cp that the mouse is currently over
  169. CDropCaret *_pdrgcrt; // Object that implements the drop caret
  170. };
  171. /*
  172. * CDropTarget::fInDrag ()
  173. *
  174. * Purpose:
  175. * Tells interested parties whether a drag operation is occurring
  176. *
  177. */
  178. inline BOOL CDropTarget::fInDrag()
  179. {
  180. return _pcallmgr != NULL;
  181. }
  182. #endif // !__DRAGDRP_H__