DIRECTORY Atom USING [GetPName], ChoiceButtons USING [GetSelectedButton, SetButtonState, UpdateChoiceButtons], Containers USING [Container, Create], EditSpanSupport USING [Apply], Icons USING [IconFlavor, NewIconFromFile], IO USING [char, PutFR], Labels USING [Set], Menus USING [CreateEntry, CreateMenu, MenuProc, InsertMenuEntry], MessageWindow USING [Append, Blink, Clear], NodeStyle USING [GetReal, RealParam, Ref], NodeStyleOps USING [ApplyAll, ApplyLooks, Create, OfStyle, StyleNameForNode], Rope USING [Cat, Equal, ROPE], StyleToolDefs, StyleToolBuilders, StyleToolConvert USING [GetFontFamily, 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], Commander USING [CommandProc, Register], ViewerClasses USING [Viewer], ViewerOps USING [--DestroyViewer,-- PaintViewer, SetOpenHeight], ViewerTools USING [SetContents]; StyleToolImpl: CEDAR PROGRAM IMPORTS Atom, ChoiceButtons, Commander, Containers, EditSpanSupport, Icons, IO, Labels, Menus, MessageWindow, NodeStyle, NodeStyleOps, Rope, StyleToolBuilders, StyleToolConvert, StyleToolSample, StyleToolToJaM, TEditOps, TextEdit, TextNode, --ViewerEvents,-- ViewerOps, ViewerTools EXPORTS StyleToolDefs = BEGIN OPEN StyleToolDefs; fontFamilyList: PUBLIC LIST OF Rope.ROPE _ LIST["Arrows", "Classic", "Cream", "Cyrillic", "Gacha", "Helvetica", "Hippo", "Logo", "Math", "OldEnglish", "TimesRoman", "Tioga", "None", "Other"]; fontFaceList: PUBLIC LIST OF Rope.ROPE _ LIST["Regular", "Bold", "Italic", "BoldItalic"]; fontAlphabetsList: PUBLIC LIST OF Rope.ROPE _ LIST["CapsAndLower", "CapsAndSmallCaps", "LowerOnly", "CapsOnly"]; fontUnderliningList: PUBLIC LIST OF Rope.ROPE _ LIST["None", "LettersAndDigits", "Visible", "All"]; lineFormattingList: PUBLIC LIST OF Rope.ROPE _ LIST["FlushLeft", "FlushRight", "Justified", "Centered"]; pathTypeList: PUBLIC LIST OF Rope.ROPE _ LIST["Filled", "Outlined", "FilledAndOutlined"]; ruleList: PUBLIC LIST OF Rope.ROPE _ LIST["ScreenRule", "PrintRule", "StyleRule"]; unitsList: PUBLIC LIST OF Rope.ROPE _ LIST["points", "picas", "inches", "centimeters", "millimeters", "didot points", "ems", "ens", "spaces"]; realNumberFormat: PUBLIC Rope.ROPE _ "%-5.2f"; integerFormat: PUBLIC Rope.ROPE _ "%g"; NotUniform: SIGNAL = CODE; styleToolIcon: Icons.IconFlavor = Icons.NewIconFromFile["StyleTool.icons", 2]; layoutIcon: PUBLIC Icons.IconFlavor = Icons.NewIconFromFile["StyleTool.icons", 3]; BuildStyleTool: Commander.CommandProc = TRUSTED BEGIN tool: StyleToolHandle _ NEW[StyleToolHandleRec]; defaultNodeStyle: NodeStyle.Ref; 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: styleToolIcon, scrollable: TRUE -- inhibit user from scrolling contents ]]; 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]; 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]; 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 _ NodeStyleOps.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; 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]; GetName[handle: handle, style: TRUE]; GetName[handle: handle, style: FALSE]; ViewerTools.SetContents[handle.looksData.textViewer, NIL]; GetFormat[handle: handle]; END; ShowLooksProc: Menus.MenuProc = BEGIN handle: StyleToolHandle _ NARROW[clientData]; GetName[handle: handle, style: TRUE]; 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 { 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: ATOM _ NIL; viewer: ViewerClasses.Viewer _ IF style THEN handle.styleNameData.textViewer ELSE handle.formatNameData.textViewer; Get: PROCEDURE [node: TextNode.Ref] = { firstName: ATOM _ IF style THEN NodeStyleOps.StyleNameForNode[node] ELSE node.formatName; IF name = NIL 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, Atom.GetPName[name]]; }; CheckPSel: PROC [pSel: TEditDocument.Selection, typescriptOK: BOOL _ FALSE] RETURNS [ok: BOOLEAN] = { IF pSel#NIL AND pSel.viewer#NIL AND (pSel.viewer.class.flavor=$Text OR (typescriptOK AND pSel.viewer.class.flavor=$Typescript)) THEN RETURN [TRUE]; MessageWindow.Append["Please make a text selection.",TRUE]; MessageWindow.Blink[]; RETURN [FALSE] }; GetLooks: PROCEDURE [handle: StyleToolHandle] = { pSel: TEditDocument.Selection = TEditOps.GetSelData[]; looks: TextLooks.Looks; looksRope: Rope.ROPE; first: BOOLEAN _ TRUE; span: TextNode.Span; nodeStyle: NodeStyle.Ref _ NodeStyleOps.Create[]; looksStyle: NodeStyle.Ref _ NodeStyleOps.Create[]; ruleStyle: NodeStyleOps.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.PutFR["%g", IO.char[c]]]; ENDLOOP; ViewerTools.SetContents[handle.looksData.textViewer, looksRope]; NodeStyleOps.ApplyAll[nodeStyle, pSel.start.pos.node, ruleStyle]; handle.nodeInfo _ nodeStyle; looksStyle^ _ nodeStyle^; NodeStyleOps.ApplyLooks[looksStyle, looks, ruleStyle]; handle.looksInfo _ looksStyle; UpdateDisplayViewer[handle, looksStyle]; }; GetFormat: PROCEDURE [handle: StyleToolHandle] = { nodeStyle: NodeStyle.Ref _ NodeStyleOps.Create[]; pSel: TEditDocument.Selection = TEditOps.GetSelData[]; ruleStyle: NodeStyleOps.OfStyle _ GetRuleStyle[handle]; IF ~CheckPSel[pSel] THEN RETURN; NodeStyleOps.ApplyAll[nodeStyle, pSel.start.pos.node, ruleStyle]; handle.nodeInfo _ nodeStyle; UpdateDisplayViewer[handle, nodeStyle]; }; GetRuleStyle: PROCEDURE [handle: StyleToolHandle] RETURNS [NodeStyleOps.OfStyle] = BEGIN 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]; ENDCASE => ERROR; END; UpdateDisplayViewer: PROCEDURE [handle: StyleToolHandle, styleInfo: NodeStyle.Ref] = BEGIN ruleStyle: NodeStyleOps.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; UpdateValueAndUnits[handle.outer, handle.display.fontSizeInfo, NodeStyle.GetReal[styleInfo, fontSize]]; 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.GetReal[styleInfo, leftIndent]]; UpdateValueAndUnits[handle.outer, handle.display.rightIndentInfo, NodeStyle.GetReal[styleInfo, rightIndent]]; UpdateValueAndUnits[handle.outer, handle.display.firstIndentInfo, NodeStyle.GetReal[styleInfo, firstIndent]]; UpdateValueAndUnits[handle.outer, handle.display.restIndentInfo, NodeStyle.GetReal[styleInfo, restIndent]]; UpdateValueAndUnits[handle.outer, handle.display.topIndentInfo, NodeStyle.GetReal[styleInfo, topIndent]]; UpdateValueAndUnits[handle.outer, handle.display.bottomIndentInfo, NodeStyle.GetReal[styleInfo, bottomIndent]]; END; UpdateLeadingInfo: PROCEDURE = BEGIN UpdateValueAndUnits[handle.outer, handle.display.leadingInfo.leading, NodeStyle.GetReal[styleInfo, leading]]; handle.display.leadingInfo.originalStretch _ NodeStyle.GetReal[styleInfo, leadingStretch]; StyleToolBuilders.DisplayRealInViewer[handle.display.leadingInfo.originalStretch, handle.display.leadingInfo.stretch.textViewer]; handle.display.leadingInfo.originalShrink _ NodeStyle.GetReal[styleInfo, leadingShrink]; StyleToolBuilders.DisplayRealInViewer[handle.display.leadingInfo.originalShrink, handle.display.leadingInfo.shrink.textViewer]; UpdateValueAndUnits[handle.outer, handle.display.topLeadingInfo.leading, NodeStyle.GetReal[styleInfo, topLeading]]; handle.display.topLeadingInfo.originalStretch _ NodeStyle.GetReal[styleInfo, topLeadingStretch]; StyleToolBuilders.DisplayRealInViewer[handle.display.topLeadingInfo.originalStretch, handle.display.topLeadingInfo.stretch.textViewer]; handle.display.topLeadingInfo.originalShrink _ NodeStyle.GetReal[styleInfo, topLeadingShrink]; StyleToolBuilders.DisplayRealInViewer[handle.display.topLeadingInfo.originalShrink, handle.display.topLeadingInfo.shrink.textViewer]; UpdateValueAndUnits[handle.outer, handle.display.bottomLeadingInfo.leading, NodeStyle.GetReal[styleInfo, bottomLeading]]; handle.display.bottomLeadingInfo.originalStretch _ NodeStyle.GetReal[styleInfo, bottomLeadingStretch]; StyleToolBuilders.DisplayRealInViewer[handle.display.bottomLeadingInfo.originalStretch, handle.display.bottomLeadingInfo.stretch.textViewer]; handle.display.bottomLeadingInfo.originalShrink _ NodeStyle.GetReal[styleInfo, bottomLeadingShrink]; StyleToolBuilders.DisplayRealInViewer[handle.display.bottomLeadingInfo.originalShrink, handle.display.bottomLeadingInfo.shrink.textViewer]; END; UpdateMiscInfo: PROCEDURE = BEGIN UpdateValueAndUnits[handle.outer, handle.display.vshiftInfo, NodeStyle.GetReal[styleInfo, vshift]]; UpdateValueAndUnits[handle.outer, handle.display.minLineGapInfo, NodeStyle.GetReal[styleInfo, minLineGap]]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, tabStops], handle.display.tabStopsViewer]; ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.lineFormattingChoice, StyleToolConvert.GetLineFormattingChoice[styleInfo.lineFormatting]]; END; UpdatePenaltyInfo: PROCEDURE = BEGIN StyleToolBuilders.DisplayRealInViewer[ NodeStyle.GetReal[styleInfo, pageBreakPenalty], handle.swap.penalty.pageBreakPenalty]; StyleToolBuilders.DisplayRealInViewer[ NodeStyle.GetReal[styleInfo, pageBreakAfterFirstLinePenalty], handle.swap.penalty.afterFirstLinePenalty]; StyleToolBuilders.DisplayRealInViewer[ NodeStyle.GetReal[styleInfo, pageBreakBeforeLastLinePenalty], handle.swap.penalty.beforeLastLinePenalty]; StyleToolBuilders.DisplayRealInViewer[ NodeStyle.GetReal[styleInfo, pageBreakBeforeFirstLinePenalty], handle.swap.penalty.beforeFirstLinePenalty]; StyleToolBuilders.DisplayRealInViewer[ NodeStyle.GetReal[styleInfo, pageBreakAfterLastLinePenalty], handle.swap.penalty.afterLastLinePenalty]; END; UpdatePageLayoutInfo: PROCEDURE = BEGIN UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.pageWidth, NodeStyle.GetReal[styleInfo, pageWidth]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.pageLength, NodeStyle.GetReal[styleInfo, pageLength]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.leftMargin, NodeStyle.GetReal[styleInfo, leftMargin]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.rightMargin, NodeStyle.GetReal[styleInfo, rightMargin]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.topMargin, NodeStyle.GetReal[styleInfo, topMargin]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.bottomMargin, NodeStyle.GetReal[styleInfo, bottomMargin]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.bindingMargin, NodeStyle.GetReal[styleInfo, bindingMargin]]; END; UpdateArtworkInfo: PROCEDURE = BEGIN ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.pathTypeChoice, StyleToolConvert.GetPathTypeChoice[styleInfo.pathType]]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, areaHue], handle.display.areaHueViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, areaSaturation], handle.display.areaSaturationViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, areaBrightness], handle.display.areaBrightnessViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, outlineHue], handle.display.outlineHueViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, outlineSaturation], handle.display.outlineSaturationViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, outlineBrightness], handle.display.outlineBrightnessViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, textHue], handle.display.textHueViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, textSaturation], handle.display.textSaturationViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, textBrightness], handle.display.textBrightnessViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, textRotation], handle.display.textRotationViewer]; StyleToolBuilders.DisplayRealInViewer[NodeStyle.GetReal[styleInfo, lineWeight], handle.display.lineWeightViewer]; END; UpdateFontInfo; UpdateIndentInfo; UpdateLeadingInfo; UpdateMiscInfo; IF ~Rope.Equal["ScreenRule", ChoiceButtons.GetSelectedButton[handle.ruleType], FALSE] THEN { UpdatePenaltyInfo; UpdatePageLayoutInfo; }; END; Commander.Register[ key: "StyleTool", proc: BuildStyleTool, doc: "Create a Tioga style modifying tool" ]; END. dStyleToolImpl.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, February 22, 1984 3:34:35 pm PST Last Edited by: Spreitzer, May 19, 1984 4:19:47 pm PDT Pavel, June 26, 1985 11:50:19 pm PDT ViewerEvents USING [EventProc, RegisterEventProc, ViewerEvent], -- ---- ---- ---- ---- ---- ---- ---- construct the outer container [] _ ViewerEvents.RegisterEventProc[proc: DestroyProc, event: destroy, filter: tool.outer]; DestroyProc: ViewerEvents.EventProc = BEGIN handle: StyleToolHandle _ NARROW[viewer.data]; IF handle.sample.viewer # NIL THEN ViewerOps.DestroyViewer[handle.sample.viewer]; IF handle.layoutGraphics.container # NIL THEN ViewerOps.DestroyViewer[handle.layoutGraphics.container]; END; -- ---- ---- ---- ---- ---- ---- ---- First make sure the style name gets displayed Make sure there are no looks names showing (have nothing to do with the format) First make sure the style name gets displayed Make sure the format name isn't showing (has nothing to do with a look) 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. -- ---- ---- ---- ---- ---- ---- ---- Now display the looks. Now apply them to a display record. First apply the style using the first node in case > 1 Now display the info we got from Apply Looks "Gets" a display record for the selected node(s) Now we can apply the style of the node 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. Now display the info we got from ApplyAll finds out which rule style (ScreenRule, PrintRule or StyleRule) has been selected and returns the corresponsding enumerated type. NOTE: StyleRule really corresponds to base but calling NodeStyleOps.ApplyAll with base as the kind causes things to blow up. Since screen is the default, I chose that. 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) ChoiceButtons.UpdateChoiceButtons[handle.outer, handle.display.fontFaceChoice, StyleToolConvert.GetFontFace[styleInfo.fontFace]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.headerMargin, NodeStyle.GetReal[styleInfo, headerMargin]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.footerMargin, NodeStyle.GetReal[styleInfo, footerMargin]]; UpdateValueAndUnits[handle.swap.layout.outer, handle.swap.layout.lineLength, NodeStyle.GetReal[styleInfo, lineLength]]; StyleToolBuilders.DisplayIntInViewer[NodeStyle.GetInt[styleInfo, columns], handle.swap.layout.column]; Don't update these fields if they're not visible UpdateArtworkInfo; -- ---- ---- ---- ---- ---- ---- ---- Register a command with the CommandTool that will create an instance of our tool. Κ˜codešœ™Kšœ.™.Kšœ3™3Kšœ-™-Kšœ7™7Kšœ6™6Kšœ$™$—K˜šΟk ˜ Kšœœ ˜Kšœœ:˜MKšœ œ˜%Kšœœ ˜Kšœœ˜*Kšœœ˜Kšœœ˜Kšœœ6˜AKšœœ˜+Kšœ œ˜*Kšœ œ;˜MKšœœœ˜K˜K˜KšœœΟcœ^˜…Kšœœ!˜6Kšœœ˜(Kšœœ ˜ Kšœ œ˜Kšœ œ˜"Kšœ œ˜Kšœ œ/˜=Kšœ œ˜(Kšœœ ˜Kšœ œ-™?Kšœ œ1˜@Kšœ œ˜ —K˜K˜KšΠbx œœ˜K˜KšœFœΛ˜šKšœ˜K˜Kšœœ˜K˜Kš œœœœœœ˜ΏKš œœœœœœ,˜YKš œœœœœœ>˜pKš œœœœœœ/˜cKš œœœœœœ5˜hKš œœœœœœ,˜YKš œ œœœœœ)˜RKš œ œœœœœd˜ŽK˜Kšœœœ ˜.Kšœœœ˜'K˜Kšœ œœ˜K˜K˜NKšœ œ@˜RKšœ%™%šΟbœ˜/š˜Kšœœ˜0K˜ K˜Kšœ™˜ Kšœž ˜4Kšœœž<˜JK˜!Kšœž˜.K˜Kšœ œž'˜8K˜—K˜Kšœ[™[K˜Kšœ€œ˜’K˜K˜K˜ŠK˜’K˜ŠK˜K˜Kšœ~œ˜ K˜’K˜K˜Kšœ-ž˜JK˜-K˜(K˜'K˜+Kšœ'ž3˜ZKšœ)˜)K˜ K˜!K˜"K˜,Kšœ2ž˜LKšœ(ž˜?—Kšœ˜—K˜š  œ™%š™Kšœœ™.K™šœœ™"Kšœ.™.K™—Kšœ#œœ:™g—Kšœ™—K˜Kšœ%™%K˜š œ˜$š˜Kšœœ ˜-Kšœœ˜—Kšœ˜—K˜š œ˜#š˜Kšœœ ˜-Kšœœ˜—Kšœ˜—K˜š œ˜"š˜Kšœœ ˜-K˜!K˜"K˜,—Kšœ˜—K˜š œ˜!š˜Kšœœ ˜-Kšœ8œ˜>—Kšœ˜—K˜š  œ˜š˜Kšœœ ˜-Kšœ:œ˜A—Kšœ˜—K˜š œ˜ š˜Kšœœ ˜-K™Kšœ-™-Kšœœ˜%Kšœœ˜&K™KšœO™OKšœ5œ˜:K˜—Kšœ˜—K˜š  œ˜š˜Kšœœ ˜-K™Kšœ-™-Kšœœ˜%K™KšœG™GKšœ:œ˜?K˜—Kšœ˜—K˜š œ˜!š˜Kšœœ ˜-Kšœ/œ˜5K˜$K˜—Kšœ˜—K˜š œ˜$š˜Kšœœ ˜-šœœ˜KšœΑ™ΑK˜KšœVœ˜\K˜Kšœœ˜K˜—K˜Kšœ2œ˜8K˜)K˜—Kšœ˜—K™Kšœ%™%K˜šΟnœ œ"œ˜@K˜6Kšœœœ˜šœ˜šœ˜ Kšœ˜—š˜Kšœ!˜!——K˜š‘œ œ˜'šœ œ˜šœ˜ Kšœ#˜#—š˜Kšœ˜——K˜šœœ˜Kšœž ˜—šœœœ˜šœ˜šœ˜ Kšœ/˜/—š˜Kšœ2˜2—Kšœ˜—K˜Kšœ ˜Kšœ˜—K˜——˜Kšœœœž(˜I—˜šœF˜KKšœœ˜#Kšœœœ˜&Kšœ˜——˜K˜5K˜—K˜š ‘ œœ/œœœœ˜cšœ˜šœœœ œœ œœ'˜‰Kšœœ˜—K˜Kšœ5œ˜;Kšœ˜Kšœœ˜—Kšœ˜—K˜š‘œ œ˜/šœ˜K˜6K˜Kšœœ˜Kšœœœ˜K˜Kšœ1˜1Kšœ2˜2K˜7K˜š‘ œ œ:œœ˜jšœ˜Kšœœ!˜;K˜šœœ˜)K˜3K˜šœœ˜Kšœœ˜Kšœ ˜ Kšœ˜—šœœ œ˜Kšœ?œ˜EK˜7K˜Kšœœ˜ K˜—Kšœ˜—K˜Kšœœ˜ —K˜—K˜š œœœœœ"œ˜MKšœ(œ˜.K˜Kšœ˜K˜—K˜K˜K˜9K˜3K˜)Kšœœž˜>šœœœ˜ šœ ˜Kšœ%œ œ ˜A—Kšœ˜—K™Kšœ™K˜@K™Kšœ;ž ™[KšœA˜AK˜K˜Kšœ6˜6K˜K™Kšœ,™,K˜(—K˜—K˜š‘ œ œ˜0šœ˜Kšœ0™0K˜Kšœ1˜1K˜6K˜7K˜Kšœœœ˜ K˜Kšœ&™&K˜C—˜KšœΌ™Ό—˜K˜—˜Kšœ)™)—˜K˜'—K˜—K˜š‘ œ œœ˜Rš˜Kšœ™K˜Kšœœ4˜Gšœœ˜Kšœ#œœ ˜K˜SK˜—K˜K˜Kšœ™K˜Kšœg˜gK˜–K˜˜—Kšœ˜—K˜š‘œ œ˜š˜Kšœk˜kKšœm˜mKšœm˜mKšœk˜kKšœi˜iKšœo˜o—Kšœ˜—K˜š‘œ œ˜š˜Kšœm˜mKšœZ˜ZK˜KšœX˜X˜K˜—Kšœs˜sKšœ`˜`K˜‡Kšœ^˜^˜…K˜—Kšœy˜yKšœf˜fK˜Kšœd˜dK˜‹—Kšœ˜——˜š‘œ œ˜š˜Kšœc˜cKšœk˜kKšœm˜mK˜™—Kšœ˜—K˜š‘œ œ˜š˜Kšœ}˜}K˜Kšœ˜Kšœ˜K˜Kšœ’˜’KšœŽ˜Ž—Kšœ˜—K˜š‘œ œ˜!š˜Kšœu˜uKšœw˜wK˜Kšœw˜wKšœy˜yK˜Kšœu˜uKšœ{˜{K˜Kšœ{™{Kšœ{™{K™Kšœ}˜}K˜Kšœw™wKšœf™f—Kšœ˜—K˜š‘œ œ˜š˜K˜‡Kšœk˜kKšœy˜yKšœy˜yKšœq˜qKšœ˜Kšœ˜Kšœk˜kKšœy˜yKšœy˜yKšœu˜uKšœq˜q—Kšœ˜—K˜K˜K˜K˜K˜šœMœœ˜\Kšœ0™0K˜K˜K˜—K˜Kšœ™—Kšœ˜—K˜Kšœ%™%K˜KšœQ™QK˜˜K˜K˜K˜*K˜—K˜Kšœ˜—…—Lπhδ