home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / MiscKit1.2.6 / Palettes / MiscDragViews / MiscViews.subproj / MiscDragView.h < prev    next >
Encoding:
Text File  |  1994-05-23  |  4.3 KB  |  126 lines

  1. /**************************************************************************
  2.  * CLASS:        MiscDragView
  3.  * PROGRAMMER:    Todd Thomas            (todd@avocado.cuc.ab.ca)
  4.  * DATE:        Feb 14, 1994
  5.  * VERSION:        0.3
  6.  *        
  7.  *    MiscDragView is an abstract class (cannot be used as is) designed to be  
  8.  * easily extensible. Please refer to the docs for a more indepth description.
  9.  *
  10.  * To make any subclass useable for both source and destination dragging:
  11.  *
  12.  *         -override initFrame: to register the draggingTypes that your view     
  13.  *            will accept (and call [super initFrame: ]).
  14.  *        -override setupForSourceDrag to put data on the pasteboard of your
  15.              choice, and choose the image you would like to be dragged.
  16.             Don't call the [super setupForSourceDrag].
  17.  *        -override performDragOperation: to get the data from the
  18.  *            pasteboard 
  19.  *    
  20.  *    The above is the minimum needed, but you'll likely want to override
  21.  * other methods to check whether incoming draggings are acceptable, etc.
  22.  *
  23.  *     Finally, the delegate (if there is one) will be sent messages like: 
  24.  * sourceDragInitiated:, sourceDragFinished:, destinationDragInitiated:,
  25.  * destinationDragFinished. The skeleton of this code came from the 
  26.  * NW_DragLab example by Greg Burd and Randy Nelson...thanks for sharing 
  27.  * your code. 
  28.  *
  29.  * I combined this class with the MiscImageView class because dragging
  30.  * and images usually go hand in hand. You usually need to display an
  31.  * image representing the data on the pasteboard...
  32.  *
  33.  * Changes by Bruce McKenzie (spuds@netcom.com) (aka BJM) on 5/24/94:
  34.  *    1) Added proper versioning/archiving
  35.  *    2) Reset variables so that class properly recognizes freed objects
  36.  *    3) Changed "- setImageByFilename: (char *)aFilename" to 
  37.  *       "- setImageByFilename: (const char *)aFilename
  38.  *
  39.  * This object is included in the MiscKit by permission from the author
  40.  * and its use is governed by the MiscKit license, found in the file
  41.  * "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  42.  * for a list of all applicable permissions and restrictions.
  43.  ***************************************************************************/
  44.  
  45. #import <appkit/appkit.h>
  46.  
  47.  
  48. @interface MiscDragView : View  
  49. {
  50.     id  theImage;    
  51.     NXSize  imageSize;
  52.     int  border;
  53.     
  54.     id  delegate; 
  55.     id  dragImage;                
  56.     BOOL  allowSourceDragging, allowDestinationDragging;
  57.     BOOL  acceptForeignDrag, acceptLocalDrag;
  58.     BOOL  acceptSelfDrag, retainData;
  59. }
  60.  
  61. //-------------------- Methods to get things set up 
  62. - initFrame:(const NXRect *)frameRect;
  63. - awake;
  64. - free;
  65.  
  66. //--------------------- Image Manipulation Stuff
  67. - setImage: (NXImage *)anImage;
  68. - setImageByFilename: (const char *)aFilename;
  69. - (NXImage *)image;
  70.  
  71. //-------------------- Dragging Options
  72. - setAllowSourceDragging: (BOOL)aBool;
  73. - (BOOL)allowSourceDragging;
  74. - setAllowDestinationDragging: (BOOL)aBool;
  75. - (BOOL)allowDestinationDragging;
  76. - setAcceptForeignDrag: (BOOL)aBool;
  77. - (BOOL)acceptForeignDrag;
  78. - setAcceptLocalDrag: (BOOL)aBool;
  79. - (BOOL)acceptLocalDrag;
  80. - setAcceptSelfDrag: (BOOL)aBool;
  81. - (BOOL)acceptSelfDrag;
  82. - setRetainData: (BOOL)aBool;
  83. - (BOOL)retainData;
  84.  
  85. //-------------------- Methods for source dragging 
  86. - mouseDown:(NXEvent *)theEvent;
  87. - (BOOL)setupForSourceDrag;
  88. - calculateDragPoint: (NXPoint *)dragPoint andOffset: (NXPoint *)offset;
  89. - (NXDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag;
  90. - draggedImage:(NXImage *)image beganAt:(NXPoint *)screenPoint;
  91. - draggedImage:(NXImage *)image endedAt:(NXPoint *)screenPoint 
  92.         deposited:(BOOL)flag;
  93.         
  94. //-------------------- Methods for destination dragging */
  95. - (NXDragOperation)draggingEntered:sender;
  96. - (NXDragOperation)draggingUpdated:sender;
  97. - draggingExited:sender;
  98. - (BOOL)prepareForDragOperation:sender;
  99. - (BOOL)performDragOperation:sender;
  100. - concludeDragOperation:sender;
  101.  
  102. //-------------------- Basic useful methods 
  103. - (BOOL)acceptsFirstMouse;
  104. - (BOOL)shouldDelayWindowOrderingForEvent:(NXEvent *)theEvent;
  105.  
  106. //-------------------- Delegate methods 
  107. - delegate;
  108. - setDelegate: theDelegate;
  109. - sourceDragInitiated: view;
  110. - sourceDragFinished: (BOOL)success;
  111. - destinationDragInitiated: view;
  112. - destinationDragFinished: (BOOL)success;
  113.  
  114. //-------------------- Display
  115. - setBorderType: (int)aType;
  116. - (int)borderType;
  117. - drawSelf: (const NXRect *)rects :(int)rectCount;
  118.  
  119. //-------------------- Archiving methods
  120. - read: (NXTypedStream *)stream;
  121. - write: (NXTypedStream *)stream;
  122.  
  123. - (const char *)getInspectorClassName;
  124.  
  125. @end
  126.