Example #1
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            bounds.Offset(Padding.Left, Padding.Top);

            int lineHeight = RowManager.LineHeight;
            int offsetY    = (int)ScrollOffsetY;

            int      rowIndex = RowManager.FirstParagraphOnScreen;
            IGUIFont font     = RowManager.Font;

            try {
                while (rowIndex < RowManager.Paragraphs.Count)
                {
                    Paragraph para      = RowManager.Paragraphs[rowIndex];
                    Rectangle rowBounds = new Rectangle((int)bounds.Left + (int)ScrollOffsetX,
                                                        (int)(bounds.Top + para.Top + offsetY),
                                                        (int)bounds.Width,
                                                        lineHeight);

                    var glyphLines = para.ToGlyphs();

                    foreach (var line in glyphLines)
                    {
                        if (rowBounds.Bottom > bounds.Top)
                        {
                            font.Begin(ctx);
                            font.PrintTextLine(line.Select(g => g.Glyph).ToArray(), rowBounds, Style.ForeColorBrush.Color);
                            font.End();
                        }
                        rowBounds.Offset(0, lineHeight);
                        if (rowBounds.Top > bounds.Bottom)
                        {
                            break;
                        }
                    }

                    if (rowBounds.Top > bounds.Bottom)
                    {
                        break;
                    }

                    rowIndex++;
                }

                if (CursorOn && CursorVisible)
                {
                    RectangleF CursorRectangle = RowManager.CalcCursorRectangle();
                    int        x  = Math.Max((int)bounds.Left + 1, (int)(CursorRectangle.X + bounds.Left + ScrollOffsetX + 0.5f));
                    float      y1 = CursorRectangle.Top + bounds.Top + ScrollOffsetY + 2;
                    float      y2 = y1 + CursorRectangle.Height - 4;
                    ctx.DrawLine(CursorPen, x, y1, x, y2);
                }
            } catch (Exception ex) {
                ex.LogError();
            }
        }
Example #2
0
        public void PrintTextLine(IGUIContext ctx, string fontTag, uint[] glyphs, RectangleF bounds, Color foreColor)
        {
            IGUIFont font = FontByTag(fontTag);

            if (font == null)
            {
                return;
            }
            font.Begin(ctx);
            try {
                font.PrintTextLine(glyphs, bounds, foreColor);
            } catch (Exception ex) {
                ex.LogError();
            }
            finally {
                font.End();
            }
        }