<> <> <> <> <> <> <> <> <<>> <> <<>> DIRECTORY Convert, Feedback, FeedbackTypes, FileNames, GGBasicTypes, GGBoundBox, GGCoreOps, GGCoreTypes, GGFont, GGFromImager, GGHistoryTypes, GGInterfaceTypes, GGModelTypes, GGParseIn, GGParseOut, GGProps, GGScene, GGSegment, GGSegmentTypes, GGShapes, GGSlice, GGSliceOps, GGTransform, GGUtility, Imager, ImagerFont, ImagerSys, ImagerTransformation, ImagerTypeface, IO, Lines2d, NodeStyle, PFS, Real, RealFns, Rope, SF, Vector2, Vectors2d; GGSliceImplB: CEDAR PROGRAM IMPORTS Convert, Feedback, FileNames, GGBoundBox, GGCoreOps, GGFont, GGFromImager, GGParseIn, GGParseOut, GGProps, GGScene, GGSegment, GGShapes, GGSlice, GGSliceOps, GGTransform, GGUtility, Imager, ImagerFont, ImagerSys, ImagerTransformation, ImagerTypeface, IO, Lines2d, PFS, Real, RealFns, Rope, Vector2, Vectors2d EXPORTS GGSlice = BEGIN << [Artwork node; type 'ArtworkInterpress on' to command tool] >> <<Text Points as shown>> < left, 1=> top, 2=> right, 3=> bottom, 4 => baseline, 5 => horizontal centerline, 6 => vertical centerline>> BoundBox: TYPE = GGCoreTypes.BoundBox; BoundBoxObj: TYPE = GGCoreTypes.BoundBoxObj; Camera: TYPE = GGModelTypes.Camera; CameraObj: TYPE = GGModelTypes.CameraObj; Color: TYPE = Imager.Color; DefaultData: TYPE = GGModelTypes.DefaultData; DisplayStyle: TYPE = GGModelTypes.DisplayStyle; EditConstraints: TYPE = GGModelTypes.EditConstraints; ExtendMode: TYPE = GGModelTypes.ExtendMode; MsgRouter: TYPE = FeedbackTypes.MsgRouter; Font: TYPE = ImagerFont.Font; FontData: TYPE = GGFont.FontData; HistoryEvent: TYPE = GGHistoryTypes.HistoryEvent; Point: TYPE = GGBasicTypes.Point; PointGenerator: TYPE = GGModelTypes.PointGenerator; PointGeneratorObj: TYPE = GGModelTypes.PointGeneratorObj; PointPairGenerator: TYPE = GGModelTypes.PointPairGenerator; PointPairGeneratorObj: TYPE = GGModelTypes.PointPairGeneratorObj; PointWalkProc: TYPE = GGModelTypes.PointWalkProc; Scene: TYPE = GGModelTypes.Scene; Segment: TYPE = GGSegmentTypes.Segment; SegmentGenerator: TYPE = GGModelTypes.SegmentGenerator; SegmentGeneratorObj: TYPE = GGModelTypes.SegmentGeneratorObj; SelectedObjectData: TYPE = GGModelTypes.SelectedObjectData; SelectionClass: TYPE = GGSegmentTypes.SelectionClass; SelectMode: TYPE = GGModelTypes.SelectMode; Slice: TYPE = GGModelTypes.Slice; SliceClass: TYPE = GGModelTypes.SliceClass; SliceClassObj: TYPE = GGModelTypes.SliceClassObj; SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor; SliceDescriptorObj: TYPE = GGModelTypes.SliceDescriptorObj; SliceObj: TYPE = GGModelTypes.SliceObj; SliceParts: TYPE = GGModelTypes.SliceParts; Transformation: TYPE = ImagerTransformation.Transformation; VEC: TYPE = Imager.VEC; Vector: TYPE = GGBasicTypes.Vector; <> WalkProc: TYPE = GGModelTypes.WalkProc; Problem: PUBLIC SIGNAL [msg: Rope.ROPE] = Feedback.Problem; <> <> <> <> < = 0.0.>> < = Width[string].>> <> <>> <> <>> <> <<>> textMaxPoints: INTEGER = 12; textMaxEdges: INTEGER = 7; TextPoints: TYPE = REF TextPointsData; TextPointsData: TYPE = ARRAY [0..textMaxPoints) OF Point; -- see picture TextEdgeArray: TYPE = PACKED ARRAY [0..textMaxEdges) OF BOOL; -- left, top, right, bottom, baseline, centerline. TextPointArray: TYPE = PACKED ARRAY [0..textMaxPoints) OF BOOL; -- see picture. Used in text parts data. textPointRopes: ARRAY [0..textMaxPoints) OF Rope.ROPE = [ "lower left point", "base left point", "center left point", "upper left point", "lower mid point", "base mid point", "center mid point", "upper mid point", "lower right point", "base right point", "center right point", "upper right point" ]; textEdgeRopes: ARRAY [0..textMaxEdges) OF Rope.ROPE = [ "left edge", "top edge", "right edge", "bottom edge", "baseline", "horizontal center line", "vertical center line" ]; <<>> LeftRightAnchor: TYPE = {left, middle, right}; <> defaultLineSpacing: REAL = 1.2; TextData: TYPE = REF TextDataObj; TextDataObj: TYPE = RECORD [ box: BoundBox, -- not a bounding box but part of the text representation points: TextPoints, -- cache for "joints" leftRightAnchor: LeftRightAnchor, -- which point of the text remains fixed when the text is edited rope: Rope.ROPE, color: Imager.Color, fontData: FontData, trueFont: ImagerFont.Font, screenFont: ImagerFont.Font, displayStyle: DisplayStyle _ print, -- which of the fonts to use inverse: ImagerTransformation.Transformation, -- inverse of transform inverseScale: Vector, -- cached value of ImagerTransformation.Factor[inverse].s amplifySpace: REAL _ 1.0, -- because the Imager allows space correction (see Imager.mesa) dropShadowOn: BOOL _ FALSE, dropShadowOffset: Vector, shadowColor: Imager.Color, lineSpacing: REAL _ defaultLineSpacing, -- multiplicative factor on the font scale for line spacing after CR seg: Segment -- a null segment whose entire purpose is to contain properties in seg.props ]; TextParts: TYPE = REF TextPartsObj; TextPartsObj: TYPE = RECORD [ points: TextPointArray, -- which corners of text box are selected. edges: TextEdgeArray, -- which edges of text box are selected. includeText: BOOL -- FALSE => corners and edges only; no text ]; TextHitData: TYPE = REF TextHitDataObj; TextHitDataObj: TYPE = RECORD [ <> point: [-1..textMaxPoints), -- which point of box is hit. edge: [-1..textMaxEdges), -- which edge of box is hit. hitPoint: Point ]; FontNameError: PUBLIC SIGNAL = CODE; BuildTextSliceClass: PUBLIC PROC [] RETURNS [class: SliceClass] = { OPEN GGSlice; class _ NEW[SliceClassObj _ [ type: $Text, unlink: GGSlice.UnlinkSlice, -- textData doesn't need unlinking <> getBoundBox: TextGetBoundBox, getTransformedBoundBox: GGSlice.GenericTransformedBoundBox, getTightBox: TextGetTightBox, copy: TextCopy, restore: TextRestore, <> buildPath: NoOpBuildPath, drawBorder: NoOpDrawBorder, drawParts: TextDrawParts, drawTransform: TextDrawTransform, drawSelectionFeedback: TextDrawSelectionFeedback, drawAttractorFeedback: TextDrawAttractorFeedback, saveSelections: NoOpSaveSelections, remakeSelections: NoOpRemakeSelections, <> transform: TextTransform, <> describe: TextDescribe, describeHit: TextDescribeHit, fileout: TextFileout, filein: TextFilein, <> isEmptyParts: TextIsEmptyParts, isCompleteParts: TextIsCompleteParts, newParts: TextNewParts, unionParts: TextUnionParts, differenceParts: TextDiffParts, movingParts: TextMovingParts, augmentParts: TextAugmentParts, alterParts: NoOpAlterParts, setSelectedFields: NoOpSetSelectedFields, <> pointsInDescriptor: TextPointsInDescriptor, walkPointsInDescriptor: TextWalkPointsInDescriptor, pointPairsInDescriptor: TextPointPairsInDescriptor, segmentsInDescriptor: TextSegmentsInDescriptor, walkSegments: TextWalkSegments, nextPoint: TextNextPoint, nextPointPair: TextNextPointPair, nextSegment: TextNextSegment, <> closestPoint: TextClosestPoint, closestJointToHitData: TextClosestJointToHitData, closestPointAndTangent: NoOpClosestPointAndTangent, closestSegment: TextClosestSegment, filledPathsUnderPoint: NoOpFilledPathsUnderPoint, lineIntersection: NoOpLineIntersection, circleIntersection: NoOpCircleIntersection, hitDataAsSimpleCurve: NoOpHitDataAsSimpleCurve, <