GriffinStyle:
CEDAR
DEFINITIONS
~ BEGIN
StyleHandle: TYPE = StyleDefs.StyleHandle;
StringType: TYPE = StyleDefs.StringType;
The Griffin Style machinery is very simple. Each object has a style, which is a REF. There is a current style which can be modified by the style menus (implemented in ControllerMenus).
A NEW object created by Draw or Close gets a COPY of the current style. Equivalent styles will be merged when the file is written. A COPY of an object, however, copies the style REF.
ApplyStyle will give all selected objects the same style REF.
Styles read from a file will be compared to the existing set of styles before generating a new style. Therefore, reading the same file over and over will not create multiple copies of the styles.
CurrentStyle: PROCEDURE RETURNS [StyleHandle];
ControllerMenus changes the value of the current style through this handle.
CopyCurrentStyle: PROCEDURE RETURNS [StyleHandle];
Makes a new StyleHandle. Only copies of the current style are ever stored on objects
SetCurrentStyle: PROC[style: StyleHandle];
called when Indicate Style is bugged and when an object is Modified.
Sets VALUE of current style to the VALUE of the indicated style.
Initialize: PROC; --initialize the current style
For use by GriffinFile.
The Griffin File format understands sharing styles. It puts a list of all unique styles at the front of the file. The same sort of indirection is applied to Fonts. The styles are stored in the objects as numbers.
CreateStyleList and CreateFontList enumerate the existing undeleted objects and create a list of styles and fonts. NumberOfStyle and NumberOfFont do the obvious search. Both style and font numbers start at 1 to correspond to Griffin file conventions.
InternalFontFromFont, FontFromInternalFont and ComputeStringType convert types between the file format and those in StyleDefs
When a file is read, new styles are generated and renamed with NextName.
FindEquivalentStyle is an attempt to eliminate duplication when reading in a file.
NextName: PROCEDURE RETURNS [Rope.ROPE];
Reading in a style from a file changes its name.
Font: TYPE = StyleDefs.Font;
InternalFont: TYPE = GriffinFontDefs.FontDescriptorHandle;
FontSequence: TYPE = REF FontSequenceRec;
FontSequenceRec: TYPE = RECORD[element: SEQUENCE length:NAT OF Font];
StyleSequence: TYPE = REF StyleSequenceRec;
StyleSequenceRec: TYPE = RECORD[element: SEQUENCE length: NAT OF StyleHandle];
CreateStyleList: PROC RETURNS[styles: StyleSequence];
CreateFontList: PROC[styles: StyleSequence] RETURNS[fonts: FontSequence];
NumberOfStyle: PROC[style: StyleHandle, styles: StyleSequence] RETURNS [CARDINAL];
NumberOfFont: PROC[font: Font, fonts: FontSequence] RETURNS[CARDINAL];
FindEquivalentStyle: PROC[style: StyleHandle, styles: StyleSequence] RETURNS [StyleHandle];
InternalFontFromFont: PROC[Font] RETURNS[InternalFont];
FontFromInternalFont: PROC[ifont: InternalFont] RETURNS[Font];
ComputeStringType: PROC[stringRotation: StyleDefs.StringRotation, font: Font] RETURNS[StyleDefs.StringType];
END.