public OverBar(Box box, double kern, double thickness) : base() { Add(new StrutBox(0, thickness, 0, 0)); Add(new HorizontalRule(thickness, box.Width, 0)); Add(new StrutBox(0, kern, 0, 0)); Add(box); }
public override void Add(Box box) { base.Add(box); childBoxesTotalWidth += box.Width; this.Width = Math.Max(this.Width, childBoxesTotalWidth); this.Height = Math.Max((this.Children.Count == 0 ? double.NegativeInfinity : Height), box.Height - box.Shift); this.Depth = Math.Max((this.Children.Count == 0 ? double.NegativeInfinity : Depth), box.Depth + box.Shift); }
public override void Add(Box box) { base.Add(box); if (this.Children.Count == 1) { this.Height = box.Height; this.Depth = box.Depth; } else { this.Depth += box.Height + box.Depth; } RecalculateWidth(box); }
public override void Add(int position, Box box) { base.Add(position, box); if (position == 0) { this.Depth += box.Depth + Height; this.Height = box.Height; } else { this.Depth += box.Height + box.Depth; } RecalculateWidth(box); }
public OverUnderBox(Box baseBox, Box delimeterBox, Box scriptBox, double kern, bool over) : base() { this.BaseBox = baseBox; this.DelimeterBox = delimeterBox; this.ScriptBox = scriptBox; this.Kern = kern; this.Over = over; // Calculate dimensions of box. this.Width = baseBox.Width; this.Height = baseBox.Height + (over ? delimeterBox.Width : 0) + (over && scriptBox != null ? scriptBox.Height + scriptBox.Depth + kern : 0); this.Depth = baseBox.Depth + (over ? 0 : delimeterBox.Width) + (!over && scriptBox == null ? 0 : scriptBox.Height + scriptBox.Depth + kern); }
public HorizontalBox(Box box, double width, TexAlignment alignment) : this() { var extraWidth = width - box.Width; if (alignment == TexAlignment.Center) { var strutBox = new StrutBox(extraWidth / 2, 0, 0, 0); Add(strutBox); Add(box); Add(strutBox); } else if (alignment == TexAlignment.Left) { Add(box); Add(new StrutBox(extraWidth, 0, 0, 0)); } else if (alignment == TexAlignment.Right) { Add(new StrutBox(extraWidth, 0, 0, 0)); Add(box); } }
public VerticalBox(Box box, double rest, TexAlignment alignment) : this() { Add(box); if (alignment == TexAlignment.Center) { var strutBox = new StrutBox(0, rest / 2, 0, 0); base.Add(0, strutBox); this.Height += rest / 2; this.Depth += rest / 2; base.Add(strutBox); } else if (alignment == TexAlignment.Top) { this.Depth += rest; base.Add(new StrutBox(0, rest, 0, 0)); } else if (alignment == TexAlignment.Bottom) { this.Height += rest; base.Add(0, new StrutBox(0, rest, 0, 0)); } }
private void RecalculateWidth(Box box) { this.leftMostPos = Math.Min(leftMostPos, box.Shift); this.rightMostPos = Math.Max(rightMostPos, box.Shift + (box.Width > 0 ? box.Width : 0)); this.Width = rightMostPos - leftMostPos; }
public HorizontalBox(Box box) : this() { Add(box); }
public virtual void Add(int position, Box box) { this.children.Insert(position, box); }
private static Box ChangeWidth(Box box, double maxWidth) { if (box != null && Math.Abs(maxWidth - box.Width) > TexUtilities.FloatPrecision) return new HorizontalBox(box, maxWidth, TexAlignment.Center); else return box; }
public virtual void Add(Box box) { this.children.Add(box); }
private static Box ChangeWidth(Box box, double maxWidth) { // Centre specified box in new box of specified width, if necessary. if (Math.Abs(maxWidth - box.Width) > TexUtilities.FloatPrecision) return new HorizontalBox(box, maxWidth, TexAlignment.Center); else return box; }
private static void CentreBox(Box box, double axis) { var totalHeight = box.Height + box.Depth; box.Shift = -(totalHeight / 2 - box.Height) - axis; }
internal TexRenderer(Box box, double scale) { this.Box = box; this.Scale = scale; }