public double DrawMultilineTextAt(Context ctx, double posX, double posY, EnumTextOrientation orientation = EnumTextOrientation.Left)
        {
            Font.SetupContext(ctx);

            TextLine[] lines = textUtil.Lineize(Font, text, Bounds.InnerWidth);

            ctx.Save();
            Matrix m = ctx.Matrix;

            m.Translate(posX, posY);
            ctx.Matrix = m;

            textUtil.DrawMultilineText(ctx, Font, lines, orientation);
            ctx.Restore();

            return(lines.Length == 0 ? 0 : (lines[lines.Length - 1].Bounds.Y + lines[lines.Length - 1].Bounds.Height));
        }
Exemple #2
0
        /// <summary>
        /// Initializes the size and stuff. Return true if you had to enter the next line
        /// </summary>
        /// <param name="flowPath"></param>
        /// <param name="xPos"></param>
        /// <returns>True when longer than 1 line</returns>
        public override bool CalcBounds(TextFlowPath[] flowPath, double currentLineHeight, double lineX, double lineY)
        {
            lines = textUtil.Lineize(font, displayText, flowPath, lineX + GuiElement.scaled(PaddingLeft), lineY);

            BoundsPerLine = new LineRectangled[lines.Length];
            for (int i = 0; i < lines.Length; i++)
            {
                TextLine line = lines[i];
                BoundsPerLine[i] = line.Bounds;
            }

            if (lines.Length > 0)
            {
                lines[0].PaddingLeft = GuiElement.scaled(PaddingLeft);
                lines[lines.Length - 1].PaddingRight  = PaddingRight;
                lines[lines.Length - 1].Bounds.Width += PaddingRight;
            }

            return(lines.Length > 1);
        }