home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Palettes / MiscDragViews / MiscViews.subproj / MiscDragView.h < prev    next >
Encoding:
Text File  |  1994-02-15  |  4.0 KB  |  120 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.  * This object is included in the MiscKit by permission from the author
  34.  * and its use is governed by the MiscKit license, found in the file
  35.  * "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  36.  * for a list of all applicable permissions and restrictions.
  37.  ***************************************************************************/
  38.  
  39. #import <appkit/appkit.h>
  40.  
  41.  
  42. @interface MiscDragView : View  
  43. {
  44.     id  theImage;    
  45.     NXSize  imageSize;
  46.     int  border;
  47.     
  48.     id  delegate; 
  49.     id  dragImage;                
  50.     BOOL  allowSourceDragging, allowDestinationDragging;
  51.     BOOL  acceptForeignDrag, acceptLocalDrag;
  52.     BOOL  acceptSelfDrag, retainData;
  53. }
  54.  
  55. //-------------------- Methods to get things set up 
  56. - initFrame:(const NXRect *)frameRect;
  57. - awake;
  58. - free;
  59.  
  60. //--------------------- Image Manipulation Stuff
  61. - setImage: (NXImage *)anImage;
  62. - setImageByFilename: (char *)aFilename;
  63. - (NXImage *)image;
  64.  
  65. //-------------------- Dragging Options
  66. - setAllowSourceDragging: (BOOL)aBool;
  67. - (BOOL)allowSourceDragging;
  68. - setAllowDestinationDragging: (BOOL)aBool;
  69. - (BOOL)allowDestinationDragging;
  70. - setAcceptForeignDrag: (BOOL)aBool;
  71. - (BOOL)acceptForeignDrag;
  72. - setAcceptLocalDrag: (BOOL)aBool;
  73. - (BOOL)acceptLocalDrag;
  74. - setAcceptSelfDrag: (BOOL)aBool;
  75. - (BOOL)acceptSelfDrag;
  76. - setRetainData: (BOOL)aBool;
  77. - (BOOL)retainData;
  78.  
  79. //-------------------- Methods for source dragging 
  80. - mouseDown:(NXEvent *)theEvent;
  81. - (BOOL)setupForSourceDrag;
  82. - calculateDragPoint: (NXPoint *)dragPoint andOffset: (NXPoint *)offset;
  83. - (NXDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag;
  84. - draggedImage:(NXImage *)image beganAt:(NXPoint *)screenPoint;
  85. - draggedImage:(NXImage *)image endedAt:(NXPoint *)screenPoint 
  86.         deposited:(BOOL)flag;
  87.         
  88. //-------------------- Methods for destination dragging */
  89. - (NXDragOperation)draggingEntered:sender;
  90. - (NXDragOperation)draggingUpdated:sender;
  91. - draggingExited:sender;
  92. - (BOOL)prepareForDragOperation:sender;
  93. - (BOOL)performDragOperation:sender;
  94. - concludeDragOperation:sender;
  95.  
  96. //-------------------- Basic useful methods 
  97. - (BOOL)acceptsFirstMouse;
  98. - (BOOL)shouldDelayWindowOrderingForEvent:(NXEvent *)theEvent;
  99.  
  100. //-------------------- Delegate methods 
  101. - delegate;
  102. - setDelegate: theDelegate;
  103. - sourceDragInitiated: view;
  104. - sourceDragFinished: (BOOL)success;
  105. - destinationDragInitiated: view;
  106. - destinationDragFinished: (BOOL)success;
  107.  
  108. //-------------------- Display
  109. - setBorderType: (int)aType;
  110. - (int)borderType;
  111. - drawSelf: (const NXRect *)rects :(int)rectCount;
  112.  
  113. //-------------------- Archiving methods
  114. - read: (NXTypedStream *)stream;
  115. - write: (NXTypedStream *)stream;
  116.  
  117. - (const char *)getInspectorClassName;
  118.  
  119. @end
  120.