BiAxials.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Spreitze, June 7, 1991 8:43 am PDT
DIRECTORY Atom, BiScrollers, Cursors, Icons, Imager, Menus, Rope, TIPUser, ViewerClasses;
BiAxials: CEDAR DEFINITIONS
= BEGIN
LORA: TYPE ~ LIST OF REF ANY;
ROPE: TYPE ~ Rope.ROPE;
VEC: TYPE ~ Imager.VEC;
Box: TYPE ~ Imager.Box;
Font: TYPE ~ Imager.Font;
Viewer: TYPE ~ ViewerClasses.Viewer;
BiScrollerClass: TYPE ~ BiScrollers.BiScrollerClass;
BiScroller: TYPE ~ BiScrollers.BiScroller;
BiAxial: TYPE ~ BiScroller;
Class: TYPE ~ REF ClassRep;
ClassRep: TYPE ~ RECORD [
private: ClassPrivate,
classData: REF ANY
];
ClassPrivate: TYPE ~ REF ClassPrivateRep;
ClassPrivateRep: TYPE; --private to BiAxials impl
ImageDestination: TYPE ~ {screen, print};
ClassCommon: TYPE = RECORD [--just like a BiScrollers.ClassCommon, except that the PaintProc takes an additional argument, and there's a property list.
flavor: ATOM,
extrema: BiScrollers.ExtremaProc,
notify: ViewerClasses.NotifyProc ¬ NIL,
bsUserAction: BiScrollers.BSUserActionProc ¬ NIL,
paint: PaintProc ¬ NIL,
modify: ViewerClasses.ModifyProc ¬ NIL,
destroy: ViewerClasses.DestroyProc ¬ NIL,
copy: ViewerClasses.CopyProc ¬ NIL,
set: ViewerClasses.SetProc ¬ NIL,
get: ViewerClasses.GetProc ¬ NIL,
init: ViewerClasses.InitProc ¬ NIL,
finish: LORA ¬ NIL,
Passed to Notify when mouse leaves an Activated BiScroller
save: ViewerClasses.SaveProc ¬ NIL,
caption: ViewerClasses.CaptionProc ¬ NIL,
adjust: ViewerClasses.AdjustProc ¬ NIL,
menu: Menus.Menu ¬ NIL,
tipTable: TIPUser.TIPTable ¬ NIL,
icon: Icons.IconFlavor ¬ document,
cursor: Cursors.CursorType ¬ textPointer,
mayStretch: BOOLEAN ¬ TRUE,
OK to scale X and Y differently?
offsetsMustBeIntegers, preferIntegerCoefficients: BOOL ¬ FALSE,
vanilla: BiScrollers.TransformGenerator ¬ NIL --means GenID--,
preserve: BiScrollers.PreservationPair ¬ [0.5, 0.5],
What stays put when viewer grows/shrinks.
props: Atom.PropList ¬ NIL
];
PaintProc: TYPE ~ PROC [self: Viewer, context: Imager.Context, bounds: Box, dest: ImageDestination, whatChanged: REF ANY, clear: BOOL] RETURNS [quit: BOOL ¬ FALSE];
bounds is a reasonably tight upper bound on the clipping region.
CreateClass: PROC [bsStyle: BiScrollers.BiScrollerStyle, bcc: ClassCommon, classData: REF ANY ¬ NIL] RETURNS [Class];
DecomposeClass: PROC [Class] RETURNS [bsClass: BiScrollerClass, bcc: ClassCommon, classData: REF ANY];
CreateDrawingButton: PROC
[
viewerInfo: ViewerClasses.ViewerRec,
ba: BiAxial,
font: Font--for button's text-- ¬ NIL]
RETURNS [button: Viewer];
ToIP: PROC [ba: BiAxial, fileName, defaultExtension: ROPE ¬ NIL] RETURNS [writtenName: ROPE, width, height: REAL];
Writes an Interpress master, at same size as on screen, which is returned in inches. If the fileName has no extension, and defaultExtension#NIL, it's appended (defaultExtension should include the dot). If fileName=NIL, Cat[Viewer's name, defaultExtension] is used. File system errors may be raised.
LabelPolicies: TYPE ~ ARRAY Axis OF LabelPolicy;
Axis: TYPE ~ BiScrollers.Axis;
LabelPolicy: TYPE ~ REF LabelPolicyRep;
LabelPolicyRep: TYPE ~ RECORD [
EstimateLabelSize: PROC [LabelPolicy, Axis] RETURNS [VEC--Viewer scale--],
EnumerateTicks: PROC [
labelPolicy: LabelPolicy,
ba: BiAxial,
axis: Axis,
imageDest: ImageDestination,
bMin, bMax: REAL, --bounds of visible area for ticks, client cordinates--
aMin, aMax: REAL, --intersection of above with extent of client data--
labelWidthEstc: REAL, --the estimate, appropriately scaled
ctx: Imager.Context--Viewer coordinates--,
ConsumeTick: PROC [
coord: REAL--in client cordinates--,
labelBounds: Box--Viewer scale--,
DrawLabel: PROC [org: VEC] ¬ NIL
If non-NIL, draws into labelBounds+org.
]
],
props: Atom.PropList ¬ NIL,
data: REF ANY ¬ NIL];
Create: PROC [class: Class, labelPolicies: LabelPolicies, info: ViewerClasses.ViewerRec, paint: BOOL ¬ TRUE] RETURNS [BiAxial];
Decompose: PROC [BiAxial] RETURNS [class: Class, labelPolicies: LabelPolicies, clientData: REF ANY, bs: BiScroller];
ClientDataOf: PROC [BiAxial] RETURNS [REF ANY];
Returns what was in info.data in call on Create. BiScrollers.ClientDataOf[ba] won't return that.
CreateLinearLabelPolicy: PROC
[
axis: Axis,
format: ROPE, --produces at most labelChars chars
labelChars: NAT,
ctl: LinearCoordToLabel,
font: ARRAY ImageDestination OF Font ¬ ALL[NIL] --NIL means pick a standard default
]
RETURNS [LabelPolicy];
Returns a policy that puts ticks at regular intervals.
LinearCoordToLabel: TYPE ~ RECORD [
log: BOOL,
cc: REAL,
bc: REAL,
bt: REAL ¬ 10.0,
zc: REAL ¬ 0.0];
This represents the function from client coordinate x to label value l, and tick choosing policy.
If logarithmic:
At client coord x the label is cc * bc ^ x if x>zc, 0 otherwise.
The tick labels are integer powers of bt ^ (n^p) [except for those that are forced to be 0], for some integer n and for p being +1 or -1.
If not logarithmic:
At client coord x the label is cc + bc * x.
The tick labels are multiples of C * 10^n, for some integer n and for C being 1, 2, or 5.
RealSeq: TYPE ~ REF RealSequence;
RealSequence: TYPE ~ RECORD [elts: SEQUENCE length: NAT OF REAL];
PositionalCeiling: PROC [x, base, lnBase: REAL, coefs: RealSeq] RETURNS [REAL];
rounds x up to the nearest (base**n)*coef. Coefs are in increasing order, starting with 1, and ending with something less than base.
HarmonicCeiling: PROC [x: REAL] RETURNS [REAL];
x > 0. Returns least n+-1 >= x.
HarmonicFloor: PROC [x: REAL] RETURNS [REAL];
x > 0. Returns greatest n+-1 <= x.
END.