Box CreateTestBox4_1() { VerticalStackBox vbox1 = new VerticalStackBox(); vbox1.AddChild(CreateTestBox3()); vbox1.AddChild(CreateTestBox3()); vbox1.Layout(); return(vbox1); }
Box CreateTestBox2() { VerticalStackBox vbox1 = new VerticalStackBox(); vbox1.AddChild(CreateTestBox1("Hello")); vbox1.AddChild(CreateTestBox1("Hello(3*2)")); vbox1.AddChild(CreateTestBox1("World[1+2]", 15)); vbox1.Layout(); return(vbox1); }
Box CreateTestBox4() { VerticalStackBox vbox1 = new VerticalStackBox(); vbox1.AddChild(CreateTestBox3()); vbox1.AddChild(CreateTestBox3()); vbox1.Layout(); GlyphBox h_sepBar = NewGlyphBox(); h_sepBar.SetSize(vbox1.Width, 5); vbox1.Insert(1, h_sepBar); vbox1.Layout(); return(vbox1); }
Box CreateMathBox(MathNode node) { //create box foreach node //TODO: most box are glyph box + its text content //except some boxes are Horizontal (eg. mrow) or some box are vertical (...) //this should be config from DomSpec.xml or Autogen code Box result = null; switch (node.Name) { default: { //text span box if (node.Text == null) { return(null); } char[] text_buff = node.Text.ToCharArray(); if (text_buff.Length == 0) { //???? return(null); } else if (text_buff.Length > 1) { HorizontalStackBox textSpan = new HorizontalStackBox(); textSpan.MathNode = node; for (int i = 0; i < text_buff.Length; ++i) { GlyphBox glyphBox = NewGlyphBox(); glyphBox.Character = text_buff[i]; textSpan.AddChild(glyphBox); } //return textSpan; result = textSpan; } else { //len=1 GlyphBox glyphBox = NewGlyphBox(); glyphBox.MathNode = node; glyphBox.Character = text_buff[0]; //return glyphBox; result = glyphBox; } } break; case "math": case "mrow": case "msub": case "msup": { HorizontalStackBox hbox = new HorizontalStackBox(); hbox.MathNode = node; // int child_count = node.ChildCount; for (int i = 0; i < child_count; ++i) { Box childBox = CreateMathBox(node.GetNode(i)); if (childBox != null) { hbox.AddChild(childBox); } } //return hbox; result = hbox; } break; case "mfrac": case "munder": { VerticalStackBox vbox = new VerticalStackBox(); vbox.MathNode = node; int child_count = node.ChildCount; for (int i = 0; i < child_count; ++i) { Box childBox = CreateMathBox(node.GetNode(i)); if (childBox != null) { vbox.AddChild(childBox); } } //return hbox; result = vbox; } break; case "mover": { VerticalStackBox vbox = new VerticalStackBox(); vbox.MathNode = node; int child_count = node.ChildCount; if (child_count != 2) //expect 2 { return(null); } Box baseBox = CreateMathBox(node.GetNode(0)); Box overBox = CreateMathBox(node.GetNode(1)); vbox.AddChild(overBox); vbox.AddChild(baseBox); //return hbox; result = vbox; } break; } if (result != null) { AssignGlyphVxs(result); } return(result); }