Ejemplo n.º 1
0
        public Document parseAndLayout(string str, int width = 40)
        {
            var root = Parser.Default.Parse(str);

            root.LayoutedWidth = root.Width = width;
            var layouter = new Layouter(root);

            layouter.Reflow();
            return(root);
        }
Ejemplo n.º 2
0
        void reflowInlineBlock(Element e)
        {
            e.LayoutedWidth = e.Width;
            var layouter = new Layouter(e);

            layouter.Reflow();

            e.CalculateBlockHeight();

            addInlineFragment(e);
        }
Ejemplo n.º 3
0
 static void Main(string[] args)
 {
     foreach (var arg in args)
     {
         var src  = System.IO.File.ReadAllText(arg);
         var root = Tml.Parser.Default.Parse(src);
         root.LayoutedWidth  = root.Width = 100;
         root.LayoutedHeight = root.Height = 100;
         var layouter = new Layouter(root);
         layouter.Reflow();
         Console.Write(root.DumpToHtml());
     }
 }
Ejemplo n.º 4
0
        // ブロック要素を配置する
        void reflowBlock(Element e)
        {
            // ブロックレイアウトの場合
            // まず、幅を決定してから、高さを計算する
            e.LayoutedWidth = Target.LayoutedInnerWidth - e.Style.MarginLeft - e.Style.MarginBottom;
            var layouter = new Layouter(e);

            layouter.Reflow();

            e.CalculateBlockHeight();
            e.LayoutedY = currentY_ + e.Style.MarginTop;
            e.LayoutedX = Target.Style.PaddingLeft + e.Style.MarginLeft;
            currentY_  += e.LayoutedHeight + e.Style.MarginTop + e.Style.MarginBottom;

            Target.Fragments.Add(e);
        }
Ejemplo n.º 5
0
        public void LoaderTest2()
        {
            string src   = @"<div id='div' width='100'><p id='p1'>hoge</p><p id='p2'>fuga</p></div>";
            string css   = "p { margin-left: 1; margin-right: 2; margin-top: 3; margin-bottom: 4; }";
            var    root  = Tml.Parser.Default.Parse(src);
            var    sheet = new StyleSheet();

            new StyleParser().ParseStyleSheet(sheet, css);
            root.ApplyStyle(sheet);
            root.LayoutedWidth = 100;
            var layouter = new Layouter(root);

            layouter.Reflow();
            var p1 = root.FindById("p1");
            var p2 = root.FindById("p2");

            Logger.Log(p1.Id);
            Assert.AreEqual(95, p1.LayoutedWidth);
            Assert.AreEqual(15, p1.LayoutedHeight);
            Assert.AreEqual(15, p2.LayoutedHeight);
            Assert.AreEqual(44, root.LayoutedHeight);
            //Assert.AreEqual(element, null);
        }