public VisualTextBlockSegment(
     VisualSpanner Parent, int SegNum, int SegBx,
     string Text, ZeroRowCol RowCol, byte?AttrByte, CanvasDefn CanvasDefn,
     bool AttrByteOccupySpace)
     : base(Text, RowCol, AttrByte,
            CanvasDefn.CharBoxDim, CanvasDefn.KernDim, CanvasDefn.FontDefn)
 {
     this.Parent = Parent;
     this.SegNum = SegNum;
     this.SegBx  = SegBx;
     this.AttrByteOccupySpace = AttrByteOccupySpace;
 }
Esempio n. 2
0
        private static void CreateTextBlockSegments(
            VisualSpanner Parent,
            string Text, IRowCol StartRowCol, byte?AttrByte,
            CanvasDefn CanvasDefn)
        {
            IRowCol rowCol = StartRowCol;
            string  text   = Text;
            int     segNum = 0;
            int     segBx  = 0;

            // advance past attrByte.
#if skip
            if (AttrByte != null)
            {
                rowCol = rowCol.Advance(1);
            }
#endif
            bool attrByteOccupySpace = true;

            // loop create textblock segments until no more text.
            while (text.Length > 0)
            {
                // space on this row.
                var remLx = rowCol.GetRowRemaining();
                if (attrByteOccupySpace == true)
                {
                    remLx -= 1;
                }

                // text to place on current row.
                int usedLx = 0;
                if (remLx > text.Length)
                {
                    usedLx = text.Length;
                }
                else
                {
                    usedLx = remLx;
                }

                // create the textblock segment.
                if (usedLx > 0)
                {
                    segNum += 1;
                    var vtb = new VisualTextBlockSegment(
                        Parent, segNum, segBx,
                        Text.Substring(segBx, usedLx), rowCol as ZeroRowCol, AttrByte,
                        CanvasDefn, attrByteOccupySpace);
                    vtb.SetupUnderline();
                    Parent.SegmentList.Add(vtb);

                    // advance to next segment in show text.
                    segBx += usedLx;
                    if (text.Length > usedLx)
                    {
                        text = text.Substring(usedLx);
                    }
                    else
                    {
                        text = "";
                    }
                }

                // advance rowCol
                if (attrByteOccupySpace == true)
                {
                    usedLx += 1;
                }
                rowCol = rowCol.Advance(usedLx);

                attrByteOccupySpace = false;
            }
        }