XTSetter.mesa
Copyright Ó 1987, 1992 by Xerox Corporation. All rights reserved.
Jean-Marc Frailong, February 8, 1989 9:24:26 pm PST
Viewer tool for XNS formatting and printing
Weiser, January 21, 1991 11:32 pm PST
DIRECTORY
Atom USING [PutPropOnList],
BasicTime USING [GMT],
ImagerInterpress USING [Ref],
IO USING [STREAM],
Rope USING [ROPE],
ViewerClasses USING [Viewer, ViewerClass],
ViewerOps USING [AddProp],
XNSPrint USING [Properties];
Tool structure
Tool: TYPE ~ REF ToolRep;
ToolRep:
TYPE;
A Tool is the user handle onto an XNS printer through XTSetter. Internal details of the tool structure are not accessible to the user.
Options: TYPE ~ REF OptionsRep;
OptionsRep:
TYPE ~
RECORD [
keepIP: BOOL ¬ FALSE, -- TRUE when interpress files generated by XTSetter should be kept instead of thrown away
compress: BOOL ¬ FALSE, -- TRUE when compresed files should be sent to printer
copyCount: CARD16 ¬ 1, -- number of copies to be printed
device: ROPE ¬ NIL, -- device propertoy to be assigned to root node (if any)
pageFirst: CARD16 ¬ 1, -- first page number to be printed
pageLast: CARD16 ¬ LAST [CARD16], -- last page number to be printed
mediumHint: ROPE ¬ NIL, -- Describes the paper size (or more generally print support) to be used. Defaults to UsLetter format
stapled: BOOL ¬ FALSE, -- TRUE when printer output should be stapled (if supported)
twoSided: BOOL ¬ FALSE, -- TRUE when printer should print on both sides of the paper (if supported)
telephone: ROPE ¬ NIL, -- Phone number to be used to telefax documents - Not yet supported
tiogaStyle: ROPE ¬ NIL, -- Tioga style to be applied if formatting a Tioga document. NIL or "" means use style specified in root node of document
tiogaScale: REAL ¬ 1.0 -- Scale factor to be applied if formatting a Tioga document.
];
Options describe the current settings of options in an XTSetter tool.
Error:
ERROR[why:
ROPE];
-- Raised if unable to access printer
GetTool:
PROC [printer:
ROPE ¬
NIL, new:
BOOL ¬
FALSE]
RETURNS [tool: Tool];
Returns a tool for this printer (use default printer from profile if NIL). If new is FALSE, will try to get an already existing tool. If new is TRUE or no tool for this printer already exists, will try to create a new tool with default options. Will raise Error if the printer does not respond.
DestroyTool:
PROC [tool: Tool];
Destroy this tool. Any print request in progress will not be affected, but there will be no more user feedback since the viewer will be destroyed. This tool will never be returned by GetTool, but may still be used by programs still having a handle onto it. Destroying a tool actually destroys the viewer, the tool really vanishes only when there are no more pointers onto it.
DefaultOptions:
PROC []
RETURNS [options: Options];
Returns a set of default options taken from the user profile.
GetOptions:
PROC [tool: Tool, reset:
BOOL ¬
TRUE]
RETURNS [options: Options];
Returns a copy of the current options for a tool. The returned options may be modified by the user without any effect on the tool. Use SetOptions to modify tool options. If reset is TRUE, some volatile options (copyCount, pageFirst, pageLast) are reset to default values (1, first, last).
Position: TYPE = RECORD [start, length: CARDINAL];
ComponentPositions: TYPE = RECORD [server, dir, subDirs, base, ext, ver: Position];
ExpandName:
PROC[name:
ROPE, wDir:
ROPE ¬
NIL]
RETURNS [fullFName: ROPE ¬ NIL, cp: ComponentPositions, dirOmitted: BOOL];
SetOptions:
PROC [tool: Tool, options: Options];
Forces the current options for a tool.
GetProperties:
PROC [tool: Tool]
RETURNS [printerProperties: XNSPrint.Properties];
Forces the properties of the printer associated to the tool. Printer properties are invariant during the lifetime of a tool.
CreateOptionsViewer:
PROC [tool: Tool];
Makes the options viewer appear in the tool
DestroyOptionsViewer:
PROC [tool: Tool];
Makes the options viewer disappear in the tool
CreateServerStatusViewer:
PROC [tool: Tool];
Makes the printer status viewer appear in the tool
DestroyServerStatusViewer:
PROC [tool: Tool];
Makes the printer status viewer disappear in the tool
Printing requests
All print requests do whatever is possible to do something. No error is ever passed back onto the user, except if an invalid tool is passed along. Instead, errors are printed on the tool feedback typescript or in the message window if the tool has been destroyed.
All print requests use the current tool settings if their options argument is NIL (default value), but users may override current options by passing a specific set of options that will be in effect for this request only and will not change the current tool options.
If a print request results in the creation of an IP master and the keepIP option is TRUE, the IP master will be stored at some reasonable place.
Control is returned to the user before the print object has been formatted and sent to the printer. This implies that users should not destroy the print object after initiating a print requests. If the need arises, it would be possible to provide a call back mechanism informing the user of the completion of a print request.
PrintFile:
PROC [tool: Tool, file:
ROPE, options: Options ¬
NIL];
Print a file using the tool. The file may be an IP master (file name ending in .IP or .Interpress), or a tioga document. In the latter case, it will be formatted first into an IP master and stored in the same directory as the source if possible, else in a temporary directory. The options passed override for this request the current tool settings. If options is NIL, the current tool settings will be used instead.
PrintViewer:
PROC [tool: Tool, v: ViewerClasses.Viewer, options: Options ¬
NIL];
Print a viewer using the tool. First, the viewer is transformed into its top-level ancestor. If the viewer is a tioga document, it will be formatted. If the viewer class has an IP printing property (c.f. IPGenerator), it will be used to format it. In other cases, an attempt will be made to display what can be seen of the viewer onto a single page. The options passed override for this request the current tool settings. If options is NIL, the current tool settings will be used instead.
Screen:
TYPE ~ {bw, left, right, color};
-- the four flavors that may be printed
PrintScreen:
PROC [tool: Tool, screen: Screen, options: Options ¬
NIL];
Print the requested screen or screen portion on a single page.
Viewer to IP mechanism
This section of the interface of of interest only to Viewer class implementors.
It provides a generic mechanism for viewer implementations that require a special viewer -> IP master processing. The printing mechanism is an inherited property: it is first looked up on the specific viewer, then on the viewer class if not found. A default IPProducer is provided by XTSetter that approximates the viewer's paint mechanism (the default IPProducer will not work properly on viewer classes that do not use the Imager in a device-independant fashion to paint heir viewers). As mentionned above, this property is used only for top-level viewers.
Info: TYPE ~ REF InfoRep;
InfoRep:
TYPE ~
RECORD [
date: BasicTime.GMT, -- creation date that should be used on the printed document.
title: ROPE, -- document name that should be used on the printed document.
keptFile: ROPE -- Name of the IP file if it is kept.
];
ProductionProgressProc: TYPE ~ PROC [percent: REAL] RETURNS [stop: BOOL];
IPProducer:
TYPE ~
PROC [source:
REF, options: Options, info: Info, master: ImagerInterpress.Ref, err:
IO.
STREAM, progress: ProductionProgressProc]
RETURNS [pages:
INT ¬ 0];
A IPProducer is expected to produce a complete IP master in the passed master and close it upon completion. The error stream may be used to indicate errors. The progress proc should be called regularly to notify of relative progress expressed in % (i.e. 0.0 at first, increasing to 100.0%). The producer should terminate immediately should the progress proc return TRUE. Source will always NARROW into a ViewerClasses.Viewer. The producer has access to the options as they may impact the formatting process (especially paper size and one/two sided printing). The info parameter contains values that will be used for the printing process itself. They may be modified by the producer if the defaults provided are not adequate. The producer must return the number of pages produced, or a non-positive number if it failed to produce valid results.
SetClassGenerator:
PROC [class: ViewerClasses.ViewerClass, producer: IPProducer] ~
INLINE {
Set the IPProducer for a class of viewers.
This procedure is INLINE to allow clients to set generators prior to loading XTSetter.
class.props ¬ Atom.PutPropOnList[class.props, $IPProducer, NEW [IPProducer ¬ producer]];
};
SetGenerator:
PROC [v: ViewerClasses.Viewer, producer: IPProducer] ~
INLINE {
Set the IPProducer property for a specific viewer.
This procedure is INLINE to allow clients to set generators prior to loading XTSetter.
ViewerOps.AddProp[v, $IPProducer, NEW [IPProducer ¬ producer]];
};
GetGenerator:
PROC [v: ViewerClasses.Viewer]
RETURNS [producer: IPProducer];
Returns the producer used for a specific viewer, using the inheritance mechanism.
PaperSize:
PROC [paper:
ROPE]
RETURNS [length:
REAL, width:
REAL];
Computes the size in millimeters of the type of paper given. length will be 0 for roll paper. width will be 0 if the paper is not known.