// ================================================================================= // CDragTask.h ©1995 J. Rodden, DD/MF & Associates. All rights reserved // ================================================================================= // You do not need to inherit this class. // // LDragTask gives us general drag functionality and behaviour. CDragTask exists so // that we can add behaviour specific to dragging our items without having to inherit // from LDragTask anymore. // // CDragTask actually acts as a stub object, it passes the work onto the object being // dragged so that all drag manager code can be isolated in the object being dragged // or its owner and you don't ever have to deal with an LDragTask again. // // By using CDragTask and overriding AddFlavors and MakeDragRegion in the object // being dragged, you can (a) include as many flavors of an item as you want, (b) // define your own outline to replace the generic rectangle that LDragTask provides, // (c) arrange to send drag data on demand by calling InstallDragSendData when // adding flavors (and installing null data in the drag) and overriding DoSendDragData // for the object being dragged, and (d) override the drag manager's default behaviors // for DragInput and DragDrawing by calling InstallDragInput or InstallDragDrawing // and overriding DoDragInput or DoDragDrawing respectively. // ================================================================================= #pragma once #include class CDragItem; class CDragTask : public LDragTask { public: CDragTask(const EventRecord &inEventRecord, CDragItem* inDragItem = nil); CDragTask(const EventRecord& inEventRecord, const Rect* inItemRect, ItemReference inItemRef, CDragItem* inDragItem = nil); protected: virtual void AddFlavors (DragReference inDragRef); virtual void MakeDragRegion (DragReference inDragRef, RgnHandle inDragRegion); virtual void InstallDragSendData(); virtual void InstallDragInput(); virtual void InstallDragDrawing(); private: CDragItem* dragItem; };