Ejemplo n.º 1
0
 protected void DrawCircle(Cairo.Context cr, double x, double y, double size)
 {
     x += 0.5;
     y += 0.5;
     cr.NewPath();
     cr.Arc(x + size / 2, y + size / 2, (size - 4) / 2, 0, 2 * Math.PI);
     cr.ClosePath();
 }
Ejemplo n.º 2
0
 void RenderTriangleUp(Cairo.Context cr, double x, double y, double w, double h)
 {
     cr.MoveTo(x + w / 2.0, y);
     cr.LineTo(x, y + h);
     cr.LineTo(x + w, y + h);
     cr.ClosePath();
     cr.Fill();
 }
Ejemplo n.º 3
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

            if (GradientBackround)
            {
                rect = new Gdk.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
                HslColor gcol = 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);
        }
        void DrawMessageExtendIcon(Mono.TextEditor.TextEditor editor, Cairo.Context g, double y, int errorCounterWidth, int eh)
        {
            EnsureLayoutCreated(editor);
            double rW = errorCounterWidth - 2;
            double rH = editor.LineHeight * 3 / 4;

            double rX = editor.Allocation.Width - rW - 2;
            double rY = y + (editor.LineHeight - rH) / 2;

            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)
            {
                if (errorCountLayout != null)
                {
                    g.Color = cache.gcLight;
                    g.Save();
                    g.Translate(rX + rW / 4, rY + (rH - eh) / 2);
                    g.ShowLayout(errorCountLayout);
                    g.Restore();
                }
                else
                {
                    g.MoveTo(rX + rW / 2 - rW / 4, rY + rH / 4);
                    g.LineTo(rX + rW / 2 + rW / 4, rY + rH / 4);
                    g.LineTo(rX + rW / 2, rY + rH - rH / 4);
                    g.ClosePath();

                    g.Color = new Cairo.Color(1, 1, 1);
                    g.Fill();
                }
            }
            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();
            }
        }
Ejemplo n.º 5
0
 public void DrawPath(Cairo.Context aContext)
 {
     aContext.MoveTo(Left, Top);
     aContext.LineTo(Left, Bottom);
     aContext.LineTo(Right, Bottom);
     aContext.LineTo(Right, Top);
     aContext.LineTo(Left, Top);
     aContext.ClosePath();
 }
Ejemplo n.º 6
0
 void DrawPathSeparator(Cairo.Context ctx, double x, double y, double size)
 {
     ctx.MoveTo(x, y);
     ctx.LineTo(x + arrowSize, y + size / 2);
     ctx.LineTo(x, y + size);
     ctx.ClosePath();
     ctx.SetSourceColor(Styles.BaseIconColor.ToCairoColor());
     ctx.Fill();
 }
Ejemplo n.º 7
0
 void DrawPathSeparator(Cairo.Context ctx, double x, double y, double size)
 {
     ctx.MoveTo(x, y);
     ctx.LineTo(x + arrowSize, y + size / 2);
     ctx.LineTo(x, y + size);
     ctx.ClosePath();
     ctx.SetSourceColor(CairoExtensions.ColorShade(Style.Dark(State).ToCairoColor(), 0.6));
     ctx.Fill();
 }
        protected Severity DrawQuickTasks(Cairo.Context cr)
        {
            Severity severity = Severity.None;

            foreach (var usage in AllUsages)
            {
                double y          = GetYPosition(usage.Location.Line);
                var    usageColor = TextEditor.ColorStyle.PlainText.Foreground;
                usageColor.A = 0.4;
                HslColor color;
                if ((usage.UsageType & MonoDevelop.Ide.FindInFiles.ReferenceUsageType.Write) != 0)
                {
                    color = TextEditor.ColorStyle.ChangingUsagesRectangle.Color;
                }
                else if ((usage.UsageType & MonoDevelop.Ide.FindInFiles.ReferenceUsageType.Read) != 0)
                {
                    color = TextEditor.ColorStyle.UsagesRectangle.Color;
                }
                else
                {
                    color = usageColor;
                }
                color.L  = 0.5;
                cr.Color = color;
                cr.MoveTo(0, y - 3);
                cr.LineTo(5, y);
                cr.LineTo(0, y + 3);
                cr.LineTo(0, y - 3);
                cr.ClosePath();
                cr.Fill();
            }

            foreach (var task in AllTasks)
            {
                double y = GetYPosition(task.Location.Line);

                cr.SetSourceColor(GetBarColor(task.Severity));
                cr.Rectangle(0, Math.Round(y) - 1, Allocation.Width, 2);
                cr.Fill();

                switch (task.Severity)
                {
                case Severity.Error:
                    severity = Severity.Error;
                    break;

                case Severity.Warning:
                    if (severity == Severity.None)
                    {
                        severity = Severity.Warning;
                    }
                    break;
                }
            }
            return(severity);
        }
Ejemplo n.º 9
0
 public void EndFigure(bool isClosed)
 {
     if (this.Path == null)
     {
         if (isClosed)
         {
             _context.ClosePath();
         }
     }
 }
Ejemplo n.º 10
0
        private static void RoundBorder(Cairo.Context ctx, double x, double y, double w, double h)
        {
            double radius = h / 2.0;

            ctx.Arc(x + radius, y + radius, radius, Math.PI / 2.0, 3.0 * Math.PI / 2.0);
            ctx.LineTo(x + w - radius, y);
            ctx.Arc(x + w - radius, y + radius, radius, 3.0 * Math.PI / 2.0, 5.0 * Math.PI / 2.0);
            ctx.LineTo(x + radius, y + h);
            ctx.ClosePath();
        }
Ejemplo n.º 11
0
        void Render(Cairo.Context context)
        {
            var hourRadians = (time.Hour % 12 + time.Minute / 60F) * 30 * Math.PI / 180;

            DrawHand(3, hourLength, hourColor, hourRadians, context);

            var minuteRadians = (time.Minute) * 6 * Math.PI / 180;

            DrawHand(2, minuteLength, minuteColor, minuteRadians, context);

            var secondRadians = (time.Second) * 6 * Math.PI / 180;

            DrawHand(1, secondLength, secondColor, secondRadians, context);

            for (int i = 0; i < 60; i++)
            {
                if (i % 5 == 0)
                {
                    var p1 = new Cairo.PointD(center.X + (radius / 1.50 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos(i * 6 * Math.PI / 180)));
                    var p2 = new Cairo.PointD(center.X + (radius / 1.65 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.65 * Math.Cos(i * 6 * Math.PI / 180)));
                    context.LineWidth = 1;
                    context.Color     = ticksColor;
                    context.MoveTo(p1);
                    context.LineTo(p2);
                    context.ClosePath();
                    context.Stroke();
                }
                else
                {
                    var p1 = new Cairo.PointD(center.X + (radius / 1.50 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos(i * 6 * Math.PI / 180)));
                    var p2 = new Cairo.PointD(center.X + (radius / 1.55 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.55 * Math.Cos(i * 6 * Math.PI / 180)));
                    context.LineWidth = 1;
                    context.Color     = ticksColor;
                    context.MoveTo(p1);
                    context.LineTo(p2);
                    context.ClosePath();
                    context.Stroke();
                }
            }
            //DrawFace (center, (radius / 2) + 17, e);
            //DrawFace (center, 8, e);
        }
Ejemplo n.º 12
0
        private static void MakeSquare(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            double size = msize - lw;

            context.MoveTo(item.X * scale.X, item.Y * scale.Y);
            context.RelMoveTo(-size / 2, -size / 2);
            context.RelLineTo(size, 0);
            context.RelLineTo(0, size);
            context.RelLineTo(-size, 0);
            context.ClosePath();
        }
Ejemplo n.º 13
0
		static void DrawRectangle (Cairo.Context g, double x, double y, double width, double height)
		{
			double right = x + width;
			double bottom = y + height;
			g.MoveTo (new Cairo.PointD (x, y));
			g.LineTo (new Cairo.PointD (right, y));
			g.LineTo (new Cairo.PointD (right, bottom));
			g.LineTo (new Cairo.PointD (x, bottom));
			g.LineTo (new Cairo.PointD (x, y));
			g.ClosePath ();
		}
Ejemplo n.º 14
0
        public override void Draw(Cairo.Context context)
        {
            context.MoveTo(_points[0].X, _points[0].Y);

            foreach (var point in _points)
            {
                context.LineTo(point.X, point.Y);
            }

            context.ClosePath();
        }
Ejemplo n.º 15
0
 void DrawHand(double fThickness, double length, Cairo.Color color, double radians, Cairo.Context e)
 {
     e.MoveTo(new Cairo.PointD(center.X - (length / 9 * Math.Sin(radians)), center.Y + (length / 9 * Math.Cos(radians))));
     e.LineTo(new Cairo.PointD(center.X + (length * Math.Sin(radians)), center.Y - (length * Math.Cos(radians))));
     e.ClosePath();
     e.LineCap   = Cairo.LineCap.Round;
     e.LineJoin  = Cairo.LineJoin.Round;
     e.Color     = color;
     e.LineWidth = fThickness;
     e.Stroke();
 }
Ejemplo n.º 16
0
 public static void RenderCircle(Cairo.Context g, Cairo.Color c, double r, double x, double y)
 {
     g.Save();
     g.Color = c;
     g.MoveTo(x, y);
     g.Arc(x, y, r, 0, 6.28);
     g.LineWidth = 3;
     g.ClosePath();
     g.Fill();
     g.Restore();
 }
Ejemplo n.º 17
0
 protected void DrawDiamond(Cairo.Context cr, double x, double y, double size)
 {
     x    += 0.5; y += 0.5;
     size -= 2;
     cr.NewPath();
     cr.MoveTo(x + size / 2, y);
     cr.LineTo(x + size, y + size / 2);
     cr.LineTo(x + size / 2, y + size);
     cr.LineTo(x, y + size / 2);
     cr.LineTo(x + size / 2, y);
     cr.ClosePath();
 }
Ejemplo n.º 18
0
        void DrawClosedFolding(Cairo.Context cr, Cairo.Color col, double x, double y)
        {
            var drawArea = new Cairo.Rectangle(System.Math.Floor(x + (Width - foldSegmentSize) / 2) + 0.5,
                                               System.Math.Floor(y + (editor.LineHeight - foldSegmentSize) / 2) + 0.5, foldSegmentSize, foldSegmentSize);

            cr.MoveTo(new Cairo.PointD(drawArea.X, drawArea.Y));
            cr.LineTo(new Cairo.PointD(drawArea.X, drawArea.Y + drawArea.Height));
            cr.LineTo(new Cairo.PointD(drawArea.X + drawArea.Width, drawArea.Y + drawArea.Height / 2));
            cr.ClosePath();
            cr.Color = GetColor(col);
            cr.Fill();
        }
        /*
         * static double min (params double[] arr)
         * {
         *      int minp = 0;
         *      for (int i = 1; i < arr.Length; i++)
         *              if (arr[i] < arr[minp])
         *                      minp = i;
         *      return arr[minp];
         * }*/

        static void DrawRectangle(Cairo.Context g, int x, int y, int width, int height)
        {
            int right  = x + width;
            int bottom = y + height;

            g.MoveTo(new Cairo.PointD(x, y));
            g.LineTo(new Cairo.PointD(right, y));
            g.LineTo(new Cairo.PointD(right, bottom));
            g.LineTo(new Cairo.PointD(x, bottom));
            g.LineTo(new Cairo.PointD(x, y));
            g.ClosePath();
        }
Ejemplo n.º 20
0
        public void EndFigure(bool isClosed)
        {
            if (isClosed)
            {
                _context.ClosePath();
            }

            var extents = _context.StrokeExtents();

            _impl.Bounds = new Rect(extents.X, extents.Y, extents.Width, extents.Height);
            _impl.Path   = _context.CopyPath();
        }
Ejemplo n.º 21
0
        /* private methods */
        private void DrawPointGlyph(Cairo.Context cr, PointShape type, float x, float y, float side_size)
        {
            float half_size = side_size / 2;

            switch (type)
            {
            case PointShape.Square:
                cr.Rectangle(x - half_size, y - half_size,
                             side_size, side_size);
                break;

            case PointShape.Circle:
                cr.MoveTo(x + half_size, y);
                cr.Arc(x, y, half_size, 0, 2 * Math.PI);
                cr.ClosePath();
                break;

            case PointShape.Diamond:
                cr.MoveTo(x - half_size, y);
                cr.LineTo(x, y - half_size);
                cr.LineTo(x + half_size, y);
                cr.LineTo(x, y + half_size);
                cr.ClosePath();
                break;

            case PointShape.Triangle:
                cr.MoveTo(x - half_size, y + half_size);
                cr.LineTo(x, y - half_size);
                cr.LineTo(x + half_size, y + half_size);
                cr.ClosePath();
                break;

            case PointShape.X:
                cr.MoveTo(x - half_size, y - half_size);
                cr.LineTo(x + half_size, y + half_size);
                cr.MoveTo(x + half_size, y - half_size);
                cr.LineTo(x - half_size, y + half_size);
                break;
            }
        }
Ejemplo n.º 22
0
        public override void Draw(Cairo.Context context)
        {
            Cairo.Matrix oldMatrix = context.Matrix;
            double       a         = MinorAxis / _majorAxis;

            context.Translate(0.0, _position.Y * (1 - a));
            context.Scale(1.0, a);
            context.MoveTo(_position.X + _majorAxis, _position.Y);
            context.Arc(_position.X, _position.Y, _majorAxis, 0.0, 2 * Math.PI);
            context.ClosePath();
            //todo change in order to process rotated ellipses (i.e. MajorAxis is collinear with OY)
            context.Matrix = oldMatrix;
        }
Ejemplo n.º 23
0
        static void RoundBorder(Cairo.Context ctx, double x, double y, double w, double h)
        {
            double r = h / 2;

            ctx.Arc(x + r, y + r, r, Math.PI / 2, Math.PI + Math.PI / 2);
            ctx.LineTo(x + w - r, y);

            ctx.Arc(x + w - r, y + r, r, Math.PI + Math.PI / 2, Math.PI + Math.PI + Math.PI / 2);

            ctx.LineTo(x + r, y + h);

            ctx.ClosePath();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Renders a single pager arrow inside a bounding box.
        /// </summary>
        protected virtual void RenderPagerArrow(Cairo.Context context, Gdk.Rectangle bounds, ArrowType direction)
        {
            switch (direction)
            {
            case ArrowType.Up:
                context.MoveTo(bounds.X + bounds.Width / 2.0, bounds.Y);
                context.LineTo(bounds.X, bounds.Y + bounds.Height);
                context.LineTo(bounds.X + bounds.Width, bounds.Y + bounds.Height);
                context.ClosePath();
                break;

            case ArrowType.Down:
                context.MoveTo(bounds.X + bounds.Width / 2.0, bounds.Y + bounds.Height);
                context.LineTo(bounds.X, bounds.Y);
                context.LineTo(bounds.X + bounds.Width, bounds.Y);
                context.ClosePath();
                break;

            case ArrowType.Left:
                context.MoveTo(bounds.X, bounds.Y + bounds.Height / 2.0);
                context.LineTo(bounds.X + bounds.Width, bounds.Y);
                context.LineTo(bounds.X + bounds.Width, bounds.Y + bounds.Height);
                context.ClosePath();
                break;

            case ArrowType.Right:
                context.MoveTo(bounds.X + bounds.Width, bounds.Y + bounds.Height / 2.0);
                context.LineTo(bounds.X, bounds.Y);
                context.LineTo(bounds.X, bounds.Y + bounds.Height);
                context.ClosePath();
                break;

            default:
                return;
            }

            context.SetSourceColor(PagerTriangleColor);
            context.Fill();
        }
Ejemplo n.º 25
0
        public void EndFigure(bool isClosed)
        {
            if (this.Path == null)
            {
                if (isClosed)
                {
                    _context.ClosePath();
                }

                Path   = _context.CopyPath();
                Bounds = _context.FillExtents().ToPerspex();
            }
        }
Ejemplo n.º 26
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);
            }
        }
Ejemplo n.º 27
0
 internal static void FillRectangle(this Cairo.Context g,
                                    Rect rect,
                                    Color color)
 {
     g.NewPath();
     g.MoveTo(rect.TopLeft.ToPointD());
     g.SetSourceColor(color);
     g.LineTo(rect.TopRight.ToPointD());
     g.LineTo(rect.BottomRight.ToPointD());
     g.LineTo(rect.BottomLeft.ToPointD());
     g.LineTo(rect.TopLeft.ToPointD());
     g.ClosePath();
     g.Fill();
 }
        void DrawQuota(Cairo.Context context, double angle, Color color)
        {
            context.Save();
            context.Rotate(angle * Math.PI / 180.0);
            context.MoveTo(0, -95);
            context.LineTo(1, -110);
            context.LineTo(-1, -110);
            context.ClosePath();
            var c = color.ToCairo();

            context.SetSourceRGBA(c.R, c.G, c.B, c.A);
            context.Stroke();
            context.Restore();
        }
Ejemplo n.º 29
0
        private static void MakeTriangle(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            double halfsize = (msize - lw) / 2;

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

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

            context.RelLineTo(dx, -halfsize - dy);
            context.RelLineTo(2 * -dx, 0);
            context.ClosePath();
        }
Ejemplo n.º 30
0
        private void DrawFigure(PathFigure figure)
        {
            cr.MoveTo(figure.StartPoint.X, figure.StartPoint.Y);

            foreach (var segment in figure.Segments)
            {
                DrawSegment(segment);
            }

            if (figure.IsClosed)
            {
                cr.ClosePath();
            }
        }