Example #1
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();
    }
Example #2
0
 private dfMarkupBox()
 {
     this.Position = Vector2.zero;
     this.Size     = Vector2.zero;
     this.Margins  = new dfMarkupBorders(0, 0, 0, 0);
     this.Padding  = new dfMarkupBorders(0, 0, 0, 0);
     this.children = new System.Collections.Generic.List <dfMarkupBox>();
     throw new NotImplementedException();
 }
Example #3
0
    private void addInline(dfMarkupBox box)
    {
        dfMarkupBorders margins = box.Margins;
        bool            flag    = !this.Style.Preformatted && ((this.currentLine != null) && ((this.currentLinePos + box.Size.x) > this.currentLine.Size.x));

        if ((this.currentLine == null) || flag)
        {
            dfDynamicFont font;
            this.endCurrentLine(false);
            int         num             = this.getVerticalPosition(margins.top);
            dfMarkupBox containingBlock = this.GetContainingBlock();
            if (containingBlock == null)
            {
                Debug.LogError("Containing block not found");
                return;
            }
            if (this.Style.Font != null)
            {
                font = this.Style.Font;
            }
            else
            {
                font = this.Style.Host.Font;
            }
            float       num2 = ((float)font.FontSize) / ((float)font.FontSize);
            float       num3 = font.Baseline * num2;
            dfMarkupBox box3 = new dfMarkupBox(this.Element, dfMarkupDisplayType.block, this.Style)
            {
                Size     = new Vector2(containingBlock.Size.x, (float)this.Style.LineHeight),
                Position = new Vector2(0f, (float)num),
                Parent   = this,
                Baseline = (int)num3
            };
            this.currentLine = box3;
            this.children.Add(this.currentLine);
        }
        if (((this.currentLinePos == 0) && !box.Style.PreserveWhitespace) && (box is dfMarkupBoxText))
        {
            dfMarkupBoxText text = box as dfMarkupBoxText;
            if (text.IsWhitespace)
            {
                return;
            }
        }
        Vector2 vector = new Vector2((float)(this.currentLinePos + margins.left), (float)margins.top);

        box.Position = vector;
        box.Parent   = this.currentLine;
        this.currentLine.children.Add(box);
        this.currentLinePos = ((int)(vector.x + box.Size.x)) + box.Margins.right;
        float x = Mathf.Max(this.currentLine.Size.x, vector.x + box.Size.x);
        float y = Mathf.Max(this.currentLine.Size.y, vector.y + box.Size.y);

        this.currentLine.Size = new Vector2(x, y);
    }
Example #4
0
 public virtual void Release()
 {
     for (int i = 0; i < this.children.Count; i++)
     {
         this.children[i].Release();
     }
     this.children.Clear();
     this.Element = null;
     this.Parent  = null;
     this.Margins = new dfMarkupBorders();
 }
Example #5
0
    public static dfMarkupBorders Parse(string value)
    {
        int             num;
        dfMarkupBorders dfMarkupBorder = new dfMarkupBorders();

        value = Regex.Replace(value, "\\s+", " ");
        string[] strArrays = value.Split(new char[] { ' ' });
        if ((int)strArrays.Length == 1)
        {
            int num1 = dfMarkupStyle.ParseSize(value, 0);
            int num2 = num1;
            num = num2;
            dfMarkupBorder.right = num2;
            dfMarkupBorder.left  = num;
            int num3 = num1;
            num = num3;
            dfMarkupBorder.bottom = num3;
            dfMarkupBorder.top    = num;
        }
        else if ((int)strArrays.Length == 2)
        {
            int num4 = dfMarkupStyle.ParseSize(strArrays[0], 0);
            num = num4;
            dfMarkupBorder.bottom = num4;
            dfMarkupBorder.top    = num;
            int num5 = dfMarkupStyle.ParseSize(strArrays[1], 0);
            num = num5;
            dfMarkupBorder.right = num5;
            dfMarkupBorder.left  = num;
        }
        else if ((int)strArrays.Length == 3)
        {
            int num6 = dfMarkupStyle.ParseSize(strArrays[0], 0);
            dfMarkupBorder.top = num6;
            int num7 = dfMarkupStyle.ParseSize(strArrays[1], 0);
            num = num7;
            dfMarkupBorder.right = num7;
            dfMarkupBorder.left  = num;
            int num8 = dfMarkupStyle.ParseSize(strArrays[2], 0);
            dfMarkupBorder.bottom = num8;
        }
        else if ((int)strArrays.Length == 4)
        {
            int num9 = dfMarkupStyle.ParseSize(strArrays[0], 0);
            dfMarkupBorder.top = num9;
            int num10 = dfMarkupStyle.ParseSize(strArrays[1], 0);
            dfMarkupBorder.right = num10;
            int num11 = dfMarkupStyle.ParseSize(strArrays[2], 0);
            dfMarkupBorder.bottom = num11;
            int num12 = dfMarkupStyle.ParseSize(strArrays[3], 0);
            dfMarkupBorder.left = num12;
        }
        return(dfMarkupBorder);
    }
Example #6
0
 public dfMarkupBox(dfMarkupElement element, dfMarkupDisplayType display, dfMarkupStyle style)
 {
     this.Position = Vector2.zero;
     this.Size     = Vector2.zero;
     this.Margins  = new dfMarkupBorders(0, 0, 0, 0);
     this.Padding  = new dfMarkupBorders(0, 0, 0, 0);
     this.children = new System.Collections.Generic.List <dfMarkupBox>();
     this.Element  = element;
     this.Display  = display;
     this.Style    = style;
     this.Baseline = style.FontSize;
 }
Example #7
0
 public static dfMarkupBorders Parse(string value)
 {
     int num;
     dfMarkupBorders dfMarkupBorder = new dfMarkupBorders();
     value = Regex.Replace(value, "\\s+", " ");
     string[] strArrays = value.Split(new char[] { ' ' });
     if ((int)strArrays.Length == 1)
     {
         int num1 = dfMarkupStyle.ParseSize(value, 0);
         int num2 = num1;
         num = num2;
         dfMarkupBorder.right = num2;
         dfMarkupBorder.left = num;
         int num3 = num1;
         num = num3;
         dfMarkupBorder.bottom = num3;
         dfMarkupBorder.top = num;
     }
     else if ((int)strArrays.Length == 2)
     {
         int num4 = dfMarkupStyle.ParseSize(strArrays[0], 0);
         num = num4;
         dfMarkupBorder.bottom = num4;
         dfMarkupBorder.top = num;
         int num5 = dfMarkupStyle.ParseSize(strArrays[1], 0);
         num = num5;
         dfMarkupBorder.right = num5;
         dfMarkupBorder.left = num;
     }
     else if ((int)strArrays.Length == 3)
     {
         int num6 = dfMarkupStyle.ParseSize(strArrays[0], 0);
         dfMarkupBorder.top = num6;
         int num7 = dfMarkupStyle.ParseSize(strArrays[1], 0);
         num = num7;
         dfMarkupBorder.right = num7;
         dfMarkupBorder.left = num;
         int num8 = dfMarkupStyle.ParseSize(strArrays[2], 0);
         dfMarkupBorder.bottom = num8;
     }
     else if ((int)strArrays.Length == 4)
     {
         int num9 = dfMarkupStyle.ParseSize(strArrays[0], 0);
         dfMarkupBorder.top = num9;
         int num10 = dfMarkupStyle.ParseSize(strArrays[1], 0);
         dfMarkupBorder.right = num10;
         int num11 = dfMarkupStyle.ParseSize(strArrays[2], 0);
         dfMarkupBorder.bottom = num11;
         int num12 = dfMarkupStyle.ParseSize(strArrays[3], 0);
         dfMarkupBorder.left = num12;
     }
     return dfMarkupBorder;
 }
Example #8
0
    public virtual void Release()
    {
        for (int i = 0; i < children.Count; i++)
        {
            children[i].Release();
        }

        children.Clear();

        Element = null;
        Parent  = null;
        Margins = new dfMarkupBorders();
    }
Example #9
0
    public static dfMarkupBorders Parse(string value)
    {
        // https://developer.mozilla.org/en-US/docs/Web/CSS/margin#Syntax

        var result = new dfMarkupBorders();

        value = Regex.Replace(value, "\\s+", " ");
        var parts = value.Split(' ');

        if (parts.Length == 1)
        {
            int num = dfMarkupStyle.ParseSize(value, 0);
            result.left = result.right = num;
            result.top  = result.bottom = num;
        }
        else if (parts.Length == 2)
        {
            int vert = dfMarkupStyle.ParseSize(parts[0], 0);
            result.top = result.bottom = vert;

            int horz = dfMarkupStyle.ParseSize(parts[1], 0);
            result.left = result.right = horz;
        }
        else if (parts.Length == 3)
        {
            int top = dfMarkupStyle.ParseSize(parts[0], 0);
            result.top = top;

            int horz = dfMarkupStyle.ParseSize(parts[1], 0);
            result.left = result.right = horz;

            int bottom = dfMarkupStyle.ParseSize(parts[2], 0);
            result.bottom = bottom;
        }
        else if (parts.Length == 4)
        {
            int top = dfMarkupStyle.ParseSize(parts[0], 0);
            result.top = top;

            int right = dfMarkupStyle.ParseSize(parts[1], 0);
            result.right = right;

            int bottom = dfMarkupStyle.ParseSize(parts[2], 0);
            result.bottom = bottom;

            int left = dfMarkupStyle.ParseSize(parts[3], 0);
            result.left = left;
        }

        return(result);
    }
Example #10
0
    private void addInline(dfMarkupBox box)
    {
        bool            flag;
        dfMarkupBorders margins = box.Margins;

        if (this.Style.Preformatted)
        {
            flag = false;
        }
        else
        {
            flag = (this.currentLine == null ? false : (float)this.currentLinePos + box.Size.x > this.currentLine.Size.x);
        }
        if (this.currentLine == null || flag)
        {
            this.endCurrentLine(false);
            int         verticalPosition = this.getVerticalPosition(margins.top);
            dfMarkupBox containingBlock  = this.GetContainingBlock();
            if (containingBlock == null)
            {
                Debug.LogError("Containing block not found");
                return;
            }
            dfDynamicFont font         = this.Style.Font ?? this.Style.Host.Font;
            float         fontSize     = (float)font.FontSize / (float)font.FontSize;
            float         baseline     = (float)font.Baseline * fontSize;
            dfMarkupBox   _dfMarkupBox = new dfMarkupBox(this.Element, dfMarkupDisplayType.block, this.Style)
            {
                Size     = new Vector2(containingBlock.Size.x, (float)this.Style.LineHeight),
                Position = new Vector2(0f, (float)verticalPosition),
                Parent   = this,
                Baseline = (int)baseline
            };
            this.currentLine = _dfMarkupBox;
            this.children.Add(this.currentLine);
        }
        if (this.currentLinePos == 0 && !box.Style.PreserveWhitespace && box is dfMarkupBoxText && (box as dfMarkupBoxText).IsWhitespace)
        {
            return;
        }
        Vector2 vector2 = new Vector2((float)(this.currentLinePos + margins.left), (float)margins.top);

        box.Position = vector2;
        box.Parent   = this.currentLine;
        this.currentLine.children.Add(box);
        this.currentLinePos = (int)(vector2.x + box.Size.x + (float)box.Margins.right);
        float single  = Mathf.Max(this.currentLine.Size.x, vector2.x + box.Size.x);
        float single1 = Mathf.Max(this.currentLine.Size.y, vector2.y + box.Size.y);

        this.currentLine.Size = new Vector2(single, single1);
    }
Example #11
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);
    }
Example #12
0
    public static dfMarkupBorders Parse(string value)
    {
        dfMarkupBorders borders = new dfMarkupBorders();

        value = Regex.Replace(value, @"\s+", " ");
        char[]   separator = new char[] { ' ' };
        string[] strArray  = value.Split(separator);
        if (strArray.Length == 1)
        {
            int num = dfMarkupStyle.ParseSize(value, 0);
            borders.left = borders.right = num;
            borders.top  = borders.bottom = num;
            return(borders);
        }
        if (strArray.Length == 2)
        {
            int num2 = dfMarkupStyle.ParseSize(strArray[0], 0);
            borders.top = borders.bottom = num2;
            int num3 = dfMarkupStyle.ParseSize(strArray[1], 0);
            borders.left = borders.right = num3;
            return(borders);
        }
        if (strArray.Length == 3)
        {
            int num4 = dfMarkupStyle.ParseSize(strArray[0], 0);
            borders.top = num4;
            int num5 = dfMarkupStyle.ParseSize(strArray[1], 0);
            borders.left = borders.right = num5;
            int num6 = dfMarkupStyle.ParseSize(strArray[2], 0);
            borders.bottom = num6;
            return(borders);
        }
        if (strArray.Length == 4)
        {
            int num7 = dfMarkupStyle.ParseSize(strArray[0], 0);
            borders.top = num7;
            int num8 = dfMarkupStyle.ParseSize(strArray[1], 0);
            borders.right = num8;
            int num9 = dfMarkupStyle.ParseSize(strArray[2], 0);
            borders.bottom = num9;
            int num10 = dfMarkupStyle.ParseSize(strArray[3], 0);
            borders.left = num10;
        }
        return(borders);
    }
Example #13
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);
Example #14
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        dfMarkupBorders dfMarkupBorder = new dfMarkupBorders();
        dfMarkupStyle   _dfMarkupStyle = this.applyDefaultStyles(style, ref dfMarkupBorder);

        _dfMarkupStyle = base.applyTextStyleAttributes(_dfMarkupStyle);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });

        if (_dfMarkupAttribute != null)
        {
            dfMarkupBorder = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
        }
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, _dfMarkupStyle)
        {
            Margins = dfMarkupBorder
        };

        container.AddChild(_dfMarkupBox);
        base._PerformLayoutImpl(_dfMarkupBox, _dfMarkupStyle);
        _dfMarkupBox.FitToContents(false);
    }
Example #15
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        dfMarkupBorders margins = new dfMarkupBorders();
        dfMarkupStyle   style2  = this.applyDefaultStyles(style, ref margins);

        style2 = base.applyTextStyleAttributes(style2);
        string[]          names     = new string[] { "margin" };
        dfMarkupAttribute attribute = base.findAttribute(names);

        if (attribute != null)
        {
            margins = dfMarkupBorders.Parse(attribute.Value);
        }
        dfMarkupBox box = new dfMarkupBox(this, dfMarkupDisplayType.block, style2)
        {
            Margins = margins
        };

        container.AddChild(box);
        base._PerformLayoutImpl(box, style2);
        box.FitToContents(false);
    }
Example #16
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;
    }
Example #17
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();
    }
Example #18
0
    public static dfMarkupBorders Parse( string value )
    {
        // https://developer.mozilla.org/en-US/docs/Web/CSS/margin#Syntax

        var result = new dfMarkupBorders();

        value = Regex.Replace( value, "\\s+", " " );
        var parts = value.Split( ' ' );

        if( parts.Length == 1 )
        {

            int num = dfMarkupStyle.ParseSize( value, 0 );
            result.left = result.right = num;
            result.top = result.bottom = num;

        }
        else if( parts.Length == 2 )
        {

            int vert = dfMarkupStyle.ParseSize( parts[ 0 ], 0 );
            result.top = result.bottom = vert;

            int horz = dfMarkupStyle.ParseSize( parts[ 1 ], 0 );
            result.left = result.right = horz;

        }
        else if( parts.Length == 3 )
        {

            int top = dfMarkupStyle.ParseSize( parts[ 0 ], 0 );
            result.top = top;

            int horz = dfMarkupStyle.ParseSize( parts[ 1 ], 0 );
            result.left = result.right = horz;

            int bottom = dfMarkupStyle.ParseSize( parts[ 2 ], 0 );
            result.bottom = bottom;

        }
        else if( parts.Length == 4 )
        {

            int top = dfMarkupStyle.ParseSize( parts[ 0 ], 0 );
            result.top = top;

            int right = dfMarkupStyle.ParseSize( parts[ 1 ], 0 );
            result.right = right;

            int bottom = dfMarkupStyle.ParseSize( parts[ 2 ], 0 );
            result.bottom = bottom;

            int left = dfMarkupStyle.ParseSize( parts[ 3 ], 0 );
            result.left = left;

        }

        return result;
    }
Example #19
0
    public virtual void Release()
    {
        for( int i = 0; i < children.Count; i++ )
        {
            children[ i ].Release();
        }

        children.Clear();

        Element = null;
        Parent = null;
        Margins = new dfMarkupBorders();
    }
Example #20
0
 public virtual void Release()
 {
     for (int i = 0; i < this.children.Count; i++)
     {
         this.children[i].Release();
     }
     this.children.Clear();
     this.Element = null;
     this.Parent = null;
     this.Margins = new dfMarkupBorders();
 }
Example #21
0
    private dfMarkupStyle applyDefaultStyles(dfMarkupStyle style, ref dfMarkupBorders margins)
    {
        int    num;
        float  fontSize = 1f;
        float  single   = 1f;
        string tagName  = base.TagName;

        if (tagName != null)
        {
            if (dfMarkupTagHeading.< > f__switch$mapE == null)
            {
                Dictionary <string, int> strs = new Dictionary <string, int>(6)
                {
                    { "h1", 0 },
                    { "h2", 1 },
                    { "h3", 2 },
                    { "h4", 3 },
                    { "h5", 4 },
                    { "h6", 5 }
                };
                dfMarkupTagHeading.< > f__switch$mapE = strs;
            }
            if (dfMarkupTagHeading.< > f__switch$mapE.TryGetValue(tagName, out num))
            {
                switch (num)
                {
                case 0:
                {
                    single   = 2f;
                    fontSize = 0.65f;
                    break;
                }

                case 1:
                {
                    single   = 1.5f;
                    fontSize = 0.75f;
                    break;
                }

                case 2:
                {
                    single   = 1.35f;
                    fontSize = 0.85f;
                    break;
                }

                case 3:
                {
                    single   = 1.15f;
                    fontSize = 0f;
                    break;
                }

                case 4:
                {
                    single   = 0.85f;
                    fontSize = 1.5f;
                    break;
                }

                case 5:
                {
                    single   = 0.75f;
                    fontSize = 1.75f;
                    break;
                }
                }
            }
        }
        style.FontSize  = (int)((float)style.FontSize * single);
        style.FontStyle = FontStyle.Bold;
        style.Align     = dfMarkupTextAlign.Left;
        fontSize        = fontSize * (float)style.FontSize;
        int num1 = (int)fontSize;

        num            = num1;
        margins.bottom = num1;
        margins.top    = num;
        return(style);
    }