public TextEditRenderBox(RootGraphic rootgfx,
                                 int width, int height,
                                 bool isMultiLine)
            : base(rootgfx, width, height)
        {
            GlobalCaretController.RegisterCaretBlink(rootgfx);
            myCaret = new CaretRenderElement(rootgfx, 2, 17);
            myCaret.TransparentForAllEvents = true;

            this.MayHasViewport  = true;
            this.BackgroundColor = Color.White;// Color.Transparent;

            this.currentSpanStyle          = new TextSpanStyle();
            this.currentSpanStyle.FontInfo = rootgfx.DefaultTextEditFontInfo;

            textLayer = new EditableTextFlowLayer(this);

            internalTextLayerController = new InternalTextLayerController(this, textLayer);

            this.isMultiLine = isMultiLine;
            if (isMultiLine)
            {
                textLayer.SetUseDoubleCanvas(false, true);
            }
            else
            {
                textLayer.SetUseDoubleCanvas(true, false);
            }
            this.IsBlockElement = false;
        }
 public TextEditRenderBox(RootGraphic rootgfx,
     int width, int height,
     bool isMultiLine)
     : base(rootgfx, width, height)
 {
     GlobalCaretController.RegisterCaretBlink(rootgfx);            
     myCaret = new CaretRenderElement(rootgfx, 2, 17);
     myCaret.TransparentForAllEvents = true;
     this.MayHasViewport = true;
     this.BackgroundColor = Color.White;// Color.Transparent;
     this.currentSpanStyle = new TextSpanStyle();
     this.currentSpanStyle.FontInfo = rootgfx.DefaultTextEditFontInfo;
     textLayer = new EditableTextFlowLayer(this);
     internalTextLayerController = new InternalTextLayerController(this, textLayer);
     this.isMultiLine = isMultiLine;
     if (isMultiLine)
     {
         textLayer.SetUseDoubleCanvas(false, true);
     }
     else
     {
         textLayer.SetUseDoubleCanvas(true, false);
     }
     this.IsBlockElement = false;
 }
Пример #3
0
        internal EditableTextLine(EditableTextFlowLayer ownerFlowLayer)
        {
            this.editableFlowLayer = ownerFlowLayer;
            this.actualLineHeight  = DEFAULT_LINE_HEIGHT; //we start with default line height
#if DEBUG
            this.dbugLineId = dbugLineTotalCount;
            dbugLineTotalCount++;
#endif
        }
 public void Load(EditableTextFlowLayer flowLayer)
 {
     this.flowLayer = flowLayer;
     if ((flowLayer.layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
     {
         Load((List <EditableTextLine>)flowLayer.lineCollection);
     }
     else
     {
         Load((EditableTextLine)flowLayer.lineCollection);
     }
 }
 public void Load(EditableTextFlowLayer flowLayer)
 {
     this.flowLayer = flowLayer;
     this.feeder = FlowFeeder.GetNewFlowFeeder();
     this.feeder.Load(flowLayer);
     if ((flowLayer.layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
     {
         Load((List<EditableTextLine>)flowLayer.lineCollection);
     }
     else
     {
         Load((EditableTextLine)flowLayer.lineCollection);
     }
 }
        public TextLineReader(EditableTextFlowLayer flowlayer)
        {
#if DEBUG
            this.dbug_MyId = dbugTotalId;
            dbugTotalId++;
#endif

            this.visualFlowLayer = flowlayer;
            flowlayer.Reflow    += new EventHandler(flowlayer_Reflow);
            currentLine          = flowlayer.GetTextLine(0);
            if (currentLine.FirstRun != null)
            {
                currentTextRun = currentLine.FirstRun;
            }
        }
Пример #7
0
        public InternalTextLayerController(
            TextEditRenderBox visualTextSurface,
            EditableTextFlowLayer textLayer)
        {
            this.visualTextSurface = visualTextSurface;
            textLineWriter         = new TextLineWriter(textLayer);
            commandHistory         = new DocumentCommandCollection(this);
#if DEBUG
            if (dbugEnableTextManRecorder)
            {
                _dbugActivityRecorder = new debugActivityRecorder();
                textLineWriter.dbugTextManRecorder = _dbugActivityRecorder;
                throw new NotSupportedException();
                _dbugActivityRecorder.Start(null);
            }
#endif
        }
        public void BindToTextLayer(EditableTextFlowLayer textLayer)
        {
            this.textLayer = textLayer;
            //check is on the sameline,
            //or multiple lines
            //
            if (IsOnTheSameLine)
            {
                EditableTextLine line = textLayer.GetTextLine(selectionRangeSnapshot.startLineNum);
                //at this line
                //find start and end point
                int startColNum = selectionRangeSnapshot.startColumnNum;
                int endColNum   = selectionRangeSnapshot.endColumnNum;
                int lineHeight  = line.ActualLineHeight;

                _startLocation = new MarkerLocation()
                {
                    lineNum = line.LineNumber, x_offset = line.GetXOffsetAtCharIndex(startColNum), line = line
                };
                _stopLocation = new MarkerLocation()
                {
                    lineNum = line.LineNumber, x_offset = line.GetXOffsetAtCharIndex(endColNum), line = line
                };
            }
            else
            {
                EditableTextLine startLine = textLayer.GetTextLine(selectionRangeSnapshot.startLineNum);
                _startLocation = new MarkerLocation()
                {
                    lineNum  = startLine.LineNumber,
                    x_offset = startLine.GetXOffsetAtCharIndex(selectionRangeSnapshot.startColumnNum),
                    line     = startLine
                };
                //
                EditableTextLine endLine = textLayer.GetTextLine(selectionRangeSnapshot.endLineNum);
                _stopLocation = new MarkerLocation()
                {
                    lineNum  = endLine.LineNumber,
                    x_offset = endLine.GetXOffsetAtCharIndex(selectionRangeSnapshot.endColumnNum),
                    line     = endLine
                };
                //
            }
        }
Пример #9
0
        public InternalTextLayerController(
            TextEditRenderBox visualTextSurface,
            EditableTextFlowLayer textLayer)
        {
            this.visualTextSurface = visualTextSurface;
            textLineWriter = new TextLineWriter(textLayer);
            backGroundTextLineWriter = textLineWriter.GetBackgroundWriter();
            commandHistory = new DocumentCommandCollection(this);
            this.textMan = new TextMan(this, visualTextSurface);
#if DEBUG
            if (dbugEnableTextManRecorder)
            {
                dbugTextManRecorder = new dbugMultiTextManRecorder();
                textLineWriter.dbugTextManRecorder = dbugTextManRecorder;
                throw new NotSupportedException();
                dbugTextManRecorder.Start(null);
            }
#endif
        }
Пример #10
0
        public InternalTextLayerController(
            TextEditRenderBox visualTextSurface,
            EditableTextFlowLayer textLayer)
        {
            this.visualTextSurface   = visualTextSurface;
            textLineWriter           = new TextLineWriter(textLayer);
            backGroundTextLineWriter = textLineWriter.GetBackgroundWriter();
            commandHistory           = new DocumentCommandCollection(this);
            this.textMan             = new TextMan(this, visualTextSurface);
#if DEBUG
            if (dbugEnableTextManRecorder)
            {
                dbugTextManRecorder = new dbugMultiTextManRecorder();
                textLineWriter.dbugTextManRecorder = dbugTextManRecorder;
                throw new NotSupportedException();
                dbugTextManRecorder.Start(null);
            }
#endif
        }
        public Rectangle GetRectAreaOf(int beginlineNum, int beginColumnNum, int endLineNum, int endColumnNum)
        {
            EditableTextFlowLayer flowLayer = this.textLayer;
            EditableTextLine      beginLine = flowLayer.GetTextLineAtPos(beginlineNum);

            if (beginLine == null)
            {
                return(Rectangle.Empty);
            }
            if (beginlineNum == endLineNum)
            {
                VisualPointInfo beginPoint = beginLine.GetTextPointInfoFromCharIndex(beginColumnNum);
                VisualPointInfo endPoint   = beginLine.GetTextPointInfoFromCharIndex(endColumnNum);
                return(new Rectangle(beginPoint.X, beginLine.Top, endPoint.X, beginLine.ActualLineHeight));
            }
            else
            {
                VisualPointInfo  beginPoint = beginLine.GetTextPointInfoFromCharIndex(beginColumnNum);
                EditableTextLine endLine    = flowLayer.GetTextLineAtPos(endLineNum);
                VisualPointInfo  endPoint   = endLine.GetTextPointInfoFromCharIndex(endColumnNum);
                return(new Rectangle(beginPoint.X, beginLine.Top, endPoint.X, beginLine.ActualLineHeight));
            }
        }
Пример #12
0
        static Size ReCalculateContentSizeHorizontalFlow(EditableTextFlowLayer layer)
        {
            if (layer.lineCollection == null)
            {
                return(Size.Empty);
            }

            //only one line
            EditableTextLine             line   = (EditableTextLine)layer.lineCollection;
            LinkedListNode <EditableRun> c_node = line.First;
            //--------
            int curX = 0;

            int maxHeightInRow = 0;
            int maxWidth       = 0;

            while (c_node != null)
            {
                EditableRun run       = c_node.Value;
                int         runHeight = run.Height;
                if (runHeight > maxHeightInRow)
                {
                    maxHeightInRow = runHeight;
                }
                curX += run.Width;
                if (curX > maxWidth)
                {
                    maxWidth = curX;
                }


                //next
                c_node = c_node.Next;
            }

            return(new Size(maxWidth, maxHeightInRow));
        }
Пример #13
0
        public IEnumerable <EditableRun> GetPrintableTextRunIter()
        {
            EditableRun startRun = null;

            if (startPoint.TextRun == null)
            {
                EditableTextLine line = startPoint.EditableLine;
                startRun = line.FirstRun;
            }
            else
            {
                startRun = startPoint.TextRun.NextTextRun;
            }

            EditableTextFlowLayer layer = startRun.OwnerEditableLine.editableFlowLayer;

            foreach (EditableRun t in layer.GetDrawingIter(startRun, endPoint.TextRun))
            {
                if (!t.IsLineBreak)
                {
                    yield return(t);
                }
            }
        }
Пример #14
0
 public BackGroundTextLineWriter(EditableTextFlowLayer visualElementLayer)
     : base(visualElementLayer)
 {
 }
Пример #15
0
 public TextLineWriter(EditableTextFlowLayer textLayer)
     : base(textLayer)
 {
 }
Пример #16
0
 public TextLineWriter(EditableTextFlowLayer textLayer)
     : base(textLayer)
 {
 }
Пример #17
0
        public TextLineReader(EditableTextFlowLayer flowlayer)
        {
#if DEBUG
            this.dbug_MyId = dbugTotalId;
            dbugTotalId++;
#endif

            this.visualFlowLayer = flowlayer;
            flowlayer.Reflow += new EventHandler(flowlayer_Reflow);
            currentLine = flowlayer.GetTextLine(0);
            if (currentLine.FirstRun != null)
            {
                currentTextRun = currentLine.FirstRun;
            }
        }
Пример #18
0
 public BackGroundTextLineWriter(EditableTextFlowLayer visualElementLayer)
     : base(visualElementLayer)
 {
 }
        static Size ReCalculateContentSizeHorizontalFlow(EditableTextFlowLayer layer)
        {
            if (layer.lineCollection == null)
            {
                return(Size.Empty);
            }

            FlowFeeder flowFeeder = FlowFeeder.GetNewFlowFeeder();

            flowFeeder.Load(layer);
            int         curX               = 0;
            int         curY               = 0;
            bool        lastestIsBlock     = false;
            int         maxHeightInRow     = 0;
            int         maxWidth           = 0;
            int         curY_fromTop       = 0;
            bool        isFirstRunOfLine   = true;
            int         childCount         = 0;
            EditableRun lastNotNullElement = null;

            while (flowFeeder.Read())
            {
                EditableRun currentRun = flowFeeder.CurrentRun;
                if (currentRun != null)
                {
#if DEBUG
                    vinv_dbug_BeginSetElementBound(currentRun);
#endif

                    lastNotNullElement = currentRun;
                    childCount++;
                    if (lastestIsBlock || currentRun.IsBlockElement)
                    {
                        curX = 0;
                        if (!isFirstRunOfLine)
                        {
                            if (maxWidth < curX)
                            {
                                maxWidth = curX;
                            }

                            curY           = curY_fromTop + maxHeightInRow;
                            curY_fromTop   = curY;
                            maxHeightInRow = 0;
                        }
                        lastestIsBlock = currentRun.IsBlockElement;
                        if (lastestIsBlock)
                        {
                        }
                        if (!currentRun.HasCalculatedSize)
                        {
                            EditableRun.InnerTextRunTopDownReCalculateContentSize(currentRun);
                        }
#if DEBUG
                        else
                        {
                            vinv_dbug_WriteInfo(dbugVisitorMessage.SKIP, currentRun);
                        }
#endif
                        int v_ds_height = currentRun.Height;
                        if (v_ds_height > maxHeightInRow)
                        {
                            maxHeightInRow = v_ds_height;
                        }
                        curX += currentRun.Width;
                        if (curX > maxWidth)
                        {
                            maxWidth = curX;
                        }
                        isFirstRunOfLine = false;
                    }
                    else
                    {
                        lastestIsBlock = currentRun.IsBlockElement;
                        if (!currentRun.HasCalculatedSize)
                        {
                            EditableRun.InnerTextRunTopDownReCalculateContentSize(currentRun);
                        }
#if DEBUG
                        else
                        {
                            vinv_dbug_WriteInfo(dbugVisitorMessage.SKIP, currentRun);
                        }
#endif
                        int v_ds_height = currentRun.Height;
                        if (v_ds_height > maxHeightInRow)
                        {
                            maxHeightInRow = v_ds_height;
                        }
                        curX += currentRun.Width;
                        if (curX > maxWidth)
                        {
                            maxWidth = curX;
                        }
                        isFirstRunOfLine = false;
                    }
#if DEBUG
                    vinv_dbug_EndSetElementBound(currentRun);
#endif
                }
                else
                {
                    if (flowFeeder.ReadState == 1)
                    {
                        curX           = 0;
                        curY           = curY_fromTop + maxHeightInRow;
                        curY_fromTop   = curY;
                        maxHeightInRow = 0;
                    }
                    else
                    {
                    }
                }
            }


            if (curX > maxWidth)
            {
                maxWidth = curX;
            }

            int finalHeight = curY_fromTop + maxHeightInRow;
            FlowFeeder.FreeFlowFeeder(flowFeeder);
            return(new Size(maxWidth, finalHeight));
        }
        static Size ReCalculateContentSizeHorizontalFlow(EditableTextFlowLayer layer)
        {
            if (layer.lineCollection == null)
            {
                return Size.Empty;
            }

            FlowFeeder flowFeeder = FlowFeeder.GetNewFlowFeeder();
            flowFeeder.Load(layer);
            int curX = 0;
            int curY = 0;
            bool lastestIsBlock = false;
            int maxHeightInRow = 0;
            int maxWidth = 0;
            int curY_fromTop = 0;
            bool isFirstRunOfLine = true;
            int childCount = 0;
            EditableRun lastNotNullElement = null;
            while (flowFeeder.Read())
            {
                EditableRun currentRun = flowFeeder.CurrentRun;
                if (currentRun != null)
                {
#if DEBUG
                    vinv_dbug_BeginSetElementBound(currentRun);
#endif

                    lastNotNullElement = currentRun;
                    childCount++;
                    if (lastestIsBlock || currentRun.IsBlockElement)
                    {
                        curX = 0;
                        if (!isFirstRunOfLine)
                        {
                            if (maxWidth < curX)
                            {
                                maxWidth = curX;
                            }

                            curY = curY_fromTop + maxHeightInRow;
                            curY_fromTop = curY;
                            maxHeightInRow = 0;
                        }
                        lastestIsBlock = currentRun.IsBlockElement;
                        if (lastestIsBlock)
                        {
                        }
                        if (!currentRun.HasCalculatedSize)
                        {
                            EditableRun.InnerTextRunTopDownReCalculateContentSize(currentRun);
                        }
#if DEBUG
                        else
                        {
                            vinv_dbug_WriteInfo(dbugVisitorMessage.SKIP, currentRun);
                        }
#endif
                        int v_ds_height = currentRun.Height;
                        if (v_ds_height > maxHeightInRow)
                        {
                            maxHeightInRow = v_ds_height;
                        }
                        curX += currentRun.Width;
                        if (curX > maxWidth)
                        {
                            maxWidth = curX;
                        }
                        isFirstRunOfLine = false;
                    }
                    else
                    {
                        lastestIsBlock = currentRun.IsBlockElement;
                        if (!currentRun.HasCalculatedSize)
                        {
                            EditableRun.InnerTextRunTopDownReCalculateContentSize(currentRun);
                        }
#if DEBUG
                        else
                        {
                            vinv_dbug_WriteInfo(dbugVisitorMessage.SKIP, currentRun);
                        }
#endif
                        int v_ds_height = currentRun.Height;
                        if (v_ds_height > maxHeightInRow)
                        {
                            maxHeightInRow = v_ds_height;
                        }
                        curX += currentRun.Width;
                        if (curX > maxWidth)
                        {
                            maxWidth = curX;
                        }
                        isFirstRunOfLine = false;
                    }
#if DEBUG
                    vinv_dbug_EndSetElementBound(currentRun);
#endif
                }
                else
                {
                    if (flowFeeder.ReadState == 1)
                    {
                        curX = 0;
                        curY = curY_fromTop + maxHeightInRow;
                        curY_fromTop = curY;
                        maxHeightInRow = 0;
                    }
                    else
                    {
                    }
                }
            }


            if (curX > maxWidth)
            {
                maxWidth = curX;
            }

            int finalHeight = curY_fromTop + maxHeightInRow;
            FlowFeeder.FreeFlowFeeder(flowFeeder);
            return new Size(maxWidth, finalHeight);
        }