static void DrawIcon (MonoTextEditor editor, Cairo.Context cr, DocumentLine lineSegment, double x, double y, double width, double height)
		{
			if (lineSegment.IsBookmarked) {
				var color1 = editor.ColorStyle.Bookmarks.Color;
				var color2 = editor.ColorStyle.Bookmarks.SecondColor;
				
				DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4);

				// FIXME: VV: Remove gradient features
				using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) {
					pat.AddColorStop (0, color1);
					pat.AddColorStop (1, color2);
					cr.SetSource (pat);
					cr.FillPreserve ();
				}

				// FIXME: VV: Remove gradient features
				using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) {
					pat.AddColorStop (0, color2);
					//pat.AddColorStop (1, color1);
					cr.SetSource (pat);
					cr.Stroke ();
				}
			}
		}
Exemple #2
0
 private Cairo.Gradient createGradient(double x1, double y1, double x2, double y2, Color c)
 {
     Cairo.Gradient gradient = new Cairo.LinearGradient(x1, y1, x2, y2);
     gradient.AddColorStop(0, new Cairo.Color(c.R / 256.0, c.G / 256.0, c.B / 256.0, 1.0));
     gradient.AddColorStop(0.5, new Cairo.Color(c.R / 256.0, c.G / 256.0, c.B / 256.0, 1.0));
     gradient.AddColorStop(0.5, new Cairo.Color(c.R / 256.0, c.G / 256.0, c.B / 256.0, 0.5));
     gradient.AddColorStop(1.0, new Cairo.Color(c.R / 256.0, c.G / 256.0, c.B / 256.0, 0.1));
     return(gradient);
 }
Exemple #3
0
 protected void DrawBorder(Cairo.Context cr, Cairo.Color color, double x, double y, double size)
 {
     using (var pat = new Cairo.LinearGradient(x, y + size, x + size, y))
     {
         pat.AddColorStop(0, color);
         cr.Pattern = pat;
         cr.Stroke();
     }
 }
 protected void FillGradient(Cairo.Context cr, Cairo.Color color1, Cairo.Color color2, double x, double y, double size)
 {
     using (var pat = new Cairo.LinearGradient(x + size / 4, y, x + size / 2, y + size - 4)) {
         pat.AddColorStop(0, color1);
         pat.AddColorStop(1, color2);
         cr.Pattern = pat;
         cr.FillPreserve();
     }
 }
Exemple #5
0
        void DrawBlockBg(Cairo.Context ctx, double x, int width, BlockInfo block)
        {
            if (!IsChangeBlock(block.Type))
            {
                return;
            }

            var    color  = block.Type == BlockType.Added ? Styles.LogView.DiffAddBackgroundColor : Styles.LogView.DiffRemoveBackgroundColor;
            double y      = block.YStart;
            int    height = block.YEnd - block.YStart;

            double markerx = x + LeftPaddingBlock;
            double rd      = RoundedSectionRadius;

            if (block.SectionStart)
            {
                ctx.Arc(x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
                ctx.LineTo(markerx, y);
            }
            else
            {
                ctx.MoveTo(markerx, y);
            }

            ctx.LineTo(markerx, y + height);

            if (block.SectionEnd)
            {
                ctx.LineTo(x + rd, y + height);
                ctx.Arc(x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
            }
            else
            {
                ctx.LineTo(x, y + height);
            }
            if (block.SectionStart)
            {
                ctx.LineTo(x, y + rd);
            }
            else
            {
                ctx.LineTo(x, y);
            }
            ctx.SetSourceColor(color.AddLight(0.1).ToCairoColor());
            ctx.Fill();

            ctx.Rectangle(markerx, y, width - markerx, height);

            // FIXME: VV: Remove gradient features
            using (Cairo.Gradient pat = new Cairo.LinearGradient(x, y, x + width, y)) {
                pat.AddColorStop(0, color.AddLight(0.21).ToCairoColor());
                pat.AddColorStop(1, color.AddLight(0.3).ToCairoColor());
                ctx.SetSource(pat);
                ctx.Fill();
            }
        }
Exemple #6
0
 /// <summary>
 /// Renders the background. Rendering will automatically be clipped to border constraints in later steps.
 /// </summary>
 public virtual void RenderBackground(Cairo.Context context, Gdk.Rectangle region)
 {
     using (var lg = new Cairo.LinearGradient(0, region.Y, 0, region.Y + region.Height)) {
         lg.AddColorStop(0, TopColor);
         lg.AddColorStop(1, BottomColor);
         context.Rectangle(region.X, region.Y, region.Width, region.Height);
         context.SetSource(lg);
         context.Fill();
     }
 }
Exemple #7
0
        protected override void MakePatterns()
        {
            d_outer = new Cairo.LinearGradient(0, 1, 0, 0);
            d_outer.AddColorStopRgb(0, new Cairo.Color(0.5, 0.5, 0.8));
            d_outer.AddColorStopRgb(d_object != null ? d_object.Allocation.Height : 1, new Cairo.Color(1, 1, 1));

            d_inner = new Cairo.LinearGradient(0, 1, 0, 0);
            d_inner.AddColorStopRgb(0, new Cairo.Color(0.75, 0.85, 1));
            d_inner.AddColorStopRgb((d_object != null ? d_object.Allocation.Height : 1) * 0.8, new Cairo.Color(1, 1, 1));
        }
Exemple #8
0
        private void SetBackground()
        {
            Cairo.Color light = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Normal));
            Cairo.Color dark  = CairoExtensions.ColorShade(light, 0.85);

            Cairo.LinearGradient grad = new Cairo.LinearGradient(0, Allocation.Y, 0, Allocation.Y + Allocation.Height);
            grad.AddColorStop(0, dark);
            grad.AddColorStop(1, light);
            FillPattern = grad;
        }
Exemple #9
0
        protected virtual void MakePatterns()
        {
            d_outer = new Cairo.LinearGradient(0, 1, 0, 0);
            d_outer.AddColorStopRgb(0, new Cairo.Color(1, 1, 1));
            d_outer.AddColorStopRgb(d_object != null ? d_object.Allocation.Height : 1, new Cairo.Color(1, 1, 1));

            d_inner = new Cairo.LinearGradient(0, 1, 0, 0);
            d_inner.AddColorStopRgb(0, new Cairo.Color(1, 1, 1));
            d_inner.AddColorStopRgb(d_object != null ? d_object.Allocation.Height : 1, new Cairo.Color(1, 1, 1));
        }
Exemple #10
0
        void DrawBlockBg(Cairo.Context ctx, double x, int width, BlockInfo block)
        {
            if (!IsChangeBlock(block.Type))
            {
                return;
            }

            x += 0.5;
            Gdk.Color color  = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor;
            double    y      = block.YStart + 0.5;
            int       height = block.YEnd - block.YStart;

            double markerx = x + LeftPaddingBlock - 0.5;
            double rd      = RoundedSectionRadius;

            if (block.SectionStart)
            {
                ctx.Arc(x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
                ctx.LineTo(markerx, y);
            }
            else
            {
                ctx.MoveTo(markerx, y);
            }

            ctx.LineTo(markerx, y + height);

            if (block.SectionEnd)
            {
                ctx.LineTo(x + rd, y + height);
                ctx.Arc(x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
            }
            else
            {
                ctx.LineTo(x, y + height);
            }
            if (block.SectionStart)
            {
                ctx.LineTo(x, y + rd);
            }
            else
            {
                ctx.LineTo(x, y);
            }
            ctx.Color = color.AddLight(0.1).ToCairoColor();
            ctx.Fill();

            ctx.Rectangle(markerx, y, width - markerx, height);
            using (Cairo.Gradient pat = new Cairo.LinearGradient(x, y, x + width, y)) {
                pat.AddColorStop(0, color.AddLight(0.21).ToCairoColor());
                pat.AddColorStop(1, color.AddLight(0.3).ToCairoColor());
                ctx.Pattern = pat;
                ctx.Fill();
            }
        }
Exemple #11
0
		void DrawFace (Cairo.PointD center, double radius, Cairo.Context e)
		{
			e.Arc (center.X, center.Y, radius, 0, 360);
			Cairo.Gradient pat = new Cairo.LinearGradient (100, 200, 200, 100);
			pat.AddColorStop (0, Generator.ConvertC (new Eto.Drawing.Color (240, 240, 230, 75)));
			pat.AddColorStop (1, Generator.ConvertC (new Eto.Drawing.Color (0, 0, 0, 50)));
			e.LineWidth = 0.1;
			e.Pattern = pat;
			e.FillPreserve ();
			e.Stroke ();
		}
 private void DrawCenterFilledCircle(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, CairoUtil.ColorFromRgb(240, 235, 229, 0.3));
     pat.AddColorStop(1, CairoUtil.ColorFromRgb(0, 0, 0, 0.2));
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }
Exemple #13
0
 static void DrawFace(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, Eto.Drawing.Color.FromArgb(240, 240, 230, 75).ToCairo());
     pat.AddColorStop(1, Eto.Drawing.Color.FromArgb(0, 0, 0, 50).ToCairo());
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }
        protected override bool OnExposeEvent(Gdk.EventExpose e)
        {
            if (TextEditor == null)
            {
                return(true);
            }
            using (Cairo.Context cr = Gdk.CairoHelper.Create(e.Window))
            {
                cr.LineWidth = 1;
                cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);

                if (TextEditor.ColorStyle != null)
                {
                    var grad = new Cairo.LinearGradient(0, 0, Allocation.Width, 0);
                    var col  = (HslColor)TextEditor.ColorStyle.Default.CairoBackgroundColor;
                    col.L *= 0.95;
                    grad.AddColorStop(0, col);
                    grad.AddColorStop(0.7, TextEditor.ColorStyle.Default.CairoBackgroundColor);
                    grad.AddColorStop(1, col);
                    cr.Pattern = grad;
                }
                cr.Fill();

                cr.Color = (HslColor)Style.Dark(State);
                cr.MoveTo(-0.5, 0.5);
                cr.LineTo(Allocation.Width, 0.5);

                cr.MoveTo(-0.5, Allocation.Height - 0.5);
                cr.LineTo(Allocation.Width, Allocation.Height - 0.5);
                cr.Stroke();

                if (TextEditor == null)
                {
                    return(true);
                }

                if (TextEditor.HighlightSearchPattern)
                {
                    DrawSearchResults(cr);
                    DrawSearchIndicator(cr);
                }
                else
                {
                    var severity = DrawQuickTasks(cr);
                    DrawIndicator(cr, severity);
                }
                DrawCaret(cr);

                DrawBar(cr);
                DrawLeftBorder(cr);
            }

            return(true);
        }
Exemple #15
0
		static void DrawFace (Cairo.PointD center, double radius, Cairo.Context e)
		{
			e.Arc (center.X, center.Y, radius, 0, 360);
			Cairo.Gradient pat = new Cairo.LinearGradient (100, 200, 200, 100);
			pat.AddColorStop (0, Eto.Drawing.Color.FromArgb (240, 240, 230, 75).ToCairo ());
			pat.AddColorStop (1, Eto.Drawing.Color.FromArgb (0, 0, 0, 50).ToCairo ());
			e.LineWidth = 0.1;
			e.Pattern = pat;
			e.FillPreserve ();
			e.Stroke ();
		}
Exemple #16
0
 void DrawFace(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, Generator.ConvertC(new Eto.Drawing.Color(240, 240, 230, 75)));
     pat.AddColorStop(1, Generator.ConvertC(new Eto.Drawing.Color(0, 0, 0, 50)));
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }
        void DrawNormal(Gdk.EventExpose evnt)
        {
            using (var ctx = Gdk.CairoHelper.Create(GdkWindow))
            {
                var x = Allocation.X;
                var y = Allocation.Y;

                ctx.Rectangle(x, y + 1, Allocation.Width, Allocation.Height - 1);
                using (var g = new Cairo.LinearGradient(x, y + 1, x, y + Allocation.Height - 1))
                {
                    g.AddColorStop(0, Styles.DockTabBarGradientStart);
                    g.AddColorStop(1, Styles.DockTabBarGradientEnd);
                    ctx.SetSource(g);
                    ctx.Fill();
                }

                ctx.MoveTo(x + 0.5, y + 0.5);
                ctx.LineTo(x + Allocation.Width - 0.5d, y + 0.5);
                ctx.SetSourceColor(Styles.DockTabBarGradientTop);
                ctx.Stroke();

                if (active)
                {
                    ctx.Rectangle(x, y + 1, Allocation.Width, Allocation.Height - 1);
                    using (var g = new Cairo.LinearGradient(x, y + 1, x, y + Allocation.Height - 1))
                    {
                        g.AddColorStop(0, new Cairo.Color(0, 0, 0, 0.01));
                        g.AddColorStop(0.5, new Cairo.Color(0, 0, 0, 0.08));
                        g.AddColorStop(1, new Cairo.Color(0, 0, 0, 0.01));
                        ctx.SetSource(g);
                        ctx.Fill();
                    }

                    /*             double offset = Allocation.Height * 0.25;
                     *             var rect = new Cairo.Rectangle (x - Allocation.Height + offset, y, Allocation.Height, Allocation.Height);
                     *             var cg = new Cairo.RadialGradient (rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 0, rect.X, rect.Y + rect.Height / 2, rect.Height / 2);
                     *             cg.AddColorStop (0, Styles.DockTabBarShadowGradientStart);
                     *             cg.AddColorStop (1, Styles.DockTabBarShadowGradientEnd);
                     *             ctx.Pattern = cg;
                     *             ctx.Rectangle (rect);
                     *             ctx.Fill ();
                     *
                     *             rect = new Cairo.Rectangle (x + Allocation.Width - offset, y, Allocation.Height, Allocation.Height);
                     *             cg = new Cairo.RadialGradient (rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 0, rect.X, rect.Y + rect.Height / 2, rect.Height / 2);
                     *             cg.AddColorStop (0, Styles.DockTabBarShadowGradientStart);
                     *             cg.AddColorStop (1, Styles.DockTabBarShadowGradientEnd);
                     *             ctx.Pattern = cg;
                     *             ctx.Rectangle (rect);
                     *             ctx.Fill ();*/
                }
            }
        }
 void FillGradient(Cairo.Context cr, double y, double h)
 {
     cr.Rectangle(0.5, y, Allocation.Width, h);
     using (var grad = new Cairo.LinearGradient(0, y, Allocation.Width, y)) {
         var col = (HslColor)Style.Base(StateType.Normal);
         col.L *= 0.95;
         grad.AddColorStop(0, col);
         grad.AddColorStop(0.7, (HslColor)Style.Base(StateType.Normal));
         grad.AddColorStop(1, col);
         cr.SetSource(grad);
         cr.Fill();
     }
 }
Exemple #19
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (var context = Gdk.CairoHelper.Create(evnt.Window)) {
                if (pickerCircle == null || pickerCircle.Width != Radius * 2 + 100 || pickerCircle.Height != Radius * 2 + 100)
                {
                    pickerCircle = new Cairo.ImageSurface(Cairo.Format.ARGB32, Radius * 2 + 100, Radius * 2 + 100);
                    using (var g = new Cairo.Context(pickerCircle)) {
                        // apparently quartz needs the surface initialized
                        g.Color = new Color(0, 0, 0);
                        g.Paint();
                    }
                    DrawPickerCircle(pickerCircle, Radius);
                }

                Gdk.Point center = PickerCenter();

                context.Arc(center.X, center.Y, Radius, 0, Math.PI * 2);
                context.Clip();
                pickerCircle.Show(context, center.X - pickerCircle.Width / 2, center.Y - pickerCircle.Height / 2);

                context.ResetClip();
                context.Arc(center.X, center.Y, Radius + 5, 0, Math.PI * 2);
                context.LineWidth = 10;

                using (var lg = new Cairo.LinearGradient(0, center.Y - (Radius + 30), 0, center.Y + (Radius + 30))) {
                    lg.AddColorStop(0, new Color(0, 0, 0, 0.3));
                    lg.AddColorStop(1, new Color(0, 0, 0, 0.1));
                    context.Pattern = lg;
                    context.Stroke();
                }

                context.Arc(center.X, center.Y, Radius + 15, 0, Math.PI * 2);
                context.LineWidth = 10;

                using (var lg = new Cairo.LinearGradient(0, center.Y - (Radius + 30), 0, center.Y + (Radius + 30))) {
                    lg.AddColorStop(0, new Color(0, 0, 0, 0.1));
                    lg.AddColorStop(1, new Color(0, 0, 0, 0.3));
                    context.Pattern = lg;
                    context.Stroke();
                }

                if (HighlightColor.HasValue)
                {
                    DrawColorOverlay(context, center, HighlightColor.Value);
                }

                Gdk.Rectangle selectedRegion = new Gdk.Rectangle(Allocation.X + 40, Allocation.Bottom - 100, Allocation.Width - 80, 50);
                DrawSelectedColorBox(context, selectedRegion);
            }
            return(base.OnExposeEvent(evnt));
        }
Exemple #20
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 #21
0
            void FillGradient(Cairo.Context cr, double y, double h)
            {
                cr.Rectangle(0.5, y, Allocation.Width, h);
                var grad = new Cairo.LinearGradient(0, y, Allocation.Width, y);
                var col  = (Mono.TextEditor.HslColor)Style.Base(StateType.Normal);

                col.L *= 0.95;
                grad.AddColorStop(0, col);
                grad.AddColorStop(0.7, (Mono.TextEditor.HslColor)Style.Base(StateType.Normal));
                grad.AddColorStop(1, col);
                cr.Pattern = grad;

                cr.Fill();
            }
Exemple #22
0
        void DrawShadow(Cairo.Context ctx, Gdk.Rectangle ar, PositionType pos, List <Section> secs)
        {
            foreach (Section s in secs)
            {
                Cairo.Gradient pat = null;
                Gdk.Rectangle  r   = ar;
                switch (pos)
                {
                case PositionType.Top:
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X     += s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.X, r.Bottom);
                    break;

                case PositionType.Bottom:
                    r.Y      = r.Bottom - shadowSize;
                    r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
                    r.X      = r.X + s.Offset;
                    r.Width  = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Bottom, r.X, r.Y);
                    break;

                case PositionType.Left:
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.X, r.Y, r.Right, r.Y);
                    break;

                case PositionType.Right:
                    r.X      = r.Right - shadowSize;
                    r.Width  = shadowSize > r.Width ? r.Width / 2 : shadowSize;
                    r.Y     += s.Offset;
                    r.Height = s.Size;
                    pat      = new Cairo.LinearGradient(r.Right, r.Y, r.X, r.Y);
                    break;
                }
                Cairo.Color c = darkColor.ToCairoColor();
                pat.AddColorStop(0, c);
                c.A = 0;
                pat.AddColorStop(1, c);
                ctx.NewPath();
                ctx.Rectangle(r.X, r.Y, r.Width, r.Height);
                ctx.SetSource(pat);
                ctx.Fill();
                pat.Dispose();
            }
        }
Exemple #23
0
        private void RenderBackground(Gdk.Window window, Gdk.Region region)
        {
            var cr = Gdk.CairoHelper.Create(window);

            var grad = new Cairo.LinearGradient(0, 0, 0, Allocation.Height);

            grad.AddColorStop(0, CairoExtensions.RgbToColor(0xffffff));
            grad.AddColorStop(1, CairoExtensions.RgbToColor(0xc3c3c3));
            cr.Pattern = grad;
            cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);
            cr.Fill();
            grad.Destroy();

            CairoExtensions.DisposeContext(cr);
        }
 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 #25
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 #26
0
        protected override Cairo.LinearGradient CreateGradient()
        {
            double r, g, b;

            r = (double)frameColor.Red / ushort.MaxValue;
            g = (double)frameColor.Green / ushort.MaxValue;
            b = (double)frameColor.Blue / ushort.MaxValue;

            Cairo.LinearGradient grad = new Cairo.LinearGradient(0, 0, x + width, 0);
            grad.AddColorStop(.1, new Cairo.Color(r, g, b, 0));
            grad.AddColorStop(.35, new Cairo.Color(r, g, b, fillAlpha));
            grad.AddColorStop(.65, new Cairo.Color(r, g, b, fillAlpha));
            grad.AddColorStop(.9, new Cairo.Color(r, g, b, 0));

            return(grad);
        }
Exemple #27
0
        private void DrawSocketConnection(Cairo.Context cr, NodeViewConnection c)
        {
            Cairo.LinearGradient pat;
            RGBA colSrc, colSink;

            Rectangle allocation;
            Rectangle allocParent;
            int       x0, x1, y0, y1;

            allocParent = c.Source.Parent.Allocation;
            allocation  = c.Source.Allocation;
            x0          = allocation.X + allocation.Width / 2 + allocParent.X;
            y0          = allocation.Y + allocation.Height / 2 + allocParent.Y;

            allocParent = c.Sink.Parent.Allocation;
            allocation  = c.Sink.Allocation;
            x1          = allocation.X + allocation.Width / 2 + allocParent.X;
            y1          = allocation.Y + allocation.Height / 2 + allocParent.Y;

            pat = new Cairo.LinearGradient(x0, y0, x1, y1);

            colSrc  = c.Source.RGBA;
            colSink = c.Sink.RGBA;

            pat.AddColorStop
            (
                0,
                new Cairo.Color(colSrc.Red, colSrc.Green, colSrc.Blue, colSrc.Alpha)
            );

            pat.AddColorStop
            (
                1,
                new Cairo.Color(colSink.Red, colSink.Green, colSink.Blue, colSink.Alpha)
            );

            cr.Save();

            NodeConnectingCurve(cr, x0, y0, x1, y1);

            cr.SetSource(pat);
            cr.Stroke();
            pat.Dispose();

            cr.Restore();
        }
Exemple #28
0
        protected void DrawIndicator(Cairo.Context cr, Severity severity)
        {
            cr.Rectangle(3, Allocation.Height - IndicatorHeight + 4, Allocation.Width - 6, IndicatorHeight - 6);

            var darkColor = (HslColor)GetIndicatorColor(severity);

            darkColor.L *= 0.5;

            using (var pattern = new Cairo.LinearGradient(0, 0, Allocation.Width - 3, IndicatorHeight)) {
                pattern.AddColorStop(0, darkColor);
                pattern.AddColorStop(1, GetIndicatorColor(severity));
                cr.Pattern = pattern;
                cr.FillPreserve();
            }

            cr.Color = darkColor;
            cr.Stroke();
        }
Exemple #29
0
            protected override bool OnExposeEvent(Gdk.EventExpose evnt)
            {
                using (var ctx = Gdk.CairoHelper.Create(GdkWindow)) {
                    ctx.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                    Cairo.LinearGradient g = new Cairo.LinearGradient(0, 0, 0, Allocation.Height);
                    g.AddColorStop(0, Styles.BreadcrumbBackgroundColor);
                    g.AddColorStop(1, Styles.BreadcrumbGradientEndColor);
                    ctx.Pattern = g;
                    ctx.Fill();

                    ctx.MoveTo(0.5, Allocation.Height - 0.5);
                    ctx.RelLineTo(Allocation.Width, 0);
                    ctx.Color     = Styles.BreadcrumbBottomBorderColor;
                    ctx.LineWidth = 1;
                    ctx.Stroke();
                }
                return(base.OnExposeEvent(evnt));
            }
Exemple #30
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 #31
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 #32
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            using (var context = Gdk.CairoHelper.Create(evnt.Window)) {
                var alloc = Allocation;

                // TODO: VV: Remove preflight gradient features and replace with a flat color

                Cairo.LinearGradient lg;

                if (bar.Orientation == Orientation.Horizontal)
                {
                    lg = new Cairo.LinearGradient(alloc.X, 0, alloc.X + alloc.Width, 0);
                }
                else
                {
                    lg = new Cairo.LinearGradient(0, alloc.Y, 0, alloc.Y + alloc.Height);
                }

                using (lg) {
                    Cairo.Color primaryColor = Styles.DockBarPrelightColor.ToCairoColor();
                    primaryColor.A = hoverProgress;

                    Cairo.Color transparent = primaryColor;
                    transparent.A = 0;

                    lg.AddColorStop(0.0, transparent);
                    lg.AddColorStop(0.35, primaryColor);
                    lg.AddColorStop(0.65, primaryColor);
                    lg.AddColorStop(1.0, transparent);

                    context.Rectangle(alloc.ToCairoRect());
                    context.SetSource(lg);
                }
                context.Fill();
            }

            if (HasFocus)
            {
                Gtk.Style.PaintFocus(Style, GdkWindow, State, Allocation, this, "button", Allocation.X + 2, Allocation.Y + 2, Allocation.Width - 4, Allocation.Height - 4);
            }
            return(base.OnExposeEvent(evnt));
        }
		public void DrawIcon (TextEditor editor, Cairo.Context cr, LineSegment lineSegment, int lineNumber, double x, double y, double width, double height)
		{
			if (lineSegment.IsBookmarked) {
				Cairo.Color color1 = editor.ColorStyle.BookmarkColor1;
				Cairo.Color color2 = editor.ColorStyle.BookmarkColor2;
				
				DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4);
				Cairo.Gradient pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4);
				pat.AddColorStop (0, color1);
				pat.AddColorStop (1, color2);
				cr.Pattern = pat;
				cr.FillPreserve ();
				
				pat = new Cairo.LinearGradient (x, y + height, x + width, y);
				pat.AddColorStop (0, color2);
				//pat.AddColorStop (1, color1);
				cr.Pattern = pat;
				cr.Stroke ();
			}
		}
Exemple #34
0
        void DrawBookmark(Gdk.Drawable win, int x, int y)
        {
            Cairo.Color color1 = ToCairoColor(Style.BookmarkColor1);
            Cairo.Color color2 = ToCairoColor(Style.BookmarkColor2);

            Cairo.Context cr = Gdk.CairoHelper.Create(win);
            DrawRoundRectangle(cr, x + 1, y + 1, 8, Width - 4, Editor.LineHeight - 4);
            Cairo.Gradient pat = new Cairo.LinearGradient(x + Width / 4, y, x + Width / 2, y + Editor.LineHeight - 4);
            pat.AddColorStop(0, color1);
            pat.AddColorStop(1, color2);
            cr.Pattern = pat;
            cr.FillPreserve();

            pat = new Cairo.LinearGradient(x, y + Editor.LineHeight, x + Width, y);
            pat.AddColorStop(0, color2);
            //pat.AddColorStop (1, color1);
            cr.Pattern = pat;
            cr.Stroke();
            ((IDisposable)cr).Dispose();
        }
		public void DrawIcon (TextEditor editor, Gdk.Drawable win, LineSegment lineSegment, int lineNumber, int x, int y, int width, int height)
		{
			if (lineSegment.IsBookmarked) {
				Cairo.Color color1 = Style.ToCairoColor (editor.ColorStyle.BookmarkColor1);
				Cairo.Color color2 = Style.ToCairoColor (editor.ColorStyle.BookmarkColor2);
				
				Cairo.Context cr = Gdk.CairoHelper.Create (win);
				DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4);
				Cairo.Gradient pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4);
				pat.AddColorStop (0, color1);
				pat.AddColorStop (1, color2);
				cr.Pattern = pat;
				cr.FillPreserve ();
				
				pat = new Cairo.LinearGradient (x, y + height, x + width, y);
				pat.AddColorStop (0, color2);
				//pat.AddColorStop (1, color1);
				cr.Pattern = pat;
				cr.Stroke ();
				((IDisposable)cr).Dispose();
			}
		}
			protected override bool OnExposeEvent (Gdk.EventExpose evnt)
			{
				using (var context = Gdk.CairoHelper.Create (evnt.Window)) {
					context.Rectangle (
						evnt.Area.X,
						evnt.Area.Y,
						evnt.Area.Width,
						evnt.Area.Height
					);
					context.Clip ();
					context.LineWidth = 1;
					if (Background != null && Background.Width > 0) {
						for (int x=0; x < Allocation.Width; x += Background.Width) {
							Background.Show (context, x, -TitleBarHeight);
						}
					} else {
						context.Rectangle (0, 0, Allocation.Width, Allocation.Height);
						using (var lg = new Cairo.LinearGradient (0, 0, 0, Allocation.Height)) {
							lg.AddColorStop (0, Style.Light (Gtk.StateType.Normal).ToCairoColor ());
							lg.AddColorStop (1, Style.Mid (Gtk.StateType.Normal).ToCairoColor ());
							context.SetSource (lg);
						}
						context.Fill ();

					}
					context.MoveTo (0, Allocation.Height - 0.5);
					context.RelLineTo (Allocation.Width, 0);
					context.SetSourceColor (MonoDevelop.Ide.Gui.Styles.ToolbarBottomBorderColor);
					context.Stroke ();

					context.MoveTo (0, Allocation.Height - 1.5);
					context.RelLineTo (Allocation.Width, 0);
					context.SetSourceColor (MonoDevelop.Ide.Gui.Styles.ToolbarBottomGlowColor);
					context.Stroke ();

				}
				return base.OnExposeEvent (evnt);
			}
		void DrawBlockBg (Cairo.Context ctx, double x, int width, BlockInfo block)
		{
			if (!IsChangeBlock (block.Type))
				return;
			
			var color = block.Type == BlockType.Added ? Styles.LogView.DiffAddBackgroundColor : Styles.LogView.DiffRemoveBackgroundColor;
			double y = block.YStart;
			int height = block.YEnd - block.YStart;
			
			double markerx = x + LeftPaddingBlock;
			double rd = RoundedSectionRadius;
			if (block.SectionStart) {
				ctx.Arc (x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
				ctx.LineTo (markerx, y);
			} else {
				ctx.MoveTo (markerx, y);
			}
			
			ctx.LineTo (markerx, y + height);
			
			if (block.SectionEnd) {
				ctx.LineTo (x + rd, y + height);
				ctx.Arc (x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
			} else {
				ctx.LineTo (x, y + height);
			}
			if (block.SectionStart) {
				ctx.LineTo (x, y + rd);
			} else {
				ctx.LineTo (x, y);
			}
			ctx.SetSourceColor (color.AddLight (0.1).ToCairoColor ());
			ctx.Fill ();
			
			ctx.Rectangle (markerx, y, width - markerx, height);

			// FIXME: VV: Remove gradient features
			using (Cairo.Gradient pat = new Cairo.LinearGradient (x, y, x + width, y)) {
				pat.AddColorStop (0, color.AddLight (0.21).ToCairoColor ());
				pat.AddColorStop (1, color.AddLight (0.3).ToCairoColor ());
				ctx.SetSource (pat);
				ctx.Fill ();
			}
		}
Exemple #38
0
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			using (var context = Gdk.CairoHelper.Create (evnt.Window)) {
				var alloc = Allocation;

				// TODO: VV: Remove preflight gradient features and replace with a flat color

				Cairo.LinearGradient lg;

				if (bar.Orientation == Orientation.Horizontal) {
					lg = new Cairo.LinearGradient (alloc.X, 0, alloc.X + alloc.Width, 0);
				} else {
					lg = new Cairo.LinearGradient (0, alloc.Y, 0, alloc.Y + alloc.Height);
				}

				using (lg) {
					Cairo.Color primaryColor = Styles.DockBarPrelightColor.ToCairoColor ();
					primaryColor.A = hoverProgress;

					Cairo.Color transparent = primaryColor;
					transparent.A = 0;

					lg.AddColorStop (0.0, transparent);
					lg.AddColorStop (0.35, primaryColor);
					lg.AddColorStop (0.65, primaryColor);
					lg.AddColorStop (1.0, transparent);

					context.Rectangle (alloc.ToCairoRect ());
					context.SetSource (lg);
				}
				context.Fill ();
			}
			return base.OnExposeEvent (evnt);
		}
		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 = 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 = 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;
		}
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			Gdk.Rectangle rect = Allocation;
			
			if (GradientBackround) {
				HslColor gcol = 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);
			
			//for some reason we seem to need to paint a sightly bigger box to align with the header
			//even though the allocation appears to be the same
			rect.Width += 1;
			rect.Height += 1;
			
			using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
				cr.Color = (HslColor) Style.Dark (Gtk.StateType.Normal);
				
				double y = rect.Y + topMargin / 2d;
				cr.LineWidth = topMargin;
				cr.Line (rect.X, y, rect.Right, y);
				cr.Stroke ();
				
				y = rect.Bottom - bottomMargin / 2d;
				cr.LineWidth = bottomMargin;
				cr.Line (rect.X, y, rect.Right, y);
				cr.Stroke ();
				
				double x = rect.X + leftMargin / 2d;
				cr.LineWidth = leftMargin;
				cr.Line (x, rect.Y, x, rect.Bottom);
				cr.Stroke ();
				
				x = rect.Right - rightMargin / 2d;
				cr.LineWidth = rightMargin;
				cr.Line (x, rect.Y, x, rect.Bottom);
				cr.Stroke ();
			}
			
			return res;
		}
		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 = 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 ();
				}
			} else if (BackgroundColor != null) {
				using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
					cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
					cr.Color = BackgroundColor.Value.ToCairoColor ();
					cr.Fill ();
				}
			} else if (useChildBackgroundColor && Child != null) {
				using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
					cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
					cr.Color = Child.Style.Base (StateType.Normal).ToCairoColor ();
					cr.Fill ();
				}
			}
			
			bool res = base.OnExposeEvent (evnt);
			
			var borderColor = new Gdk.GC (GdkWindow);
			borderColor.RgbFgColor = BorderColor != null ? BorderColor.Value : Style.Dark (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, rect.Right, rect.Bottom - n);
			
			for (int n=0; n<leftMargin; n++)
				GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom);
			
			for (int n=0; n<rightMargin; n++)
				GdkWindow.DrawLine (borderColor, rect.Right - n, rect.Y, rect.Right - n, rect.Bottom);

			if (showTopShadow) {
				using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
					cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, shadowSize);
					Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + shadowSize);
					pat.AddColorStop (0, new Cairo.Color (0, 0, 0, shadowStrengh));
					pat.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
					cr.Pattern = pat;
					cr.Fill ();
				}
			}

			borderColor.Dispose ();
			return res;
		}
		protected override bool OnExposeEvent (Gdk.EventExpose e)
		{
			if (TextEditor == null)
				return true;
			using (Cairo.Context cr = Gdk.CairoHelper.Create (e.Window)) {
				cr.LineWidth = 1;
				cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
				
				if (TextEditor.ColorStyle != null) {
					var col = (HslColor)TextEditor.ColorStyle.PlainText.Background;
					col.L *= 0.95;
					if (flatStyle) {
						using (var pattern = new Cairo.SolidPattern (col)) {
							cr.Pattern = pattern;
						}
					} else {
						using (var grad = new Cairo.LinearGradient (0, 0, Allocation.Width, 0)) {
							grad.AddColorStop (0, col);
							grad.AddColorStop (0.7, TextEditor.ColorStyle.PlainText.Background);
							grad.AddColorStop (1, col);
							cr.Pattern = grad;
						}
					}
				}
				cr.Fill ();

				/*
				cr.Color = (HslColor)Style.Dark (State);
				cr.MoveTo (-0.5, 0.5);
				cr.LineTo (Allocation.Width, 0.5);

				cr.MoveTo (-0.5, Allocation.Height - 0.5);
				cr.LineTo (Allocation.Width, Allocation.Height - 0.5);
				cr.Stroke ();*/

				if (TextEditor == null)
					return true;
				
				if (TextEditor.HighlightSearchPattern) {
					DrawSearchResults (cr);
					DrawSearchIndicator (cr);
				} else {
					if (!Debugger.DebuggingService.IsDebugging) {
						var severity = DrawQuickTasks (cr);
						DrawIndicator (cr, severity);
					}
				}
				DrawCaret (cr);
				
				DrawBar (cr);
				DrawLeftBorder (cr);
			}
			
			return true;
		}
Exemple #43
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 #44
0
		protected override bool OnExposeEvent (EventExpose evnt)
		{
			using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {

				ctx.Rectangle (0, 0, Allocation.Width, Allocation.Height);
				using (var g = new Cairo.LinearGradient (0, 0, 0, Allocation.Height)) {
					g.AddColorStop (0, Styles.BreadcrumbBackgroundColor);
					g.AddColorStop (1, Styles.BreadcrumbGradientEndColor);
					ctx.SetSource (g);
				}
				ctx.Fill ();

				if (widths == null)
					return true;

				// Calculate the total required with, and the reduction to be applied in case it doesn't fit the available space

				bool widthReduced;
				var currentWidths = GetCurrentWidths (out widthReduced);

				// Render the paths

				int textTopPadding = topPadding + (height - textHeight) / 2;
				int xpos = leftPadding, ypos = topPadding;

				for (int i = 0; i < leftPath.Length; i++) {
					bool last = i == leftPath.Length - 1;

					// Reduce the item size when required
					int itemWidth = currentWidths [i];
					int x = xpos;
					xpos += itemWidth;

					if (hoverIndex >= 0 && hoverIndex < Path.Length && leftPath [i] == Path [hoverIndex] && (menuVisible || pressed || hovering))
						DrawButtonBorder (ctx, x - padding, itemWidth + padding + padding);

					int textOffset = 0;
					if (leftPath [i].DarkIcon != null) {
						int iy = (height - (int)leftPath [i].DarkIcon.Height) / 2 + topPadding;
						ctx.DrawImage (this, leftPath [i].DarkIcon, x, iy);
						textOffset += (int) leftPath [i].DarkIcon.Width + iconSpacing;
					}
					
					layout.Attributes = (i == activeIndex) ? boldAtts : null;
					layout.SetMarkup (GetFirstLineFromMarkup (leftPath [i].Markup));

					ctx.Save ();

					// If size is being reduced, ellipsize it
					bool showText = true;
					if (widthReduced) {
						int w = itemWidth - textOffset;
						if (w > 0) {
							ctx.Rectangle (x + textOffset, textTopPadding, w, height);
							ctx.Clip ();
						} else
							showText = false;
					} else
						layout.Width = -1;

					if (showText) {
						// Text
						ctx.SetSourceColor (Styles.BreadcrumbTextColor.ToCairoColor ());
						ctx.MoveTo (x + textOffset, textTopPadding);
						Pango.CairoHelper.ShowLayout (ctx, layout);
					}
					ctx.Restore ();

					if (!last) {
						xpos += arrowLeftPadding;
						if (leftPath [i].IsPathEnd) {
							Style.PaintVline (Style, GdkWindow, State, evnt.Area, this, "", ypos, ypos + height, xpos - arrowSize / 2);
						} else {
							int arrowH = Math.Min (height, arrowSize);
							int arrowY = ypos + (height - arrowH) / 2;
							DrawPathSeparator (ctx, xpos, arrowY, arrowH);
						}
						xpos += arrowSize + arrowRightPadding;
					}
				}
				
				int xposRight = Allocation.Width - rightPadding;
				for (int i = 0; i < rightPath.Length; i++) {
					//				bool last = i == rightPath.Length - 1;

					// Reduce the item size when required
					int itemWidth = currentWidths [i + leftPath.Length];
					xposRight -= itemWidth;
					xposRight -= arrowSize;
						
					int x = xposRight;
					
					if (hoverIndex >= 0 && hoverIndex < Path.Length && rightPath [i] == Path [hoverIndex] && (menuVisible || pressed || hovering))
						DrawButtonBorder (ctx, x - padding, itemWidth + padding + padding);
					
					int textOffset = 0;
					if (rightPath [i].DarkIcon != null) {
						ctx.DrawImage (this, rightPath [i].DarkIcon, x, ypos);
						textOffset += (int) rightPath [i].DarkIcon.Width + padding;
					}
					
					layout.Attributes = (i == activeIndex) ? boldAtts : null;
					layout.SetMarkup (GetFirstLineFromMarkup (rightPath [i].Markup));

					ctx.Save ();

					// If size is being reduced, ellipsize it
					bool showText = true;
					if (widthReduced) {
						int w = itemWidth - textOffset;
						if (w > 0) {
							ctx.Rectangle (x + textOffset, textTopPadding, w, height);
							ctx.Clip ();
						} else
							showText = false;
					} else
						layout.Width = -1;

					if (showText) {
						// Text
						ctx.SetSourceColor (Styles.BreadcrumbTextColor.ToCairoColor ());
						ctx.MoveTo (x + textOffset, textTopPadding);
						Pango.CairoHelper.ShowLayout (ctx, layout);
					}

					ctx.Restore ();
				}

				ctx.MoveTo (0, Allocation.Height - 0.5);
				ctx.RelLineTo (Allocation.Width, 0);
				ctx.SetSourceColor (Styles.BreadcrumbBottomBorderColor);
				ctx.LineWidth = 1;
				ctx.Stroke ();
			}

			return true;
		}
		public bool DrawBackground (TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, int selectionStart, int selectionEnd, int startOffset, int endOffset, double y, double startXPos, double endXPos, ref bool drawBg)
		{
			if (!IsVisible || DebuggingService.IsDebugging)
				return true;
			EnsureLayoutCreated (editor);
			double x = editor.TextViewMargin.XOffset;
			int right = editor.Allocation.Width;
			int errorCounterWidth = 0;
			bool isCaretInLine = startOffset <= editor.Caret.Offset && editor.Caret.Offset <= endOffset;
			int ew = 0, eh = 0;
			if (errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				errorCounterWidth = ew + 10;
			}
			
			double x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.EditableLength) : false;
			
			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			int highlighted = active == 0 && isCaretInLine ? 1 : 0;
			int selected = 0;
			
			double topSize = editor.LineHeight / 2;
			double bottomSize = editor.LineHeight / 2 + editor.LineHeight % 2;
		
			if (!fitsInSameLine) {
				if (isEolSelected) {
					x -= (int)editor.HAdjustment.Value;
					editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y + editor.LineHeight, editor.TextViewMargin.TextStartPosition, editor.LineHeight), editor.ColorStyle.Default.CairoBackgroundColor, true);
					editor.TextViewMargin.DrawRectangleWithRuler (g, x + editor.TextViewMargin.TextStartPosition, new Cairo.Rectangle (x + editor.TextViewMargin.TextStartPosition, y + editor.LineHeight, editor.Allocation.Width + (int)editor.HAdjustment.Value, editor.LineHeight), editor.ColorStyle.Selection.CairoBackgroundColor, true);
					x += (int)editor.HAdjustment.Value;
				} else {
					editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y + editor.LineHeight, x2, editor.LineHeight), editor.ColorStyle.Default.CairoBackgroundColor, true);
				}
			}
			DrawRectangle (g, x, y, right, topSize);
			g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
			g.Fill ();
			DrawRectangle (g, x, y + topSize, right, bottomSize);
			g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
			g.Fill ();
			
			g.MoveTo (new Cairo.PointD (x, y + 0.5));
			g.LineTo (new Cairo.PointD (x + right, y + 0.5));
			g.Color = colorMatrix[active, TOP, LINE, highlighted, selected];
			g.Stroke ();
			
			g.MoveTo (new Cairo.PointD (x, y + editor.LineHeight - 0.5));
			g.LineTo (new Cairo.PointD ((fitsInSameLine ? x + right : x2 + 1), y + editor.LineHeight - 0.5));
			g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
			g.Stroke ();
			if (editor.Options.ShowRuler) {
				double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
				g.MoveTo (new Cairo.PointD (divider + 0.5, y));
				g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
				g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
				g.Stroke ();
			}
			
			// draw background
			if (layout2.StartSet || selectionStart == endOffset) {
				double startX;
				double endX;
				
				if (selectionStart != endOffset) {
					var start = layout2.Layout.IndexToPos ((int)layout2.SelectionStartIndex);
					startX = (int)(start.X / Pango.Scale.PangoScale);
					var end = layout2.Layout.IndexToPos ((int)layout2.SelectionEndIndex);
					endX = (int)(end.X / Pango.Scale.PangoScale);
				} else {
					startX = x2;
					endX = startX;
				}
				
				if (editor.MainSelection.SelectionMode == SelectionMode.Block && startX == endX)
					endX = startX + 2;
				startX += startXPos;
				endX += startXPos;
				startX = Math.Max (editor.TextViewMargin.XOffset, startX);
				// clip region to textviewmargin start
				if (isEolSelected)
					endX = editor.Allocation.Width + (int)editor.HAdjustment.Value;
				if (startX < endX) {
					DrawRectangle (g, startX, y, endX - startX, topSize);
					g.Color = colorMatrix[active, TOP, LIGHT, highlighted, 1];
					g.Fill ();
					DrawRectangle (g, startX, y + topSize, endX - startX, bottomSize);
					g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
					g.Fill ();
					
					g.MoveTo (new Cairo.PointD (startX, y + 0.5));
					g.LineTo (new Cairo.PointD (endX, y + 0.5));
					g.Color = colorMatrix[active, TOP, LINE, highlighted, 1];
					g.Stroke ();
					
					if (startX < x2) {
						g.MoveTo (new Cairo.PointD (startX, y + editor.LineHeight - 0.5));
						g.LineTo (new Cairo.PointD (System.Math.Min (endX, x2 + 1), y + editor.LineHeight - 0.5));
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
						g.Stroke ();
						if (x2 + 1 < endX) {
							g.MoveTo (new Cairo.PointD (x2 + 1, y + editor.LineHeight - 0.5));
							g.LineTo (new Cairo.PointD (endX, y + editor.LineHeight - 0.5));
							g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
							g.Stroke ();
						}
					}
					
					if (editor.Options.ShowRuler) {
						double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
						g.MoveTo (new Cairo.PointD (divider + 0.5, y));
						g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
						g.Stroke ();
					}
				}
			}
			
			if (!fitsInSameLine)
				y += editor.LineHeight;
			double y2 = y + 0.5;
			double y2Bottom = y2 + editor.LineHeight - 1;
			selected = isEolSelected && (CollapseExtendedErrors || errors.Count == 1) ? 1 : 0;
			
			// draw message text background
			if (CollapseExtendedErrors || errors.Count == 1) {
				if (!fitsInSameLine) {
					// draw box below line 
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2 - 1));
					g.ClosePath ();
					g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
					g.Fill ();
					
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2Bottom));
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.Stroke ();
				} else {
					// draw 'arrow marker' in the same line
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
					double mid = y2 + topSize;
					g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, mid));
					
					g.LineTo (new Cairo.PointD (right, mid));
					g.LineTo (new Cairo.PointD (right, y2));
					g.ClosePath ();
					g.Color = colorMatrix[active, TOP, DARK, highlighted, selected];
					g.Fill ();
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, mid));
					
					g.LineTo (new Cairo.PointD (right, mid));
					g.LineTo (new Cairo.PointD (right, y2Bottom));
					g.ClosePath ();
					
					g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
					g.Fill ();
					
					// draw border
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
					g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
					
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2));
					g.ClosePath ();
					
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.Stroke ();
				}
			} else {
				if (!fitsInSameLine) {
					// draw box below line
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2 - 1));
					g.ClosePath ();
				} else {
					// draw filled arrow box
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
					g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2Bottom));
					g.LineTo (new Cairo.PointD (right, y2));
					g.ClosePath ();
				}
				g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
				g.Fill ();
				
				// draw light bottom line
				g.MoveTo (new Cairo.PointD (right, y2Bottom));
				g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
				g.Stroke ();
				
				// stroke left line
				if (fitsInSameLine) {
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
					g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
				} else {
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom + 1));
				}
				
				g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
				g.Stroke ();
				
				// stroke top line
				if (fitsInSameLine) {
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.MoveTo (new Cairo.PointD (right, y2));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2));
					g.Stroke ();
				}
			}
			
			if (editor.Options.ShowRuler) {
				double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
				if (divider >= x2) {
					g.MoveTo (new Cairo.PointD (divider + 0.5, y2));
					g.LineTo (new Cairo.PointD (divider + 0.5, y2Bottom));
					g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
					g.Stroke ();
				}
			}
			
			if (errors.Count > 1 && errorCountLayout != null) {
				double rX = x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border + LayoutWidth;
				double rY = y + editor.LineHeight / 6;
				double rW = errorCounterWidth - 2;
				double rH = editor.LineHeight * 3 / 4;
				BookmarkMarker.DrawRoundRectangle (g, rX, rY, 8, rW, rH);
				
				g.Color = oldIsOver ? new Cairo.Color (0.3, 0.3, 0.3) : new Cairo.Color (0.5, 0.5, 0.5);
				g.Fill ();
				if (CollapseExtendedErrors) {
					g.Color = gcLight;
					g.Save ();
					g.Translate (x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border + LayoutWidth + 4, y + (editor.LineHeight - eh) / 2 + eh % 2);
					g.ShowLayout (errorCountLayout);
					g.Restore ();
				} else {
					g.MoveTo (rX + rW / 2 - rW / 4, rY + rH - rH / 4);
					g.LineTo (rX + rW / 2 + rW / 4, rY + rH - rH / 4);
					g.LineTo (rX + rW / 2, rY + rH / 4);
					g.ClosePath ();
					
					g.Color = new Cairo.Color (1, 1, 1);
					g.Fill ();
				}
			}
			
			for (int i = 0; i < layouts.Count; i++) {
				LayoutDescriptor layout = layouts[i];
				x2 = right - layout.Width - border - errorPixbuf.Width;
				if (i == 0)
					x2 -= errorCounterWidth;
				x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
				if (i > 0) {
					editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y, right, editor.LineHeight), isEolSelected ? editor.ColorStyle.Selection.CairoBackgroundColor : editor.ColorStyle.Default.CairoBackgroundColor, true);
					g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
					g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
					g.LineTo (new Cairo.PointD (right, y));
					g.ClosePath ();
					
					if (CollapseExtendedErrors) {
						Cairo.Gradient pat = new Cairo.LinearGradient (x2, y, x2, y + editor.LineHeight);
						pat.AddColorStop (0, colorMatrix[active, TOP, LIGHT, highlighted, selected]);
						pat.AddColorStop (1, colorMatrix[active, BOTTOM, LIGHT, highlighted, selected]);
						g.Pattern = pat;
					} else {
						g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
					}
					g.Fill ();
					if (editor.Options.ShowRuler) {
						double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
						if (divider >= x2) {
							g.MoveTo (new Cairo.PointD (divider + 0.5, y));
							g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
							g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
							g.Stroke ();
						}
					}
				}
				int lw, lh;
				layout.Layout.GetPixelSize (out lw, out lh);
				g.Color = (HslColor)(selected == 0 ? gc : gcSelected);
				g.Save ();
				g.Translate (x2 + errorPixbuf.Width + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2);
				g.ShowLayout (layout.Layout);
				g.Restore ();
				y += editor.LineHeight;
				if (!UseVirtualLines)
					break;
			}
			return true;
		}
Exemple #46
0
			protected override bool OnExposeEvent (EventExpose evnt)
			{
				bool hideButton = widget.OriginalEditor.Document.ReadOnly || !widget.DiffEditor.Document.ReadOnly;
				using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) {
					int delta = widget.OriginalEditor.Allocation.Y - Allocation.Y;
					if (widget.Diff != null) {
						foreach (Diff.Hunk hunk in widget.Diff) {
							if (!hunk.Same) {
								int y1 = delta + widget.DiffEditor.LineToVisualY (hunk.Right.Start) - (int)widget.OriginalEditor.VAdjustment.Value;
								int y2 = delta + widget.DiffEditor.LineToVisualY (hunk.Right.Start + hunk.Right.Count) - (int)widget.OriginalEditor.VAdjustment.Value;
								if (y1 == y2)
									y2 = y1 + 1;
								
								int z1 = delta + widget.OriginalEditor.LineToVisualY (hunk.Left.Start) - (int)widget.DiffEditor.VAdjustment.Value;
								int z2 = delta + widget.OriginalEditor.LineToVisualY (hunk.Left.Start + hunk.Left.Count) - (int)widget.DiffEditor.VAdjustment.Value;
								
								if (z1 == z2)
									z2 = z1 + 1;
								cr.MoveTo (Allocation.Width, y1);
								
								cr.CurveTo (Allocation.Width / 2, y1,
									Allocation.Width / 2,  z1,
									0, z1);
								
								cr.LineTo (0, z2);
								cr.CurveTo (Allocation.Width / 2, z2, 
									Allocation.Width / 2, y2,
									Allocation.Width, y2);
								cr.ClosePath ();
								cr.Color = GetColor (hunk, fillAlpha);
								cr.Fill ();
								
								cr.Color = GetColor (hunk, lineAlpha);
								cr.MoveTo (Allocation.Width, y1);
								cr.CurveTo (Allocation.Width / 2, y1,
									Allocation.Width / 2,  z1,
									0, z1);
								cr.Stroke ();
								
								cr.MoveTo (0, z2);
								cr.CurveTo (Allocation.Width / 2, z2, 
									Allocation.Width / 2, y2,
									Allocation.Width, y2);
								cr.Stroke ();
								
								if (!hideButton) {
									bool isButtonSelected = selectedHunk != null && hunk.Left.Start == selectedHunk.Left.Start && hunk.Right.Start == selectedHunk.Right.Start;
									
									cr.Save ();
									int x, y, r;
									GetButtonPosition (hunk, z1, z2, y1, y2, out x, out y, out r);
									
									FoldingScreenbackgroundRenderer.DrawRoundRectangle (cr, true, true, x, y, r / 2, r, r);
									cr.Color = new Cairo.Color (1, 0, 0);
									cr.Fill ();
									FoldingScreenbackgroundRenderer.DrawRoundRectangle (cr, true, true, x + 1, y + 1, (r - 2) / 2, r - 2, r - 2);
	
									var shadowGradient = new Cairo.LinearGradient (x, y, x + r, y + r);
									if (isButtonSelected) {
										shadowGradient.AddColorStop (0, new Cairo.Color (1, 1, 1, 0));
										shadowGradient.AddColorStop (1, new Cairo.Color (1, 1, 1, 0.8));
									} else {
										shadowGradient.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.8));
										shadowGradient.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));
									}
									cr.Source = shadowGradient;
									cr.Fill ();
									
									cr.LineWidth = 2;
									cr.LineCap = Cairo.LineCap.Round;
									cr.Color = isButtonSelected ? new Cairo.Color (0.9, 0.9, 0.9) : new Cairo.Color (1, 1, 1);
									
									int a = 4;
									cr.MoveTo (x + a, y + a);
									cr.LineTo (x + r - a, y + r - a);
									cr.MoveTo (x + r - a, y + a);
									cr.LineTo (x + a, y + r - a);
									cr.Stroke ();
									cr.Restore ();
								}
							}
						}
					}
				}
				var result = base.OnExposeEvent (evnt);
				
				Gdk.GC gc = Style.DarkGC (State);
				evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom);
				evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom);
				
				evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y);
				evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom);
				
				return result;
			}
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect = Allocation;

            //Gdk.Rectangle.Right and Bottom are inconsistent
            int right = rect.X + rect.Width, bottom = rect.Y + rect.Height;

            var bcolor = backgroundColorSet ? BackgroundColor : Style.Background (Gtk.StateType.Normal);
            using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) {

                if (GradientBackround) {
                    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, bottom)) {
                        pat.AddColorStop (0, bcolor.ToCairoColor ());
                        Xwt.Drawing.Color gcol = bcolor.ToXwtColor ();
                        gcol.Light -= 0.1;
                        if (gcol.Light < 0)
                            gcol.Light = 0;
                        pat.AddColorStop (1, gcol.ToCairoColor ());
                        cr.SetSource (pat);
                        cr.Fill ();
                    }
                } else {
                    if (backgroundColorSet) {
                        Gdk.GC gc = new Gdk.GC (GdkWindow);
                        gc.RgbFgColor = bcolor;
                        evnt.Window.DrawRectangle (gc, true, rect.X, rect.Y, rect.Width, rect.Height);
                        gc.Dispose ();
                    }
                }

            }
            base.OnExposeEvent (evnt);

            using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) {
                cr.SetSourceColor (Style.Dark (Gtk.StateType.Normal).ToCairoColor ());

                double y = rect.Y + topMargin / 2d;
                cr.LineWidth = topMargin;
                cr.Line (rect.X, y, right, y);
                cr.Stroke ();

                y = bottom - bottomMargin / 2d;
                cr.LineWidth = bottomMargin;
                cr.Line (rect.X, y, right, y);
                cr.Stroke ();

                double x = rect.X + leftMargin / 2d;
                cr.LineWidth = leftMargin;
                cr.Line (x, rect.Y, x, bottom);
                cr.Stroke ();

                x = right - rightMargin / 2d;
                cr.LineWidth = rightMargin;
                cr.Line (x, rect.Y, x, bottom);
                cr.Stroke ();

                return false;
            }
        }
		protected void FillGradient (Cairo.Context cr, Cairo.Color color1, Cairo.Color color2, double x, double y, double size)
		{
			using (var pat = new Cairo.LinearGradient (x + size / 4, y, x + size / 2, y + size - 4)) {
				pat.AddColorStop (0, color1);
				pat.AddColorStop (1, color2);
				cr.Pattern = pat;
				cr.FillPreserve ();
			}
		}
		public override void DrawAfterEol (TextEditor textEditor, Cairo.Context g, double y, EndOfLineMetrics metrics)
		{
			if (!IsVisible)
				return;
			EnsureLayoutCreated (editor);
			int errorCounterWidth = 0, eh = 0;
			if (errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out errorCounterWidth, out eh);
				errorCounterWidth = Math.Max (15, Math.Max (errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4)));
			}

			var sx = metrics.TextRenderEndPosition;
			var width = LayoutWidth + errorCounterWidth + editor.LineHeight;
			var drawLayout = layouts[0].Layout;
			int ex = 0 , ey = 0;
			bool customLayout = true; //sx + width > editor.Allocation.Width;
			bool hideText = false;
			bubbleIsReduced = customLayout;
			var showErrorCount = errorCounterWidth > 0 && errorCountLayout != null;
			if (customLayout) {
				width = editor.Allocation.Width - sx;
				string text = layouts[0].Layout.Text;
				drawLayout = new Pango.Layout (editor.PangoContext);
				drawLayout.FontDescription = cache.fontDescription;
				var paintWidth = (width - errorCounterWidth - editor.LineHeight + 4);
				var minWidth = Math.Max (17, errorCounterWidth) + editor.LineHeight;
				if (paintWidth < minWidth) {
					hideText = true;
					drawLayout.SetMarkup ("<span weight='heavy'>···</span>");
					width = minWidth;
					showErrorCount = false;
					sx = Math.Min (sx, editor.Allocation.Width - width);
				} else {
					drawLayout.Ellipsize = Pango.EllipsizeMode.End;
					drawLayout.Width = (int)(paintWidth * Pango.Scale.PangoScale);
					drawLayout.SetText (text);
					int w2, h2;
					drawLayout.GetPixelSize (out w2, out h2);
					width = w2 + errorCounterWidth + editor.LineHeight;
				}
			}
			bubbleDrawX = sx - editor.TextViewMargin.XOffset;
			bubbleDrawY = y;
			bubbleWidth = width;

			var bubbleHeight = editor.LineHeight - 1;
			g.RoundedRectangle (sx, y + 1, width, bubbleHeight, editor.LineHeight / 2 - 1);
			g.SetSourceColor (TagColor.Color);
			g.Fill ();

			// Draw error count icon
			if (showErrorCount) {
				var errorCounterHeight = bubbleHeight - 2;
				var errorCounterX = sx + width - errorCounterWidth - 3;
				var errorCounterY = y + 1 + (bubbleHeight - errorCounterHeight) / 2;

				g.RoundedRectangle (
					errorCounterX - 1, 
					errorCounterY - 1, 
					errorCounterWidth + 2, 
					errorCounterHeight + 2, 
					editor.LineHeight / 2 - 3
				);

				g.SetSourceColor (new Cairo.Color (0, 0, 0, 0.081));
				g.Fill ();

				g.RoundedRectangle (
					errorCounterX, 
					errorCounterY, 
					errorCounterWidth, 
					errorCounterHeight, 
					editor.LineHeight / 2 - 3
				);
				using (var lg = new Cairo.LinearGradient (errorCounterX, errorCounterY, errorCounterX, errorCounterY + errorCounterHeight)) {
					lg.AddColorStop (0, CounterColor.Color);
					lg.AddColorStop (1, CounterColor.Color.AddLight (-0.1));
					g.Pattern = lg;
					g.Fill ();
				}

				g.Save ();

				int ew;
				errorCountLayout.GetPixelSize (out ew, out eh);

				g.Translate (
					errorCounterX + (errorCounterWidth - ew) / 2,
					errorCounterY + (errorCounterHeight - eh) / 2
				);
				g.SetSourceColor (CounterColor.SecondColor);
				g.ShowLayout (errorCountLayout);
				g.Restore ();
			}

			// Draw label text
			if (!showErrorCount || !hideText) {
				g.Save ();
				g.Translate (sx + editor.LineHeight / 2, y + (editor.LineHeight - layouts [0].Height) / 2 + 1);

				// draw shadow
				g.SetSourceColor (MessageBubbleCache.ShadowColor);
				g.ShowLayout (drawLayout);
				g.Translate (0, -1);

				g.SetSourceColor (TagColor.SecondColor);
				g.ShowLayout (drawLayout);
				g.Restore ();
			}

			if (customLayout)
				drawLayout.Dispose ();

		}
Exemple #50
0
		void DrawIndicator (Cairo.Context cr, QuickTaskSeverity severity)
		{
			cr.Rectangle (3, Allocation.Height - Allocation.Width + 3, Allocation.Width - 6, Allocation.Width - 6);
			
			var darkColor = (HslColor)GetIndicatorColor (severity);
			darkColor.L *= 0.5;
			
			using (var pattern = new Cairo.LinearGradient (0, 0, Allocation.Width - 3, Allocation.Width - 3)) {
				pattern.AddColorStop (0, darkColor);
				pattern.AddColorStop (1, GetIndicatorColor (severity));
				cr.Pattern = pattern;
				cr.FillPreserve ();
			}
			
			cr.Color = darkColor;
			cr.Stroke ();
		}
		void DrawBlockBg (Cairo.Context ctx, double x, int width, BlockInfo block)
		{
			if (!IsChangeBlock (block.Type))
				return;
			
			x += 0.5;
			Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor;
			double y = block.YStart + 0.5;
			int height = block.YEnd - block.YStart;
			
			double markerx = x + LeftPaddingBlock - 0.5;
			double rd = RoundedSectionRadius;
			if (block.SectionStart) {
				ctx.Arc (x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180));
				ctx.LineTo (markerx, y);
			} else {
				ctx.MoveTo (markerx, y);
			}
			
			ctx.LineTo (markerx, y + height);
			
			if (block.SectionEnd) {
				ctx.LineTo (x + rd, y + height);
				ctx.Arc (x + rd, y + height - rd, rd, 90 * (Math.PI / 180), 180 * (Math.PI / 180));
			} else {
				ctx.LineTo (x, y + height);
			}
			if (block.SectionStart) {
				ctx.LineTo (x, y + rd);
			} else {
				ctx.LineTo (x, y);
			}
			ctx.Color = color.AddLight (0.1).ToCairoColor ();
			ctx.Fill ();
			
			ctx.Rectangle (markerx, y, width - markerx, height);
			Cairo.Gradient pat = new Cairo.LinearGradient (x, y, x + width, y);
			pat.AddColorStop (0, color.AddLight (0.21).ToCairoColor ());
			pat.AddColorStop (1, color.AddLight (0.3).ToCairoColor ());
			ctx.Pattern = pat;
			ctx.Fill ();
		}
		public override void DrawAfterEol (MonoTextEditor textEditor, Cairo.Context g, EndOfLineMetrics metrics)
		{
			if (!IsVisible)
				return;
			EnsureLayoutCreated (editor);
			int errorCounterWidth = 0, eh = 0;
			if (errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out errorCounterWidth, out eh);
				errorCounterWidth = Math.Max (15, Math.Max (errorCounterWidth + 3, (int)(editor.LineHeight * 3 / 4)));
			}

			var sx = metrics.TextRenderEndPosition;
			var width = LayoutWidth + errorCounterWidth + editor.LineHeight;
			var drawLayout = layouts[0].Layout;
			var y = metrics.LineYRenderStartPosition;
			bool customLayout = true; //sx + width > editor.Allocation.Width;
			bool hideText = false;
			bubbleIsReduced = customLayout;
			var showErrorCount = errorCounterWidth > 0 && errorCountLayout != null;
			double roundingRadius = editor.LineHeight / 2 - 1;

			if (customLayout) {
				width = editor.Allocation.Width - sx;
				string text = layouts[0].Layout.Text;
				drawLayout = new Pango.Layout (editor.PangoContext);
				drawLayout.FontDescription = cache.fontDescription;
				var paintWidth = (width - errorCounterWidth - editor.LineHeight + 4);
				var minWidth = Math.Max (25, errorCounterWidth) * editor.Options.Zoom;
				if (paintWidth < minWidth) {
					hideText = true;
					showErrorCount = false;
//					drawLayout.SetMarkup ("<span weight='heavy'>···</span>");
					width = minWidth;
					//roundingRadius = 10 * editor.Options.Zoom;
					sx = Math.Min (sx, editor.Allocation.Width - width);
				} else {
					drawLayout.Ellipsize = Pango.EllipsizeMode.End;
					drawLayout.Width = (int)(paintWidth * Pango.Scale.PangoScale);
					drawLayout.SetText (text);
					int w2, h2;
					drawLayout.GetPixelSize (out w2, out h2);
					width = w2 + errorCounterWidth + editor.LineHeight - 2;
				}
			}

			bubbleDrawX = sx - editor.TextViewMargin.XOffset;
			bubbleDrawY = y + 2;
			bubbleWidth = width;
			var bubbleHeight = editor.LineHeight;

			g.RoundedRectangle (sx, y, width, bubbleHeight, roundingRadius);
			g.SetSourceColor (TagColor.Color);
			g.Fill ();

			// Draw error count icon
			if (showErrorCount) {
				var errorCounterHeight = bubbleHeight - 2;
				var errorCounterX = sx + width - errorCounterWidth - 1;
				var errorCounterY = Math.Round (y + (bubbleHeight - errorCounterHeight) / 2);

				g.RoundedRectangle (
					errorCounterX, 
					errorCounterY, 
					errorCounterWidth, 
					errorCounterHeight, 
					editor.LineHeight / 2 - 2
				);

				using (var lg = new Cairo.LinearGradient (errorCounterX, errorCounterY, errorCounterX, errorCounterY + errorCounterHeight)) {
					lg.AddColorStop (0, CounterColor.Color);
					lg.AddColorStop (1, CounterColor.Color.AddLight (-0.1));
					g.SetSource (lg);
					g.Fill ();
				}

				g.Save ();

				int ew;
				errorCountLayout.GetPixelSize (out ew, out eh);

				var tx = Math.Round (errorCounterX + (2 + errorCounterWidth - ew) / 2);
				var ty = Math.Round (errorCounterY + (-1 + errorCounterHeight - eh) / 2);

				g.Translate (tx, ty);
				g.SetSourceColor (CounterColor.SecondColor);
				g.ShowLayout (errorCountLayout);
				g.Restore ();
			}

			if (hideText) {
				// Draw dots
				double radius = 2 * editor.Options.Zoom;
				double spacing = 1 * editor.Options.Zoom;

				sx += 1 * editor.Options.Zoom + Math.Ceiling((bubbleWidth - 3 * (radius * 2) - 2 * spacing) / 2);

				for (int i = 0; i < 3; i++) {
					g.Arc (sx, y + bubbleHeight / 2, radius, 0, Math.PI * 2);
					g.SetSourceColor (TagColor.SecondColor);
					g.Fill ();
					sx += radius * 2 + spacing;
				}
			} else {
				// Draw label text
				var tx = Math.Round (sx + editor.LineHeight / 2);
				var ty = Math.Round (y + (editor.LineHeight - layouts [0].Height) / 2) - 1;

				g.Save ();
				g.Translate (tx, ty);

				g.SetSourceColor (TagColor.SecondColor);
				g.ShowLayout (drawLayout);
				g.Restore ();
			}

			if (customLayout)
				drawLayout.Dispose ();
		}
Exemple #53
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            Gdk.Window win = GdkWindow;
            int rwidth, rheight;

            Cairo.Context ctx = CairoHelper.Create (win);

            win.GetSize (out rwidth, out rheight);

            if (autoStartY || autoEndY) {
                double nstartY = double.MaxValue;
                double nendY = double.MinValue;
                GetValueRange (AxisDimension.Y, out nstartY, out nendY);

                if (!autoStartY) nstartY = startY;
                if (!autoEndY) nendY = endY;
                if (nendY < nstartY) nendY = nstartY;

                if (nstartY != startY || nendY != endY) {
                    yrangeChanged = true;
                    startY = nstartY;
                    endY = nendY;
                }
            }

            if (autoStartX || autoEndX) {
                double nstartX = double.MaxValue;
                double nendX = double.MinValue;
                GetValueRange (AxisDimension.X, out nstartX, out nendX);

                if (!autoStartX) nstartX = startX;
                if (!autoEndX) nendX = endX;
                if (nendX < nstartX) nendX = nstartX;

                if (nstartX != startX || nendX != endX) {
                    xrangeChanged = true;
                    startX = nstartX;
                    endX = nendX;
                }
            }

            if (yrangeChanged) {
                FixOrigins ();
                int right = rwidth - 2 - AreaBorderWidth;
                left = AreaBorderWidth;
                left += MeasureAxisSize (AxisPosition.Left) + 1;
                right -= MeasureAxisSize (AxisPosition.Right) + 1;
                yrangeChanged = false;
                width = right - left + 1;
                if (width <= 0) width = 1;
            }

            if (xrangeChanged) {
                FixOrigins ();
                int bottom = rheight - 2 - AreaBorderWidth;
                top = AreaBorderWidth;
                bottom -= MeasureAxisSize (AxisPosition.Bottom);
                top += MeasureAxisSize (AxisPosition.Top);

                // Make room for cursor handles
                foreach (ChartCursor cursor in cursors) {
                    if (cursor.Dimension == AxisDimension.X && top - AreaBorderWidth < cursor.HandleSize)
                        top = cursor.HandleSize + AreaBorderWidth;
                }

                xrangeChanged = false;
                height = bottom - top + 1;
                if (height <= 0) height = 1;
            }

            if (AutoScaleMargin != 0 && height > 0) {
                double margin = (double)AutoScaleMargin * (endY - startY) / (double) height;
                if (autoStartY) startY -= margin;
                if (autoEndY) endY += margin;
            }

            //			Console.WriteLine ("L:" + left + " T:" + top + " W:" + width + " H:" + height);

            // Draw the background

            if (backgroundDisplay == BackgroundDisplay.Gradient) {
                ctx.Rectangle (left - 1, top - 1, width + 2, height + 2);
                using (var pat = new Cairo.LinearGradient (left - 1, top - 1, left - 1, height + 2)) {
                    pat.AddColorStop (0, backroundColor);
                    Cairo.Color endc = new Cairo.Color (1,1,1);
                    pat.AddColorStop (1, endc);
                    ctx.SetSource (pat);
                    ctx.Fill ();
                }
            } else {
                ctx.Rectangle (left - 1, top - 1, width + 2, height + 2);
                ctx.SetSourceColor (backroundColor);
                ctx.Fill ();
            }
            //			win.DrawRectangle (Style.WhiteGC, true, left - 1, top - 1, width + 2, height + 2);
            win.DrawRectangle (Style.BlackGC, false, left - AreaBorderWidth, top - AreaBorderWidth, width + AreaBorderWidth*2, height + AreaBorderWidth*2);

            // Draw selected area

            if (enableSelection) {
                int sx, sy, ex, ey;
                GetPoint (selectionStart.Value, selectionStart.Value, out sx, out sy);
                GetPoint (selectionEnd.Value, selectionEnd.Value, out ex, out ey);
                if (sx > ex) {
                    int tmp = sx; sx = ex; ex = tmp;
                }
                Gdk.GC sgc = new Gdk.GC (GdkWindow);
               		sgc.RgbFgColor = new Color (225, 225, 225);
                win.DrawRectangle (sgc, true, sx, top, ex - sx, height + 1);
            }

            // Draw axes

            Gdk.GC gc = Style.BlackGC;

            foreach (Axis ax in axis)
                DrawAxis (win, gc, ax);

            // Draw values
            foreach (Serie serie in series)
                if (serie.Visible)
                    DrawSerie (ctx, serie);

            // Draw cursors
            foreach (ChartCursor cursor in cursors)
                DrawCursor (cursor);

            // Draw cursor labels
            foreach (ChartCursor cursor in cursors)
                if (cursor.ShowValueLabel)
                    DrawCursorLabel (cursor);

            ((IDisposable)ctx).Dispose ();
            return true;
        }
        public void DrawIcon(TextEditor editor, Cairo.Context cr, DocumentLine lineSegment, int lineNumber, double x, double y, double width, double height)
        {
            if (BookmarkService.Instance.CheckLineForBookmark (editor.FileName, lineSegment.LineNumber)) {
                Cairo.Color color1 = editor.ColorStyle.Bookmarks.Color;
                Cairo.Color color2 = editor.ColorStyle.Bookmarks.SecondColor;

                if (Bookmark.BookmarkType == BookmarkType.Local)
                    DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4);
                else
                    DrawCircle (cr, x + (width / 2), y + (height / 2), 6);

                using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) {
                    pat.AddColorStop (0, color1);
                    pat.AddColorStop (1, color2);
                    cr.Pattern = pat;
                    cr.FillPreserve ();
                }

                using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) {
                    pat.AddColorStop (0, color2);
                    //pat.AddColorStop (1, color1);
                    cr.Pattern = pat;
                    cr.Stroke ();
                }

                cr.Color = new Cairo.Color (0, 0, 0);
                cr.SelectFontFace (DesktopService.DefaultMonospaceFont, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
                cr.SetFontSize (12);
                var te = cr.TextExtents (Bookmark.Number.ToString ());
                cr.MoveTo (x + 5, y + 1 + te.Height);
                cr.ShowText (Bookmark.Number.ToString ());
            }
        }
		static void DrawCloseButton (Cairo.Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
		{
			if (hovered) {
				double radius = 6;
				context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
				context.SetSourceRGBA (.6, .6, .6, opacity);
				context.Fill ();

				context.SetSourceRGBA (0.95, 0.95, 0.95, opacity);
				context.LineWidth = 2;

				context.MoveTo (center.X - 3, center.Y - 3);
				context.LineTo (center.X + 3, center.Y + 3);
				context.MoveTo (center.X - 3, center.Y + 3);
				context.LineTo (center.X + 3, center.Y - 3);
				context.Stroke ();
			} else {
				double lineColor = .63 - .1 * animationProgress;
				double fillColor = .74;

				double heightMod = Math.Max (0, 1.0 - animationProgress * 2);
				context.MoveTo (center.X - 3, center.Y - 3 * heightMod);
				context.LineTo (center.X + 3, center.Y + 3 * heightMod);
				context.MoveTo (center.X - 3, center.Y + 3 * heightMod);
				context.LineTo (center.X + 3, center.Y - 3 * heightMod);

				context.LineWidth = 2;
				context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
				context.Stroke ();

				if (animationProgress > 0.5) {
					double partialProg = (animationProgress - 0.5) * 2;
					context.MoveTo (center.X - 3, center.Y);
					context.LineTo (center.X + 3, center.Y);

					context.LineWidth = 2 - partialProg;
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();


					double radius = partialProg * 3.5;

					// Background
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (fillColor, fillColor, fillColor, opacity);
					context.Fill ();

					// Inset shadow
					using (var lg = new Cairo.LinearGradient (0, center.Y - 5, 0, center.Y)) {
						context.Arc (center.X, center.Y + 1, radius, 0, Math.PI * 2);
						lg.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.2 * opacity));
						lg.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
						context.Pattern = lg;
						context.Stroke ();
					}

					// Outline
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();
				}
			}
		}
Exemple #56
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (DrawBackground) {
                GdkWindow.DrawRectangle (Style.BackgroundGC (Gtk.StateType.Normal), true, Allocation.X, Allocation.Y, Allocation.Width - 1, Allocation.Height - 1);
            }

            if (GradientBackround) {
                rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                Color gcol = Util.ToXwtColor (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 = Util.ToCairoColor (gcol);
                    pat.AddColorStop (0, color1);
                    gcol.Light -= 0.1;
                    pat.AddColorStop (1, Util.ToCairoColor (gcol));
                    cr.Pattern = pat;
                    cr.FillPreserve ();
                }
            }

            bool res = base.OnExposeEvent (evnt);

            Gdk.GC borderColor;
            if (color != null) {
                borderColor = new Gdk.GC (GdkWindow);
                borderColor.RgbFgColor = Util.ToGdkColor (color.Value);
            }
            else
                borderColor = Style.DarkGC (Gtk.StateType.Normal);

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

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

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

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

            if (color != null)
                borderColor.Dispose ();

            return res;
        }
		protected void DrawBorder (Cairo.Context cr, Cairo.Color color, double x, double y, double size)
		{
			using (var pat = new Cairo.LinearGradient (x, y + size, x + size, y)) {
				pat.AddColorStop (0, color);
				cr.Pattern = pat;
				cr.Stroke ();
			}
		}
Exemple #58
0
		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			var alloc = Allocation;
			using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
				ctx.Rectangle (alloc.X, alloc.Y, alloc.X + alloc.Width, alloc.Y + alloc.Height);
				Cairo.LinearGradient gr;
				if (Orientation == Gtk.Orientation.Vertical)
					gr = new Cairo.LinearGradient (alloc.X, alloc.Y, alloc.X + alloc.Width, alloc.Y);
				else
					gr = new Cairo.LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
				using (gr) {
					gr.AddColorStop (0, Styles.DockBarBackground1);
					gr.AddColorStop (1, Styles.DockBarBackground2);
					ctx.SetSource (gr);
				}
				ctx.Fill ();

				// Light shadow
				double offs = ShowBorder ? 1.5 : 0.5;
				switch (Position) {
				case PositionType.Left:ctx.MoveTo (alloc.X + alloc.Width - offs, alloc.Y); ctx.RelLineTo (0, Allocation.Height); break;
				case PositionType.Right: ctx.MoveTo (alloc.X + offs, alloc.Y); ctx.RelLineTo (0, Allocation.Height); break;
				case PositionType.Top: ctx.MoveTo (alloc.X, alloc.Y + alloc.Height - offs); ctx.RelLineTo (Allocation.Width, 0); break;
				case PositionType.Bottom: ctx.MoveTo (alloc.X, alloc.Y + offs); ctx.RelLineTo (Allocation.Width, 0); break;
				}
				ctx.LineWidth = 1;
				ctx.SetSourceColor (Styles.DockBarSeparatorColorLight);
				ctx.Stroke ();
			}

			if (Child != null)
				PropagateExpose (Child, evnt);

			if (ShowBorder) {
				using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
					ctx.LineWidth = 1;

					// Dark separator
					switch (Position) {
					case PositionType.Left:ctx.MoveTo (alloc.X + alloc.Width - 0.5, alloc.Y); ctx.RelLineTo (0, Allocation.Height); break;
					case PositionType.Right: ctx.MoveTo (alloc.X + 0.5, alloc.Y); ctx.RelLineTo (0, Allocation.Height); break;
					case PositionType.Top: ctx.MoveTo (alloc.X, alloc.Y + alloc.Height + 0.5); ctx.RelLineTo (Allocation.Width, 0); break;
					case PositionType.Bottom: ctx.MoveTo (alloc.X, alloc.Y + 0.5); ctx.RelLineTo (Allocation.Width, 0); break;
					}
					ctx.SetSourceColor (Styles.DockSeparatorColor.ToCairoColor ());
					ctx.Stroke ();
				}
			}
			return true;
		}
		protected override bool OnExposeEvent (Gdk.EventExpose e)
		{
			if (TextEditor == null)
				return true;
			using (Cairo.Context cr = Gdk.CairoHelper.Create (e.Window)) {
				cr.LineWidth = 1;
				cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
				
				if (TextEditor.ColorStyle != null) {
					if (Platform.IsWindows) {
						using (var pattern = new Cairo.SolidPattern (win81Background)) {
							cr.SetSource (pattern);
						}
					} else {
						var col = new Cairo.Color (229 / 255.0, 229 / 255.0, 229 / 255.0);
						using (var grad = new Cairo.LinearGradient (0, 0, Allocation.Width, 0)) {
							grad.AddColorStop (0, col);
							grad.AddColorStop (0.5, new Cairo.Color (1, 1, 1));
							grad.AddColorStop (1, col);
							cr.SetSource (grad);
						}
					}
				}
				cr.Fill ();

				if (TextEditor == null)
					return true;
				
				if (TextEditor.HighlightSearchPattern) {
					DrawSearchResults (cr);
					DrawSearchIndicator (cr);
				} else {
					if (!Debugger.DebuggingService.IsDebugging) {
						var severity = DrawQuickTasks (cr);
						DrawIndicator (cr, severity);
					}
				}
				DrawCaret (cr);
				
				DrawBar (cr);
				DrawLeftBorder (cr);
			}
			
			return true;
		}
		void DrawNormal (Gdk.EventExpose evnt)
		{
			using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
				var x = Allocation.X;
				var y = Allocation.Y;

				ctx.Rectangle (x, y + 1, Allocation.Width, Allocation.Height - 1);
				using (var g = new Cairo.LinearGradient (x, y + 1, x, y + Allocation.Height - 1)) {
					g.AddColorStop (0, Styles.DockTabBarGradientStart);
					g.AddColorStop (1, Styles.DockTabBarGradientEnd);
					ctx.Pattern = g;
					ctx.Fill ();
				}

				ctx.MoveTo (x + 0.5, y + 0.5);
				ctx.LineTo (x + Allocation.Width - 0.5d, y + 0.5);
				ctx.Color = Styles.DockTabBarGradientTop;
				ctx.Stroke ();

				if (active) {

					ctx.Rectangle (x, y + 1, Allocation.Width, Allocation.Height - 1);
					using (var g = new Cairo.LinearGradient (x, y + 1, x, y + Allocation.Height - 1)) {
						g.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.01));
						g.AddColorStop (0.5, new Cairo.Color (0, 0, 0, 0.08));
						g.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.01));
						ctx.Pattern = g;
						ctx.Fill ();
					}

/*					double offset = Allocation.Height * 0.25;
					var rect = new Cairo.Rectangle (x - Allocation.Height + offset, y, Allocation.Height, Allocation.Height);
					var cg = new Cairo.RadialGradient (rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 0, rect.X, rect.Y + rect.Height / 2, rect.Height / 2);
					cg.AddColorStop (0, Styles.DockTabBarShadowGradientStart);
					cg.AddColorStop (1, Styles.DockTabBarShadowGradientEnd);
					ctx.Pattern = cg;
					ctx.Rectangle (rect);
					ctx.Fill ();

					rect = new Cairo.Rectangle (x + Allocation.Width - offset, y, Allocation.Height, Allocation.Height);
					cg = new Cairo.RadialGradient (rect.X + rect.Width / 2, rect.Y + rect.Height / 2, 0, rect.X, rect.Y + rect.Height / 2, rect.Height / 2);
					cg.AddColorStop (0, Styles.DockTabBarShadowGradientStart);
					cg.AddColorStop (1, Styles.DockTabBarShadowGradientEnd);
					ctx.Pattern = cg;
					ctx.Rectangle (rect);
					ctx.Fill ();*/
				}
			}
		}