Ejemplo n.º 1
0
        public void CommentHitTestError()
        {
            string test="<p><!--OddPage--></p>";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml(test);

            Stylesheet s=new Stylesheet();
            s.BindStyles(doc.NameTable);

            Rectangle rc=new Rectangle(0, 0, 500, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);

                layoutEngine.Reflow(ctx, doc.DocumentElement);

                Console.WriteLine("Bounds {0}", layoutEngine.BoundingRect);
                for (int x=0; x< layoutEngine.BoundingRect.Width; x+=10)
                {
                    HitTestInfo hti=layoutEngine.GetHitTestInfo(gr, new Point(x,8));
                    SelectionPoint sp=hti.SelectionPoint;
                    Console.WriteLine("Hit test at {0} = {1}", x, sp);
                }
            }
        }
Ejemplo n.º 2
0
        public void HitTestHandling()
        {
            string test="<p><b>xxxxxxxxxxxxx</b></p>";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml(test);

            Stylesheet s=//Stylesheet.Load("c:/tmp/website/site.style", doc.NameTable);
            new Stylesheet();
            s.BindStyles(doc.NameTable);

            Rectangle rc=new Rectangle(0, 0, 500, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);

                layoutEngine.Reflow(ctx, doc.DocumentElement);

                layoutEngine.GetHitTestInfo(gr, new Point(141,16));
            }
        }
Ejemplo n.º 3
0
 //        private DrawContext dc;
 public LayoutEngine(Stylesheet stylesheet)
 {
     this.Stylesheet=stylesheet;
 }
Ejemplo n.º 4
0
        public Size Invalidate(DrawContext dc, XmlElement e, Stylesheet s, out Rectangle invalidRect)
        {
            invalidRect=Rectangle.Empty;

            if ( rootBlock == null )
                Reflow(dc, e);

            IBlock b=rootBlock.FindBlock(e);
            // block can be null if just removed from doc, for example
            if ( b != null )
            {
                XmlNode n=b.Invalidate(dc);
                invalidRect=GetBoundingRect(n);
            }
            // TODO: L: we return the overall size here just so that the scrollbars can be
            // reset if needed - but still not quite sure why we need two returns
            return new Size(rootBlock.Width, rootBlock.Height);
        }
Ejemplo n.º 5
0
        public void Bind(IGraphics gr, Stylesheet s)
        {
            stylesheet=s;
            FontDesc fd=desc;
            if ( fd.Family == null )
                fd=s.DefaultFont;

            object fontHandle=gr.GetFontHandle(fd);
            gr.PushFont(fontHandle);
            fontAscent=gr.GetFontAscent();
            fontHeight=gr.GetFontHeight();
            gr.PopFont();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// The main control for XEditNet applications.
        /// </summary>
        // TODO: D: add remarks section
        public XEditNetCtrl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            //			if ( !this.DesignMode )
            //			{
            //				Application.EnableVisualStyles();
            //				Application.DoEvents();
            //			}

            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);

            nodocWnd=new NoDocumentControl();
            nodocWnd.Parent=this;

            findWindow=new FindPopup(this);

            if ( this.DesignMode )
                return;

            caret=grFactory.CreateCaret(this);
            caret.Visible=true;
            quickFixIndicator=new QuickFixIndicator(this, caret);

            Stylesheet=new Stylesheet();
            undoManager=new UndoManager(this);
            commandMapper=CommandMapper.CreateInstance(this);
        }
Ejemplo n.º 7
0
        public void WhitespaceHandling1()
        {
            string test="aaaa bbbb  cccc";
            XmlDocument doc=new XmlDocument();
            doc.LoadXml("<doc>"+test+"</doc>");

            Stylesheet s=new Stylesheet();
            s.BindStyles(doc.NameTable);

            //			Rectangle rc=new Rectangle(0, 0, 480, int.MaxValue);
            Rectangle rc=new Rectangle(0, 0, 110, int.MaxValue);

            using ( IGraphics gr=new DummyGraphics() )
            {
                DrawContext ctx=new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null);
                LayoutEngine layoutEngine=new LayoutEngine(s);
                layoutEngine.Reflow(ctx, doc.DocumentElement);

                SelectionPoint start=new TextSelectionPoint(doc.DocumentElement.FirstChild, 11);
                Console.WriteLine("Getting caret pos for {0}", start);
                Rectangle c=layoutEngine.GetCaretPosition(gr, start, CaretDirection.None);
                Console.WriteLine("Char {0} at {1}", start.ToString(), c);
            }
        }