예제 #1
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);
            }
        }