Beispiel #1
0
 public Info(Node _node, Painter Graphics)
 {
     this.x = 0;
     this.y = 0;
     this.w = 0;
     this.h = 0;
     this.b = 0;
     this.painter = Graphics;
     this.node = _node;
     this.w = this.node.box.Width;
     this.h = this.node.box.Height;
     this.b = this.node.box.Baseline;
     Rectangle rectangle = this.painter.CalcRect(this.node, this.node.style_);
     this.size_ = new Size(rectangle.Width, rectangle.Height);
 }
Beispiel #2
0
        public void MeasurePass(Painter g)
        {
            if (parent_ != null)
            {
                level = parent_.level + 1;
            }
            int x = 0;
            int y = 0;
            bool hasBox = false;
            if ((box != null))
            {
                hasBox = true;
                x = box.X;
                y = box.Y;
            }
            
            if ((((box == null) || ((level < 2))) || ((level == 2))) || ((level > 2)))
            {
                BoxBuilder.MakeBox(this, g);
            }
            if ((type_ != null) && (type_.type == ElementType.Math))
            {
                PushdownStyleScript();
            }

            if (hasBox)
            {
                box.X = x;
                box.Y = y;
            }
            
            
                NodesList list = GetChildrenNodes();
                Node n = list.Next();
                if ((style_ != null) && (style_.size.Length > 0))
                {
                    try
                    {
                        style_.scale = StyleAttributes.FontScale(style_.size, (double) g.GetSuitableFont(this, style_).SizeInPoints); 
                        style_.size = "";
                    }
                    catch
                    {
                    }
                }
                if ((style_ != null))
                {
                    if (type_.type == ElementType.Math)
                    {
                        style_.isTop = true;
                    }
                    else if (style_.canOverride)
                    {
                        style_.isTop = false;
                    }
                }
                while (n != null)
                {
                    if (style_ != null)
                    {
                        if (((n.style_ != null) && n.style_.canOverride) && n.IsSameStyleParent())
                        {
                            n.CombineStyles(n.style_, style_);
                        }
                        else if (n.type_.type == ElementType.Entity)
                        {
                            n.style_ = null;
                        }
                        else
                        {
                            try
                            {
                                StyleAttributes style = n.CascadeOverride(style_);
                                if (style != null)
                                {
                                    if (type_.type == ElementType.Math)
                                    {
                                        style.fontFamily = "";
                                        style.isUnderline = false;
                                    }
                                    n.style_ = new StyleAttributes();
                                    style.CopyTo(n.style_);
                                    if ((style_ != null) && style_.isTop)
                                    {
                                        n.style_.canOverride = false;
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    n.MeasurePass(g);
                    box.setChildSize(n);
                    n = list.Next();
                }
            
            if (((((level < 2)) || ((level == 2))) || ((level > 2))))
            {
                box.getSize(this);
            }
        }
Beispiel #3
0
 public SubscriptCalc(Node _node, Painter Graphics)
 {
     this.x = 0;
     this.y = 0;
     this.w = 0;
     this.h = 0;
     this.b = 0;
     this.xInc = 0;
     this.yInc = 0;
     this.xplus = 0;
     this.wplus = 0;
     this.bplus = 0;
     this.hplus = 0;
     this.kind_ = SubType.subsup;
     this.base_ = null;
     this.subInfo = null;
     this.supInfo = null;
     this.painter = Graphics;
     this.node = _node;
     switch (this.node.type_.type)
     {
         case ElementType.Msup:
         {
             this.kind_ = SubType.sup;
             break;
         }
         case ElementType.Msub:
         {
             this.kind_ = SubType.sub;
             break;
         }
         case ElementType.Msubsup:
         {
             this.kind_ = SubType.subsup;
             break;
         }
     }
     if (this.node.HasChildren())
     {
         NodesList list = this.node.GetChildrenNodes();
         for (Node n = list.Next(); n != null; n = list.Next())
         {
             if (n.childIndex == 0)
             {
                 this.BaseInfo(n, this.painter);
             }
             else if (((this.kind_ == SubType.sup) && (n.childIndex == 1)) ||
                      ((this.kind_ == SubType.subsup) && (n.childIndex == 2)))
             {
                 if (n.prevSibling != null)
                 {
                     if (n.childIndex == 1)
                     {
                         n.lowerNode = n.prevSibling;
                         n.prevSibling.upperNode = n;
                     }
                     else if ((n.childIndex == 2) && (n.prevSibling.prevSibling != null))
                     {
                         n.prevSibling.prevSibling.upperNode = n;
                         n.lowerNode = n.prevSibling.prevSibling;
                     }
                 }
                 this.SupInfo(n, this.painter);
             }
             else if (((this.kind_ == SubType.sub) && (n.childIndex == 1)) ||
                      ((this.kind_ == SubType.subsup) && (n.childIndex == 1)))
             {
                 if (n.prevSibling != null)
                 {
                     n.upperNode = n.prevSibling;
                     n.prevSibling.lowerNode = n;
                 }
                 this.SubInfo(n, this.painter);
             }
         }
     }
     this.calc();
     this.updateNode();
 }
Beispiel #4
0
 public void SupInfo(Node node, Painter Graphics)
 {
     this.supInfo = new Info(node, Graphics);
 }
Beispiel #5
0
 public void BaseInfo(Node node, Painter Graphics)
 {
     this.base_ = new Info(node, Graphics);
 }
Beispiel #6
0
 public static void MakeBox(Node node, Painter g)
 {
     BoxBuilder.MakeBox(node, g, 0);
 }
Beispiel #7
0
        private static void MakeBox(Node node, Painter g, int width)
        {
            if (node.parent_ != null)
            {
                node.isVisible = node.parent_.isVisible;
            }
            if (node.type_ == null)
            {
                return;
            }
            if ((node.parent_ != null) && !node.parent_.isVisible)
            {
                node.box = new Box_none();
                node.isVisible = false;
            }
            else
            {
                switch (node.type_.type)
                {
                    case ElementType.Math:
                    {
                        node.box = new Box_mrow();
                        break;
                    }
                    case ElementType.Mi:
                    {
                        node.box = new Box_Text();
                        node.tokenType = Tokens.ID;
                        if (node.literalText != null)
                        {
                            string trimmed = node.literalText.Trim();
                            if (trimmed.Length <= 1)
                            {
                                if (trimmed.Length == 1)
                                {
                                    node.tokenType = Tokens.GLYPH;
                                }
                            }
                            else
                            {
                                node.tokenType = Tokens.TEXT;
                            }
                        }
                        break;
                    }
                    case ElementType.Mn:
                    {
                        node.box = new Box_Text();
                        node.tokenType = Tokens.NUMBER;
                        break;
                    }
                    case ElementType.Mo:
                    {
                        node.box = new Box_Mo();
                        break;
                    }
                    case ElementType.Mtext:
                    {
                        node.box = new Box_Text();
                        node.tokenType = Tokens.TEXT;
                        break;
                    }
                    case ElementType.Mspace:
                    {
                        node.box = new Box_Mspace();
                        break;
                    }
                    case ElementType.Ms:
                    {
                        node.box = new Box_Ms();
                        node.tokenType = Tokens.TEXT;
                        break;
                    }
                    case ElementType.Mglyph:
                    {
                        node.box = new Box_Mglyph();
                        node.isGlyph = true;
                        break;
                    }
                    case ElementType.Mfrac:
                    {
                        node.box = new Box_Mfrac();
                        break;
                    }
                    case ElementType.Msqrt:
                    {
                        node.box = new Box_Msqrt();
                        break;
                    }
                    case ElementType.Mroot:
                    {
                        node.box = new Box_mroot();
                        break;
                    }
                    case ElementType.Mrow:
                    {
                        node.box = new Box_mrow();
                        break;
                    }
                    case ElementType.Mfenced:
                    {
                        node.box = new Box_mfenced();
                        break;
                    }
                    case ElementType.Mstyle:
                    {
                        node.box = new Box_mstyle();
                        break;
                    }
                    case ElementType.Mphantom:
                    {
                        node.box = new Box_mphantom();
                        break;
                    }
                    case ElementType.Merror:
                    {
                        node.box = new Box_Text();
                        break;
                    }
                    case ElementType.Msup:
                    case ElementType.Msub:
                    case ElementType.Msubsup:
                    {
                        node.box = new Box_msub();
                        break;
                    }
                    case ElementType.Mover:
                    {
                        node.box = new Box_mover();
                        break;
                    }
                    case ElementType.Munder:
                    {
                        node.box = new Box_munder();
                        break;
                    }
                    case ElementType.Munderover:
                    {
                        node.box = new Box_munderover();
                        break;
                    }
                    case ElementType.Mmultiscripts:
                    {
                        node.box = new Box_multiscripts();
                        break;
                    }
                    case ElementType.Mprescripts:
                    {
                        node.box = new Box_none();
                        node.isVisible = false;
                        break;
                    }
                    case ElementType.Mnone:
                    {
                        node.box = new Box_none();
                        node.isVisible = false;
                        break;
                    }
                    case ElementType.Mtable:
                    {
                        node.box = new Box_mtable();
                        break;
                    }
                    case ElementType.Mtr:
                    {
                        node.box = new Box_mtr();
                        node.skip = true;
                        break;
                    }
                    case ElementType.Mtd:
                    {
                        node.box = new Box_mtd();
                        node.skip = true;
                        break;
                    }
                    case ElementType.Mlabeledtr:
                    {
                        node.box = new Box_mlabeledtr();
                        node.skip = true;
                        break;
                    }
                    case ElementType.Maction:
                    {
                        node.box = new Box_maction();
                        break;
                    }
                    
                    case ElementType.Entity:
                    {
                        node.box = new Box_entity();
                        node.isGlyph = true;
                        break;
                    }

                    default:
                        node.box = new Box_mrow();
                        break;
                }
            }
        
            node.box.Painter = g;
        }