home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_HitDetect / DrawingView.h < prev    next >
Encoding:
Text File  |  1992-12-19  |  4.0 KB  |  136 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    DrawingView.h
  35.  *
  36.  *    This view represents the page that the bezier is drawn onto. It is
  37.  *    a subview of the doc view and can be zoomed and reduced.
  38.  *
  39.  *    The buffers are used to allow for fast redrawing and moving. The
  40.  *    drawing is performed in the alpha buffer and then this is
  41.  *    composited into the buffered window. When the bezier is
  42.  *    selected and changed, the drawing of the new bezier 
  43.  *    occurs in the buffered window. With each mouse drag the
  44.  *    old image in alpha is first composited into the window and
  45.  *    then the new bezier drawn atop the old image.
  46.  *
  47.  *    When the image is moved, it is first drawn into the beta
  48.  *    buffer and then simply composited to a new location. If
  49.  *    the image is larger than the beta buffer, then the image
  50.  *    is redrawn instead of using the buffer.
  51.  *
  52.  *    Version:    2.0
  53.  *    Author:    Ken Fromm
  54.  *    History:
  55.  *            03-07-91        Added this comment.
  56.  */
  57.  
  58. #import "DetectApp.h"
  59. #import <appkit/View.h>
  60. #import <appkit/timer.h>
  61.  
  62. #define  PTS_UPATH_BUFFER        100
  63. #define  OPS_UPATH_BUFFER        100
  64.  
  65. #define  NUM_POINTS_HIT            12
  66. #define  NUM_OPS_HIT            6
  67.  
  68. #define COLORGRID                NX_LTGRAY
  69. #define WIDTHGRID                2.0
  70. #define SIZEGRID                    36
  71.  
  72. typedef struct _UPath {
  73.     float     * pts;
  74.     int        num_pts;
  75.     char        *ops;
  76.     int        num_ops;
  77. } UPath;
  78.     
  79. @interface DrawingView:View
  80. {
  81.     id            objectId,            /* id of the bezier */
  82.                 bufferAlpha,        /* id of the main drawing buffer */
  83.                 bufferBeta;        /* id of the buffer used when moving */
  84.  
  85.     BOOL        scrolling,            /* YES if need to update bufferAlpha */
  86.                 selected,            /* YES if the bezier has been selected */
  87.                 tracedetect,        /* YES if tracing the hit detection */
  88.                 tracedraw,        /* YES if tracing the drawing */
  89.                 drawgrid;            /* YES if drawing the grid */
  90.  
  91.     int            timermask,
  92.                 gridUpath;
  93.  
  94.     UPath        hitPoint,            /* User path descriptions that will be used */
  95.                 drawUpath;        /* for the hit detection point and the graphics. */
  96.  
  97.     NXTrackingTimer    *timer;
  98. }
  99.  
  100. - initFrame:(NXRect *) frm;
  101. - initializeHitPoint;
  102. - createGrid;
  103. - createObject;
  104. - free;
  105.  
  106. - traceDetect:sender;
  107. - traceDraw:sender;
  108. - drawGrid:sender;
  109.  
  110. - compositeBufferAlpha:(NXRect *) r;
  111.  
  112. - moveTo:(NXCoord)x :(NXCoord)y;
  113. - scale:(NXCoord)x :(NXCoord)y;
  114. - sizeTo:(NXCoord)x :(NXCoord)y;
  115.  
  116. - constrainPoint:(NXPoint *)aPt  withOffset:(const NXSize*)llOffset  :(const NXSize*)urOffset;
  117. - constrainRect:(NXRect *)aRect;
  118.  
  119. - (BOOL) isScrolling;
  120. - scrollToRect:(const NXRect *)toRect;
  121.  
  122. - redrawObject:(int) pt_num :(NXRect *)redrawRect;
  123. - moveObject:(NXEvent *)event :(NXRect *)redrawRect;
  124.  
  125.  - (BOOL) checkControl:(const NXPoint *) p :(int *) pt_num;
  126. - (BOOL) checkObject:(const NXPoint *) p;
  127.  
  128. - mouseDown:(NXEvent *)event;
  129.  
  130. - drawObject:(NXRect *)r  for:object  withUcache:(BOOL)flag;
  131. - drawControl:(NXRect *)r  for:object;
  132.  
  133. - drawSelf:(NXRect *)r :(int) count;
  134.  
  135. @end
  136.