home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * (a) (C) 1990 by Adobe Systems Incorporated. All rights reserved.
- *
- * (b) If this Sample Code is distributed as part of the Display PostScript
- * System Software Development Kit from Adobe Systems Incorporated,
- * then this copy is designated as Development Software and its use is
- * subject to the terms of the License Agreement attached to such Kit.
- *
- * (c) If this Sample Code is distributed independently, then the following
- * terms apply:
- *
- * (d) This file may be freely copied and redistributed as long as:
- * 1) Parts (a), (d), (e) and (f) continue to be included in the file,
- * 2) If the file has been modified in any way, a notice of such
- * modification is conspicuously indicated.
- *
- * (e) PostScript, Display PostScript, and Adobe are registered trademarks of
- * Adobe Systems Incorporated.
- *
- * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
- * CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
- * AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
- * ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
- * OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
- * WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
- * WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
- * DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
- * OF THIRD PARTY RIGHTS.
- */
-
- /*
- * DrawViewWraps.psw
- *
- * Here lie the wraps used in DrawView.m for the LineDrawing application.
- * Several ways to draw lines are shown here. One that is not is to use the
- * single operator functions from the method directly.
- *
- * PostScript operators obtain their operands from the stack.
- * As a result the order of placing the operands on the stack is very important.
- * In the examples below, comments are used in the bound procedures
- * to indicate the operands on stack when the procedure is called.
- * One common problem area is to inadvertently place the operands on
- * stack in the wrong order.
- *
- * Version: 2.0
- * Author: Ken Anderson, Ken Fromm
- * History:
- * 03-07-91 Added this comment.
- */
-
- /* StartTime is stored in the interpreter and contains the initial real time */
- defineps PSWMarkTime ()
- /StartTime realtime def
- endps
-
- /* The difference between the current real time and the initial time stored */
- /* in StartTime is returned to the calling procedure in the output arg ElapsedTime. */
- defineps PSWReturnTime (|int *ElapsedTime)
- realtime StartTime sub
- ElapsedTime
- endps
-
- /*
- * This wrap is called in the +newFrame:(NXRect *) frm method to
- * define and bind procedures in the interpreter. These procedures
- * are then called from within other wraps. Binding replaces each
- * executable operator name with its value. During execution of the
- * procedures, the interpreter encounters the operators themselves
- * instead of the names of the operators. A procedure that has been
- * bounded will execute faster than one that has not been bound.
- * Certain caveats pertain; see the red book for further information.
- */
- defineps PSWDefs ()
-
- /EVB { % BGrect BGStrWidth BGStrColor BGColor
- setgray 2 index rectfill
- setgray setlinewidth rectstroke
- } bind def
-
- /DLB { % X1 Y1 X Y LineColor LineWidth
- setlinewidth setgray
- moveto lineto stroke
- } bind def
-
- /DLRB { % i
- 0 1 3 -1 roll 1 sub { % for
- dup PSW exch get setlinewidth
- dup PSC exch get setgray
- dup PSX exch get PSY 2 index get moveto
- dup PSX1 exch get PSY1 2 index get lineto
- stroke pop
- } for
- } bind def
-
- /MLB { % X1 Y1 X Y
- moveto
- lineto
- } bind def
-
- /SLB { % LineColor LineWidth
- setlinewidth
- setgray
- stroke
- } bind def
-
- endps
-
- /*** Called by -drawWraps ***/
- /* Calls the operators from the wrap itself. */
- defineps PSWEraseView (float BGColor, BGStrColor, BGStrWidth, BGrect[4])
- BGColor setgray
- BGrect rectfill
- BGStrColor setgray
- BGStrWidth setlinewidth
- BGrect rectstroke
- endps
-
- /* Calls the operators from the wrap itself. */
- defineps PSWDrawLine (float LineWidth, LineColor, X, Y, X1, Y1)
- LineWidth setlinewidth
- LineColor setgray
- X Y moveto
- X1 Y1 lineto
- stroke
- endps
-
-
- /*** Called by -drawWrapsBind ***/
- /* Places the input args on the stack and calls the EraseViewBind procedure. */
- defineps PSWEraseViewBind (float BGColor, BGStrColor, BGStrWidth, BGrect[4])
- BGrect BGStrWidth BGStrColor BGColor EVB
- endps
-
- /* Places the input args on the stack and calls the DrawLineBind procedure. */
- defineps PSWDrawLineBind (float LineWidth, LineColor, X, Y, X1, Y1)
- X1 Y1 X Y LineColor LineWidth DLB
- endps
-
-
- /*** Called by -drawWrapsRepeat ***/
- /* Defines input args, places the number of repetitions on the stack and then */
- /* calls the DrawLineRepeatBind procedure. */
- defineps PSWDrawLineRepeatBind (float W[i], C[i], X[i], Y[i], X1[i], Y1[i]; int i)
- /PSW W def
- /PSC C def
- /PSX X def /PSY Y def
- /PSX1 X1 def /PSY1 Y1 def
- i DLRB
- endps
-
-
- /*** Called by -drawOptimizedStroke ***/
- /* Places the input args on the stack and calls the MakeLineBind procedure. */
- defineps PSWMakeLineBind (float X, Y, X1, Y1)
- X1 Y1 X Y MLB
- endps
-
- /* Places the input args on the stack and calls the StrokeLineBind procedure. */
- defineps PSWStrokeLineBind (float LineWidth, LineColor)
- LineColor LineWidth SLB
- endps
-
-