Esempio n. 1
0
    private void calculateBulletWidth(dfMarkupStyle style)
    {
        if (this.TagName == "ul")
        {
            var measuredBullet = style.Font.MeasureText("•", style.FontSize, style.FontStyle);

            BulletWidth = Mathf.CeilToInt(measuredBullet.x);

            return;
        }

        var itemCount = 0;

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            var child = ChildNodes[i] as dfMarkupTag;
            if (child != null && child.TagName == "li")
            {
                itemCount += 1;
            }
        }

        var numberText     = new string( 'X', itemCount.ToString().Length ) + ".";
        var measuredNumber = style.Font.MeasureText(numberText, style.FontSize, style.FontStyle);

        BulletWidth = Mathf.CeilToInt(measuredNumber.x);
    }
Esempio n. 2
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        var headingMargins = new dfMarkupBorders();

        var headingStyle = applyDefaultStyles(style, ref headingMargins);

        headingStyle = applyTextStyleAttributes(headingStyle);

        // Allow overriding of margins
        var marginAttribute = findAttribute("margin");

        if (marginAttribute != null)
        {
            headingMargins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var headingBox = new dfMarkupBox(this, dfMarkupDisplayType.block, headingStyle);

        headingBox.Margins = headingMargins;

        container.AddChild(headingBox);

        base._PerformLayoutImpl(headingBox, headingStyle);
        headingBox.FitToContents();
    }
Esempio n. 3
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        var fontAttribute = findAttribute("name", "face");

        if (fontAttribute != null)
        {
            style.Font = dfDynamicFont.FindByName(fontAttribute.Value) ?? style.Font;
        }

        var fontSizeAttribute = findAttribute("size", "font-size");

        if (fontSizeAttribute != null)
        {
            style.FontSize = dfMarkupStyle.ParseSize(fontSizeAttribute.Value, style.FontSize);
        }

        var fontColorAttribute = findAttribute("color");

        if (fontColorAttribute != null)
        {
            style.Color   = dfMarkupStyle.ParseColor(fontColorAttribute.Value, Color.red);
            style.Color.a = style.Opacity;
        }

        var fontStyleAttribute = findAttribute("style");

        if (fontStyleAttribute != null)
        {
            style.FontStyle = dfMarkupStyle.ParseFontStyle(fontStyleAttribute.Value, style.FontStyle);
        }

        base._PerformLayoutImpl(container, style);
    }
Esempio n. 4
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (this.ChildNodes.Count == 0)
        {
            return;
        }

        style.Align = dfMarkupTextAlign.Left;

        var listContainer = new dfMarkupBox(this, dfMarkupDisplayType.block, style);

        container.AddChild(listContainer);

        calculateBulletWidth(style);

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            var child = ChildNodes[i] as dfMarkupTag;
            if (child == null || child.TagName != "li")
            {
                continue;
            }

            child.PerformLayout(listContainer, style);
        }

        listContainer.FitToContents();
    }
Esempio n. 5
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     style.PreserveWhitespace = true;
     style.Preformatted = true;
     if (style.Align == dfMarkupTextAlign.Justify)
     {
         style.Align = dfMarkupTextAlign.Left;
     }
     dfMarkupBox _dfMarkupBox = null;
     if (style.BackgroundColor.a <= 0.1f)
     {
         _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     }
     else
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
         _dfMarkupBoxSprite.LoadImage(base.Owner.Atlas, base.Owner.BlankTextureSprite);
         _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
         _dfMarkupBox = _dfMarkupBoxSprite;
     }
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });
     if (_dfMarkupAttribute != null)
     {
         _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });
     if (_dfMarkupAttribute1 != null)
     {
         _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
     }
     container.AddChild(_dfMarkupBox);
     base._PerformLayoutImpl(_dfMarkupBox, style);
     _dfMarkupBox.FitToContents(false);
 }
Esempio n. 6
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "name", "face" });
     if (_dfMarkupAttribute != null)
     {
         style.Font = dfDynamicFont.FindByName(_dfMarkupAttribute.Value) ?? style.Font;
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "size", "font-size" });
     if (_dfMarkupAttribute1 != null)
     {
         style.FontSize = dfMarkupStyle.ParseSize(_dfMarkupAttribute1.Value, style.FontSize);
     }
     dfMarkupAttribute _dfMarkupAttribute2 = base.findAttribute(new string[] { "color" });
     if (_dfMarkupAttribute2 != null)
     {
         style.Color = dfMarkupStyle.ParseColor(_dfMarkupAttribute2.Value, Color.red);
         style.Color.a = style.Opacity;
     }
     dfMarkupAttribute _dfMarkupAttribute3 = base.findAttribute(new string[] { "style" });
     if (_dfMarkupAttribute3 != null)
     {
         style.FontStyle = dfMarkupStyle.ParseFontStyle(_dfMarkupAttribute3.Value, style.FontStyle);
     }
     base._PerformLayoutImpl(container, style);
 }
Esempio n. 7
0
 public dfMarkupBox(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     this.Element = element;
     this.Display = display;
     this.Style = style;
     this.Baseline = style.FontSize;
 }
Esempio n. 8
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        style.TextDecoration = dfMarkupTextDecoration.Underline;
        style = applyTextStyleAttributes(style);

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            var child = ChildNodes[i];

            if (child is dfMarkupString)
            {
                var text = child as dfMarkupString;
                if (text.Text == "\n")
                {
                    if (style.PreserveWhitespace)
                    {
                        container.AddLineBreak();
                    }
                    continue;
                }
            }

            child.PerformLayout(container, style);
        }
    }
Esempio n. 9
0
    private void processMarkup()
    {
        this.releaseMarkupReferences();
        this.elements = dfMarkupParser.Parse(this, this.text);
        float         num   = this.getTextScaleMultiplier();
        int           num2  = Mathf.CeilToInt(this.FontSize * num);
        int           num3  = Mathf.CeilToInt(this.LineHeight * num);
        dfMarkupStyle style = new dfMarkupStyle {
            Host               = this,
            Atlas              = this.Atlas,
            Font               = this.Font,
            FontSize           = num2,
            FontStyle          = this.FontStyle,
            LineHeight         = num3,
            Color              = (Color)base.ApplyOpacity(base.Color),
            Opacity            = base.CalculateOpacity(),
            Align              = this.TextAlignment,
            PreserveWhitespace = this.preserveWhitespace
        };
        dfMarkupBox box = new dfMarkupBox(null, dfMarkupDisplayType.block, style)
        {
            Size = base.Size
        };

        this.viewportBox = box;
        for (int i = 0; i < this.elements.Count; i++)
        {
            dfMarkupElement element = this.elements[i];
            if (element != null)
            {
                element.PerformLayout(this.viewportBox, style);
            }
        }
    }
Esempio n. 10
0
    private dfMarkupBox createImageBox(dfAtlas atlas, string source, dfMarkupStyle style)
    {
        if (source.ToLowerInvariant().StartsWith("http://"))
        {
            return(null);
        }
        else if (atlas != null && atlas[source] != null)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.inline, style);
            spriteBox.LoadImage(atlas, source);

            return(spriteBox);
        }
        else
        {
            var texture = dfMarkupImageCache.Load(source);
            if (texture != null)
            {
                var textureBox = new dfMarkupBoxTexture(this, dfMarkupDisplayType.inline, style);
                textureBox.LoadTexture(texture);

                return(textureBox);
            }
        }

        return(null);
    }
Esempio n. 11
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (this.ChildNodes.Count == 0)
        {
            return;
        }

        style = applyTextStyleAttributes(style);

        var topMargin = container.Children.Count == 0 ? 0 : style.LineHeight;

        dfMarkupBox paragraphBox = null;

        if (style.BackgroundColor.a > 0.005f)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            spriteBox.Atlas       = this.Owner.Atlas;
            spriteBox.Source      = this.Owner.BlankTextureSprite;
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;
        }
        else
        {
            paragraphBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }

        paragraphBox.Margins = new dfMarkupBorders(0, 0, topMargin, style.LineHeight);

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute("margin");
        if (marginAttribute != null)
        {
            paragraphBox.Margins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var paddingAttribute = findAttribute("padding");
        if (paddingAttribute != null)
        {
            paragraphBox.Padding = dfMarkupBorders.Parse(paddingAttribute.Value);
        }

        #endregion

        container.AddChild(paragraphBox);

        base._PerformLayoutImpl(paragraphBox, style);

        if (paragraphBox.Children.Count > 0)
        {
            paragraphBox.Children[paragraphBox.Children.Count - 1].IsNewline = true;
        }

        paragraphBox.FitToContents(true);
    }
Esempio n. 12
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (style.Font != null)
     {
         string          str = (!style.PreserveWhitespace && this.isWhitespace) ? " " : this.Text;
         dfMarkupBoxText box = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inline, style);
         box.SetText(str);
         container.AddChild(box);
     }
 }
Esempio n. 13
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (style.Font == null)
        {
            return;
        }
        string          str = (style.PreserveWhitespace || !this.isWhitespace ? this.Text : " ");
        dfMarkupBoxText _dfMarkupBoxText = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inline, style);

        _dfMarkupBoxText.SetText(str);
        container.AddChild(_dfMarkupBoxText);
    }
Esempio n. 14
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     if (style.FontStyle == FontStyle.Normal)
     {
         style.FontStyle = FontStyle.Bold;
     }
     else if (style.FontStyle == FontStyle.Italic)
     {
         style.FontStyle = FontStyle.BoldAndItalic;
     }
     base._PerformLayoutImpl(container, style);
 }
Esempio n. 15
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.Owner == null)
        {
            Debug.LogError(string.Concat("Tag has no parent: ", this));
            return;
        }
        style = this.applyStyleAttributes(style);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "src" });

        if (_dfMarkupAttribute == null)
        {
            return;
        }
        string      value        = _dfMarkupAttribute.Value;
        dfMarkupBox _dfMarkupBox = this.createImageBox(base.Owner.Atlas, value, style);

        if (_dfMarkupBox == null)
        {
            return;
        }
        Vector2           size = Vector2.zero;
        dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "height" });

        if (_dfMarkupAttribute1 != null)
        {
            size.y = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute1.Value, (int)_dfMarkupBox.Size.y);
        }
        dfMarkupAttribute _dfMarkupAttribute2 = base.findAttribute(new string[] { "width" });

        if (_dfMarkupAttribute2 != null)
        {
            size.x = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute2.Value, (int)_dfMarkupBox.Size.x);
        }
        if (size.sqrMagnitude <= 1.401298E-45f)
        {
            size = _dfMarkupBox.Size;
        }
        else if (size.x <= 1.401298E-45f)
        {
            size.x = size.y * (_dfMarkupBox.Size.x / _dfMarkupBox.Size.y);
        }
        else if (size.y <= 1.401298E-45f)
        {
            size.y = size.x * (_dfMarkupBox.Size.y / _dfMarkupBox.Size.x);
        }
        _dfMarkupBox.Size     = size;
        _dfMarkupBox.Baseline = (int)size.y;
        container.AddChild(_dfMarkupBox);
    }
Esempio n. 16
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        float       size         = container.Size.x;
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.listItem, style);

        _dfMarkupBox.Margins.top = 10;
        container.AddChild(_dfMarkupBox);
        dfMarkupTagList parent = base.Parent as dfMarkupTagList;

        if (parent == null)
        {
            base._PerformLayoutImpl(container, style);
            return;
        }
        style.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        string str = "•";

        if (parent.TagName == "ol")
        {
            str = string.Concat(container.Children.Count, ".");
        }
        dfMarkupStyle _dfMarkupStyle = style;

        _dfMarkupStyle.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        _dfMarkupStyle.Align         = dfMarkupTextAlign.Right;
        dfMarkupBoxText bulletWidth = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inlineBlock, _dfMarkupStyle);

        bulletWidth.SetText(str);
        bulletWidth.Width        = parent.BulletWidth;
        bulletWidth.Margins.left = style.FontSize * 2;
        _dfMarkupBox.AddChild(bulletWidth);
        dfMarkupBox vector2  = new dfMarkupBox(this, dfMarkupDisplayType.inlineBlock, style);
        int         fontSize = style.FontSize;
        float       single   = size - bulletWidth.Size.x - (float)bulletWidth.Margins.left - (float)fontSize;

        vector2.Size         = new Vector2(single, (float)fontSize);
        vector2.Margins.left = (int)((float)style.FontSize * 0.5f);
        _dfMarkupBox.AddChild(vector2);
        for (int i = 0; i < base.ChildNodes.Count; i++)
        {
            base.ChildNodes[i].PerformLayout(vector2, style);
        }
        vector2.FitToContents(false);
        vector2.Parent.FitToContents(false);
        _dfMarkupBox.FitToContents(false);
    }
Esempio n. 17
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.Owner == null)
     {
         Debug.LogError("Tag has no parent: " + this);
     }
     else
     {
         style = this.applyStyleAttributes(style);
         string[]          names     = new string[] { "src" };
         dfMarkupAttribute attribute = base.findAttribute(names);
         if (attribute != null)
         {
             string      source = attribute.Value;
             dfMarkupBox box    = this.createImageBox(base.Owner.Atlas, source, style);
             if (box != null)
             {
                 Vector2           zero       = Vector2.zero;
                 string[]          textArray2 = new string[] { "height" };
                 dfMarkupAttribute attribute2 = base.findAttribute(textArray2);
                 if (attribute2 != null)
                 {
                     zero.y = dfMarkupStyle.ParseSize(attribute2.Value, (int)box.Size.y);
                 }
                 string[]          textArray3 = new string[] { "width" };
                 dfMarkupAttribute attribute3 = base.findAttribute(textArray3);
                 if (attribute3 != null)
                 {
                     zero.x = dfMarkupStyle.ParseSize(attribute3.Value, (int)box.Size.x);
                 }
                 if (zero.sqrMagnitude <= float.Epsilon)
                 {
                     zero = box.Size;
                 }
                 else if (zero.x <= float.Epsilon)
                 {
                     zero.x = zero.y * (box.Size.x / box.Size.y);
                 }
                 else if (zero.y <= float.Epsilon)
                 {
                     zero.y = zero.x * (box.Size.y / box.Size.x);
                 }
                 box.Size     = zero;
                 box.Baseline = (int)zero.y;
                 container.AddChild(box);
             }
         }
     }
 }
Esempio n. 18
0
    private dfMarkupStyle applyDefaultStyles(dfMarkupStyle style, ref dfMarkupBorders margins)
    {
        // http://www.w3.org/TR/CSS21/sample.html

        var marginSize = 1f;
        var fontSize   = 1f;

        switch (TagName)
        {
        case "h1":
            fontSize   = 2f;
            marginSize = 0.65f;
            break;

        case "h2":
            fontSize   = 1.5f;
            marginSize = 0.75f;
            break;

        case "h3":
            fontSize   = 1.35f;
            marginSize = 0.85f;
            break;

        case "h4":
            fontSize   = 1.15f;
            marginSize = 0;
            break;

        case "h5":
            fontSize   = 0.85f;
            marginSize = 1.5f;
            break;

        case "h6":
            fontSize   = 0.75f;
            marginSize = 1.75f;
            break;
        }

        style.FontSize  = (int)(style.FontSize * fontSize);
        style.FontStyle = FontStyle.Bold;
        style.Align     = dfMarkupTextAlign.Left;

        marginSize *= style.FontSize;
        margins.top = margins.bottom = (int)marginSize;

        return(style);
    }
Esempio n. 19
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupElement item = base.ChildNodes[i];
         if (!(item is dfMarkupString) || !((item as dfMarkupString).Text == "\n"))
         {
             item.PerformLayout(container, style);
         }
         else if (style.PreserveWhitespace)
         {
             container.AddLineBreak();
         }
     }
 }
Esempio n. 20
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupElement item = base.ChildNodes[i];
         if (!(item is dfMarkupString) || !((item as dfMarkupString).Text == "\n"))
         {
             item.PerformLayout(container, style);
         }
         else if (style.PreserveWhitespace)
         {
             container.AddLineBreak();
         }
     }
 }
Esempio n. 21
0
 private dfMarkupStyle applyStyleAttributes(dfMarkupStyle style)
 {
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "valign" });
     if (_dfMarkupAttribute != null)
     {
         style.VerticalAlign = dfMarkupStyle.ParseVerticalAlignment(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "color" });
     if (_dfMarkupAttribute1 != null)
     {
         Color opacity = dfMarkupStyle.ParseColor(_dfMarkupAttribute1.Value, base.Owner.Color);
         opacity.a = style.Opacity;
         style.Color = opacity;
     }
     return style;
 }
Esempio n. 22
0
 public static dfMarkupBoxText Obtain(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     if (dfMarkupBoxText.objectPool.Count <= 0)
     {
         return new dfMarkupBoxText(element, display, style);
     }
     dfMarkupBoxText fontSize = dfMarkupBoxText.objectPool.Dequeue();
     fontSize.Element = element;
     fontSize.Display = display;
     fontSize.Style = style;
     fontSize.Position = Vector2.zero;
     fontSize.Size = Vector2.zero;
     fontSize.Baseline = (int)((float)style.FontSize * 1.1f);
     fontSize.Margins = new dfMarkupBorders();
     fontSize.Padding = new dfMarkupBorders();
     return fontSize;
 }
Esempio n. 23
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.Owner == null)
     {
         Debug.LogError(string.Concat("Tag has no parent: ", this));
         return;
     }
     style = this.applyStyleAttributes(style);
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "src" });
     if (_dfMarkupAttribute == null)
     {
         return;
     }
     string value = _dfMarkupAttribute.Value;
     dfMarkupBox _dfMarkupBox = this.createImageBox(base.Owner.Atlas, value, style);
     if (_dfMarkupBox == null)
     {
         return;
     }
     Vector2 size = Vector2.zero;
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "height" });
     if (_dfMarkupAttribute1 != null)
     {
         size.y = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute1.Value, (int)_dfMarkupBox.Size.y);
     }
     dfMarkupAttribute _dfMarkupAttribute2 = base.findAttribute(new string[] { "width" });
     if (_dfMarkupAttribute2 != null)
     {
         size.x = (float)dfMarkupStyle.ParseSize(_dfMarkupAttribute2.Value, (int)_dfMarkupBox.Size.x);
     }
     if (size.sqrMagnitude <= 1.401298E-45f)
     {
         size = _dfMarkupBox.Size;
     }
     else if (size.x <= 1.401298E-45f)
     {
         size.x = size.y * (_dfMarkupBox.Size.x / _dfMarkupBox.Size.y);
     }
     else if (size.y <= 1.401298E-45f)
     {
         size.y = size.x * (_dfMarkupBox.Size.y / _dfMarkupBox.Size.x);
     }
     _dfMarkupBox.Size = size;
     _dfMarkupBox.Baseline = (int)size.y;
     container.AddChild(_dfMarkupBox);
 }
Esempio n. 24
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        style = base.applyTextStyleAttributes(style);
        int         num          = (container.Children.Count != 0 ? style.LineHeight : 0);
        dfMarkupBox _dfMarkupBox = null;

        if (style.BackgroundColor.a <= 0.005f)
        {
            _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }
        else
        {
            dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
            {
                Atlas  = base.Owner.Atlas,
                Source = base.Owner.BlankTextureSprite
            };
            _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
            _dfMarkupBox = _dfMarkupBoxSprite;
        }
        _dfMarkupBox.Margins = new dfMarkupBorders(0, 0, num, style.LineHeight);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });

        if (_dfMarkupAttribute != null)
        {
            _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
        }
        dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });

        if (_dfMarkupAttribute1 != null)
        {
            _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
        }
        container.AddChild(_dfMarkupBox);
        base._PerformLayoutImpl(_dfMarkupBox, style);
        if (_dfMarkupBox.Children.Count > 0)
        {
            _dfMarkupBox.Children[_dfMarkupBox.Children.Count - 1].IsNewline = true;
        }
        _dfMarkupBox.FitToContents(true);
    }
Esempio n. 25
0
    private dfMarkupStyle applyStyleAttributes(dfMarkupStyle style)
    {
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "valign" });

        if (_dfMarkupAttribute != null)
        {
            style.VerticalAlign = dfMarkupStyle.ParseVerticalAlignment(_dfMarkupAttribute.Value);
        }
        dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "color" });

        if (_dfMarkupAttribute1 != null)
        {
            Color opacity = dfMarkupStyle.ParseColor(_dfMarkupAttribute1.Value, base.Owner.Color);
            opacity.a   = style.Opacity;
            style.Color = opacity;
        }
        return(style);
    }
Esempio n. 26
0
    private dfMarkupStyle applyDefaultStyles(dfMarkupStyle style, ref dfMarkupBorders margins)
    {
        float  num     = 1f;
        float  num2    = 1f;
        string tagName = base.TagName;

        if (tagName != null)
        {
            int num3;
            if (< > f__switch$mapE == null)
            {
                Dictionary <string, int> dictionary = new Dictionary <string, int>(6);
                dictionary.Add("h1", 0);
                dictionary.Add("h2", 1);
                dictionary.Add("h3", 2);
                dictionary.Add("h4", 3);
                dictionary.Add("h5", 4);
                dictionary.Add("h6", 5);
Esempio n. 27
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count == 0)
     {
         return;
     }
     float size = container.Size.x;
     dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.listItem, style);
     _dfMarkupBox.Margins.top = 10;
     container.AddChild(_dfMarkupBox);
     dfMarkupTagList parent = base.Parent as dfMarkupTagList;
     if (parent == null)
     {
         base._PerformLayoutImpl(container, style);
         return;
     }
     style.VerticalAlign = dfMarkupVerticalAlign.Baseline;
     string str = "•";
     if (parent.TagName == "ol")
     {
         str = string.Concat(container.Children.Count, ".");
     }
     dfMarkupStyle _dfMarkupStyle = style;
     _dfMarkupStyle.VerticalAlign = dfMarkupVerticalAlign.Baseline;
     _dfMarkupStyle.Align = dfMarkupTextAlign.Right;
     dfMarkupBoxText bulletWidth = dfMarkupBoxText.Obtain(this, dfMarkupDisplayType.inlineBlock, _dfMarkupStyle);
     bulletWidth.SetText(str);
     bulletWidth.Width = parent.BulletWidth;
     bulletWidth.Margins.left = style.FontSize * 2;
     _dfMarkupBox.AddChild(bulletWidth);
     dfMarkupBox vector2 = new dfMarkupBox(this, dfMarkupDisplayType.inlineBlock, style);
     int fontSize = style.FontSize;
     float single = size - bulletWidth.Size.x - (float)bulletWidth.Margins.left - (float)fontSize;
     vector2.Size = new Vector2(single, (float)fontSize);
     vector2.Margins.left = (int)((float)style.FontSize * 0.5f);
     _dfMarkupBox.AddChild(vector2);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         base.ChildNodes[i].PerformLayout(vector2, style);
     }
     vector2.FitToContents(false);
     vector2.Parent.FitToContents(false);
     _dfMarkupBox.FitToContents(false);
 }
Esempio n. 28
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        // Only happens while user is in the process of typing an unfinished tag
        if (this.IsEndTag)
        {
            return;
        }

        var marginAttribute = findAttribute("margin");

        if (marginAttribute != null)
        {
        }

        for (int i = 0; i < ChildNodes.Count; i++)
        {
            ChildNodes[i].PerformLayout(container, style);
        }
    }
Esempio n. 29
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count == 0)
     {
         return;
     }
     style = base.applyTextStyleAttributes(style);
     int num = (container.Children.Count != 0 ? style.LineHeight : 0);
     dfMarkupBox _dfMarkupBox = null;
     if (style.BackgroundColor.a <= 0.005f)
     {
         _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     }
     else
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
         {
             Atlas = base.Owner.Atlas,
             Source = base.Owner.BlankTextureSprite
         };
         _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
         _dfMarkupBox = _dfMarkupBoxSprite;
     }
     _dfMarkupBox.Margins = new dfMarkupBorders(0, 0, num, style.LineHeight);
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });
     if (_dfMarkupAttribute != null)
     {
         _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });
     if (_dfMarkupAttribute1 != null)
     {
         _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
     }
     container.AddChild(_dfMarkupBox);
     base._PerformLayoutImpl(_dfMarkupBox, style);
     if (_dfMarkupBox.Children.Count > 0)
     {
         _dfMarkupBox.Children[_dfMarkupBox.Children.Count - 1].IsNewline = true;
     }
     _dfMarkupBox.FitToContents(true);
 }
Esempio n. 30
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count == 0)
     {
         return;
     }
     style.Align = dfMarkupTextAlign.Left;
     dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     container.AddChild(_dfMarkupBox);
     this.calculateBulletWidth(style);
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupTag item = base.ChildNodes[i] as dfMarkupTag;
         if (item != null && !(item.TagName != "li"))
         {
             item.PerformLayout(_dfMarkupBox, style);
         }
     }
     _dfMarkupBox.FitToContents(false);
 }
Esempio n. 31
0
 private void calculateBulletWidth(dfMarkupStyle style)
 {
     if (base.TagName == "ul")
     {
         Vector2 vector2 = style.Font.MeasureText("•", style.FontSize, style.FontStyle);
         this.BulletWidth = Mathf.CeilToInt(vector2.x);
         return;
     }
     int num = 0;
     for (int i = 0; i < base.ChildNodes.Count; i++)
     {
         dfMarkupTag item = base.ChildNodes[i] as dfMarkupTag;
         if (item != null && item.TagName == "li")
         {
             num++;
         }
     }
     string str = string.Concat(new string('X', num.ToString().Length), ".");
     Vector2 vector21 = style.Font.MeasureText(str, style.FontSize, style.FontStyle);
     this.BulletWidth = Mathf.CeilToInt(vector21.x);
 }
Esempio n. 32
0
    private dfMarkupStyle applyStyleAttributes( dfMarkupStyle style )
    {
        var alignAttribute = findAttribute( "valign" );
        if( alignAttribute != null )
        {
            style.VerticalAlign = dfMarkupStyle.ParseVerticalAlignment( alignAttribute.Value );
        }

        var fontColorAttribute = findAttribute( "color" );
        if( fontColorAttribute != null )
        {
            var color = dfMarkupStyle.ParseColor( fontColorAttribute.Value, Owner.Color );
            color.a = style.Opacity;
            style.Color = color;
        }

        return style;
    }
Esempio n. 33
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( Owner == null )
        {
            Debug.LogError( "Tag has no parent: " + this );
            return;
        }

        style = applyStyleAttributes( style );

        var sourceAttribute = findAttribute( "src" );
        if( sourceAttribute == null )
            return;

        var source = sourceAttribute.Value;

        var imageBox = createImageBox( Owner.Atlas, source, style );
        if( imageBox == null )
            return;

        var size = Vector2.zero;

        var heightAttribute = findAttribute( "height" );
        if( heightAttribute != null )
        {
            size.y = dfMarkupStyle.ParseSize( heightAttribute.Value, (int)imageBox.Size.y );
        }

        var widthAttribute = findAttribute( "width" );
        if( widthAttribute != null )
        {
            size.x = dfMarkupStyle.ParseSize( widthAttribute.Value, (int)imageBox.Size.x );
        }

        if( size.sqrMagnitude <= float.Epsilon )
        {
            size = imageBox.Size;
        }
        else if( size.x <= float.Epsilon )
        {
            size.x = size.y * ( imageBox.Size.x / imageBox.Size.y );
        }
        else if( size.y <= float.Epsilon )
        {
            size.y = size.x * ( imageBox.Size.y / imageBox.Size.x );
        }

        imageBox.Size = size;
        imageBox.Baseline = (int)size.y;

        container.AddChild( imageBox );
    }
Esempio n. 34
0
    private dfMarkupStyle applyDefaultStyles( dfMarkupStyle style, ref dfMarkupBorders margins )
    {
        // http://www.w3.org/TR/CSS21/sample.html

        var marginSize = 1f;
        var fontSize = 1f;

        switch( TagName )
        {
            case "h1":
                fontSize = 2f;
                marginSize = 0.65f;
                break;
            case "h2":
                fontSize = 1.5f;
                marginSize = 0.75f;
                break;
            case "h3":
                fontSize = 1.35f;
                marginSize = 0.85f;
                break;
            case "h4":
                fontSize = 1.15f;
                marginSize = 0;
                break;
            case "h5":
                fontSize = 0.85f;
                marginSize = 1.5f;
                break;
            case "h6":
                fontSize = 0.75f;
                marginSize = 1.75f;
                break;
        }

        style.FontSize = (int)( style.FontSize * fontSize );
        style.FontStyle = FontStyle.Bold;
        style.Align = dfMarkupTextAlign.Left;

        marginSize *= style.FontSize;
        margins.top = margins.bottom = (int)marginSize;

        return style;
    }
Esempio n. 35
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        var headingMargins = new dfMarkupBorders();

        var headingStyle = applyDefaultStyles( style, ref headingMargins );
        headingStyle = applyTextStyleAttributes( headingStyle );

        // Allow overriding of margins
        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            headingMargins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var headingBox = new dfMarkupBox( this, dfMarkupDisplayType.block, headingStyle );
        headingBox.Margins = headingMargins;

        container.AddChild( headingBox );

        base._PerformLayoutImpl( headingBox, headingStyle );
        headingBox.FitToContents();
    }
Esempio n. 36
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        var fontAttribute = findAttribute( "name", "face" );
        if( fontAttribute != null )
        {
            style.Font = dfDynamicFont.FindByName( fontAttribute.Value ) ?? style.Font;
        }

        var fontSizeAttribute = findAttribute( "size", "font-size" );
        if( fontSizeAttribute != null )
        {
            style.FontSize = dfMarkupStyle.ParseSize( fontSizeAttribute.Value, style.FontSize );
        }

        var fontColorAttribute = findAttribute( "color" );
        if( fontColorAttribute != null )
        {
            style.Color = dfMarkupStyle.ParseColor( fontColorAttribute.Value, Color.red );
            style.Color.a = style.Opacity;
        }

        var fontStyleAttribute = findAttribute( "style" );
        if( fontStyleAttribute != null )
        {
            style.FontStyle = dfMarkupStyle.ParseFontStyle( fontStyleAttribute.Value, style.FontStyle );
        }

        base._PerformLayoutImpl( container, style );
    }
Esempio n. 37
0
 protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
 {
     container.AddLineBreak();
 }
Esempio n. 38
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        style.TextDecoration = dfMarkupTextDecoration.Underline;
        style = applyTextStyleAttributes( style );

        for( int i = 0; i < ChildNodes.Count; i++ )
        {

            var child = ChildNodes[ i ];

            if( child is dfMarkupString )
            {

                var text = child as dfMarkupString;
                if( text.Text == "\n" )
                {
                    if( style.PreserveWhitespace )
                    {
                        container.AddLineBreak();
                    }
                    continue;
                }

            }

            child.PerformLayout( container, style );

        }
    }
Esempio n. 39
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        // Only happens while user is in the process of typing an unfinished tag
        if( this.IsEndTag )
        {
            return;
        }

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
        }

        for( int i = 0; i < ChildNodes.Count; i++ )
        {
            ChildNodes[ i ].PerformLayout( container, style );
        }
    }
Esempio n. 40
0
    protected dfMarkupStyle applyTextStyleAttributes( dfMarkupStyle style )
    {
        var fontAttribute = findAttribute( "font", "font-family" );
        if( fontAttribute != null )
        {
            style.Font = dfDynamicFont.FindByName( fontAttribute.Value ) ?? owner.Font;
        }

        var fontStyleAttribute = findAttribute( "style", "font-style" );
        if( fontStyleAttribute != null )
        {
            style.FontStyle = dfMarkupStyle.ParseFontStyle( fontStyleAttribute.Value, style.FontStyle );
        }

        var sizeAttribute = findAttribute( "size", "font-size" );
        if( sizeAttribute != null )
        {
            style.FontSize = dfMarkupStyle.ParseSize( sizeAttribute.Value, style.FontSize );
        }

        var colorAttribute = findAttribute( "color" );
        if( colorAttribute != null )
        {
            var color = dfMarkupStyle.ParseColor( colorAttribute.Value, style.Color );
            color.a = style.Opacity;
            style.Color = color;
        }

        var alignAttribute = findAttribute( "align", "text-align" );
        if( alignAttribute != null )
        {
            style.Align = dfMarkupStyle.ParseTextAlignment( alignAttribute.Value );
        }

        var vertAlignAttribute = findAttribute( "valign", "vertical-align" );
        if( vertAlignAttribute != null )
        {
            style.VerticalAlign = dfMarkupStyle.ParseVerticalAlignment( vertAlignAttribute.Value );
        }

        var lineHeightAttribute = findAttribute( "line-height" );
        if( lineHeightAttribute != null )
        {
            style.LineHeight = dfMarkupStyle.ParseSize( lineHeightAttribute.Value, style.LineHeight );
        }

        var textDecorationAttribute = findAttribute( "text-decoration" );
        if( textDecorationAttribute != null )
        {
            style.TextDecoration = dfMarkupStyle.ParseTextDecoration( textDecorationAttribute.Value );
        }

        var backgroundAttribute = findAttribute( "background", "background-color" );
        if( backgroundAttribute != null )
        {
            style.BackgroundColor = dfMarkupStyle.ParseColor( backgroundAttribute.Value, Color.clear );
            style.BackgroundColor.a = style.Opacity;
        }

        return style;
    }
Esempio n. 41
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        style = applyTextStyleAttributes( style );

        var topMargin = container.Children.Count == 0 ? 0 : style.LineHeight;

        dfMarkupBox paragraphBox = null;

        if( style.BackgroundColor.a > 0.005f )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.block, style );
            spriteBox.Atlas = this.Owner.Atlas;
            spriteBox.Source = this.Owner.BlankTextureSprite;
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;

        }
        else
        {
            paragraphBox = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        }

        paragraphBox.Margins = new dfMarkupBorders( 0, 0, topMargin, style.LineHeight );

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            paragraphBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var paddingAttribute = findAttribute( "padding" );
        if( paddingAttribute != null )
        {
            paragraphBox.Padding = dfMarkupBorders.Parse( paddingAttribute.Value );
        }

        #endregion

        container.AddChild( paragraphBox );

        base._PerformLayoutImpl( paragraphBox, style );

        if( paragraphBox.Children.Count > 0 )
        {
            paragraphBox.Children[ paragraphBox.Children.Count - 1 ].IsNewline = true;
        }

        paragraphBox.FitToContents( true );
    }
Esempio n. 42
0
    private void calculateBulletWidth( dfMarkupStyle style )
    {
        if( this.TagName == "ul" )
        {

            var measuredBullet = style.Font.MeasureText( "•", style.FontSize, style.FontStyle );

            BulletWidth = Mathf.CeilToInt( measuredBullet.x );

            return;

        }

        var itemCount = 0;
        for( int i = 0; i < ChildNodes.Count; i++ )
        {

            var child = ChildNodes[ i ] as dfMarkupTag;
            if( child != null && child.TagName == "li" )
            {
                itemCount += 1;
            }

        }

        var numberText = new string( 'X', itemCount.ToString().Length ) + ".";
        var measuredNumber = style.Font.MeasureText( numberText, style.FontSize, style.FontStyle );

        BulletWidth = Mathf.CeilToInt( measuredNumber.x );
    }
Esempio n. 43
0
    private dfMarkupBox createImageBox( dfAtlas atlas, string source, dfMarkupStyle style )
    {
        if( source.ToLowerInvariant().StartsWith( "http://" ) )
        {
            return null;
        }
        else if( atlas != null && atlas[ source ] != null )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.inline, style );
            spriteBox.LoadImage( atlas, source );

            return spriteBox;

        }
        else
        {
            var texture = dfMarkupImageCache.Load( source );
            if( texture != null )
            {

                var textureBox = new dfMarkupBoxTexture( this, dfMarkupDisplayType.inline, style );
                textureBox.LoadTexture( texture );

                return textureBox;

            }
        }

        return null;
    }
Esempio n. 44
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        style.Align = dfMarkupTextAlign.Left;

        var listContainer = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        container.AddChild( listContainer );

        calculateBulletWidth( style );

        for( int i = 0; i < ChildNodes.Count; i++ )
        {

            var child = ChildNodes[ i ] as dfMarkupTag;
            if( child == null || child.TagName != "li" )
            {
                continue;
            }

            child.PerformLayout( listContainer, style );

        }

        listContainer.FitToContents();
    }
Esempio n. 45
0
 public void PerformLayout( dfMarkupBox container, dfMarkupStyle style )
 {
     Profiler.BeginSample( "Perform markup layout: " + this.GetType().Name );
     _PerformLayoutImpl( container, style );
     Profiler.EndSample();
 }
Esempio n. 46
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        var containerWidth = container.Size.x;

        var listItemContainer = new dfMarkupBox( this, dfMarkupDisplayType.listItem, style );
        listItemContainer.Margins.top = 10;
        container.AddChild( listItemContainer );

        var list = this.Parent as dfMarkupTagList;
        if( list == null )
        {
            // If the list item is not contained in a list, process its
            // child elements as normal html elements
            base._PerformLayoutImpl( container, style );
            return;
        }

        style.VerticalAlign = dfMarkupVerticalAlign.Baseline;

        var bulletText = "•";
        if( list.TagName == "ol" )
        {
            bulletText = container.Children.Count + ".";
        }

        var bulletBoxStyle = style;
        bulletBoxStyle.VerticalAlign = dfMarkupVerticalAlign.Baseline;
        bulletBoxStyle.Align = dfMarkupTextAlign.Right;

        // TODO: Pre-measure bullet item size (for ordered lists) at the <UL> tag level
        var listBulletElement = dfMarkupBoxText.Obtain( this, dfMarkupDisplayType.inlineBlock, bulletBoxStyle );
        listBulletElement.SetText( bulletText );
        listBulletElement.Width = list.BulletWidth;
        listBulletElement.Margins.left = style.FontSize * 2;
        listItemContainer.AddChild( listBulletElement );

        var listItemBox = new dfMarkupBox( this, dfMarkupDisplayType.inlineBlock, style );
        var listItemLeftMargin = style.FontSize;
        var listItemWidth = containerWidth - listBulletElement.Size.x - listBulletElement.Margins.left - listItemLeftMargin;
        listItemBox.Size = new Vector2( listItemWidth, listItemLeftMargin );
        listItemBox.Margins.left = (int)( style.FontSize * 0.5f );
        listItemContainer.AddChild( listItemBox );

        for( int i = 0; i < ChildNodes.Count; i++ )
        {
            ChildNodes[ i ].PerformLayout( listItemBox, style );
        }

        listItemBox.FitToContents();

        // The listItemBox.Parent property will actually refer to an internal
        // linebox that hosts the listItemBox, which needs to be fit to the
        // contents of the list item box.
        if( listItemBox.Parent != null )
        {
            listItemBox.Parent.FitToContents();
        }

        listItemContainer.FitToContents();
    }
Esempio n. 47
0
 protected abstract void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style );
Esempio n. 48
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        style = applyTextStyleAttributes( style );

        style.PreserveWhitespace = true;
        style.Preformatted = true;

        if( style.Align == dfMarkupTextAlign.Justify )
        {
            style.Align = dfMarkupTextAlign.Left;
        }

        dfMarkupBox paragraphBox = null;

        if( style.BackgroundColor.a > 0.1f )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.block, style );
            spriteBox.LoadImage( this.Owner.Atlas, this.Owner.BlankTextureSprite );
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;

        }
        else
        {
            paragraphBox = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        }

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            paragraphBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var paddingAttribute = findAttribute( "padding" );
        if( paddingAttribute != null )
        {
            paragraphBox.Padding = dfMarkupBorders.Parse( paddingAttribute.Value );
        }

        #endregion

        container.AddChild( paragraphBox );

        base._PerformLayoutImpl( paragraphBox, style );

        paragraphBox.FitToContents();
    }
Esempio n. 49
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        style = applyTextStyleAttributes( style );

        dfMarkupBox spanBox = container;

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {

            spanBox = new dfMarkupBox( this, dfMarkupDisplayType.inlineBlock, style );
            spanBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );

            // Span does not utilize top and bottom margins
            spanBox.Margins.top = 0;
            spanBox.Margins.bottom = 0;

            container.AddChild( spanBox );

        }

        for( int i = 0; i < ChildNodes.Count; i++ )
        {

            var child = ChildNodes[i];

            if( child is dfMarkupString )
            {

                var text = child as dfMarkupString;
                if( text.Text == "\n" )
                {
                    if( style.PreserveWhitespace )
                    {
                        spanBox.AddLineBreak();
                    }
                    continue;
                }

            }

            child.PerformLayout( spanBox, style );

        }
    }