StyleToolImpl.mesa
Written by Linda Gass on July 13, 1982 1:43 pm
Last Edit by Linda Gass on November 4, 1982 5:15 pm
Last Edited by: Plass, March 28, 1983 3:12 pm
Last Edited by: Beach, May 10, 1983 5:28 pm
DIRECTORY
ChoiceButtons USING [GetSelectedButton, SetButtonState, UpdateChoiceButtons],
Containers USING [Container, Create],
EditSpanSupport USING [Apply],
Icons USING [NewIconFromFile],
IO USING [char, Close, PutFToRope],
Labels USING [Set],
Menus USING [CreateEntry, CreateMenu, MenuProc, InsertMenuEntry],
MessageWindow USING [Append, Blink, Clear],
NameSymbolTable USING [Name, nullName, RopeFromName],
NodeStyle USING [ApplyAll, ApplyLooks, Create, GetBindingMargin, GetBottomMargin,
-- GetColumns, GetFooterMargin,GetHeaderMargin,GetLineLength,
 GetFontSize, GetLeftIndent, GetRightIndent, GetFirstIndent, GetRestIndent, GetTopIndent,
 GetBottomIndent, GetLeading, GetLeadingStretch, GetLeadingShrink, GetTopLeading,
 GetTopLeadingStretch, GetTopLeadingShrink, GetBottomLeading, GetBottomLeadingStretch,
 GetBottomLeadingShrink, GetVShift, GetLeftMargin, GetMinLineGap, GetTabStops,
 GetPageBreakPenalty, GetPageBreakAfterFirstLinePenalty,
 GetPageBreakBeforeLastLinePenalty, GetPageBreakBeforeFirstLinePenalty,
 GetPageBreakAfterLastLinePenalty, GetPageLength, GetPageWidth, GetRightMargin,
GetTopMargin, GetAreaHue, GetAreaSaturation, GetAreaBrightness, GetOutlineHue,
 GetOutlineSaturation, GetOutlineBrightness, GetTextHue, GetTextSaturation,
 GetTextBrightness, GetTextRotation, GetLineWeight, OfStyle, Ref, StyleNameForNode],
Rope USING [Cat, Equal, ROPE],
StyleToolDefs,
StyleToolBuilders,
StyleToolConvert USING [GetFontFamily, -- GetFontFace,
 GetFontAlphabetsChoice, GetFontUnderliningChoice, GetLineFormattingChoice,
 GetPathTypeChoice],
StyleToolSample USING [ApplyFormat, ApplyToSelection],
StyleToolToJaM USING [WriteDisplayInfo],
TEditDocument USING [Selection],
TEditOps USING [GetSelData],
TextEdit USING [FetchLooks, Size],
TextLooks USING [Looks, Look],
TextNode USING [Offset, Ref, RefTextNode, Span, StepForward],
UserExec USING [CommandProc, RegisterCommand],
ViewerClasses USING [Viewer],
ViewerOps USING [CreateViewer, PaintViewer, SetOpenHeight],
ViewerTools USING [SetContents];
StyleToolImpl: CEDAR PROGRAM

IMPORTS ChoiceButtons, Containers, EditSpanSupport, Icons, IO, Labels, Menus, MessageWindow, NameSymbolTable, NodeStyle, Rope, StyleToolBuilders, StyleToolConvert, StyleToolSample, StyleToolToJaM, TEditOps, TextEdit, TextNode, UserExec, ViewerOps, ViewerTools
EXPORTS StyleToolDefs =

BEGIN OPEN StyleToolDefs;

fontFamilyList: PUBLIC LIST OF Rope.ROPELIST["Arrows", "Classic", "Cream", "Cyrillic", "Gacha", "Helvetica", "Hippo", "Logo", "Math", "OldEnglish", "TimesRoman", "Tioga", "None", "Other"];
fontFaceList: PUBLIC LIST OF Rope.ROPELIST["Regular", "Bold", "Italic", "BoldItalic"];
fontAlphabetsList: PUBLIC LIST OF Rope.ROPELIST["CapsAndLower", "CapsAndSmallCaps", "LowerOnly", "CapsOnly"];
fontUnderliningList: PUBLIC LIST OF Rope.ROPELIST["None", "LettersAndDigits", "Visible", "All"];
lineFormattingList: PUBLIC LIST OF Rope.ROPELIST["FlushLeft", "FlushRight", "Justified", "Centered"];
pathTypeList: PUBLIC LIST OF Rope.ROPELIST["Filled", "Outlined", "FilledAndOutlined"];
ruleList: PUBLIC LIST OF Rope.ROPELIST["ScreenRule", "PrintRule", "StyleRule"];
unitsList: PUBLIC LIST OF Rope.ROPELIST["points", "picas", "inches", "centimeters", "millimeters", "didot points", "ems", "ens", "spaces"];

realNumberFormat: PUBLIC Rope.ROPE ← "%-5.2f";
integerFormat: PUBLIC Rope.ROPE ← "%g";

NotUniform: SIGNAL = CODE;
---- ---- ---- ---- ---- ---- ---- ----
BuildStyleTool: UserExec.CommandProc = TRUSTED
BEGIN
tool: StyleToolHandle ← NEW[StyleToolHandleRec];
defaultNodeStyle: NodeStyle.Ref;

-- construct the outer container
tool.outer ← Containers.Create[[
 name: "Style Tool",  -- name displayed in the caption
 iconic: TRUE,   -- so tool will be open and on the screen when first created
 menu: Menus.CreateMenu[lines: 3],
 column: right,   -- initially in the left column
 icon: Icons.NewIconFromFile["StyleTool.icons", 2],
 scrollable: TRUE   -- inhibit user from scrolling contents
 ]];

Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name:
 "SetChangesMode", proc: SetChangesModeProc, fork: TRUE, clientData: tool], line: 2]; 
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name:
 "SetCreateMode", proc: SetCreateModeProc, clientData: tool], line: 2];
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name: "SetToDefault",
 proc: SetToDefaultProc, clientData: tool], line: 2];
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name:
 "ApplyToSelection", proc: ApplySelectionProc, fork: TRUE, clientData: tool], line: 0]; 
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name:
 "ApplyToSample", proc: ApplyFormatProc, clientData: tool], line: 0];
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name: "WriteLook",
 proc: WriteLookProc, clientData: tool], line: 1];
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name:
 "WriteFormatOnly", proc: WriteFormatProc, clientData: tool], line: 1];
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name: "ShowLooks",
 proc: ShowLooksProc, clientData: tool], line: 1];
Menus.InsertMenuEntry[menu: tool.outer.menu, entry: Menus.CreateEntry[name:
 "ShowFormatOnly", proc: ShowFormatProc, clientData: tool], line: 1];

StyleToolBuilders.BuildStyleNameField[tool];  -- build each section in turn
StyleToolBuilders.BuildFormatNameField[tool];
StyleToolBuilders.BuildLooksField[tool];
StyleToolBuilders.BuildRuleField[tool];
StyleToolBuilders.BuildDisplayViewer[tool];
StyleToolBuilders.BuildSwapArea[tool]; -- builds print information field and JaMCodeViewer
defaultNodeStyle ← NodeStyle.Create[];
tool.default ← defaultNodeStyle;
tool.nodeInfo ← defaultNodeStyle;
tool.looksInfo ← defaultNodeStyle;
UpdateDisplayViewer[tool, defaultNodeStyle];
ViewerOps.SetOpenHeight[tool.outer, tool.height];  -- hint our desired height
ViewerOps.PaintViewer[tool.outer, all];     -- reflect above change
END;
---- ---- ---- ---- ---- ---- ---- ----
SetChangesModeProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
handle.changesMode ← TRUE;
END;
SetCreateModeProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
handle.changesMode ← FALSE;
END;
SetToDefaultProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
handle.nodeInfo ← handle.default;
handle.looksInfo ← handle.default;
UpdateDisplayViewer[handle, handle.default];
END;
DestroyProc: Menus.MenuProc = BEGIN
Destroys all the viewers associated with the Style Tool (no longer used)
handle: StyleToolHandle ← NARROW[clientData];
IF ~MessageWindow.Confirm["Style Tool about to be destroyed . . ."] THEN RETURN;
ViewerOps.DestroyViewer[handle.outer];
IF handle.sample.viewer # NIL THEN ViewerOps.DestroyViewer[handle.sample.viewer];
IF handle.layoutGraphics.container # NIL THEN ViewerOps.DestroyViewer[handle.layoutGraphics.container];
END;
WriteFormatProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
StyleToolToJaM.WriteDisplayInfo[handle, handle.default, TRUE];
END;
WriteLookProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
StyleToolToJaM.WriteDisplayInfo[handle, handle.looksInfo, FALSE];
END;
ShowFormatProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
-- First make sure the style name gets displayed
GetName[handle: handle, style: TRUE];
GetName[handle: handle, style: FALSE];
-- make sure there are no looks names showing (have nothing to do with the format)
ViewerTools.SetContents[handle.looksData.textViewer, NIL];
GetFormat[handle: handle];
END;
ShowLooksProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
-- First make sure the style name gets displayed
GetName[handle: handle, style: TRUE];
-- Make sure the format name isn't showing (has nothing to do with a look)
ViewerTools.SetContents[handle.formatNameData.textViewer, NIL];
GetLooks[handle: handle];
END;
ApplyFormatProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
MessageWindow.Append["Applying to sample....", TRUE];
StyleToolSample.ApplyFormat[handle];
MessageWindow.Clear[];
END;
ApplySelectionProc: Menus.MenuProc = BEGIN
handle: StyleToolHandle ← NARROW[clientData];
IF ~handle.userAware THEN {
originally I wanted to use MessageWindow.Confirm here but that cancels the selection. Until there is a better way to accomplish this (ie - guarded menu items) I will use just Append and Blink
MessageWindow.Append["Please make sure you are using a COPY of the actual document.", TRUE];
MessageWindow.Blink[];
handle.userAware ← TRUE;
};
MessageWindow.Append["Applying to selection....", TRUE];
StyleToolSample.ApplyToSelection[handle];
MessageWindow.Clear[];
END;
---- ---- ---- ---- ---- ---- ---- ----
GetName: PROCEDURE [handle: StyleToolHandle, style: BOOLEAN] = {
pSel: TEditDocument.Selection = TEditOps.GetSelData[];
name: NameSymbolTable.Name ← NameSymbolTable.nullName;
viewer: ViewerClasses.Viewer ← IF style THEN handle.styleNameData.textViewer ELSE handle.formatNameData.textViewer;

Get: PROCEDURE [node: TextNode.Ref] = {
firstName: NameSymbolTable.Name ← IF style THEN NodeStyle.StyleNameForNode[node]
  ELSE node.typename;
IF name = NameSymbolTable.nullName THEN name ← firstName -- initialize
ELSE IF name # firstName THEN {
 MessageWindow.Append[IF style THEN "Nodes don't have uniform style. Using first."
  ELSE "Nodes don't have uniform display. Using first.", TRUE];
 MessageWindow.Blink[];
SIGNAL NotUniform};
 };
IF ~CheckPSel[pSel] THEN RETURN; -- Checks that a selection has been made
FOR node: TextNode.Ref ← pSel.start.pos.node, TextNode.StepForward[node] DO
 Get[node ! NotUniform => CONTINUE];
IF node = pSel.end.pos.node THEN EXIT;
ENDLOOP;
ViewerTools.SetContents[viewer, NameSymbolTable.RopeFromName[name]];
};
CheckPSel: PROC [pSel: TEditDocument.Selection, typescriptOK: BOOLFALSE]
RETURNS [ok: BOOLEAN] = { OPEN MessageWindow;
IF pSel#NIL AND pSel.viewer#NIL AND
 (pSel.viewer.class.flavor=$Text OR (typescriptOK AND pSel.viewer.class.flavor=$Typescript))
THEN RETURN [TRUE];
Append["Please make a text selection.",TRUE];
Blink[]; RETURN [FALSE] };
GetLooks: PROCEDURE [handle: StyleToolHandle] = {
pSel: TEditDocument.Selection = TEditOps.GetSelData[];
looks: TextLooks.Looks;
looksRope: Rope.ROPE;
first: BOOLEANTRUE;
span: TextNode.Span;
nodeStyle: NodeStyle.Ref ← NodeStyle.Create[];
looksStyle: NodeStyle.Ref ← NodeStyle.Create[];
ruleStyle: NodeStyle.OfStyle ← GetRuleStyle[handle];
GetSelLooks: PROCEDURE [node: TextNode.RefTextNode, start, len: TextNode.Offset]
RETURNS [stop: BOOLEAN] = {
end: TextNode.Offset ← MIN[TextEdit.Size[node], start+len];
FOR i: TextNode.Offset IN [start..end) DO
 lks: TextLooks.Looks ← TextEdit.FetchLooks[node,i];
IF first THEN { first ← FALSE; looks ← lks }
ELSE IF lks # looks THEN {
  MessageWindow.Append["Selection does not have uniform looks.", TRUE];
  MessageWindow.Append[" Using looks from first char."];
  MessageWindow.Blink[];
  RETURN[TRUE];
  };
ENDLOOP;
RETURN[FALSE]
};
IF pSel = NIL OR pSel.viewer = NIL OR pSel.viewer.class.flavor # $Text THEN {
 MessageWindow.Append["Make selection.", TRUE];
 MessageWindow.Blink[];
RETURN;
 };
looksRope ← "";
span.start ← [pSel.start.pos.node, pSel.start.pos.where];
span.end ← [pSel.end.pos.node, pSel.end.pos.where];
EditSpanSupport.Apply[span, GetSelLooks];
IF first THEN looks ← pSel.looks; -- null selection, use caret
FOR c: CHAR IN TextLooks.Look DO
IF looks[c] THEN looksRope ← Rope.Cat[looksRope, " ", IO.PutFToRope["%g", IO.char[c]]];
ENDLOOP;
-- now display the looks.
ViewerTools.SetContents[handle.looksData.textViewer, looksRope];
-- now apply them to a display record. First apply the style
NodeStyle.ApplyAll[nodeStyle, pSel.start.pos.node, ruleStyle]; -- using the first node in case > 1
handle.nodeInfo ← nodeStyle;
looksStyle^ ← nodeStyle^;
NodeStyle.ApplyLooks[looksStyle, looks, ruleStyle];
handle.looksInfo ← looksStyle;
-- Now display the info we got from Apply Looks
UpdateDisplayViewer[handle, looksStyle];
};
GetFormat: PROCEDURE [handle: StyleToolHandle] = {
"gets" a display record for the selected node(s)
nodeStyle: NodeStyle.Ref ← NodeStyle.Create[];
pSel: TEditDocument.Selection = TEditOps.GetSelData[];
ruleStyle: NodeStyle.OfStyle ← GetRuleStyle[handle];

IF ~CheckPSel[pSel] THEN RETURN;
now we can apply the style of the node
NodeStyle.ApplyAll[nodeStyle, pSel.start.pos.node, ruleStyle];
we use the 1st node in case the nodes in the selection weren't consistent. We dont need to test for consistency here because we guarantee this has been done before calling this procedure.
handle.nodeInfo ← nodeStyle;
Now display the info we got from ApplyAll
UpdateDisplayViewer[handle, nodeStyle];
};
GetRuleStyle: PROCEDURE [handle: StyleToolHandle] RETURNS [NodeStyle.OfStyle] = BEGIN
finds out which rule style (ScreenRule, PrintRule or StyleRule) has been selected and returns the corresponsding enumerated type.
ruleRope: Rope.ROPE ← ChoiceButtons.GetSelectedButton[handle.ruleType];
SELECT TRUE FROM
 Rope.Equal[ruleRope, "ScreenRule", FALSE] => RETURN[screen];
 Rope.Equal[ruleRope, "PrintRule", FALSE]  => RETURN[print];
 Rope.Equal[ruleRope, "StyleRule", FALSE]  => RETURN[screen];
NOTE: StyleRule really corresponds to base but calling NodeStyle.ApplyAll with base as
the kind causes things to blow up. Since screen is the default, I chose that.
 ENDCASE => ERROR;
END;
UpdateDisplayViewer: PROCEDURE [handle: StyleToolHandle, styleInfo: NodeStyle.Ref] = BEGIN
makes incremental changes to the display viewer. Depending upon which rule style is on, certain parts of the display viewer are not displayed (eg - if the rule style is ScreenRule, then it's not necessary to deal with any of the page break penalties)
ruleStyle: NodeStyle.OfStyle ← GetRuleStyle[handle];
UpdateValueAndUnits: PROCEDURE [container: Containers.Container, item: ValueAndUnitsRef, value: REAL, units: Rope.ROPE ← "points"] = BEGIN
StyleToolBuilders.DisplayRealInViewer[value, item.valueData.textViewer];
item.originalValue ← value;
ChoiceButtons.UpdateChoiceButtons[container, item.units, units];
item.originalUnits ← units
END;
UpdateFontFace: PROCEDURE = BEGIN
SELECT styleInfo.fontFace FROM
 Regular => { ChoiceButtons.SetButtonState[handle.display.boldFontFace.button, off];
      handle.display.boldFontFace.state ← off;
      ChoiceButtons.SetButtonState[handle.display.italicFontFace.button, off];
      handle.display.italicFontFace.state ← off;
      };
 Bold  => { ChoiceButtons.SetButtonState[handle.display.boldFontFace.button, on];
      handle.display.boldFontFace.state ← on;
      ChoiceButtons.SetButtonState[handle.display.italicFontFace.button, off];
      handle.display.italicFontFace.state ← off;
      };
 Italic  => { ChoiceButtons.SetButtonState[handle.display.boldFontFace.button, off];
      handle.display.boldFontFace.state ← off;
      ChoiceButtons.SetButtonState[handle.display.italicFontFace.button, on];
      handle.display.italicFontFace.state ← on;
      };
 BoldItalic => { ChoiceButtons.SetButtonState[handle.display.boldFontFace.button, on];
      handle.display.boldFontFace.state ← on;
      ChoiceButtons.SetButtonState[handle.display.italicFontFace.button, on];
      handle.display.italicFontFace.state ← on;
      };
ENDCASE => ERROR;
END;
UpdateFontInfo: PROCEDURE = BEGIN
fontFamilyInfo: FontFamilyRec←StyleToolConvert.GetFontFamily[styleInfo.name[fontFamily]];
ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.fontFamilyChoice,
 fontFamilyInfo.name];
IF Rope.Equal[fontFamilyInfo.name, "other", FALSE] THEN {
 Labels.Set[handle.display.fontFamilyOtherLabel, "Font Name:"];
 ViewerTools.SetContents[handle.display.fontFamilyOtherViewer, fontFamilyInfo.text];
 };
UpdateFontFace;
ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.fontFaceChoice,
StyleToolConvert.GetFontFace[styleInfo.fontFace]];
UpdateValueAndUnits[handle.outer, handle.display.fontSizeInfo,
NodeStyle.GetFontSize[styleInfo]];
ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.fontAlphabetsChoice,
StyleToolConvert.GetFontAlphabetsChoice[styleInfo.fontAlphabets]];
ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.fontUnderliningChoice,
StyleToolConvert.GetFontUnderliningChoice[styleInfo.underlining]];
END;
UpdateIndentInfo: PROCEDURE = BEGIN
UpdateValueAndUnits[handle.outer, handle.display.leftIndentInfo,
 NodeStyle.GetLeftIndent[styleInfo]];
UpdateValueAndUnits[handle.outer, handle.display.rightIndentInfo,
 NodeStyle.GetRightIndent[styleInfo]];
UpdateValueAndUnits[handle.outer, handle.display.firstIndentInfo,
 NodeStyle.GetFirstIndent[styleInfo]];
UpdateValueAndUnits[handle.outer, handle.display.restIndentInfo,
 NodeStyle.GetRestIndent[styleInfo]];
UpdateValueAndUnits[handle.outer, handle.display.topIndentInfo,
 NodeStyle.GetTopIndent[styleInfo]];
UpdateValueAndUnits[handle.outer, handle.display.bottomIndentInfo,
 NodeStyle.GetBottomIndent[styleInfo]];
END;
UpdateLeadingInfo: PROCEDURE = BEGIN
UpdateValueAndUnits[handle.outer, handle.display.leadingInfo.leading,
 NodeStyle.GetLeading[styleInfo]];
handle.display.leadingInfo.originalStretch ← NodeStyle.GetLeadingStretch[styleInfo];
StyleToolBuilders.DisplayRealInViewer[handle.display.leadingInfo.originalStretch,
 handle.display.leadingInfo.stretch.textViewer];
handle.display.leadingInfo.originalShrink ← NodeStyle.GetLeadingShrink[styleInfo];
StyleToolBuilders.DisplayRealInViewer[handle.display.leadingInfo.originalShrink,
 handle.display.leadingInfo.shrink.textViewer];
   
UpdateValueAndUnits[handle.outer, handle.display.topLeadingInfo.leading,
 NodeStyle.GetTopLeading[styleInfo]];
handle.display.topLeadingInfo.originalStretch ← NodeStyle.GetTopLeadingStretch[styleInfo];
StyleToolBuilders.DisplayRealInViewer[handle.display.topLeadingInfo.originalStretch,
 handle.display.topLeadingInfo.stretch.textViewer];
handle.display.topLeadingInfo.originalShrink ← NodeStyle.GetTopLeadingShrink[styleInfo];
StyleToolBuilders.DisplayRealInViewer[handle.display.topLeadingInfo.originalShrink,
 handle.display.topLeadingInfo.shrink.textViewer];
   
UpdateValueAndUnits[handle.outer, handle.display.bottomLeadingInfo.leading,
 NodeStyle.GetBottomLeading[styleInfo]];
handle.display.bottomLeadingInfo.originalStretch ←
 NodeStyle.GetBottomLeadingStretch[styleInfo];
StyleToolBuilders.DisplayRealInViewer[handle.display.bottomLeadingInfo.originalStretch,
 handle.display.bottomLeadingInfo.stretch.textViewer];
handle.display.bottomLeadingInfo.originalShrink ←
 NodeStyle.GetBottomLeadingShrink[styleInfo];
StyleToolBuilders.DisplayRealInViewer[handle.display.bottomLeadingInfo.originalShrink,
 handle.display.bottomLeadingInfo.shrink.textViewer];
END;
UpdateMiscInfo: PROCEDURE = BEGIN
UpdateValueAndUnits[handle.outer, handle.display.vshiftInfo,
 NodeStyle.GetVShift[styleInfo]];
UpdateValueAndUnits[handle.outer, handle.display.minLineGapInfo,
 NodeStyle.GetMinLineGap[styleInfo]];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetTabStops[styleInfo],
 handle.display.tabStopsViewer];
ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.lineFormattingChoice,
 StyleToolConvert.GetLineFormattingChoice[styleInfo.lineFormatting]];
END;
UpdatePenaltyInfo: PROCEDURE = BEGIN
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetPageBreakPenalty[styleInfo],
 handle.swap.penalty.pageBreakPenalty];
StyleToolBuilders.DisplayRealInViewer[
 NodeStyle.GetPageBreakAfterFirstLinePenalty[styleInfo],
 handle.swap.penalty.afterFirstLinePenalty];
StyleToolBuilders.DisplayRealInViewer[
 NodeStyle.GetPageBreakBeforeLastLinePenalty[styleInfo],
 handle.swap.penalty.beforeLastLinePenalty];
StyleToolBuilders.DisplayRealInViewer[
 NodeStyle.GetPageBreakBeforeFirstLinePenalty[styleInfo],
 handle.swap.penalty.beforeFirstLinePenalty];
StyleToolBuilders.DisplayRealInViewer[
 NodeStyle.GetPageBreakAfterLastLinePenalty[styleInfo],
 handle.swap.penalty.afterLastLinePenalty];
END;
UpdatePageLayoutInfo: PROCEDURE = BEGIN
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.pageWidth,
 NodeStyle.GetPageWidth[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.pageLength,
 NodeStyle.GetPageLength[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.leftMargin,
 NodeStyle.GetLeftMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.rightMargin,
 NodeStyle.GetRightMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.topMargin,
 NodeStyle.GetTopMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.bottomMargin,
 NodeStyle.GetBottomMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.headerMargin,
 NodeStyle.GetHeaderMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.footerMargin,
 NodeStyle.GetFooterMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.bindingMargin,
 NodeStyle.GetBindingMargin[styleInfo]];
UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.lineLength,
 NodeStyle.GetLineLength[styleInfo]];
StyleToolBuilders.DisplayIntInViewer[NodeStyle.GetColumns[styleInfo],
 handle.swap.layout.column];
END;
UpdateArtworkInfo: PROCEDURE = BEGIN
ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.pathTypeChoice,
 StyleToolConvert.GetPathTypeChoice[styleInfo.pathType]];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetAreaHue[styleInfo],
 handle.display.areaHueViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetAreaSaturation[styleInfo],
 handle.display.areaSaturationViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetAreaBrightness[styleInfo],
 handle.display.areaBrightnessViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetOutlineHue[styleInfo],
 handle.display.outlineHueViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetOutlineSaturation[styleInfo],
 handle.display.outlineSaturationViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetOutlineBrightness[styleInfo],
 handle.display.outlineBrightnessViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetTextHue[styleInfo],
 handle.display.textHueViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetTextSaturation[styleInfo],
 handle.display.textSaturationViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetTextBrightness[styleInfo],
 handle.display.textBrightnessViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetTextRotation[styleInfo],
 handle.display.textRotationViewer];
StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetLineWeight[styleInfo],
 handle.display.lineWeightViewer];
END;
UpdateFontInfo;
UpdateIndentInfo;
UpdateLeadingInfo;
UpdateMiscInfo;
IF ~Rope.Equal["ScreenRule", ChoiceButtons.GetSelectedButton[handle.ruleType], FALSE] THEN {
-- dont update these fields if they're not visible
 UpdatePenaltyInfo;
 UpdatePageLayoutInfo;
 };
UpdateArtworkInfo;
END;
---- ---- ---- ---- ---- ---- ---- ----
Below is the actual start code.
Register a command with the UserExec that will create an instance of our tool.
UserExec.RegisterCommand[
 name: "StyleTool",
 proc: BuildStyleTool,
 briefDoc: "Create a Tioga style modifying tool"
 ];

END.