home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / CDragAndDrop / CDragItem.h < prev    next >
Encoding:
Text File  |  1995-02-09  |  2.9 KB  |  77 lines  |  [TEXT/CWIE]

  1. // =================================================================================
  2. //    CDragItem.h                ©1995 J. Rodden, DD/MF & Associates. All rights reserved
  3. // =================================================================================
  4. // Mixin class to be used with anything that supports dragging of it's items.
  5. // CDragItem encapsulates the characteristics of a draggable item.
  6. //
  7. // By using CDragItem and overriding AddFlavors and MakeDragRegion, you can
  8. // (a) include as many flavors of an item as you want, (b) define your own outline
  9. // to replace the generic rectangle that LDragTask provides, (c) arrange to send 
  10. // drag data on demand by calling InstallDragSendData when adding flavors (and 
  11. // installing null data in the drag) and overriding DoSendDragData for the object 
  12. // being dragged, and (d) override the drag manager's default behaviors for DragInput 
  13. // and DragDrawing by calling InstallDragInput or InstallDragDrawing and overriding 
  14. // DoDragInput or DoDragDrawing respectively.
  15. // =================================================================================
  16.  
  17. #pragma once
  18.  
  19. #include <PP_Prefix.h>
  20.  
  21. #ifndef __DRAG__
  22. #include <Drag.h>
  23. #endif
  24.  
  25. const ItemReference    kItemRef = 1;
  26.  
  27. // =================================================================================
  28. //        • CDragItem
  29. // =================================================================================
  30.  
  31. class CDragItem
  32. {
  33. public:
  34.                      CDragItem() { };
  35.     virtual            ~CDragItem() { };
  36.             
  37.     virtual    void    AddFlavors(DragReference inDragRef);
  38.     virtual void    MakeDragRegion( DragReference inDragRef, RgnHandle inDragRegion);
  39.  
  40.     virtual void    SetLocalFrame();
  41.     virtual    void    DrawDragRegion();
  42.     virtual Boolean    AddToDragRgn(RgnHandle inDragRegion);    
  43.     virtual void    OutlineRegion(RgnHandle inRegion);
  44.  
  45.     virtual void    DoDragSendData(FlavorType inFlavor,
  46.                                 ItemReference inItemRef,
  47.                                 DragReference inDragRef);
  48.                                 
  49.     virtual void    DoDragInput(Point *ioMouse, Int16 *ioModifiers,
  50.                                 DragReference inDragRef);
  51.                                 
  52.     virtual void    DoDragDrawing(DragRegionMessage inMessage,
  53.                                 RgnHandle inShowRgn, Point inShowOrigin,
  54.                                 RgnHandle inHideRgn, Point inHideOrigin,
  55.                                 DragReference inDragRef);
  56.                                 
  57.     virtual    void    InstallDragSendData(DragReference inDragRef);
  58.     virtual    void    InstallDragInput(DragReference inDragRef);
  59.     virtual    void    InstallDragDrawing(DragReference inDragRef);
  60.  
  61.     static pascal OSErr    HandleDragSendData(FlavorType inFlavor,
  62.                                 void *inRefCon, ItemReference inItemRef,
  63.                                 DragReference inDragRef);
  64.                                 
  65.     static pascal OSErr    HandleDragInput(Point *ioMouse, Int16 *ioModifiers,
  66.                                 void *inRefCon, DragReference inDragRef);
  67.                                 
  68.     static pascal OSErr    HandleDragDrawing(DragRegionMessage inMessage,
  69.                                 RgnHandle inShowRgn, Point inShowOrigin,
  70.                                 RgnHandle inHideRgn, Point inHideOrigin,
  71.                                 void *inRefCon, DragReference inDragRef);
  72.  
  73. protected:
  74.             Rect    mLocalFrame;
  75. };
  76.  
  77.