ftp.nice.ch/pub/next/developer/apps/DrawingServant.README

This is the README for DrawingServant.0.2.N.bs.tar.gz [Download] [Browse] [Up]

Got an old, rusty C program that is just dying to have a NeXT
graphics port?  Then consider...

	DrawingServant

Now is the updated to the ever advancing version 0.2

The "usual" way of porting an application to NeXTStep
seems to be to create an NeXT frontend with IB or equivalent,
then invoke the underlying application through some interprocess
communication.  DrawingServant is a utility for performing
a port from the opposite direction.  The intended use of this
program is as a graphics head to an existing terminal-based
program.  The client program may be invoked from the terminal line;
the client forks a process and establishes pipes to DrawingServant,
then send raw postscript though a pipe to the server.
The server has a small vocabulary of commands, but for the most
part just copies everything not in its vocabulary with a DPSPrintf
to the window manager.  The server has a simple NeXT interface
that allows for saving, printing and clearing the window.

One primary application in mind is for some sort of plotting
program.  The main usually have its own setups to perform and
an event loop based on things typed into it.  Normally, this is
difficult to fit into the NeXT event loop without some major
hacking of the main.  However, if the main has some simple
hooks along the line of
	device_setup
	device_drawaline
	device_writesometext, etc.
then it is a simple matter to write a few lines of c code in
setup for fork DrawingServant, and a few more lines to send
a moveto--lineto combination in drawaline for the operation.
The code to invoke the server can be very plain and therefore
likely to be compilable with any set of compiler switches and
without including any NeXT specific include files (in fact, it really
doesn't have to be on a NeXT).

Many aspects of real NeXT applications are intentionally left out.
Preferences, Help, multiple language support is all omitted.
Since this program is intended to be only marginally present,
most of the functionality of it should be performed by the main
program.  For example, the size and placement of the drawing window
are entirely controlled by the client program.  If preferences are
needed, they should be handled by the client.

The code for DrawingServant is small enough to make it easily hacked.
Interface Builder or Project Builder were not used. 

Invoking the server should be done with an exec with the argument
list (optional)
	DrawingServant w# h# x# y# i# o#
	where
		w	width of the window in pixels (default=500)
		h	height in pixels (default=500)
		x	x location of upper left corner (default=400)
		y	y location of upper left (default=250)
		i	fd of input pipe (default=0)
		o	fd or output pipe (default=1)

The vocabulary of existing commands is:

	DSversion	Return a string to the client of the version id
	DSclear	Erase the DrawingServant window (also on a menu)
	DSsave	Save the DrawingServant window in .eps (menu, too)
	DSoops	Erase the last postscript string sent to the server
	DSprint	Print the window (also in a menu)
	DSmouseon	Return a string to the client reporting mouse clicks
	DSmouseoff	Turn off mouse reporting
	DSackon	Return "Ok" after processing command
	DSackoff	No acknowledgement
	DSquit	Die
	DSfront	Move window to the very front (even above the terminal)
	DShide	Same as hide from the menu

This is clearly not the absolutely most efficient way to draw in NeXTStep,
but may be the quickest way to provide a graphics capability to a
vanilla terminal-based C program.

DrawingServant can also be invoked from terminal shell (or double clicked),
in which case it becomes another postscript hacking tool.  Also include is
a trivial example client program tester.c; a Metafont online previewer may
also be available at archive sites.

Suggestions and complaints are welcome.  Anyone want to write a
tektronix emulator for kermit?

The code is copyright 1993 by Joe Carlson.  Permission is granted for
noncommercial redistribution of this program.  If you port an common
application using this, or have problems doing so, drop me a line and
I'll try to keep track of things.

	joe@ril3.tamri.com

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