示例#1
0
        public void Reflow(DrawContext dc, BoundingContext bounds, bool incremental)
        {
            reflowCompleted = true;

            // TODO: L: do something with item metrics?
            ItemMetrics im;

            startTag = new StartTag(this, elementNode);
            startTag.Compose(dc, style, out im);

            endTag = new EndTag(this, elementNode);
            endTag.Compose(dc, style, out im);

            ParentTable.InitRow(dc, startTag, endTag, bounds);

            cells.Clear();
            foreach (XmlNode n in elementNode.ChildNodes)
            {
                XmlElement e = n as XmlElement;
                if (e == null)
                {
                    continue;
                }

                Table.CellInfo ci = ParentTable[e];
                TableCell      c  = ci.Cell;
                cells.Add(c);
                BoundingContext newBounds = new BoundingContext(bounds, ci.Column.Width);
                c.Parent = this;
                c.Reflow(dc, newBounds, false);
                ParentTable.Update(c);
            }

            RecalcBounds();
        }
示例#2
0
        private void InitColumnWidths(DrawContext dc, BoundingContext bounds)
        {
//			BoundingContext bounds=GetBoundsForSelf(dc, false);
            bounds         = bounds.Narrow(lMargin, rMargin + 10);
            availableWidth = bounds.Width;
            double pw = 1.0 / columns.Count;

            foreach (ColumnInfo c in columns)
            {
                c.Specified         = false;
                c.ProportionalWidth = 0;
                c.Specified         = false;
                c.CalculatedWidth   = (int)Math.Round(bounds.Width * pw);
                c.MinimumWidth      = 0;
                c.DesiredWidth      = 0;
            }
            if (columnsInitialised)
            {
                foreach (CellInfo ci in grid.Values)
                {
                    if (ci.State == CellReflowState.Completed)
                    {
                        ci.State = CellReflowState.Reset;
                    }
                }
            }
            columnsInitialised = true;
        }
示例#3
0
        public override void Reflow(DrawContext dc, BoundingContext bounds, bool incremental)
        {
            ReflowStart(dc);

            if (incremental)
            {
                bounds = bounds.Narrow(style.Left, style.Right);
            }

            MarkupItem tag = new StartTag(CurrentLine, ElementNode);

            ReflowMarkup(tag, dc, style, bounds);

            ImageStyle s = style as ImageStyle;

            if (s == null)
            {
                throw new InvalidOperationException("Expected style for image to be Custom");
            }

            string imgPath = ElementNode.GetAttribute(s.SourceAttribute);

            if (imgPath == null)
            {
                throw new InvalidOperationException("SourceAttribute for image is missing");
            }

            // think about relative to doc
            Bitmap bm;

            Uri docUri = new Uri(elementNode.BaseURI);
            Uri uri    = new Uri(docUri, imgPath);

            if (uri.IsFile && File.Exists(uri.AbsolutePath))
            {
                bm = new Bitmap(uri.AbsolutePath);
            }
            else
            {
                bm = ErrorBitmap;
            }

            ImageLineItem ili = new ImageLineItem(CurrentLine, ElementNode, bm);

            ReflowMarkup(ili, dc, style, bounds);

            tag = new EndTag(CurrentLine, ElementNode);
            ReflowMarkup(tag, dc, style, bounds);

            ReflowEnd(dc);
        }
示例#4
0
        public override BoundingContext GetBoundsForChild(DrawContext dc, IContainedItem child)
        {
            BoundingContext bounds = parent.GetBoundsForChild(dc, this);

            TableCell cell = child as TableCell;

            if (cell == null)
            {
                return(bounds);
            }

            Table.ColumnInfo col = ParentTable[cell.ElementNode].Column;

            return(new BoundingContext(bounds, col.Width));
        }
示例#5
0
        private void ReflowInvalidCells(DrawContext dc)
        {
            foreach (CellInfo ci in grid.Values)
            {
                // TODO: L: cell might not be reflowed (suspect to do with partial reflow)
//				Debug.Assert(ci.State != CellReflowState.None, "Cell was not reflowed!");
                if (ci.State == CellReflowState.Reset)
                {
                    BoundingContext bounds = new BoundingContext(GetBoundsForSelf(dc, false), ci.Column.Width);
                    ci.Cell.Reflow(dc, bounds, false);
                    // TODO: M: this causes unnecessary processing of size changes
                    //			up the stack
                    BlockHelper.ProcessSizeChange((IBlock)ci.Cell.Parent);
                }
            }
        }
示例#6
0
        // TODO: M: this is same as method GetBounds(sig) in BlockImpl
        private BoundingContext GetBoundsForSelf(DrawContext dc, bool adjust)
        {
            BoundingContext ret;

            if (parent == null)
            {
                ret = new BoundingContext(dc.BoundingRectangle);
            }
            else
            {
                ret = parent.GetBoundsForChild(dc, this);
            }

            if (adjust)
            {
                ret = ret.Narrow(style.Left, style.Right);
            }

            return(ret);
        }
示例#7
0
        public void InitRow(DrawContext dc, Tag startTag, Tag endTag, BoundingContext bounds)
        {
            bool invalidate = false;

            if (lMargin < startTag.Width)
            {
                lMargin    = startTag.Width;
                invalidate = true;
            }
            if (rMargin < startTag.Width)
            {
                rMargin    = startTag.Width;
                invalidate = true;
            }

            if (invalidate || !columnsInitialised)
            {
                InitColumnWidths(dc, bounds);
            }
        }
示例#8
0
        public Size Reflow(DrawContext dc, XmlElement e)
        {
            PerfLog.Mark();

            Style s = Stylesheet.GetStyle(dc.Graphics, e, dc.DocumentType.GetElementType(e));

            rootBlock = s.CreateReflowObject(null, e) as IBlock;
            if (rootBlock == null)
            {
                // TODO: M: exception handling
                throw new ArgumentException("Invalid stylesheet / document. Root element must be a block.");
            }

            BoundingContext bounds = new BoundingContext(dc.BoundingRectangle);

            Console.WriteLine("Root block reflow {0}", bounds);
            rootBlock.Reflow(dc, bounds, false);

            PerfLog.Write("Reflow complete for '{0}'", e.Name);
            return(new Size(rootBlock.Width, rootBlock.Height));
        }
示例#9
0
        public override void Reflow(DrawContext dc, BoundingContext bounds, bool incremental)
        {
            ReflowStart(dc);

            if ( incremental )
                bounds=bounds.Narrow(style.Left, style.Right);

            MarkupItem tag=new StartTag(CurrentLine, ElementNode);
            ReflowMarkup(tag, dc, style, bounds);

            ImageStyle s=style as ImageStyle;
            if ( s == null )
                throw new InvalidOperationException("Expected style for image to be Custom");

            string imgPath=ElementNode.GetAttribute(s.SourceAttribute);
            if ( imgPath == null )
                throw new InvalidOperationException("SourceAttribute for image is missing");

            // think about relative to doc
            Bitmap bm;

            Uri docUri=new Uri(elementNode.BaseURI);
            Uri uri=new Uri(docUri, imgPath);
            if ( uri.IsFile && File.Exists(uri.AbsolutePath) )
                bm=new Bitmap(uri.AbsolutePath);
            else
                bm=ErrorBitmap;

            ImageLineItem ili=new ImageLineItem(CurrentLine, ElementNode, bm);
            ReflowMarkup(ili, dc, style, bounds);

            tag=new EndTag(CurrentLine, ElementNode);
            ReflowMarkup(tag, dc, style, bounds);

            ReflowEnd(dc);
        }
示例#10
0
        public Size Reflow(DrawContext dc, XmlElement e)
        {
            PerfLog.Mark();

            Style s=Stylesheet.GetStyle(dc.Graphics, e, dc.DocumentType.GetElementType(e));
            rootBlock=s.CreateReflowObject(null, e) as IBlock;
            if ( rootBlock == null )
                // TODO: M: exception handling
                throw new ArgumentException("Invalid stylesheet / document. Root element must be a block.");

            BoundingContext bounds=new BoundingContext(dc.BoundingRectangle);

            Console.WriteLine("Root block reflow {0}", bounds);
            rootBlock.Reflow(dc, bounds, false);

            PerfLog.Write("Reflow complete for '{0}'", e.Name);
            return new Size(rootBlock.Width, rootBlock.Height);
        }