Esempio n. 1
0
        protected override void onDraw(Cairo.Context gr)
        {
            gr.Save();

            int spacing = (Parent as TabView).Spacing;

            gr.MoveTo(0.5, TabTitle.Slot.Bottom - 0.5);
            gr.LineTo(TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom - 0.5);
            gr.CurveTo(
                TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom - 0.5,
                TabTitle.Slot.Left - spacing / 2, 0.5,
                TabTitle.Slot.Left, 0.5);
            gr.LineTo(TabTitle.Slot.Right, 0.5);
            gr.CurveTo(
                TabTitle.Slot.Right + spacing / 2, 0.5,
                TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom - 0.5,
                TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom - 0.5);
            gr.LineTo(Slot.Width - 0.5, TabTitle.Slot.Bottom - 0.5);


            gr.LineTo(Slot.Width - 0.5, Slot.Height - 0.5);
            gr.LineTo(0.5, Slot.Height - 0.5);
            gr.ClosePath();
            gr.LineWidth = 2;
            Foreground.SetAsSource(gr);
            gr.StrokePreserve();

            gr.Clip();
            base.onDraw(gr);
            gr.Restore();
        }
Esempio n. 2
0
        protected virtual void DrawInnerFunction(Cairo.Context graphics, double uw, double x, double y, double width, double height)
        {
            double bmarg = uw * 5;

            double quart = (width - 2 * bmarg) / 4;
            double half  = (width - 2 * bmarg) / 2;

            graphics.MoveTo(x + bmarg, y + height - bmarg);
            graphics.CurveTo(x + bmarg + quart, y + height - bmarg, x + bmarg + quart, y + bmarg, x + bmarg + half, y + bmarg);
            graphics.CurveTo(x + half + quart + bmarg, y + bmarg, x + half + quart + bmarg, y + height - bmarg, x + bmarg + half + half, y + height - bmarg);

            graphics.SetSourceRGB(0.3, 0.3, 0.6);
            graphics.Stroke();
        }
        protected virtual void SetupBackground()
        {
            background.Clear();
            Cairo.Context context = background.Create();

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            double margin = Margin;

            //left curvature:
            context.MoveTo(-hlwidth, -hlwidth);
            context.CurveTo(margin * 0.33, -hlwidth,
                            margin * 0.5, Height * 0.4,
                            margin * 0.5, Height * 0.5);
            context.CurveTo(margin * 0.5, Height * 0.6,
                            margin * 0.66, Height - hlwidth,
                            margin - hlwidth, Height - hlwidth);


            //straight bottom:
            context.LineTo(Width - margin - hlwidth, Height - hlwidth);

            //right curvature:
            context.CurveTo(Width - margin * 0.66, Height - hlwidth,
                            Width - margin * 0.5, Height * 0.6,
                            Width - margin * 0.5, Height * 0.5);
            context.CurveTo(Width - margin * 0.5, Height * 0.4,
                            Width - margin * 0.33, -hlwidth,
                            Width - hlwidth, -hlwidth);

            //straight top:
            context.LineTo(-hlwidth, -hlwidth);
            context.ClosePath();

            context.LineWidth = lwidth;
            context.SetSourceRGBA(1.0, 1.0, 1.0, 1.0);
            context.StrokePreserve();
            context.SetSourceRGBA(1.0, 1.0, 1.0, 0.10);
            context.Fill();

            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
Esempio n. 4
0
        private void RoundedRectangle(Cairo.Context graphics, double x, double y, double width, double height, double radius)
        {
            double x1 = x + width;
            double y1 = y + height;

            graphics.MoveTo(x, y + radius);

            graphics.CurveTo(x, y, x, y, x + radius, y);
            graphics.LineTo(x1 - radius, y);

            graphics.CurveTo(x1, y, x1, y, x1, y + radius);
            graphics.LineTo(x1, y1 - radius);

            graphics.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
            graphics.LineTo(x + radius, y1);

            graphics.CurveTo(x, y1, x, y1, x, y1 - radius);
            graphics.ClosePath();
        }
Esempio n. 5
0
        public void PathAddBezier(Point start, Point control, Point end)
        {
            builder.AppendLine("bezier start");
            PathLineTo(start);
            PathLineTo(control);
            PathLineTo(end);

            g.CurveTo(start.ToPointD(), control.ToPointD(), end.ToPointD());

            builder.AppendLine("bezier end");
        }
Esempio n. 6
0
        public override void Draw(Cairo.Context surface, int x, int y)
        {
            X = x;
            Y = y;
            int waveTops    = Radius / 3;
            int waveBottoms = Radius / 2;
            int waveDepths  = Radius / 6;

            WaterTemperature = CurrentData.GetCurrentValueByIdFloat(XIVELY_DATA_STREAM_ID);
            //WaterTemperature = WaterTemperature / 100;


            // CIRCLE
            surface.SetSourceRGBA(1, 1, 1, 0.3);
            surface.Arc(X, Y, Radius, 0, Math.PI * 2);
            surface.Fill();

            surface.SetSourceRGBA(1, 1, 1, WaterLight);
            surface.Arc(X, Y, Radius + 5, 0, Math.PI * 2);
            surface.Stroke();
            surface.Fill();

            // WAVEFORMED CIRCLE
            surface.CurveTo(X - Radius, Y - waveDepths, X - waveBottoms, Y + waveDepths, X - waveTops, Y - waveDepths);
            surface.CurveTo(X - waveTops, Y - waveDepths, X, Y + waveDepths, X + waveTops, Y - waveDepths);
            surface.CurveTo(X + waveTops, Y - waveDepths, X + waveBottoms, Y + waveDepths, X + Radius, Y - waveDepths);
            surface.SetSourceRGBA(colorWater[0], colorWater[1], colorWater[2], alphaChannel);
            surface.Arc(X, Y, Radius, 0, Math.PI * 1);
            surface.Fill();

            // TEXT
            surface.SetSourceRGBA(1, 1, 1, 0.1);
            surface.MoveTo(X, Y);
            surface.SetFontSize(Radius / 2);
            string widgetText = Convert.ToString(WaterTemperature);

            Cairo.TextExtents text = surface.TextExtents(widgetText);
            surface.MoveTo(X - (text.Width / 2), Y + (text.Height / 2));
            surface.ShowText(widgetText);
            surface.Fill();
        }
Esempio n. 7
0
        protected override void DrawInnerFunction(Cairo.Context graphics, double uw, double x, double y, double width, double height)
        {
            double marg  = uw * 3;
            double bmarg = uw * 5;

            double quart = (width - 2 * bmarg) / 4;
            double half  = (width - 2 * bmarg) / 2;

            graphics.MoveTo(x + bmarg, y + height - bmarg);
            graphics.CurveTo(x + bmarg + quart, y + height - bmarg, x + bmarg + quart, y + bmarg, x + bmarg + half, y + bmarg);
            graphics.CurveTo(x + half + quart + bmarg, y + bmarg, x + half + quart + bmarg, y + height - bmarg, x + bmarg + half + half, y + height - bmarg);

            graphics.SetSourceRGB(0.3, 0.3, 0.6);
            graphics.Stroke();

            graphics.Arc(x + bmarg, y + height - bmarg, marg, 0, System.Math.PI * 2);
            graphics.Fill();

            graphics.Arc(x + bmarg + half, y + bmarg, marg, 0, System.Math.PI * 2);
            graphics.Fill();

            graphics.Arc(x + bmarg + half + half, y + height - bmarg, marg, 0, System.Math.PI * 2);
            graphics.Fill();
        }
Esempio n. 8
0
        private void NodeConnectingCurve(Cairo.Context cr, int x0, int y0, int x1, int y1)
        {
            int x1m, y1m;
            int x2m, y2m;
            int d;

            cr.MoveTo(x0, y0);

            d = Math.Abs(x1 - x0) / 2;

            x1m = x0 + d;
            y1m = y0;

            x2m = x1 - d;
            y2m = y1;

            cr.CurveTo(x1m, y1m, x2m, y2m, x1, y1);
        }
Esempio n. 9
0
        private static void Draw(Cairo.Context graphics, Point[] points)
        {
            graphics.MoveTo(points[0].X, points[0].Y);
            graphics.CurveTo(points[1].X, points[1].Y, points[2].X, points[2].Y, points[3].X, points[3].Y);

            graphics.Stroke();

            Point  xy;
            double pos;

            // Draw the arrow, first move to the center, then rotate, then draw the arrow
            xy = EvaluateBezier(points[0], points[1], points[2], points[3], 0.5);

            if (points[0].Equals(points[3]))
            {
                pos = 0.5 * System.Math.PI;
            }
            else
            {
                Point diff = new Point(points[3].X - points[0].X, points[3].Y - points[0].Y);

                if (diff.X == 0)
                {
                    pos = (diff.Y < 0 ? 1.5 : 0.5) * System.Math.PI;
                }
                else
                {
                    pos = System.Math.Atan(diff.Y / diff.X);

                    if (diff.X < 0)
                    {
                        pos += System.Math.PI;
                    }
                    else if (diff.Y < 0)
                    {
                        pos += 2 * System.Math.PI;
                    }
                }

                pos += 0.5 * System.Math.PI;
            }

            DrawArrow(graphics, xy.X, xy.Y, pos);
        }
Esempio n. 10
0
        private void RenderBezier(Cairo.Context context, Point scale)
        {
            bool first      = true;
            bool wasoutside = true;

            context.Save();

            /* We are going to render this stuff now */
            foreach (Biorob.Math.Functions.Bezier.Piece piece in d_bezier)
            {
                bool isoutside = (d_periodic != null && (piece.Begin.X <d_periodic.Min || piece.End.X> d_periodic.Max));

                if (wasoutside != isoutside)
                {
                    StyleAccordingToOutside(context, wasoutside);

                    if (!first)
                    {
                        context.Stroke();
                        first = true;
                    }
                }

                if (first)
                {
                    context.MoveTo(piece.Begin.X * scale.X, piece.Begin.Y * scale.Y);
                    first = false;
                }

                context.CurveTo(piece.C1.X * scale.X, piece.C1.Y * scale.Y,
                                piece.C2.X * scale.X, piece.C2.Y * scale.Y,
                                piece.End.X * scale.X, piece.End.Y * scale.Y);

                wasoutside = isoutside;
            }

            if (!first)
            {
                StyleAccordingToOutside(context, wasoutside);
                context.Stroke();
            }

            context.Restore();
        }
Esempio n. 11
0
        public static void DrawRoundRectangle(Cairo.Context cr, bool topLeftRound, bool topRightRound, bool bottomLeftRound, bool bottomRightRound, double x, double y, double r, double w, double h)
        {
            //  UA****BQ
            //  H      C
            //  *      *
            //  G      D
            //  TF****ES

            cr.NewPath();

            if (topLeftRound)
            {
                cr.MoveTo(x + r, y);                                  // Move to A
            }
            else
            {
                cr.MoveTo(x, y);                              // Move to U
            }

            if (topRightRound)
            {
                cr.LineTo(x + w - r, y);                              // Straight line to B

                cr.CurveTo(x + w, y,
                           x + w, y,
                           x + w, y + r);                  // Curve to C, Control points are both at Q
            }
            else
            {
                cr.LineTo(x + w, y);                          // Straight line to Q
            }

            if (bottomRightRound)
            {
                cr.LineTo(x + w, y + h - r);                                               // Move to D

                cr.CurveTo(x + w, y + h,
                           x + w, y + h,
                           x + w - r, y + h);                  // Curve to E
            }
            else
            {
                cr.LineTo(x + w, y + h);                  // Move to S
            }

            if (bottomLeftRound)
            {
                cr.LineTo(x + r, y + h);                                       // Line to F
                cr.CurveTo(x, y + h,
                           x, y + h,
                           x, y + h - r);                  // Curve to G
            }
            else
            {
                cr.LineTo(x, y + h);                  // Line to T
            }

            if (topLeftRound)
            {
                cr.LineTo(x, y + r);                               // Line to H
                cr.CurveTo(x, y,
                           x, y,
                           x + r, y);                  // Curve to A
            }
            else
            {
                cr.LineTo(x, y);                  // Line to U
            }
            cr.ClosePath();
        }
Esempio n. 12
0
            protected override bool OnExposeEvent(EventExpose evnt)
            {
                bool hideButton = widget.MainEditor.Document.IsReadOnly;

                using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) {
                    cr.Rectangle(evnt.Region.Clipbox.X, evnt.Region.Clipbox.Y, evnt.Region.Clipbox.Width, evnt.Region.Clipbox.Height);
                    cr.Clip();
                    int delta = widget.MainEditor.Allocation.Y - Allocation.Y;
                    if (Diff != null)
                    {
                        foreach (Hunk hunk in Diff)
                        {
                            double z1 = delta + fromEditor.LineToY(hunk.RemoveStart) - fromEditor.VAdjustment.Value;
                            double z2 = delta + fromEditor.LineToY(hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value;
                            if (z1 == z2)
                            {
                                z2 = z1 + 1;
                            }

                            double y1 = delta + toEditor.LineToY(hunk.InsertStart) - toEditor.VAdjustment.Value;
                            double y2 = delta + toEditor.LineToY(hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value;

                            if (y1 == y2)
                            {
                                y2 = y1 + 1;
                            }

                            if (!useLeft)
                            {
                                var tmp = z1;
                                z1 = y1;
                                y1 = tmp;

                                tmp = z2;
                                z2  = y2;
                                y2  = tmp;
                            }

                            int x1 = 0;
                            int x2 = Allocation.Width;

                            if (!hideButton)
                            {
                                if (useLeft && hunk.Removed > 0 || !useLeft && hunk.Removed == 0)
                                {
                                    x1 += 16;
                                }
                                else
                                {
                                    x2 -= 16;
                                }
                            }

                            if (z1 == z2)
                            {
                                z2 = z1 + 1;
                            }

                            cr.MoveTo(x1, z1);

                            cr.CurveTo(x1 + (x2 - x1) / 4, z1,
                                       x1 + (x2 - x1) * 3 / 4, y1,
                                       x2, y1);

                            cr.LineTo(x2, y2);
                            cr.CurveTo(x1 + (x2 - x1) * 3 / 4, y2,
                                       x1 + (x2 - x1) / 4, z2,
                                       x1, z2);
                            cr.ClosePath();
                            cr.SetSourceColor(GetColor(hunk, this.useLeft, false, 1.0));
                            cr.Fill();

                            cr.SetSourceColor(GetColor(hunk, this.useLeft, true, 1.0));
                            cr.MoveTo(x1, z1);
                            cr.CurveTo(x1 + (x2 - x1) / 4, z1,
                                       x1 + (x2 - x1) * 3 / 4, y1,
                                       x2, y1);
                            cr.Stroke();

                            cr.MoveTo(x2, y2);
                            cr.CurveTo(x1 + (x2 - x1) * 3 / 4, y2,
                                       x1 + (x2 - x1) / 4, z2,
                                       x1, z2);
                            cr.Stroke();

                            if (!hideButton)
                            {
                                bool isButtonSelected = hunk == selectedHunk;

                                double x, y, w, h;
                                bool   drawArrow = useLeft ? GetButtonPosition(hunk, y1, y2, z1, z2, out x, out y, out w, out h) :
                                                   GetButtonPosition(hunk, z1, z2, y1, y2, out x, out y, out w, out h);

                                cr.Rectangle(x, y, w, h);
                                if (isButtonSelected)
                                {
                                    int mx, my;
                                    GetPointer(out mx, out my);
                                    //	mx -= (int)x;
                                    //	my -= (int)y;
                                    using (var gradient = new Cairo.RadialGradient(mx, my, h, mx, my, 2)) {
                                        var color = (MonoDevelop.Components.HslColor)Style.Mid(StateType.Normal);
                                        color.L *= 1.05;
                                        gradient.AddColorStop(0, color);
                                        color.L *= 1.07;
                                        gradient.AddColorStop(1, color);
                                        cr.SetSource(gradient);
                                    }
                                }
                                else
                                {
                                    cr.SetSourceColor((MonoDevelop.Components.HslColor)Style.Mid(StateType.Normal));
                                }
                                cr.FillPreserve();

                                cr.SetSourceColor((MonoDevelop.Components.HslColor)Style.Dark(StateType.Normal));
                                cr.Stroke();
                                cr.LineWidth = 1;
                                cr.SetSourceColor(MonoDevelop.Ide.Gui.Styles.BaseForegroundColor.ToCairoColor());
                                if (drawArrow)
                                {
                                    DrawArrow(cr, x + w / 1.5, y + h / 2);
                                    DrawArrow(cr, x + w / 2.5, y + h / 2);
                                }
                                else
                                {
                                    DrawCross(cr, x + w / 2, y + (h) / 2);
                                }
                                cr.Stroke();
                            }
                        }
                    }
                }
//				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(true);
            }
Esempio n. 13
0
 internal static void DrawBezier(Cairo.Context context, CubicBezierSegment bezierSegment)
 {
     context.MoveTo(bezierSegment.B(0).X, bezierSegment.B(0).Y);
     context.CurveTo(bezierSegment.B(1).X, bezierSegment.B(1).Y, bezierSegment.B(2).X, bezierSegment.B(2).Y, bezierSegment.B(3).X, bezierSegment.B(3).Y);
     context.Stroke();
 }