home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscDragViews / MiscViews.subproj / MiscDragView.h < prev    next >
Encoding:
Text File  |  1995-12-18  |  5.3 KB  |  165 lines

  1. /**************************************************************************
  2.   CLASS:            MiscDragView
  3.   INHERITS FROM:    View
  4.   PROGRAMMERS:        Todd Thomas            (todd@avocado.supernet.ab.ca)
  5.                       Bill Shirley        (Bill_Shirley@pcp.ca)
  6.                     Bruce McKenzie         (spuds@netcom.com)
  7.                     Steve Hayman         (shayman@Objectario.com)
  8.                     Daniel Boehringer    
  9.   BEGAN:            February 14, 1994
  10.   LAST CHANGED:        December 18, 1995
  11.   VERSION:            1.4
  12.   CHANGES:            See the end of MiscDragView.m
  13.           
  14.   MiscDragView is an abstract class (cannot be used as is) designed to be  
  15.   easily extensible. Please refer to the docs for a more indepth description.
  16.  
  17.   To make any subclass useable for both source and destination dragging:
  18.  
  19.           -override initDragTypes to register the draggingTypes that your view     
  20.              will accept.
  21.          -override setupForSourceDrag to put the data (representing the 
  22.             dragged icon) on the pasteboard of your choice, and choose 
  23.             the image you would like to be dragged.
  24.             *Don't call the [super setupForSourceDrag].
  25.          -override performDragOperation: to get the data from the
  26.              pasteboard (used for a destination drag view)
  27.      
  28.   The above is the minimum needed, but you'll likely want to override
  29.   other methods to check whether incoming drags are acceptable, etc.
  30.  
  31.   Finally, the delegate (if there is one) will be sent messages like: 
  32.   didInitiateSourceDrag:, didFinishSourceDrag:, didInitiateDestinationDrag:,
  33.   and didFinishDestinationDrag:. (The delegate methods have changed to be
  34.   more like NeXT's will/did methods. The old ones are still sent for 
  35.   backward compatability though). The skeleton of this code came from the 
  36.   NW_DragLab example by Greg Burd and Randy Nelson...thanks for sharing 
  37.   your code. 
  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.  * Copyright (C) 1995 Robert Todd Thomas
  45.  * Use is governed by the MiscKit license
  46.  ***************************************************************************/
  47.  
  48. #import <appkit/View.h>
  49.  
  50.  
  51. @interface MiscDragView : View
  52. {
  53.     id  theImage,theAcceptingImage;            // the image to display the well
  54.     NXSize  imageSize;        // the original size just in case you shrink it
  55.     int  border;            // border type (same as Box)
  56.  
  57. // why not making a bitfield out of this
  58.     BOOL  allowSourceDragging;
  59.     BOOL  allowDestinationDragging;
  60.     BOOL  freeWhenDragDone;
  61.     BOOL  shadowIncoming;
  62.     BOOL  dragImageIsMyImage;
  63.     
  64.     id  delegate;                 
  65.     id     target;        // For control-style target/action stuff. ..shayman
  66.     SEL  action;
  67. }
  68.  
  69. //-------------------- Methods to get things set up 
  70. + initialize;
  71. - initFrame:(const NXRect *)frameRect;
  72. - initDragTypes;
  73. - free;
  74.  
  75. //--------------------- Image Manipulation Stuff
  76. - setImage: (NXImage *)anImage;
  77. - setAcceptingImage: (NXImage *)anImage;
  78. - setImageByName: (const char *)aName;
  79. - setAcceptingImageByName: (const char *)aName;
  80. - setImageByFilename: (const char *)aFilename;
  81. - (NXImage *)image;
  82. - setDragImage: (NXImage *)anImage;
  83. - setDragImage: (NXImage *)anImage freeWhenDone: (BOOL)freeIt;
  84. - (NXImage *)dragImage;
  85. - (NXImage *)acceptingImage;
  86. -(const char*) imageName;
  87. -(const char*) acceptingImageName;
  88. //-------------------- Dragging Options
  89. - setAllowSourceDragging: (BOOL)aBool;
  90. - (BOOL)allowSourceDragging;
  91. - setAllowDestinationDragging: (BOOL)aBool;
  92. - (BOOL)allowDestinationDragging;
  93.  
  94. - (BOOL)acceptForeignDrag;
  95. - (BOOL)acceptLocalDrag;
  96. - (BOOL)acceptSelfDrag;
  97. - (BOOL)retainData;
  98. - (BOOL)shadowIncoming;
  99. - setShadowIncoming:(BOOL) aBool;
  100. - (NXColor)shadowColor;
  101.  
  102. - (BOOL)dragImageIsMyImage;
  103. - setDragImageIsMyImage:(BOOL)aDragImageIsMyImage;
  104.  
  105. //-------------------- Methods for source dragging 
  106. - mouseDown:(NXEvent *)theEvent;
  107. - cleanupAfterSourceDrag;
  108. - (BOOL)setupForSourceDrag;
  109. - (BOOL)slideback;
  110. - draggingPasteboard;
  111. - calculateDragPoint: (NXPoint *)dragPoint andOffset: (NXPoint *)offset;
  112. - (NXDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag;
  113. - draggedImage:(NXImage *)image endedAt:(NXPoint *)screenPoint 
  114.         deposited:(BOOL)flag;
  115.         
  116. //-------------------- Methods for destination dragging */
  117. - (NXDragOperation)draggingEntered:sender;
  118. - (NXDragOperation)draggingUpdated:sender;
  119. - draggingExited:sender;
  120. - (BOOL)prepareForDragOperation:sender;
  121. - (BOOL)performDragOperation:sender;
  122. - concludeDragOperation:sender;
  123. - cleanupAfterDestinationDrag;
  124.  
  125. //-------------------- Basic useful methods 
  126. - (BOOL)acceptsFirstMouse;
  127. - (BOOL)shouldDelayWindowOrderingForEvent:(NXEvent *)theEvent;
  128.  
  129. //-------------------- Display
  130. - setBorderType: (int)aType;
  131. - (int)borderType;
  132. - drawSelf: (const NXRect *)rects :(int)rectCount;
  133.  
  134. //-------------------- Archiving methods
  135. - read: (NXTypedStream *)stream;
  136. - write: (NXTypedStream *)stream;
  137. - awake;
  138.  
  139. //-------------------- Control-style Target-action stuff  (shayman)
  140. - target;
  141. - setTarget:aTarget;
  142. - (SEL)action;
  143. - setAction:(SEL)anAction;
  144. - (const char *)stringValue;
  145. - setStringValue:(const char *)aValue;
  146. - takeStringValueFrom:sender;
  147.  
  148. @end
  149.  
  150.  
  151. @interface Object (MiscDragViewDelegate)
  152.  
  153. - didInitiateSourceDrag: sender;
  154. - didFinishSourceDrag: (BOOL)successful;
  155. - didInitiateDestinationDrag: sender;
  156. - didFinishDestinationDrag: (BOOL)successful;
  157. - initDragTypes:sender;
  158. - setupForSourceDrag:sender;
  159. -(NXImage*) image;
  160. -(NXImage*) acceptingImage;
  161. -(BOOL) takeDataFromPasteboard:sender;
  162.  
  163. @end
  164.  
  165.