Beispiel #1
0
        protected override void OnDraw(Xwt.Drawing.Context cr, Rectangle bound)
        {
            {
                cr.Rectangle(bound.X, bound.Y, bound.Width, bound.Height);
                cr.SetSourceColor(editor.ColorStyle.PlainText.Background);
                cr.Fill();
                using (var layout = PangoUtil.CreateLayout(editor))
                {
                    layout.Font = editor.Options.Font;

                    layout.Text = "000,00-00";
                    var mins = layout.GetSize();

                    var line      = editor.GetLine(editor.Caret.Line);
                    var visColumn = line.GetVisualColumn(editor.GetTextEditorData(), editor.Caret.Column);

                    if (visColumn != editor.Caret.Column)
                    {
                        layout.Text = editor.Caret.Line + "," + editor.Caret.Column + "-" + visColumn;
                    }
                    else
                    {
                        layout.Text = editor.Caret.Line + "," + editor.Caret.Column;
                    }

                    var statuss = layout.GetSize();

                    statuss.Width = System.Math.Max(statuss.Width, mins.Width);

                    statuss.Width += 8;
                    cr.MoveTo(Size.Width - statuss.Width, 0);
                    statuss.Width += 8;
                    cr.SetSourceColor(editor.ColorStyle.PlainText.Foreground);
                    cr.ShowLayout(layout);

                    layout.Text = statusText ?? "";
                    var size = layout.GetSize();
                    var x    = System.Math.Min(0, -size.Width + Size.Width - editor.TextViewMargin.CharWidth - statuss.Width);
                    cr.MoveTo(x, 0);
                    cr.SetSourceColor(editor.ColorStyle.PlainText.Foreground);
                    cr.ShowLayout(layout);
                    if (ShowCaret)
                    {
                        if (editor.TextViewMargin.caretBlink)
                        {
                            cr.Rectangle(size.Width + x, 0, (int)editor.TextViewMargin.CharWidth, (int)editor.LineHeight);
                            cr.Fill();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        internal protected override void Draw(Xwt.Drawing.Context cr, Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
        {
            var gutterMarker = lineSegment != null ? (MarginMarker)lineSegment.Markers.FirstOrDefault(marker => marker is MarginMarker && ((MarginMarker)marker).CanDraw(this)) : null;

            if (gutterMarker != null && gutterMarker.CanDrawBackground(this))
            {
                bool hasDrawn = gutterMarker.DrawBackground(editor, cr, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight));
                if (!hasDrawn)
                {
                    DrawGutterBackground(cr, line, x, y, lineHeight);
                }
            }
            else
            {
                DrawGutterBackground(cr, line, x, y, lineHeight);
            }

            if (gutterMarker != null && gutterMarker.CanDrawForeground(this))
            {
                gutterMarker.DrawForeground(editor, cr, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight));
                return;
            }

            if (line <= editor.Document.LineCount)
            {
                // Due to a mac? gtk bug I need to re-create the layout here
                // otherwise I get pango exceptions.
                using (var layout = editor.LayoutCache.RequestLayout())
                {
                    layout.Font      = gutterFont;
                    layout.Width     = (int)Width;
                    layout.Alignment = Alignment.End;
                    layout.SetText(line.ToString());
                    cr.Save();
                    cr.Translate(x + (int)Width + (editor.Options.ShowFoldMargin ? 0 : -2), y);
                    cr.SetSourceColor(lineNumberGC);
                    cr.ShowLayout(layout);
                    cr.Restore();
                }
            }
        }
Beispiel #3
0
        public override void DrawForeground(TextEditor editor, Xwt.Drawing.Context cr, MarginDrawMetrics metrics)
        {
            var width          = metrics.Width;
            var lineNumberBgGC = editor.ColorStyle.LineNumbers.Background;

            if (metrics.LineNumber <= editor.Document.LineCount)
            {
                // Due to a mac? gtk bug I need to re-create the layout here
                // otherwise I get pango exceptions.
                using (var layout = PangoUtil.CreateLayout(editor))
                {
                    layout.Font          = editor.Options.Font;
                    layout.Width         = (int)width;
                    layout.TextAlignment = Alignment.End;
                    layout.Text          = metrics.LineNumber.ToString();
                    cr.Save();
                    cr.Translate(metrics.X + (int)width + (editor.Options.ShowFoldMargin ? 0 : -2), metrics.Y);
                    cr.SetSourceColor(lineNumberBgGC);
                    cr.ShowLayout(layout);
                    cr.Restore();
                }
            }
        }