void DrawErrorMarkers(MonoTextEditor editor, Cairo.Context g, LineMetrics metrics, double y)
        {
            uint curIndex = 0, byteIndex = 0;

            var o = metrics.LineSegment.Offset;

            foreach (var task in errors.Select(t => t.Task))
            {
                var column = (uint)(Math.Min(Math.Max(0, task.Column - 1), metrics.Layout.LineChars.Length));
                var line   = editor.GetLine(task.Line);
                // skip possible white space locations
                while (column < line.Length && char.IsWhiteSpace(editor.GetCharAt(line.Offset + (int)column)))
                {
                    column++;
                }
                if (column >= line.Length)
                {
                    continue;
                }
                int index = (int)metrics.Layout.TranslateToUTF8Index(column, ref curIndex, ref byteIndex);
                var pos   = metrics.Layout.Layout.IndexToPos(index);
                var co    = o + task.Column - 1;
                g.SetSourceColor(GetMarkerColor(false, metrics.SelectionStart <= co && co < metrics.SelectionEnd));
                g.MoveTo(
                    metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
                    y + editor.LineHeight - 3
                    );
                g.RelLineTo(3, 3);
                g.RelLineTo(-6, 0);
                g.ClosePath();

                g.Fill();
            }
        }
Exemple #2
0
        public virtual void RenderShadow(Cairo.Context context, Gdk.Rectangle region, PopupPosition arrowPosition)
        {
            RenderBorder(context, region, arrowPosition);
            double r = CornerRadius;
            double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

            context.MoveTo(x + w, y + h - r);
            context.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
            if (ShowArrow && (arrowPosition & PopupPosition.Bottom) != 0)
            {
                double apos = ArrowOffset;
                context.LineTo(x + apos + ArrowWidth / 2, y + h);
                context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
            }
            context.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);

            // FIXME: VV: Remove gradient features
            using (var lg = new Cairo.LinearGradient(0, y + h - r, 0, y + h)) {
                lg.AddColorStop(0.5, ShadowColor.MultiplyAlpha(0.0));
                lg.AddColorStop(1, ShadowColor);
                context.SetSource(lg);
                context.LineWidth = 1;
                context.Stroke();
            }
        }
Exemple #3
0
        public static void DrawRoundRectangle(Cairo.Context cr, double x, double y, double r, double w, double h)
        {
            const double ARC_TO_BEZIER = 0.55228475;
            double       radius_x      = r;
            double       radius_y      = r / 4;

            if (radius_x > w - radius_x)
            {
                radius_x = w / 2;
            }

            if (radius_y > h - radius_y)
            {
                radius_y = h / 2;
            }

            double c1 = ARC_TO_BEZIER * radius_x;
            double c2 = ARC_TO_BEZIER * radius_y;

            cr.NewPath();
            cr.MoveTo(x + radius_x, y);
            cr.RelLineTo(w - 2 * radius_x, 0.0);
            cr.RelCurveTo(c1, 0.0,
                          radius_x, c2,
                          radius_x, radius_y);
            cr.RelLineTo(0, h - 2 * radius_y);
            cr.RelCurveTo(0.0, c2, c1 - radius_x, radius_y, -radius_x, radius_y);
            cr.RelLineTo(-w + 2 * radius_x, 0);
            cr.RelCurveTo(-c1, 0, -radius_x, -c2, -radius_x, -radius_y);
            cr.RelLineTo(0, -h + 2 * radius_y);
            cr.RelCurveTo(0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y);
            cr.ClosePath();
        }
Exemple #4
0
 void DrawExpander(Cairo.Context ctx, double ex, double ey, bool expanded, bool hilight)
 {
     ctx.NewPath();
     ctx.LineWidth = 1;
     ctx.Rectangle(ex, ey, ExpanderSize, ExpanderSize);
     if (hilight)
     {
         ctx.SetSourceColor(Style.Background(Gtk.StateType.Normal).ToCairoColor());
     }
     else
     {
         ctx.SetSourceColor(Style.White.ToCairoColor());
     }
     ctx.FillPreserve();
     ctx.SetSourceColor(Style.Foreground(Gtk.StateType.Normal).ToCairoColor());
     ctx.Stroke();
     ctx.NewPath();
     ctx.MoveTo(ex + 2, ey + (ExpanderSize / 2));
     ctx.RelLineTo(ExpanderSize - 4, 0);
     if (!expanded)
     {
         ctx.MoveTo(ex + (ExpanderSize / 2), ey + 2);
         ctx.RelLineTo(0, ExpanderSize - 4);
     }
     ctx.Stroke();
 }
Exemple #5
0
        private void HeaderExpose(object ob, Gtk.ExposeEventArgs a)
        {
            Gdk.Rectangle rect = new Gdk.Rectangle(0, 0, header.Allocation.Width - 1, header.Allocation.Height);
            HslColor      gcol = frame.Style.Background(Gtk.StateType.Normal);

            if (pointerHover)
            {
                gcol.L *= 1.05;
            }
            gcol.L = Math.Min(1, gcol.L);

            using (Cairo.Context cr = Gdk.CairoHelper.Create(a.Event.Window)) {
                cr.NewPath();
                cr.MoveTo(0, 0);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                Cairo.SolidPattern solidPattern = new Cairo.SolidPattern(gcol);
                cr.Pattern = solidPattern;
                cr.FillPreserve();
                solidPattern.Destroy();
            }

            header.GdkWindow.DrawRectangle(frame.Style.DarkGC(Gtk.StateType.Normal), false, rect);

            foreach (Widget child in header.Children)
            {
                header.PropagateExpose(child, a.Event);
            }
        }
        public void DrawBar(Cairo.Context cr, PlotColor color, int x, int y, int width, int height, bool is_focused)
        {
            // Draw the fill
            cr.Rectangle(x, y, width, height);
            Cairo.Color fill = colors[(int)color];
            fill.A = 0.6;
            //cr.Color = fill;
            cr.SetSourceRGBA(fill.R, fill.G, fill.B, fill.A);
            cr.Fill();

            // Stroke just the top, left and right sides
            cr.MoveTo(x - DEFUZZ, y + height - DEFUZZ);
            cr.RelLineTo(0, -height);
            cr.RelLineTo(width, 0);
            cr.RelLineTo(0, height);

            // decrease saturation by 40%
            //cr.Color = CairoHelper.Darken (colors[(int)color], 0.4f);
            cr.SetSourceRGBA(CairoHelper.Darken(colors[(int)color], 0.4f).R, CairoHelper.Darken(colors[(int)color], 0.4f).G, CairoHelper.Darken(colors[(int)color], 0.4f).B, CairoHelper.Darken(colors[(int)color], 0.4f).A);

            cr.LineWidth = 1.0f;

            cr.Stroke();

            if (is_focused)
            {
                DrawFocusRect(cr, x - FOCUS_BORDER, y - FOCUS_BORDER,
                              width + (FOCUS_BORDER * 2), height + FOCUS_BORDER);
            }
        }
Exemple #7
0
            static void DrawLineEndAtIter(Cairo.Context cntx, TextView view, TextIter iter)
            {
                Gdk.Rectangle rect = view.GetIterLocation(iter);
                int           x, y;

                view.BufferToWindowCoords(TextWindowType.Text,
                                          rect.X,
                                          rect.Y + rect.Height / 2,
                                          out x, out y);
                cntx.Save();
                cntx.Color = GetDrawingColorForIter(view, iter);

                double arrowSize = 3;

                cntx.MoveTo(x + 10, y);
                cntx.RelLineTo(new Cairo.Distance(0, -arrowSize));
                cntx.RelMoveTo(new Cairo.Distance(0, arrowSize));
                cntx.RelLineTo(new Cairo.Distance(-8, 0));
                cntx.RelLineTo(new Cairo.Distance(arrowSize, arrowSize));
                cntx.RelMoveTo(new Cairo.Distance(-arrowSize, -arrowSize));
                cntx.RelLineTo(new Cairo.Distance(arrowSize, -arrowSize));

                cntx.Stroke();
                cntx.Restore();
            }
Exemple #8
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = useCustomColor ? customColor : Parent.Style.Background(Gtk.StateType.Normal);

                using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow))
                {
                    cr.NewPath();
                    cr.MoveTo(rect.X, rect.Y);
                    cr.RelLineTo(rect.Width, 0);
                    cr.RelLineTo(0, rect.Height);
                    cr.RelLineTo(-rect.Width, 0);
                    cr.RelLineTo(0, -rect.Height);
                    cr.ClosePath();
                    Cairo.Gradient pat    = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom);
                    Cairo.Color    color1 = gcol;
                    pat.AddColorStop(0, color1);
                    gcol.L -= 0.1;
                    if (gcol.L < 0)
                    {
                        gcol.L = 0;
                    }
                    pat.AddColorStop(1, gcol);
                    cr.Pattern = pat;
                    cr.FillPreserve();
                }
            }

            bool res = base.OnExposeEvent(evnt);

            Gdk.GC borderColor = Parent.Style.DarkGC(Gtk.StateType.Normal);

            rect = Allocation;
            for (int n = 0; n < topMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Y + n, rect.Right - 1, rect.Y + n);
            }

            for (int n = 0; n < bottomMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X, rect.Bottom - n - 1, rect.Right - 1, rect.Bottom - n - 1);
            }

            for (int n = 0; n < leftMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom - 1);
            }

            for (int n = 0; n < rightMargin; n++)
            {
                GdkWindow.DrawLine(borderColor, rect.Right - n - 1, rect.Y, rect.Right - n - 1, rect.Bottom - 1);
            }

            return(res);
        }
Exemple #9
0
        private static void MakeSquare(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            double size = msize - lw;

            context.MoveTo(item.X * scale.X, item.Y * scale.Y);
            context.RelMoveTo(-size / 2, -size / 2);
            context.RelLineTo(size, 0);
            context.RelLineTo(0, size);
            context.RelLineTo(-size, 0);
            context.ClosePath();
        }
Exemple #10
0
        public static void RenderCross(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            context.MoveTo(item.X * scale.X, item.Y * scale.Y);
            context.RelMoveTo(-msize / 2, -msize / 2);
            context.RelLineTo(msize, msize);
            context.Stroke();

            context.MoveTo(item.X * scale.X, item.Y * scale.Y);
            context.RelMoveTo(msize / 2, -msize / 2);
            context.RelLineTo(-msize, msize);
            context.Stroke();
        }
Exemple #11
0
        private static void DrawArrow(Cairo.Context graphics, double x, double y, double pos)
        {
            graphics.MoveTo(x, y);
            graphics.Rotate(pos);
            graphics.RelMoveTo(0, (pos + 0.5 * System.Math.PI < System.Math.PI ? -1 : 1) * s_arrowSize / 2);

            graphics.RelLineTo(-s_arrowSize, 0);
            graphics.RelLineTo(s_arrowSize, -s_arrowSize);
            graphics.RelLineTo(s_arrowSize, s_arrowSize);
            graphics.RelLineTo(-s_arrowSize, 0);

            graphics.Fill();
        }
Exemple #12
0
        void DrawTab(Gdk.EventExpose evnt, Tab tab, int pos)
        {
            Gdk.Rectangle rect = GetTabArea(tab, pos);
            StateType     st;

            if (tab.Active)
            {
                st = StateType.Normal;
            }
            else
            {
                st = StateType.Active;
            }

            if (DockFrame.IsWindows)
            {
                GdkWindow.DrawRectangle(Style.DarkGC(Gtk.StateType.Normal), false, rect);
                rect.X++;
                rect.Width--;
                if (tab.Active)
                {
                    GdkWindow.DrawRectangle(Style.LightGC(Gtk.StateType.Normal), true, rect);
                }
                else
                {
                    using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window))
                    {
                        cr.NewPath();
                        cr.MoveTo(rect.X, rect.Y);
                        cr.RelLineTo(rect.Width, 0);
                        cr.RelLineTo(0, rect.Height);
                        cr.RelLineTo(-rect.Width, 0);
                        cr.RelLineTo(0, -rect.Height);
                        cr.ClosePath();
                        Cairo.Gradient pat    = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height);
                        Cairo.Color    color1 = DockFrame.ToCairoColor(Style.Mid(Gtk.StateType.Normal));
                        pat.AddColorStop(0, color1);
                        color1.R *= 1.2;
                        color1.G *= 1.2;
                        color1.B *= 1.2;
                        pat.AddColorStop(1, color1);
                        cr.Pattern = pat;
                        cr.FillPreserve();
                    }
                }
            }
            else
            {
                Gtk.Style.PaintExtension(Style, GdkWindow, st, ShadowType.Out, evnt.Area, this, "tab", rect.X, rect.Y, rect.Width, rect.Height, Gtk.PositionType.Top);
            }
        }
Exemple #13
0
        private static void MakeTriangle(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            double halfsize = (msize - lw) / 2;

            context.MoveTo(item.X * scale.X, item.Y * scale.Y);
            context.RelMoveTo(0, halfsize);

            double dx = halfsize * s_triangleDxDy.X;
            double dy = halfsize * s_triangleDxDy.Y;

            context.RelLineTo(dx, -halfsize - dy);
            context.RelLineTo(2 * -dx, 0);
            context.ClosePath();
        }
        public void DrawEventTag(Cairo.Context cr, PlotColor color,
                                 int x, int y, Orientation orientation)
        {
            cr.MoveTo(x + DEFUZZ, y);

            if (orientation == Orientation.Vertical)
            {
                cr.RelLineTo(-1 * EVENT_TAG_HALF_WIDTH, -1 * EVENT_TAG_SEGMENT_HEIGHT);
                cr.RelLineTo(0, -2 * EVENT_TAG_SEGMENT_HEIGHT);
                cr.RelLineTo(EVENT_TAG_HALF_WIDTH * 2, 0);
                cr.RelLineTo(0, 2 * EVENT_TAG_SEGMENT_HEIGHT);
            }
            else
            {
                cr.RelLineTo(EVENT_TAG_SEGMENT_HEIGHT, -1 * EVENT_TAG_HALF_WIDTH);
                cr.RelLineTo(EVENT_TAG_SEGMENT_HEIGHT * 2, 0);
                cr.RelLineTo(0, EVENT_TAG_HALF_WIDTH * 2);
                cr.RelLineTo(-2 * EVENT_TAG_SEGMENT_HEIGHT, 0);
            }

            cr.ClosePath();
            //cr.Color = CairoHelper.GetCairoColor (gtk_style.Base (state));
            cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Base(state)).R, CairoHelper.GetCairoColor(gtk_style.Base(state)).G, CairoHelper.GetCairoColor(gtk_style.Base(state)).B, CairoHelper.GetCairoColor(gtk_style.Base(state)).A);

            cr.FillPreserve();

            cr.LineWidth = 1.0f;
            //cr.Color = colors[(int)color];
            cr.SetSourceRGBA(colors[(int)color].R, colors[(int)color].G, colors[(int)color].B, colors[(int)color].A);

            cr.Stroke();
        }
 void DrawGradient(Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2)
 {
     cr.NewPath();
     cr.MoveTo(rect.X, rect.Y);
     cr.RelLineTo(rect.Width, 0);
     cr.RelLineTo(0, rect.Height);
     cr.RelLineTo(-rect.Width, 0);
     cr.RelLineTo(0, -rect.Height);
     cr.ClosePath();
     Cairo.LinearGradient pat = new Cairo.LinearGradient(rect.X + rect.Width * fx, rect.Y + rect.Height * fy, rect.X + rect.Width * fw, rect.Y + rect.Height * fh);
     pat.AddColorStop(0, c1);
     pat.AddColorStop(1, c2);
     cr.Pattern = pat;
     cr.FillPreserve();
 }
Exemple #16
0
        public new void Draw(Cairo.Context cr)
        {
            Gdk.Rectangle rect;

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = useCustomColor ? customColor : Parent.Style.Background(Gtk.StateType.Normal);

                cr.NewPath();
                cr.MoveTo(rect.X, rect.Y);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                using (Cairo.Gradient pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height - 1)) {
                    Cairo.Color color1 = gcol;
                    pat.AddColorStop(0, color1);
                    gcol.L -= 0.1;
                    if (gcol.L < 0)
                    {
                        gcol.L = 0;
                    }
                    pat.AddColorStop(1, gcol);
                    cr.Pattern = pat;
                    cr.FillPreserve();
                }
            }

            base.Draw(cr);
            //FIXME: Get this drawing properly again!
//			Gdk.Color colour = Parent.Style.Dark (Gtk.StateType.Normal);
//			cr.SetSourceRGB (colour.Red, colour.Green, colour.Blue);
//
//			rect = Allocation;
//			for (int n=0; n<topMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Left + rect.Width - 1, rect.Y + n);
//
//			for (int n=0; n<bottomMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X, rect.Top + rect.Height - 1 - n, rect.Left + rect.Width - 1, rect.Top + rect.Height - 1 - n);
//
//			for (int n=0; n<leftMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Top + rect.Height - 1);
//
//			for (int n=0; n<rightMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.Left + rect.Width - 1 - n, rect.Y, rect.Left + rect.Width - 1 - n, rect.Top + rect.Height - 1);
        }
Exemple #17
0
        public static void RenderDash(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            context.MoveTo(item.X * scale.X - msize / 2, item.Y * scale.Y);
            context.RelLineTo(msize, 0);

            context.Stroke();
        }
Exemple #18
0
        private void RenderErrorBars(Cairo.Context context, Point scale, List <double> errors, int direction)
        {
            if (errors == null || errors.Count != Count)
            {
                return;
            }

            context.Save();

            for (int i = 0; i < Count; ++i)
            {
                Point pt = this[i];

                context.MoveTo(pt.X * scale.X, pt.Y * scale.Y);
                context.RelLineTo(0, errors[i] * scale.Y * direction);
            }

            if (d_errorColor != null)
            {
                d_errorColor.Set(context);
            }
            else if (Color != null)
            {
                Color.Set(context);
            }

            context.Stroke();
            context.Restore();
        }
Exemple #19
0
        public virtual bool SetBorderPath(Cairo.Context context, Gdk.Rectangle region, PopupPosition arrowPosition)
        {
            double r = CornerRadius;

            if (ShowArrow)
            {
                double apos = ArrowOffset;
                double x = region.X + 0.5, y = region.Y + 0.5, w = region.Width - 1, h = region.Height - 1;

                context.MoveTo(x + r, y);
                if ((arrowPosition & PopupPosition.Top) != 0)
                {
                    context.LineTo(x + apos - ArrowWidth / 2, y);
                    context.RelLineTo(ArrowWidth / 2, -ArrowLength);
                    context.RelLineTo(ArrowWidth / 2, ArrowLength);
                }
                context.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
                if ((arrowPosition & PopupPosition.Right) != 0)
                {
                    context.LineTo(x + w, y + apos - ArrowWidth / 2);
                    context.RelLineTo(ArrowLength, ArrowWidth / 2);
                    context.RelLineTo(-ArrowLength, ArrowWidth / 2);
                }
                context.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
                if ((arrowPosition & PopupPosition.Bottom) != 0)
                {
                    context.LineTo(x + apos + ArrowWidth / 2, y + h);
                    context.RelLineTo(-ArrowWidth / 2, ArrowLength);
                    context.RelLineTo(-ArrowWidth / 2, -ArrowLength);
                }
                context.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
                if ((arrowPosition & PopupPosition.Left) != 0)
                {
                    context.LineTo(x, y + apos + ArrowWidth / 2);
                    context.RelLineTo(-ArrowLength, -ArrowWidth / 2);
                    context.RelLineTo(ArrowLength, -ArrowWidth / 2);
                }
                context.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
            }
            else
            {
                CairoExtensions.RoundedRectangle(context, region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, r);
            }

            var args = new {
                Region       = region,
                ArrowPostion = arrowPosition,
                ArrowWidth   = this.ArrowWidth,
                ArrowLength  = this.arrowLength,
                ArrowOffset  = this.ArrowOffset,
            };

            bool result = setBorderPathLastArgs == null ? true : setBorderPathLastArgs.Equals(args);

            setBorderPathLastArgs = args;
            return(result);
        }
        public void DrawAxisBoundingBox(Cairo.Context cr, int x, int y,
                                        int width, int height, AxisLocation loc)
        {
            cr.MoveTo(x, y);
            if (loc == AxisLocation.Bottom)
            {
                cr.RelMoveTo(width, 0);
            }
            else
            {
                cr.RelLineTo(width, 0);
            }

            if (loc == AxisLocation.Left)
            {
                cr.RelMoveTo(0, height);
            }
            else
            {
                cr.RelLineTo(0, height);
            }

            if (loc == AxisLocation.Top)
            {
                cr.RelMoveTo(-width, 0);
            }
            else
            {
                cr.RelLineTo(-width, 0);
            }

            if (loc == AxisLocation.Right)
            {
                cr.RelMoveTo(0, -height);
            }
            else
            {
                cr.RelLineTo(0, -height);
            }

            //cr.Color = CairoHelper.GetCairoColor (gtk_style.Foreground (state));
            cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Foreground(state)).R, CairoHelper.GetCairoColor(gtk_style.Foreground(state)).G, CairoHelper.GetCairoColor(gtk_style.Foreground(state)).B, CairoHelper.GetCairoColor(gtk_style.Foreground(state)).A);

            cr.LineWidth = 2.0f;
            cr.Stroke();
        }
Exemple #21
0
        void DrawGradient(Cairo.Context cr, Gdk.Rectangle rect, int fx, int fy, int fw, int fh, Cairo.Color c1, Cairo.Color c2)
        {
            cr.NewPath();
            cr.MoveTo(rect.X, rect.Y);
            cr.RelLineTo(rect.Width, 0);
            cr.RelLineTo(0, rect.Height);
            cr.RelLineTo(-rect.Width, 0);
            cr.RelLineTo(0, -rect.Height);
            cr.ClosePath();

            // FIXME: VV: Remove gradient features
            using (var pat = new Cairo.LinearGradient(rect.X + rect.Width * fx, rect.Y + rect.Height * fy, rect.X + rect.Width * fw, rect.Y + rect.Height * fh)) {
                pat.AddColorStop(0, c1);
                pat.AddColorStop(1, c2);
                cr.Source = pat;
                cr.FillPreserve();
            }
        }
Exemple #22
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                Gdk.Rectangle rect = Allocation;

                if (BackgroundColor.HasValue)
                {
                    cr.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
                    cr.SetSourceColor(BackgroundColor.Value.ToCairoColor());
                    cr.Fill();
                }

                if (GradientBackround)
                {
                    Color gcol = Util.ToXwtColor(Style.Background(Gtk.StateType.Normal));

                    cr.NewPath();
                    cr.MoveTo(rect.X, rect.Y);
                    cr.RelLineTo(rect.Width, 0);
                    cr.RelLineTo(0, rect.Height);
                    cr.RelLineTo(-rect.Width, 0);
                    cr.RelLineTo(0, -rect.Height);
                    cr.ClosePath();
                    using (var pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom)) {
                        Cairo.Color color1 = gcol.ToCairoColor();
                        pat.AddColorStop(0, color1);
                        gcol.Light -= 0.1;
                        pat.AddColorStop(1, gcol.ToCairoColor());
                        cr.SetSource(pat);
                        cr.FillPreserve();
                    }
                }

                cr.SetSourceColor(color.HasValue ? color.Value.ToCairoColor() : Style.Dark(Gtk.StateType.Normal).ToXwtColor().ToCairoColor());
                cr.Rectangle(rect.X, rect.Y, rect.Width, topMargin);
                cr.Rectangle(rect.X, rect.Y + rect.Height - bottomMargin, rect.Width, bottomMargin);
                cr.Rectangle(rect.X, rect.Y, leftMargin, rect.Height);
                cr.Rectangle(rect.X + rect.Width - rightMargin, rect.Y, rightMargin, rect.Height);
                cr.Fill();
            }
            bool res = base.OnExposeEvent(evnt);

            return(res);
        }
Exemple #23
0
        protected void DrawArrow(Cairo.Context cr, double x, double y, double size)
        {
            y    += 2.5;
            x    += 2.5;
            size -= 4;
            double awidth  = 0.5;
            double aheight = 0.4;
            double pich    = (size - (size * aheight)) / 2;

            cr.NewPath();
            cr.MoveTo(x + size * awidth, y);
            cr.LineTo(x + size, y + size / 2);
            cr.LineTo(x + size * awidth, y + size);
            cr.RelLineTo(0, -pich);
            cr.RelLineTo(-size * awidth, 0);
            cr.RelLineTo(0, -size * aheight);
            cr.RelLineTo(size * awidth, 0);
            cr.RelLineTo(0, -pich);
            cr.ClosePath();
        }
        void DrawErrorMarkers(TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, double x, double y)
        {
            uint curIndex = 0, byteIndex = 0;


            foreach (var task in errors.Select(t => t.Task))
            {
                int index = (int)layout2.TranslateToUTF8Index((uint)(task.Column - 1), ref curIndex, ref byteIndex);
                var pos   = layout2.Layout.IndexToPos(index);
                g.Color = MarkerColor.Color;

                g.MoveTo(
                    x + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
                    y + editor.LineHeight - 4
                    );
                g.RelLineTo(3, 3);
                g.RelLineTo(-6, 0);
                g.ClosePath();


                g.Fill();
            }
        }
        public void DrawSelectedBar(Cairo.Context cr, PlotColor color, int x, int y, int width, int height)
        {
            // Draw the fill
            cr.Rectangle(x, y, width, height);
            cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Base(state)).R, CairoHelper.GetCairoColor(gtk_style.Base(state)).G, CairoHelper.GetCairoColor(gtk_style.Base(state)).B, CairoHelper.GetCairoColor(gtk_style.Base(state)).A);
            //cr.Color = CairoHelper.GetCairoColor (gtk_style.Base (state));
            cr.Fill();

            // Stroke just the top, left and right sides
            cr.MoveTo(x, y + height);
            cr.RelLineTo(0, -height);
            cr.RelLineTo(width, 0);
            cr.RelLineTo(0, height);

            // darken by 40%
            //cr.Color = CairoHelper.Darken (colors[(int)color], 0.4f);

            cr.SetSourceRGBA(CairoHelper.Darken(colors[(int)color], 0.4f).R, CairoHelper.Darken(colors[(int)color], 0.4f).G, CairoHelper.Darken(colors[(int)color], 0.4f).B, CairoHelper.Darken(colors[(int)color], 0.4f).A);

            cr.LineWidth = 2.0f;

            cr.Stroke();
        }
Exemple #26
0
        protected override void OnDrawn(Cairo.Context cr, Gdk.Rectangle rect)
        {
            if (BackgroundColor.HasValue)
            {
                cr.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
                cr.SetSourceColor(BackgroundColor.Value.ToCairoColor());
                cr.Fill();
            }

            if (GradientBackround)
            {
                Color gcol = Style.Background(Gtk.StateType.Normal).ToXwtValue();

                cr.NewPath();
                cr.MoveTo(rect.X, rect.Y);
                cr.RelLineTo(rect.Width, 0);
                cr.RelLineTo(0, rect.Height);
                cr.RelLineTo(-rect.Width, 0);
                cr.RelLineTo(0, -rect.Height);
                cr.ClosePath();
                using (var pat = new Cairo.LinearGradient(rect.X, rect.Y, rect.X, rect.Bottom)) {
                    Cairo.Color color1 = gcol.ToCairoColor();
                    pat.AddColorStop(0, color1);
                    gcol.Light -= 0.1;
                    pat.AddColorStop(1, gcol.ToCairoColor());
                    cr.SetSource(pat);
                    cr.FillPreserve();
                }
            }

            cr.SetSourceColor(color.HasValue ? color.Value.ToCairoColor() : Style.Dark(Gtk.StateType.Normal).ToXwtValue().ToCairoColor());
            cr.Rectangle(rect.X, rect.Y, rect.Width, topMargin);
            cr.Rectangle(rect.X, rect.Y + rect.Height - bottomMargin, rect.Width, bottomMargin);
            cr.Rectangle(rect.X, rect.Y, leftMargin, rect.Height);
            cr.Rectangle(rect.X + rect.Width - rightMargin, rect.Y, rightMargin, rect.Height);
            cr.Fill();
        }
Exemple #27
0
 protected virtual void DrawHoverBackground(Cairo.Context ctx)
 {
     if (BorderPadding <= 0)
     {
         ctx.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
         ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBackgroundColor));
         ctx.Fill();
         ctx.MoveTo(Allocation.X, Allocation.Y + 0.5);
         ctx.RelLineTo(Allocation.Width, 0);
         ctx.MoveTo(Allocation.X, Allocation.Y + Allocation.Height - 0.5);
         ctx.RelLineTo(Allocation.Width, 0);
         if (DrawRightBorder)
         {
             ctx.MoveTo(Allocation.Right + 0.5, Allocation.Y + 0.5);
             ctx.LineTo(Allocation.Right + 0.5, Allocation.Bottom - 0.5);
         }
         if (DrawLeftBorder)
         {
             ctx.MoveTo(Allocation.Left + 0.5, Allocation.Y + 0.5);
             ctx.LineTo(Allocation.Left + 0.5, Allocation.Bottom - 0.5);
         }
         ctx.LineWidth = 1;
         ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBorderColor));
         ctx.Stroke();
     }
     else
     {
         Gdk.Rectangle region = Allocation;
         region.Inflate(-BorderPadding, -BorderPadding);
         ctx.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3);
         ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBackgroundColor));
         ctx.FillPreserve();
         ctx.LineWidth = 1;
         ctx.SetSourceColor(CairoExtensions.ParseColor(HoverBorderColor));
         ctx.Stroke();
     }
 }
        void DrawErrorMarkers(TextEditor editor, Cairo.Context g, LineMetrics metrics, double y)
        {
            uint curIndex = 0, byteIndex = 0;

            var o = metrics.LineSegment.Offset;

            foreach (var task in errors.Select(t => t.Task))
            {
                var column = (uint)(Math.Min(Math.Max(0, task.Column - 1), metrics.Layout.LineChars.Length));
                int index  = (int)metrics.Layout.TranslateToUTF8Index(column, ref curIndex, ref byteIndex);
                var pos    = metrics.Layout.Layout.IndexToPos(index);
                var co     = o + task.Column - 1;
                g.SetSourceColor(GetMarkerColor(false, metrics.SelectionStart <= co && co < metrics.SelectionEnd));
                g.MoveTo(
                    metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
                    y + editor.LineHeight - 3
                    );
                g.RelLineTo(3, 3);
                g.RelLineTo(-6, 0);
                g.ClosePath();

                g.Fill();
            }
        }
Exemple #29
0
        private void DrawIcon(Cairo.Context graphics)
        {
            Allocation alloc = d_object != null ? d_object.Allocation : new Allocation(0, 0, 1, 1);

            graphics.SetSourceRGB(0.3, 0.3, 0.3);

            double uw = graphics.LineWidth;

            graphics.LineWidth = uw * 2;
            double ar = uw * 5;

            double dh = (alloc.Height + uw) / 2;

            graphics.MoveTo(alloc.Width, dh);
            graphics.LineTo(uw * 2 + ar, dh);
            graphics.Stroke();

            graphics.MoveTo(uw * 2, dh);
            graphics.RelLineTo(ar, -ar / 2);
            graphics.RelLineTo(0, ar);
            graphics.ClosePath();
            graphics.FillPreserve();
            graphics.Stroke();
        }
Exemple #30
0
 public override void RelLineTo(object backend, double dx, double dy)
 {
     Cairo.Context ctx = ((CairoContextBackend)backend).Context;
     ctx.RelLineTo(dx, dy);
 }