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.
- */
-
- /*
- * ControlPoint.m
- * This file handles the particulars for the control point.
- *
- * Version: 2.0
- * Author: Ken Fromm
- * History:
- * 03-07-91 Added this comment.
- */
-
- #import "ControlPoint.h"
- #import "ControlView.h"
- #import "ControlPointWraps.h"
- #import "ControlViewWraps.h"
- #import <appkit/View.h>
- #import <appkit/nextstd.h>
- #import <dpsclient/dpsclient.h>
- #import <dpsclient/wraps.h>
-
- static char fontname[ ] = "ControlPointsFont";
-
- /* The point arrays below have the number of points in the array as the first entry
- * followed by the points. The op arrays have the number of ops in the array
- * as the first entry followed by the operators.
- */
-
- static float ptsRectfill[] = {8, -2, -2, 0, 4, 4, 0, 0, -4};
- static char opsRectfill[] = {5, dps_rmoveto, dps_rlineto, dps_rlineto, dps_rlineto,
- dps_closepath};
-
- static float ptsRectstroke[] = {8, -2, -2, 0, 4, 4, 0, 0, -4};
- static char opsRectstroke[] = {5, dps_rmoveto, dps_rlineto, dps_rlineto, dps_rlineto,
- dps_closepath};
-
- static float ptsX[] = {8, -2, -2, 4, 4, 0, -4, -4, 4};
- static char opsX[] = {4, dps_rmoveto, dps_rlineto, dps_rmoveto, dps_rlineto};
-
- static float ptsCross[] = {8, 0, 2, 0, -4, -2, 2, 4, 0};
- static char opsCross[] = {4, dps_rmoveto, dps_rlineto, dps_rmoveto, dps_rlineto};
-
- @implementation ControlPoint
-
- - setControlView:anObject
- {
- controlView = anObject;
-
- PSWDefsContPts ();
- PSWSetDependent();
- PSWDefineFont(fontname);
-
- [self setRectfill:self];
-
- return self;
- }
-
- /* These four methods set the values for drawing a type of control point. */
- - setRectfill:sender
- {
- fontchar = 'a';
- basicProc = "BRF";
- basicOp = "fill";
- userPtsArray = ptsRectfill;
- userOpsArray = opsRectfill;
- userOp = "ufill";
- rectOp = "rectfill";
-
- [controlView setButtonTitle:FILL];
- [controlView setButtonEnable:YES];
- [controlView eraseTimes:self];
-
- return self;
- }
-
- - setRectstroke:sender
- {
- fontchar = 'b';
- basicProc = "BRS";
- basicOp = "stroke";
- userPtsArray = ptsRectstroke;
- userOpsArray = opsRectstroke;
- userOp = "ustroke";
- rectOp = "rectstroke";
-
- [controlView setButtonTitle:STROKE];
- [controlView setButtonEnable:YES];
- [controlView eraseTimes:self];
-
- return self;
- }
-
- - setX:sender
- {
- fontchar = 'c';
- basicProc = "BX";
- basicOp = "stroke";
- userPtsArray = ptsX;
- userOpsArray = opsX;
- userOp = "ustroke";
- rectOp = "pop";
-
- [controlView setButtonTitle:STROKE];
- [controlView setButtonEnable:NO];
- [controlView eraseTimes:self];
-
- return self;
- }
-
- - setCross:sender
- {
- fontchar = 'd';
- basicProc = "BC";
- basicOp = "stroke";
- userPtsArray = ptsCross;
- userOpsArray = opsCross;
- userOp = "ustroke";
- rectOp = "pop";
-
- [controlView setButtonTitle:STROKE];
- [controlView setButtonEnable:NO];
- [controlView eraseTimes:self];
-
- return self;
- }
-
- /* Sets a flag to use or not use the device space rounding techniques. */
- -deviceDependence:(BOOL) independent
- {
- if (independent)
- PSWSetIndependent();
- else
- PSWSetDependent();
-
- PSundefinefont(fontname);
- PSWDefineFont(fontname);
- }
-
- - selectFont:(int) fontsize;
- {
- PSselectfont(fontname, fontsize);
-
- return self;
- }
-
- /* These methods return the current values for the type of control point to draw. */
- - (char) getChar
- {
- return fontchar;
- }
-
- - (char *) getBasicProc
- {
- return basicProc;
- }
-
- - (char *) getBasicOp
- {
- return basicOp;
- }
-
- - (float *) getUserPtsArray
- {
- return userPtsArray;
- }
-
- - (char *) getUserOpsArray
- {
- return userOpsArray;
- }
-
- - (char *) getUserOp
- {
- return userOp;
- }
-
- - (char *) getRectOp
- {
- return rectOp;
- }
-
- /* Draws the contol point into a bit map. Uses the alpha to allow transparency. */
- - drawImage:imageId
- {
- [imageId lockFocus];
- PSgsave();
- PSsetalpha(0.0); /* Transparent */
- PSsetgray(NX_WHITE);
- PSrectfill(0, 0, FIGURESIZE, FIGURESIZE);
- PSsetalpha(1.0); /* Opaque */
- PSsetgray(NX_BLACK);
- PSWBasic(FIGURESIZE/2, FIGURESIZE/2, basicProc, basicOp);
- PSgrestore();
- [imageId unlockFocus];
-
- return self;
- }
-
- @end
-