NodeStyleImpl.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Written by Bill Paxton, January 1981
Bill Paxton, December 1, 1982 7:38 am
Maxwell, January 6, 1983 8:46 am
Russ Atkinson, March 7, 1985 3:34:46 am PST
Plass, March 14, 1985 5:00:54 pm PST
Rick Beach, March 21, 1985 2:32:26 pm PST
Doug Wyatt, September 2, 1986 1:15:40 pm PDT
DIRECTORY
NodeStyle USING [DataEntry, DataList, RealInit0, overflow, RealCode, RealParam, Style, TabStop, LeaderTabStop, RuleTabStop, RulesTabStop, TabRealParam],
Real USING [RoundI];
Real Parameters
GetReal:
PUBLIC
PROC [ref: Style, param: RealParam]
RETURNS [value:
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← ref.real[param]) # overflow THEN RETURN [realArray[code]];
RETURN [GetRealOverflow[ref,param]];
};
GetInt:
PUBLIC
PROC [ref: Style, param: RealParam]
RETURNS [value:
INTEGER] ~ {
code: RealCode;
IF (code ← ref.real[param]) # overflow THEN RETURN [intArray[code]];
RETURN [GetIntOverflow[ref,param]];
};
GetRealOverflow:
PROC [ref: Style, param: RealParam]
RETURNS [value:
REAL ← 0.0] ~ {
code: RealCode ← ref.real[param];
IF code # overflow THEN RETURN [realArray[code]];
FOR x: DataList ← ref.dataList, x.next
UNTIL x=
NIL
DO
xx: REF DataEntry.real = NARROW[x];
IF xx.param = param THEN RETURN [xx.value];
ENDLOOP;
ERROR -- failed to find it on the data list --
};
GetIntOverflow:
PROC [ref: Style, param: RealParam]
RETURNS [value:
INTEGER] ~ {
code: RealCode ← ref.real[param];
IF code # overflow THEN RETURN [intArray[code]];
FOR x: DataList ← ref.dataList, x.next
UNTIL x=
NIL
DO
xx: REF DataEntry.real = NARROW[x];
IF xx.param = param THEN RETURN [xx.valueI];
ENDLOOP;
ERROR -- failed to find it on the data list --
};
realArray:
PUBLIC
REF
ARRAY RealCode
OF RealInit0 ←
NEW[
ARRAY RealCode
OF RealInit0];
array of real-valued distances
intArray:
PUBLIC
REF
ARRAY RealCode
OF
INTEGER ←
NEW[
ARRAY RealCode
OF
INTEGER];
parallel array of integer-valued distances
nextFreeRealCode: RealCode ← 1;
next free entry in realArray
reserve entry 0 for 0.0
overflowCount: INT ← 0;
realTableOverflow: PUBLIC ERROR ~ CODE;
IntegerValue:
PUBLIC
PROC [value:
REAL ← 0.0]
RETURNS [
INTEGER] ~ {
RETURN [
SELECT value
FROM
> lastIntegerAsReal => LAST[INTEGER],
< firstIntegerAsReal => FIRST[INTEGER],
ENDCASE => Real.RoundI[value]];
};
lastIntegerAsReal: REAL ← LAST[INTEGER];
firstIntegerAsReal:
REAL ←
FIRST[
INTEGER];
EnterReal:
PUBLIC
ENTRY
PROC [value:
REAL ← 0.0]
RETURNS [code: RealCode] ~ {
ENABLE UNWIND => NULL;
code ← nextFreeRealCode;
FOR c: RealCode
IN [
FIRST[RealCode]..nextFreeRealCode)
DO
IF realArray[c]=value THEN { code ← c; EXIT };
ENDLOOP;
SELECT code
FROM
< nextFreeRealCode => NULL; -- already was in realArray
= overflow => {
-- realArray is full
overflowCount ← overflowCount+1;
ERROR realTableOverflow;
};
= nextFreeRealCode => {
-- enter in realArray
nextFreeRealCode ← nextFreeRealCode+1;
realArray[code] ← value;
intArray[code] ← IntegerValue[value];
};
ENDCASE => ERROR;
};
SetReal:
PUBLIC
PROC [ref: Style, param: RealParam, value:
REAL ← 0.0] ~ {
ref.real[param] ← EnterReal[value !
realTableOverflow => {
ref.real[param] ← overflow;
ref.dataList ← NEW[DataEntry ← [ref.dataList, real[param, value, IntegerValue[value]]]];
CONTINUE }
];
};
Tabs
GetTabLoc:
PUBLIC
PROC [stop: TabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.loc) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,loc]];
};
GetTabLocI:
PUBLIC
PROC [stop: TabStop, s:Style]
RETURNS [
INTEGER] ~ {
code: RealCode;
IF (code ← stop.loc) # overflow THEN RETURN [intArray[code]];
RETURN [GetTabIntOverflow[s,stop,loc]];
};
GetTabLeaderSpacing:
PUBLIC
PROC [stop: LeaderTabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.spacing) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,spacing]];
};
GetTabLeaderSpacingI:
PUBLIC
PROC [stop: LeaderTabStop, s:Style]
RETURNS [
INTEGER] ~ {
code: RealCode;
IF (code ← stop.spacing) # overflow THEN RETURN [intArray[code]];
RETURN [GetTabIntOverflow[s,stop,spacing]];
};
GetTabRuleWeight:
PUBLIC
PROC [stop: RuleTabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.weight) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,weight]];
};
GetTabRuleWeightI:
PUBLIC
PROC [stop: RuleTabStop, s:Style]
RETURNS [
INTEGER] ~ {
code: RealCode;
IF (code ← stop.weight) # overflow THEN RETURN [intArray[code]];
RETURN [GetTabIntOverflow[s,stop,weight]];
};
GetTabRuleVShift:
PUBLIC
PROC [stop: RuleTabStop, s:Style]
RETURNS [
REAL ← 0.0] ~ {
code: RealCode;
IF (code ← stop.vshift) # overflow THEN RETURN [realArray[code]];
RETURN [GetTabOverflow[s,stop,vshift]];
};
GetTabRuleVShiftI:
PUBLIC
PROC [stop: RuleTabStop, s:Style]
RETURNS [
INTEGER] ~ {
code: RealCode;
IF (code ← stop.vshift) # overflow THEN RETURN [intArray[code]];
RETURN [GetTabIntOverflow[s,stop,vshift]];
};
GetTabRealCode:
PUBLIC
PROC [ref: Style, stop: TabStop, which: TabRealParam,
value:
REAL ← 0.0]
RETURNS [code: RealCode] ~ {
code ← EnterReal[value ! realTableOverflow => {
code ← overflow;
ref.dataList ← NEW[DataEntry ← [ref.dataList,
tab[stop, which, value, IntegerValue[value]]]];
CONTINUE }];
};
GetRulesTabCount:
PUBLIC
PROC [stop: RulesTabStop]
RETURNS [count:
INTEGER] ~ {
RETURN [stop.rules.length];
};
GetRulesTabInfo:
PUBLIC
PROC [stop: RulesTabStop, num:
INTEGER]
RETURNS [weight, vshift:
REAL] ~ {
For num in [0..RulesTabCount), returns the weight and vshift values for that rule.
weight ← stop.rules.array[num].weight;
vshift ← stop.rules.array[num].vshift };
GetRulesTabInfoI:
PUBLIC
PROC [stop: RulesTabStop, num:
INTEGER]
RETURNS [weight, vshift:
INTEGER] ~ {
weight ← IntegerValue[stop.rules.array[num].weight];
vshift ← IntegerValue[stop.rules.array[num].vshift] };
GetTabOverflow:
PROC [ref: Style, stop: TabStop, which: TabRealParam]
RETURNS [value:
REAL ← 0.0] ~ {
FOR x: DataList ← ref.dataList, x.next
UNTIL x=
NIL
DO
xx: REF DataEntry.tab = NARROW[x];
IF xx.tabStop=stop AND xx.which=which THEN RETURN [xx.value];
ENDLOOP;
ERROR -- failed to find it on the data list --
};
GetTabIntOverflow:
PROC [ref: Style, stop: TabStop, which: TabRealParam]
RETURNS [value:
INTEGER] ~ {
FOR x: DataList ← ref.dataList, x.next
UNTIL x=
NIL
DO
xx: REF DataEntry.tab = NARROW[x];
IF xx.tabStop=stop AND xx.which=which THEN RETURN [xx.valueI];
ENDLOOP;
ERROR -- failed to find it on the data list --
};
Dimensions
PointsPerPica: PUBLIC REAL ← 12.0;
PointsPerInch: PUBLIC REAL ← 1.0/0.0138370; -- 72.27
PointsPerCentimeter: PUBLIC REAL ← PointsPerInch/2.540;
PointsPerMillimeter: PUBLIC REAL ← PointsPerCentimeter/10;
PointsPerDidot: PUBLIC REAL ← PointsPerCentimeter/26.60;
PointsPerFil: PUBLIC REAL ← 10000.0;
PointsPerFill: PUBLIC REAL ← PointsPerFil*PointsPerFil;
PointsPerFilll: PUBLIC REAL ← PointsPerFill*PointsPerFil;