CtDispatch.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, December 7, 1992 3:39 pm PST
Andrew Glassner November 14, 1990 12:50 pm PST
DIRECTORY CtBasic, Commander, Imager, ImagerSample, Rope, SF, ViewerClasses;
CtDispatch: CEDAR DEFINITIONS
~ BEGIN
Types
CmdHandle:  TYPE ~ Commander.Handle;
SampleMaps:  TYPE ~ CtBasic.SampleMaps;
Context:   TYPE ~ Imager.Context;
Box:    TYPE ~ ImagerSample.Box;
ROPE:    TYPE ~ Rope.ROPE;
Viewer:   TYPE ~ ViewerClasses.Viewer;
CtProc:   TYPE ~ PROC [          -- Must not be nested
       viewer: Viewer ¬ NIL,
       maps: SampleMaps ¬ NIL,
       context: Context ¬ NIL,
       cmd: CmdHandle ¬ NIL,
       wDir: ROPE ¬ NIL]
       RETURNS [
       error: ROPE ¬ NIL,
       affect: Box ¬ ImagerSample.maxBox]; -- region affected by CtProc
OpType:   TYPE ~ {ct, cm};
Op:    TYPE ~ RECORD [
name:      ROPE ¬ NIL,
type:      OpType ¬ ct,
proc:      CtProc ¬ NIL,
usage:      ROPE ¬ NIL,
needViewer:    BOOL ¬ TRUE,
makeViewer:    BOOL ¬ TRUE];
Ops:    TYPE ~ REF OpsSequence;
OpsSequence:  TYPE ~ RECORD [length: NAT ¬ 0, s: SEQUENCE maxLength: NAT OF Op];
Color Trix Registry
If an op is registered with proc = NIL, then usage is used only when listing available options.
RegisterCmOp: PROC [name: ROPE, proc: CtProc, usage: ROPE];
Register a color map command proc with the Color Trix dispatcher.
proc is NOT called from within a ViewerClasses.PaintProc.
RegisterCtOp: PROC [
name: ROPE,
proc: CtProc,
usage: ROPE,
needViewer: BOOL ¬ TRUE,
makeViewer: BOOL ¬ TRUE];
Register a color trix command proc with the Color Trix dispatcher.
If needViewer is false, then proc is called without viewer, context, or maps.
If makeViewer is false, then, if the ``current'' ColorTrix viewer is NIL, proc is not called.
If needViewer, then, when called, proc is called within a PaintProc.
If called within PaintProc and proc needs to create any new viewers:
Do so in the column opposite from that containing proc.viewer, or
Do so within a forked process.
GetCmOp: PROC [name: ROPE] RETURNS [Op];
Return the named color trix map op.
GetCtOp: PROC [name: ROPE] RETURNS [Op];
Return the named color trix op.
UnregisterAll: PROC;
Unregister all the registered color trix and color trix map operations.
Dispatcher
Dispatch: Commander.CommandProc;
Parse the command line and dispatch the command.
Box Support
GetBox: PROC [viewer: Viewer, cmd: CmdHandle, clip: Box ¬ SF.maxBox] RETURNS [Box];
Search for -w arguments and return the resulting box, clipped against context and clip.
END.