home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Examples / AppKit / Draw / GraphicView.h < prev    next >
Text File  |  1992-07-19  |  10KB  |  303 lines

  1. typedef enum { Normal, Resizing } DrawStatusType;
  2. typedef enum { LEFT = 1, RIGHT, BOTTOM, TOP, HORIZONTAL_CENTERS, VERTICAL_CENTERS, BASELINES } AlignmentType;
  3.  
  4. extern DrawStatusType DrawStatus;
  5. extern NXAtom DrawPboardType;
  6. extern BOOL InMsgPrint;
  7.  
  8. typedef enum { ByRect, ByGraphic, ByList } DrawSelectionType;
  9.  
  10. /* Update modes for links. */
  11.  
  12. #define UPDATE_NEVER 0
  13. #define UPDATE_IMMEDIATELY -1
  14. #define UPDATE_NORMALLY 1
  15.  
  16. @interface GraphicView : View
  17. {
  18.     List *glist;            /* the list of Graphics */
  19.     List *slist;            /* the list of selected Graphics. In 
  20.                            Draw with undo we are very careful
  21.                        to keep slist sorted, like glist */
  22.     Window *cacheWindow;        /* the off-screen cache */
  23.     struct {
  24.     unsigned int groupInSlist:1;    /* whether a Group is in the slist */
  25.     unsigned int cacheing:1;    /* whether cacheing or drawing */
  26.     unsigned int suspendLinkUpdate:1; /* don't update links */
  27.     unsigned int grid:8;        /* grid size */
  28.     unsigned int showGrid:1;    /* whether grid is visible */
  29.     unsigned int locked:1;        /* some graphics are locked */
  30.     unsigned int gridDisabled:1;    /* whether grid is enabled */
  31.     unsigned int freeOriginalPaste:1;/* whether originalPaste needs free */
  32.     unsigned int serviceActsOnSelection:1;    /* whether service acts on selection */
  33.     unsigned int selectAll:1;    /* select all was last select operation performed */
  34.     unsigned int dragCopyOk:1;    /* true if dragging with sourcMask == copy is ok */
  35.     unsigned int dragLinkOk:1;    /* true if dragging with sourcMask == link is ok */
  36.     unsigned int padding:13;
  37.     } gvFlags;
  38.     short *gupCoords;            /* points in the grid user path */
  39.     int gupLength;            /* number of points in gupCoords */
  40.     char *gupOps;            /* movetos and linetos in the gup */
  41.     short *gupBBox;            /* bounding box of the gup */
  42.     float gridGray;            /* grayness of the grid */
  43.     int consecutivePastes;        /* number of consRWive pastes */
  44.     int lastPastedChangeCount;        /* the change count of last paste */
  45.     int lastCopiedChangeCount;        /* the change count of last cut or copy */
  46.     int lastCutChangeCount;        /* the change count of last cut */
  47.     View *editView;            /* flipped subview for editing */
  48.     Graphic *originalPaste;        /* the first pasted graphic */
  49.     NXDataLinkManager *linkManager;    /* manager of data links */
  50.     NXRect *invalidRect;        /* invalid area which must be cleaned up */
  51.     NXRect *dragRect;            /* last rectangle we dragged out to select */
  52.     Storage *linkTrackingRects;        /* the rects of the links we are tracking */
  53. }
  54.  
  55. /* Class initialization */
  56.  
  57. + initialize;
  58.  
  59. /* Alignment methods */
  60.  
  61. + (SEL)actionFromAlignType:(AlignmentType)alignType;
  62.  
  63. /* Creation methods */
  64.  
  65. - initFrame:(const NXRect *)frameRect;
  66.  
  67. /* Free method */
  68.  
  69. - free;
  70.  
  71. /* Public methods */
  72.  
  73. - (BOOL)isEmpty;
  74. - (BOOL)hasEmptySelection;
  75. - dirty;
  76. - getSelection;
  77. - setGroupInSlist:(BOOL)setting;
  78. - resetGroupInSlist;
  79. - resetLockedFlag;
  80. - getBBox:(NXRect *)bbox of:(List *)list;
  81. - getBBox:(NXRect *)bbox of:(List *)list extended:(BOOL)flag;
  82.  
  83. - redrawGraphics:graphicsList afterChangeAgent:changeAgent performs:(SEL)aSelector;
  84. - graphicsPerform:(SEL)aSelector;
  85. - graphicsPerform:(SEL)aSelector with:(void *)argument;
  86.  
  87. - cache:(const NXRect *)rect;
  88. - cache:(const NXRect *)rect andUpdateLinks:(BOOL)updateLinks;
  89. - recacheSelection;
  90. - createCacheWindow:(Window *)cacheWindow;
  91. - selectionCache;
  92. - (int)cacheSelection;
  93. - (int)cacheList:(List *)list into:(Window *)cacheWindow withTransparentBackground:(BOOL)flag;
  94. - (int)cacheList:(List *)list into:(Window *)cacheWindow;
  95. - cacheGraphic:(Graphic *)graphic;
  96.  
  97. - removeGraphic:(Graphic *)graphic;
  98. - insertGraphic:(Graphic *)graphic;
  99. - (Graphic *)selectedGraphic;
  100. - (List *)selectedGraphics;
  101. - (List *)graphics;
  102.  
  103. - (int)gridSpacing;
  104. - (BOOL)gridIsVisible;
  105. - (BOOL)gridIsEnabled;
  106. - (float)gridGray;
  107. - setGridSpacing:(int)gridSpacing;
  108. - setGridEnabled:(BOOL)flag;
  109. - setGridVisible:(BOOL)flag;
  110. - setGridGray:(float)gray;
  111. - setGridSpacing:(int)gridSpacing andGray:(float)gray;
  112. - grid:(NXPoint *)point;
  113.  
  114. - placeGraphic:(Graphic *)graphic at:(const NXPoint *)location;
  115.  
  116. /* Methods overridden from superclass */
  117.  
  118. - sizeTo:(NXCoord)width :(NXCoord)height;
  119. - mouseDown:(NXEvent *)event;
  120. - drawSelf:(const NXRect *)rects :(int)rectCount;
  121. - keyDown:(NXEvRW*)event;
  122.  
  123. /* Getting/Setting the current Graphic */
  124.  
  125. - (Graphic *)currentGraphic;
  126. - setCurrentGraphic:sender;
  127.  
  128. /* Writing Draw Forms */
  129.  
  130. - (BOOL)hasFormEntries;
  131. - writeFormEntriesToFile:(const char *)filename;
  132.  
  133. /* Target/Action methods */
  134.  
  135. - delete:sender;
  136. - selectAll:sender;
  137. - deselectAll:sender;
  138. - lock:sender;
  139. - unlock:sender;
  140. - bringToFront:sender;
  141. - sendToBack:sender;
  142. - group:sender;
  143. - ungroup:sender;
  144. - align:sender;
  145. - changeAspectRatio:sender;
  146. - alignToGrid:sender;
  147. - sizeToGrid:sender;
  148. - enableGrid:sender;
  149. - hideGrid:sender;
  150. - addCoverSheetEntry:sender;
  151. - addLocalizableCoverSheetEntry:sender;
  152.  
  153. /* Target/Action messages sent from Controls to set various parameters */
  154.  
  155. - takeGridValueFrom:sender;
  156. - takeGridGrayFrom:sender;
  157. - takeGrayValueFrom:sender;
  158. - takeLineWidthFrom:sender;
  159. - takeLineJoinFrom:sender;
  160. - takeLineCapFrom:sender;
  161. - takeLineArrowFrom:sender;
  162. - takeFillValueFrom:sender;
  163. - takeFrameValueFrom:sender;
  164. - takeLineColorFrom:sender;
  165. - takeFillColorFrom:sender;
  166. - takeFormEntryStatusFrom:sender;
  167.  
  168. - changeFont:sender;
  169.  
  170. /* Accepting becoming the First Responder */
  171.  
  172. - (BOOL)acceptsFirstResponder;
  173.  
  174. /* Printing-related methods */
  175.  
  176. - beginPrologueBBox:(NXRect *)boundingBox creationDate:(char *)dateCreated
  177.     createdBy:(char *)anApplication fonts:(char *)fontNames
  178.     forWhom:(char *)user pages:(int )numPages title:(char *)aTitle;
  179. - beginSetup;
  180.  
  181. /* Archiving methods */
  182.  
  183. - awake;
  184. - write:(NXTypedStream *)stream;
  185. - read:(NXTypedStream *)stream;
  186.  
  187. /* Validates whether a menu command makes sense now */
  188.  
  189. - (BOOL)validateCommand:(MenuCell *)menuCell;
  190.  
  191. /* Useful scrolling methods */
  192.  
  193. - scrollGraphicToVisible:(Graphic *)graphic;
  194. - scrollPointToVisible:(const NXPoint *)point;
  195. - scrollSelectionToVisible;
  196.  
  197. @end
  198.  
  199. /* Pasteboard */
  200.  
  201. typedef enum { LinkOnly = -1, DontLink = 0, Link = 1 } LinkType;
  202.  
  203. @interface GraphicView(Pasteboard)
  204.  
  205. #define NUM_TYPES_DRAW_EXPORTS 3
  206.  
  207. extern NXAtom *TypesDrawExports(void);
  208. extern NXAtom DrawPasteType(const NXAtom *types);
  209. extern NXAtom ForeignPasteType(const NXAtom *types);
  210. extern NXAtom TextPasteType(const NXAtom *types);
  211. extern BOOL IncludesType(const NXAtom *types, NXAtom type);
  212. extern NXAtom MatchTypes(const NXAtom *typesToMatch, const NXAtom *orderedTypes);
  213.  
  214. + convert:(NXTypedStream *)ts to:(const char *)type using:(SEL)writer toPasteboard:(Pasteboard *)pb;
  215. + pasteboard:(Pasteboard RWnder provideData:(const char *)type;
  216.  
  217. - writePSToStream:(NXStream *)stream;
  218. - writePSToStream:(NXStream *)stream usingList:(List *)aList;
  219. - writeTIFFToStream:(NXStream *)stream;
  220. - writeTIFFToStream:(NXStream *)stream usingList:(List *)aList;
  221.  
  222. - copySelectionAsPSToStream:(NXStream *)stream;
  223. - copySelectionAsTIFFToStream:(NXStream *)stream;
  224. - copySelectionToStream:(NXStream *)stream;
  225.  
  226. - copyToPasteboard:(Pasteboard *)pboard types:(NXAtom *)types;
  227. - copyToPasteboard:(Pasteboard *)pboard;
  228. - (BOOL)pasteForeignDataFromPasteboard:(Pasteboard *)pboard andLink:(LinkType)doLink at:(const NXPoint *)point;
  229. - pasteFromPasteboard:(Pasteboard *)pboard andLink:(LinkType)doLink at:(const NXPoint *)point;
  230. - paste:sender andLink:(LinkType)doLink;
  231. - cut:sender;
  232. - copy:sender;
  233. - paste:sender;
  234. - pasteAndLink:sender;
  235.  
  236. @end
  237.  
  238. /* Data link methods */
  239.  
  240. @interface GraphicView(Links)
  241.  
  242. - (NXSelection *)currentSelection;
  243. - (Graphic *)findGraphicInSelection:(NXSelection *)selection;
  244. - (List *)findGraphicsInSelection:(NXSelection *)selection;
  245.  
  246. - writeLinkToPasteboard:(Pasteboard *)pboard types:(const NXAtom *)typesList;
  247. - readLinkForGraphic:(Graphic *)graphic fromPasteboard:(Pasteboard *)pboard useNewIdentifier:(BOOL)useNewIdentifier;
  248. - (BOOL)addLink:(NXDataLink *)link toGraphic:(Graphic *)graphic at:(const NXPoint *)p update:(int)update;
  249.  
  250. - pasteFromPasteboard:(Pasteboard *)pboard at:(NXSelection *)selection;
  251. - importFile:(const char *)filename at:(NXSelection *)selection;
  252. - pasteboard:(Pasteboard *)sender provideData:(const char *)type;
  253. - copyToPasteboard:(Pasteboard *)pboard at:(NXSelection *)selection cheapCopyAllowed:(BOOL)cheapCopyAllowed;
  254.  
  255. - updateLinksPanel;
  256. - (NXDataLinkManager *)linkManager;
  257. - setLinkManager:(NXDataLinkManager *)linkManager;
  258. - showSelection:(NXSelection *)selection;
  259. - breakLinkAndRedrawOutlines:(NXDataLink *)aLink;
  260. - updateTrackedLinks:(const NXRect *)rect;
  261. - startTrackingLink:(NXDataLink *)link;
  262. - stopTrackingLink:(NXDataLink *)link;
  263.  
  264. @end
  265.  
  266. /* Dragging */
  267.  
  268. @interface GraphicView(Drag)
  269.  
  270. - registerForDragging;
  271. - (NXDragOperation)draggingEntered:(id <NXDraggingInfo>)sender;
  272. - (NXDragOperation)draggingUpdated:(id <NXDraggingInfo>)sender;
  273. - (BOOL)performDragOperation:(id <NXDraggingInfo>)sender;
  274.  
  275. @end
  276.  
  277. /* Services Menu */
  278.  
  279. @interface GraphicView(Services)
  280.  
  281. - validRequestorForSendType:(NXAtom)sendType andReturnType:(NXAtom)returnType;
  282. - (BOOL)writeSelectionToPasteboard:(Pasteboard *)pboard types:(NXAtom *)types;
  283. - readSelectionFromPasteboard:(Pasteboard *)pboard;
  284.  
  285. @end
  286.  
  287. /*
  288.  * Since we can't be sure that we have an InspectorPanel, we use RW * objective-C respondsTo: mechanism to see if we can send the message
  289.  * initializeGraphic: to [NXApp inspectorPanel].  This dummy interface
  290.  * declaration declares those messages (so that even if they don't exists,
  291.  * we can at least use them to check with respondsTo:).  We don't want
  292.  * to import DrawApp.h or InspectorPanel.h since we might accidentally
  293.  * introduce a dependency on them which wouldn't be caught because we
  294.  * imported both of their interfaces.
  295.  */
  296.  
  297. @interface PossibleInspectorPanel : Object
  298.  
  299. - inspectorPanel;
  300. - initializeGraphic:(Graphic *)graphic;
  301.  
  302. @end
  303.