ftp.nice.ch/peanuts/GeneralData/Documents/adobe/DPS.Purple.ImportInt.tar.gz#/NX_ImportInt/ImportApp.m

This is ImportApp.m in view mode; [Download] [Up]

/*
 * (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.
 */

/*
*	ImportApp.m
*
*	This class performs some of the global functions necessary to
*	manage the application.
*
*	Several application wide resources are retained as
*	instance variables. Examples are the hitPoint and
*	upathBuffer buffers, the hitSetting value and the
*	epsfContext.
*
*	The epsfContext is a separate context that is
*	used solely for imaging included epsf files. It
*	prevents any errors in the epsf files from harming
*	the application's context. If errors occur when imaging
*	an epsf file, the context is destroyed and a new one
*	created. (See the context setting methods in this file
*	as well as in GraphicEpsf.m for specific details on
*	how to switch the contexts.) 
*
*	Version:	2.0
*	Author:	Ken Fromm
*	History:
*			03-07-91		Added this comment.
*/

#import "ImportApp.h"
#import "Document.h"
#import "SaveAsPanel.h"

#import "DrawingViewWraps.h"

#import <appkit/Matrix.h>
#import <appkit/NXCursor.h>
#import <appkit/NXImage.h>
#import <appkit/Window.h>
#import <appkit/defaults.h>
#import <appkit/nextstd.h>

char	ControlFont[ ] = "ControlPointsFont";

@implementation ImportApp

+ new
{
	self = [super new];

	[self  setAutoupdate:YES];
	[self  initializeSelf];

	return self;
}

- free
{
	if (upathBuffer.pts)
		NX_FREE(upathBuffer.pts);
	if (upathBuffer.ops)
		NX_FREE(upathBuffer.ops);
	if (hitPoint.pts)
		NX_FREE(hitPoint.pts);
	if (hitPoint.ops)
		NX_FREE(hitPoint.ops);

	return [super free];
}

/*
* 	Allocate a buffer for use by any drawing view to send
* 	data to the PostScript server.
*
*	Allocate another buffer for use by any drawing view to
*	use as the hitdetection userpath. Initialize the description
*	since most of the components will remain the same.
*/
- initializeSelf
{
	int		i;

	contextFlag = YES;

	PSWDefineFont(ControlFont);

	NX_MALLOC(upathBuffer.pts, float, PTS_BUFFER);
	NX_MALLOC(upathBuffer.ops, char, OPS_BUFFER);

	NX_MALLOC(hitPoint.pts, float, PTS_HITPOINT);
	NX_MALLOC(hitPoint.ops, char, OPS_HITPOINT);

	for (i = 0; i < PTS_HITPOINT; i++)
		hitPoint.pts[i] = 0;			
	hitPoint.num_pts = i;
 	
	i = 0;
	hitPoint.ops[i++] = dps_setbbox;
	hitPoint.ops[i++] = dps_moveto;
	hitPoint.ops[i++] = dps_rlineto;
	hitPoint.ops[i++] = dps_rlineto;
	hitPoint.ops[i++] = dps_rlineto;
	hitPoint.ops[i++] = dps_closepath;
	hitPoint.num_ops = i;

	return self;
}

- setSaveAccessory:anObject
{
	id		savepanel;

	savepanel = [SaveAsPanel  new];

	[savepanel  setAccessoryView:anObject];
	[savepanel  setSaveTo];

	return self;
}

- setContextFlag:sender
{
	if (!contextFlag)
		[[sender selectedCell] setTitle:"Separate Context On"];
	else
		[[sender selectedCell] setTitle:"Separate Context Off"];

	contextFlag = !contextFlag;
	
	return self;
}

- (BOOL) contextFlag
{
	return contextFlag;
}

- setShowEpsfFlag:sender
{
	if (!showEpsfFlag)
		[[sender selectedCell] setTitle:"Show Epsf On"];
	else
		[[sender selectedCell] setTitle:"Show Epsf Off"];

	showEpsfFlag = !showEpsfFlag;

	return self;
}

- (BOOL) showEpsfFlag
{
	return showEpsfFlag;
}

- setTracingFlag:sender
{
	if (!tracingFlag)
		[[sender selectedCell] setTitle:"Trace On"];
	else
		[[sender selectedCell] setTitle:"Trace Off"];

	tracingFlag = !tracingFlag;
	
	return self;
}

- (BOOL) tracingFlag
{
	return tracingFlag;
}

- (UPath *) hitPoint;
{
	return &hitPoint;
}

- (UPath *) upathBuffer;
{
	return &upathBuffer;
}

- resourcePanel
{
	if (!resourcePanel)
		[NXApp  loadNibSection:"ResourcePanel.nib"  owner:self  withNames:NO];

	return resourcePanel;
}

- cursor
{
	id		imageId, cursorId;

	NXPoint	spot;

	if (operation == OP_IMPORT)
	{
		if (!importId)
		{
			imageId = [NXImage  newFromSection:"cursorImport.tiff"];
			importId = [NXCursor  newFromImage:imageId];
			spot.x = 2.0;  spot.y = 1.0;
			[importId setHotSpot:&spot];
		}
		cursorId = importId;
	}
	else
		cursorId = NXArrow;

	return cursorId;
}

- setOperation:(int) op
{
	operation = op;
	[[documentId  window]  invalidateCursorRectsForView:[[documentId  window] contentView]];

	return self;
}

- (int) operation
{
	return operation;
}

/*
 *	Application delegate methods.
 */
- appDidInit:sender
{
	documentId = [Document  new];	

	return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.