Example #1
0
        /// <summary>
        /// Applies vertical alignment to the linebox
        /// </summary>
        /// <param name="g"></param>
        /// <param name="lineBox"></param>
        private static void ApplyVerticalAlignment(RGraphics g, CssLineBox lineBox)
        {
            double baseline = Single.MinValue;

            foreach (var box in lineBox.Rectangles.Keys)
            {
                baseline = Math.Max(baseline, lineBox.Rectangles[box].Top);
            }

            var boxes = new List <CssBox>(lineBox.Rectangles.Keys);

            foreach (CssBox box in boxes)
            {
                //Important notes on http://www.w3.org/TR/CSS21/tables.html#height-layout
                switch (box.VerticalAlign)
                {
                case CssConstants.Sub:
                    lineBox.SetBaseLine(g, box, baseline + lineBox.Rectangles[box].Height * .5f);
                    break;

                case CssConstants.Super:
                    lineBox.SetBaseLine(g, box, baseline - lineBox.Rectangles[box].Height * .2f);
                    break;

                case CssConstants.TextTop:

                    break;

                case CssConstants.TextBottom:

                    break;

                case CssConstants.Top:

                    break;

                case CssConstants.Bottom:

                    break;

                case CssConstants.Middle:

                    break;

                default:
                    //case: baseline
                    lineBox.SetBaseLine(g, box, baseline);
                    break;
                }
            }
        }