Ejemplo n.º 1
0
		object MathML.MathMLVisitor.Visit(MathMLOperatorElement e, object args)
		{
			return ((Area)formatter.Visit(e, args)).BoundingBox;
		}
Ejemplo n.º 2
0
 object MathML.MathMLVisitor.Visit(MathMLOperatorElement e, object args)
 {
     return(((Area)formatter.Visit(e, args)).BoundingBox);
 }
Ejemplo n.º 3
0
 object MathML.MathMLVisitor.Visit(MathMLOperatorElement e, object args)
 {
     // not sure why we have to cast this???
     return(((MathMLVisitor)this).Visit((MathMLPresentationToken)e, args));
 }
Ejemplo n.º 4
0
        object MathML.MathMLVisitor.Visit(MathMLPresentationContainer e, object args)
        {
            IFormattingContext context   = ((IFormattingContext)args).Clone();
            MathMLNodeList     arguments = e.Arguments;
            BoundingBox        extent    = BoundingBox.New();
            int stretchCount             = 0;

            // save the stretch size because stretch scope can not extend into another
            // level of nesting
            BoundingBox stretch = context.Stretch;

            context.Stretch = BoundingBox.New();

            // process all nodes that are not stretchy operators, get thier total
            // extents
            for (int i = 0; i < arguments.Count; i++)
            {
                MathMLElement         element = (MathMLElement)arguments[i];
                MathMLOperatorElement op      = element as MathMLOperatorElement;

                if (op == null || op.Stretchy == false)
                {
                    //areas[i] = (Area)element.Accept(this, context);
                    extent.Append((BoundingBox)element.Accept(this, context));
                }
                if (op != null && op.Stretchy)
                {
                    stretchCount++;
                }
            }

            // if we have any elements that can be stretched, stretch them
            if (stretchCount > 0)
            {
                if (!stretch.Defined)
                {
                    // avail width is epsilon because stretchy glyphs were not counted in the
                    // width calculation
                    context.Stretch = BoundingBox.New(Single.Epsilon, extent.Height, extent.Depth);
                }
                else
                {
                    // set the stretch size back to stretch the child elements
                    context.Stretch = stretch;

                    // calculate availible width
                    context.StretchWidth = context.StretchWidth - extent.Width;
                    if (context.Stretch.Width < 0)
                    {
                        context.StretchWidth = 0;
                    }

                    // size to stretch each width equally
                    context.StretchWidth = context.Stretch.Width / (float)stretchCount;
                }

                // process all areas that need to be stretched
                for (int i = 0; i < arguments.Count; i++)
                {
                    MathMLOperatorElement op = arguments[i] as MathMLOperatorElement;
                    if (op != null && op.Stretchy)
                    {
                        //areas[i] = (Area)op.Accept(this, context);
                        extent.Append((BoundingBox)op.Accept(this, context));
                    }
                }
            }

            return(extent);
        }