示例#1
0
        protected override void DrawFrame(Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
        {
            // base.DrawFrame (context, lineWidth, lineColor, fillColor);

            rect = DisplayBox;
            rect.OffsetDot5();

            // HERZUM SPRINT 1.2
            // CairoFigures.CurvedRectangle(context, rect, 30);
            CairoFigures.AngleFrame(context, rect, 0, 0, 0, 0);
            // END HERZUM SPRINT 1.2

            Cairo.Color fillColorOrigin;
            fillColorOrigin = fillColor;

            lineWidth = 1;
            fillColor = new Cairo.Color(1.0, 1.0, 1.0, 1.0);

            context.Color = fillColor;
            context.FillPreserve();
            context.Color     = lineColor;
            context.LineWidth = lineWidth;

            double[] dash = { 2, 0, 2 };
            context.SetDash(dash, 0);

            context.Stroke();

            rect2        = DisplayBox;
            rect2.Width  = DisplayBox.Width;
            rect2.Height = 30;
            rect2.OffsetDot5();
            CairoFigures.CurvedRectangle(context, rect2, 30);
            fillColor     = fillColorOrigin;
            context.Color = fillColor;
            context.FillPreserve();
            context.Color     = lineColor;
            context.LineWidth = lineWidth;

            context.Stroke();

            // HERZUM SPRINT 2.1
            // m_applicationContext.MainWindow.ExperimentCanvasPad.LoopNodeControlCurrent = this;
            // END HERZUM SPRINT 2.1

            // HERZUM SPRINT 5.0: TLAB-235
            // DrawScope ();
            DrawScope("Enter", "Exit");
            // END HERZUM SPRINT 5.0: TLAB-235
        }
示例#2
0
        public static void RenderFilledTriangle(Cairo.Context context, Point scale, Point item, double msize, double lw)
        {
            MakeTriangle(context, scale, item, msize, lw);

            context.FillPreserve();
            context.Stroke();
        }
示例#3
0
        protected virtual void PaintFill()
        {
            double r, g, b;

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

            cairo.Save();
            GetFrame(cairo);

            if (!drawGradient)
            {
                cairo.SetSourceRGBA(r, g, b, fillAlpha);
            }
            else
            {
                using (var grad = CreateGradient()) {
                    cairo.SetSource(grad);
                }
            }

            cairo.FillPreserve();
            cairo.Restore();
        }
示例#4
0
        QuickTaskSeverity DrawQuickTasks(Cairo.Context cr)
        {
            QuickTaskSeverity severity = QuickTaskSeverity.None;
            int h = Allocation.Height - Allocation.Width - 6;

            foreach (var task in AllTasks)
            {
                double y = h * TextEditor.LineToY(task.Location.Line) / Math.Max(TextEditor.EditorLineThreshold * TextEditor.LineHeight + TextEditor.GetTextEditorData().TotalHeight, TextEditor.Allocation.Height);

                var color = (HslColor)GetBarColor(task.Severity);
                cr.Color = color;
                cr.Rectangle(3, y - 1, Allocation.Width - 5, 4);
                cr.FillPreserve();

                color.L *= 0.7;
                cr.Color = color;
                cr.Rectangle(3, y - 1, Allocation.Width - 5, 4);
                cr.Stroke();

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

                case QuickTaskSeverity.Warning:
                    if (severity == QuickTaskSeverity.None)
                    {
                        severity = QuickTaskSeverity.Warning;
                    }
                    break;
                }
            }
            return(severity);
        }
        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();
                }
            }
        }
示例#6
0
        public void DrawEventTag(Cairo.Context cr, PlotColor color,
                                 int x, int y, Orientation orientation)
        {
            cr.MoveTo(x + DEFUZZ, y);

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

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

            cr.FillPreserve();

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

            cr.Stroke();
        }
        void DrawFoldSegment(Cairo.Context ctx, double x, double y, bool isOpen, bool isSelected)
        {
            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);

            ctx.Rectangle(drawArea);
            ctx.Color = foldBgGC;
            ctx.FillPreserve();
            ctx.Color = isSelected ? foldLineHighlightedGC  : foldLineGC;
            ctx.Stroke();

            ctx.DrawLine(foldToggleMarkerGC,
                         drawArea.X + drawArea.Width * 2 / 10,
                         drawArea.Y + drawArea.Height / 2,
                         drawArea.X + drawArea.Width - drawArea.Width * 2 / 10,
                         drawArea.Y + drawArea.Height / 2);

            if (!isOpen)
            {
                ctx.DrawLine(foldToggleMarkerGC,
                             drawArea.X + drawArea.Width / 2,
                             drawArea.Y + drawArea.Height * 2 / 10,
                             drawArea.X + drawArea.Width / 2,
                             drawArea.Y + drawArea.Height - drawArea.Height * 2 / 10);
            }
        }
        public override bool DrawBackground(TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
        {
            // check, if a message bubble is active in that line.
            if (LineSegment != null && LineSegment.Markers.Any(m => m != this && (m is IExtendingTextLineMarker)))
            {
                return(false);
            }

            var sidePadding = 4;
            var rounding    = editor.LineHeight / 2 - 1;

            var d = metrics.TextRenderEndPosition - metrics.TextRenderStartPosition;

            if (d > 0)
            {
                cr.LineWidth = 1;
                cr.RoundedRectangle(metrics.TextRenderStartPosition, Math.Floor(y) + 0.5, d + sidePadding, metrics.LineHeight - 1, rounding);
                cr.SetSourceColor(BackgroundColor);
                cr.FillPreserve();
                cr.SetSourceColor(BorderColor);
                cr.Stroke();
            }

            return(base.DrawBackground(editor, cr, y, metrics));
        }
        protected void DrawSearchIndicator(Cairo.Context cr)
        {
            var x1 = 1 + Allocation.Width / 2;
            var y1 = Allocation.Height - IndicatorHeight / 2;

            cr.Arc(x1,
                   y1,
                   (IndicatorHeight - 1) / 2,
                   0,
                   2 * Math.PI);

            var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg;

            darkColor.L *= 0.5;

            using (var pattern = new Cairo.RadialGradient(x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width))
            {
                pattern.AddColorStop(0, darkColor);
                pattern.AddColorStop(1, TextEditor.ColorStyle.SearchTextMainBg);
                cr.Pattern = pattern;
                cr.FillPreserve();
            }

            cr.Color = darkColor;
            cr.Stroke();
        }
示例#10
0
        public void DrawIcon(TextEditor editor, Cairo.Context cr, DocumentLine 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);
                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();
                }
            }
        }
示例#11
0
        /// <summary>
        /// Draws a geometry.
        /// </summary>
        /// <param name="brush">The fill brush.</param>
        /// <param name="pen">The stroke pen.</param>
        /// <param name="geometry">The geometry.</param>
        public void DrawGeometry(Brush brush, Pen pen, Geometry geometry)
        {
            var impl = geometry.PlatformImpl as StreamGeometryImpl;

            var oldMatrix = Transform;

            Transform = impl.Transform * Transform;


            if (brush != null)
            {
                _context.AppendPath(impl.Path);
                using (var b = SetBrush(brush, geometry.Bounds.Size))
                {
                    if (pen != null)
                    {
                        _context.FillPreserve();
                    }
                    else
                    {
                        _context.Fill();
                    }
                }
            }
            Transform = oldMatrix;

            if (pen != null)
            {
                _context.AppendPath(impl.Path);
                using (var p = SetPen(pen, geometry.Bounds.Size))
                {
                    _context.Stroke();
                }
            }
        }
示例#12
0
 void DrawExpander(Cairo.Context ctx, double ex, double ey, bool expanded, bool hilight)
 {
     ctx.NewPath();
     ctx.LineWidth = 1;
     ctx.Rectangle(ex, ey, ExpanderSize, ExpanderSize);
     if (hilight)
     {
         ctx.SetSourceColor(Style.Background(Gtk.StateType.Normal).ToCairoColor());
     }
     else
     {
         ctx.SetSourceColor(Style.White.ToCairoColor());
     }
     ctx.FillPreserve();
     ctx.SetSourceColor(Style.Foreground(Gtk.StateType.Normal).ToCairoColor());
     ctx.Stroke();
     ctx.NewPath();
     ctx.MoveTo(ex + 2, ey + (ExpanderSize / 2));
     ctx.RelLineTo(ExpanderSize - 4, 0);
     if (!expanded)
     {
         ctx.MoveTo(ex + (ExpanderSize / 2), ey + 2);
         ctx.RelLineTo(0, ExpanderSize - 4);
     }
     ctx.Stroke();
 }
示例#13
0
        private void HeaderExpose(object ob, Gtk.ExposeEventArgs a)
        {
            Gdk.Rectangle rect = new Gdk.Rectangle(0, 0, header.Allocation.Width - 1, header.Allocation.Height);
            HslColor      gcol = frame.Style.Background(Gtk.StateType.Normal);

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

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

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

            foreach (Widget child in header.Children)
            {
                header.PropagateExpose(child, a.Event);
            }
        }
示例#14
0
        public override void DrawBackground(MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
        {
            this.editor = editor;
            int markerStart = base.Offset;
            int markerEnd   = base.EndOffset;

            if (markerEnd < startOffset || markerStart > endOffset)
            {
                return;
            }

            double @from;
            double to;
            var    startXPos = metrics.TextRenderStartPosition;
            var    endXPos   = metrics.TextRenderEndPosition;
            var    y         = metrics.LineYRenderStartPosition;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int start = startOffset < markerStart ? markerStart : startOffset;
                int end   = endOffset < markerEnd ? endOffset : markerEnd;

                uint curIndex = 0, byteIndex = 0;
                TextViewMargin.TranslateToUTF8Index(metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);

                int x_pos = metrics.Layout.Layout.IndexToPos((int)byteIndex).X;

                @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                TextViewMargin.TranslateToUTF8Index(metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
                x_pos = metrics.Layout.Layout.IndexToPos((int)byteIndex).X;

                to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
            }

            @from = Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from < to)
            {
                cr.SetSourceColor(background(editor).Color);
                cr.RoundedRectangle(@from + 2.5, y + 0.5, to - @from, editor.LineHeight - 1, 2);                  // 2.5 to make space for the column guideline

                if (background(editor).HasBorderColor)
                {
                    cr.FillPreserve();

                    cr.SetSourceColor(background(editor).BorderColor);
                    cr.Stroke();
                }
                else
                {
                    cr.Fill();
                }
            }
        }
示例#15
0
        /// <summary>
        /// Draws a geometry.
        /// </summary>
        /// <param name="brush">The fill brush.</param>
        /// <param name="pen">The stroke pen.</param>
        /// <param name="geometry">The geometry.</param>
        public void DrawGeometry(Brush brush, Pen pen, Geometry geometry)
        {
            var impl = geometry.PlatformImpl as StreamGeometryImpl;

            using (var pop = PushTransform(impl.Transform))
            {
                _context.AppendPath(impl.Path);

                if (brush != null)
                {
                    SetBrush(brush, geometry.Bounds.Size);

                    if (pen != null)
                    {
                        _context.FillPreserve();
                    }
                    else
                    {
                        _context.Fill();
                    }
                }


                if (pen != null)
                {
                    SetPen(pen, geometry.Bounds.Size);
                    _context.Stroke();
                }
            }
        }
示例#16
0
文件: TechBorder.cs 项目: masums/Crow
		void drawTechBorder1 (Cairo.Context gr){
			Rectangle r = ClientRectangle;

			double l1 = Math.Round(0.2 * Math.Min (r.Width, r.Height)) + 0.5;

			Foreground.SetAsSource (gr);
			gr.LineWidth = 6.0;
			gr.MoveTo (r.Left + 1.5, r.Top + l1);
			gr.LineTo (r.Left + 1.5, r.Top + 1.5);
			gr.LineTo (r.Left + l1, r.Top + 1.5);
			gr.MoveTo (r.Left + r.Width * 0.65, r.Bottom - 1.5);
			gr.LineTo (r.Left + r.Width * 0.85, r.Bottom - 1.5);
			gr.Stroke ();

			gr.MoveTo (r.Left + 2.5, r.Top + 2.5);
			gr.LineTo (r.Left + 2.5, r.Bottom - l1);
			gr.LineTo (r.Left + l1, r.Bottom - 2.5);
			gr.LineTo (r.Right - 2.5, r.Bottom - 2.5);
			gr.LineTo (r.Right - 2.5, r.Top + l1);
			gr.LineTo (r.Right - l1, r.Top + 2.5);
			gr.ClosePath ();

			if (ClipToClientRect) //clip to client zone				
				gr.ClipPreserve ();			

			Background.SetAsSource (gr);
			gr.FillPreserve ();

			gr.LineWidth = 1.0;
			Foreground.SetAsSource (gr);
			gr.Stroke ();			
		}
示例#17
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            Gdk.Rectangle rect;

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

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

            bool res = base.OnExposeEvent(evnt);

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

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

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

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

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

            return(res);
        }
示例#18
0
 protected void FillGradient(Cairo.Context cr, Cairo.Color color1, Cairo.Color color2, double x, double y, double size)
 {
     Cairo.Gradient 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();
 }
示例#19
0
        void DrawChangeSymbol(Cairo.Context ctx, double x, int width, BlockInfo block)
        {
            if (!IsChangeBlock(block.Type))
            {
                return;
            }

            Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor;

            int ssize   = 8;
            int barSize = 3;

            if (ssize - 2 > lineHeight)
            {
                ssize = lineHeight - 2;
            }
            if (ssize <= 0)
            {
                return;
            }

            double inSize = (ssize / 2) - (barSize / 2);
            double py     = block.YStart + ((block.YEnd - block.YStart) / 2 - ssize / 2) + 0.5;
            double px     = x + (LeftPaddingBlock / 2) - (ssize / 2) + 0.5;

            if (block.Type == BlockType.Added)
            {
                ctx.MoveTo(px + inSize, py);
                ctx.RelLineTo(barSize, 0);
                ctx.RelLineTo(0, inSize);
                ctx.RelLineTo(inSize, 0);
                ctx.RelLineTo(0, barSize);
                ctx.RelLineTo(-inSize, 0);
                ctx.RelLineTo(0, inSize);
                ctx.RelLineTo(-barSize, 0);
                ctx.RelLineTo(0, -inSize);
                ctx.RelLineTo(-inSize, 0);
                ctx.RelLineTo(0, -barSize);
                ctx.RelLineTo(inSize, 0);
                ctx.RelLineTo(0, -inSize);
                ctx.ClosePath();
            }
            else
            {
                ctx.MoveTo(px, py + inSize);
                ctx.RelLineTo(ssize, 0);
                ctx.RelLineTo(0, barSize);
                ctx.RelLineTo(-ssize, 0);
                ctx.RelLineTo(0, -barSize);
                ctx.ClosePath();
            }

            ctx.Color = color.ToCairoColor();
            ctx.FillPreserve();
            ctx.Color     = color.AddLight(-0.2).ToCairoColor();;
            ctx.LineWidth = 1;
            ctx.Stroke();
        }
示例#20
0
 protected static 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.SetSource(pat);
         cr.FillPreserve();
     }
 }
示例#21
0
        void DrawSelectedColorBox(Cairo.Context context, Gdk.Rectangle region)
        {
            context.Rectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1);
            context.Color = SelectedColor;
            context.FillPreserve();

            context.LineWidth = 1;
            context.Color     = new Color(0, 0, 0);
            context.Stroke();
        }
示例#22
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();
 }
示例#23
0
 protected void paintSquare(Cairo.Context context, int x, int y, bool fill)
 {
     context.Save();
     context.SetSourceRGB(0, 0, 1);
     context.Translate(x, y);
     context.Rectangle(new Cairo.Rectangle(0, 0, fieldSize, fieldSize));
     context.SetSourceRGBA(0, 0, 0, fill ? 0.5 : 0.3);
     context.FillPreserve();
     context.NewPath();
     context.Restore();
 }
示例#24
0
 protected void paintTrail(Cairo.Context context, int x, int y)
 {
     context.Save();
     context.SetSourceRGB(0, 1, 0);
     context.Translate(x, y);
     context.Rectangle(new Cairo.Rectangle(0, 0, fieldSize, fieldSize));
     context.SetSourceRGBA(0, 1, 0, 0.3);
     context.FillPreserve();
     context.NewPath();
     context.Restore();
 }
示例#25
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();
 }
示例#26
0
 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();
 }
示例#27
0
        protected override void DrawFrame(Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
        {
            RectangleD rect = DisplayBox;

            rect.OffsetDot5();
            context.Rectangle(GdkCairoHelper.CairoRectangle(rect));
            context.Color = fillColor;
            context.FillPreserve();
            context.Color     = lineColor;
            context.LineWidth = lineWidth;
            context.Stroke();
        }
示例#28
0
        protected override void DrawFrame(Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
        {
            RectangleD rect = DisplayBox;

            rect.OffsetDot5();
            CairoFigures.AngleFrame(context, rect, 15, 0, 15, 0);
            context.Color = fillColor;
            context.FillPreserve();
            context.Color     = lineColor;
            context.LineWidth = lineWidth;
            context.Stroke();
        }
        /*
         * void InternalDrawBackground (TextEditor Editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, ref int startXPos, int endXPos, ref bool drawBg)
         * {
         *      Gdk.Rectangle clipRectangle = new Gdk.Rectangle (mode.Editor.TextViewMargin.XOffset, 0,
         *                                                                                      Editor.Allocation.Width - mode.Editor.TextViewMargin.XOffset, Editor.Allocation.Height);
         *
         *      // draw default background
         *      using (Gdk.GC fillGc = new Gdk.GC (win)) {
         *              fillGc.ClipRectangle = clipRectangle;
         *              fillGc.RgbFgColor = selected ? Editor.ColorStyle.Selection.BackgroundColor : Editor.ColorStyle.Default.BackgroundColor;
         *              win.DrawRectangle (fillGc, true, startXPos, y, endXPos, Editor.LineHeight);
         *      }
         *
         *      if (startOffset >= endOffset)
         *              return;
         *
         *      int caretOffset = Editor.Caret.Offset - BaseOffset;
         *      foreach (TextLink link in mode.Links) {
         *              if (!link.IsEditable)
         *                      continue;
         *              bool isPrimaryHighlighted = link.PrimaryLink.Offset <= caretOffset && caretOffset <= link.PrimaryLink.EndOffset;
         *
         *              foreach (TextSegment segment in link.Links) {
         *
         *                      if ((BaseOffset + segment.Offset <= startOffset && startOffset < BaseOffset + segment.EndOffset) ||
         *                              (startOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < endOffset)) {
         *                              int strOffset    = BaseOffset + segment.Offset - startOffset;
         *                              int strEndOffset = BaseOffset + segment.EndOffset - startOffset;
         *
         *                              int lineNr, x_pos, x_pos2;
         *                              layout.IndexToLineX (strOffset, false, out lineNr, out x_pos);
         *                              layout.IndexToLineX (strEndOffset, false, out lineNr, out x_pos2);
         *                              x_pos  = (int)(x_pos / Pango.Scale.PangoScale);
         *                              x_pos2 = (int)(x_pos2 / Pango.Scale.PangoScale);
         *                              using (Gdk.GC rectangleGc = new Gdk.GC (win)) {
         *                                      rectangleGc.ClipRectangle = clipRectangle;
         *                                      using (Gdk.GC fillGc = new Gdk.GC (win)) {
         *                                              fillGc.ClipRectangle = clipRectangle;
         *                                              drawBg = false;
         *
         *                                              if (segment == link.PrimaryLink) {
         *                                                      fillGc.RgbFgColor      = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.BackgroundColor : Editor.ColorStyle.PrimaryTemplate.BackgroundColor;
         *                                                      rectangleGc.RgbFgColor = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.Color           : Editor.ColorStyle.PrimaryTemplate.Color;
         *                                              } else {
         *                                                      fillGc.RgbFgColor      = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.BackgroundColor : Editor.ColorStyle.SecondaryTemplate.BackgroundColor;
         *                                                      rectangleGc.RgbFgColor = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.Color           : Editor.ColorStyle.SecondaryTemplate.Color;
         *                                              }
         *                                              // Draw segment
         *                                              if (!selected)
         *                                                      win.DrawRectangle (fillGc, true, startXPos, y, x_pos2 - x_pos, Editor.LineHeight);
         *
         *                                              int x1 = startXPos + x_pos - 1;
         *                                              int x2 = startXPos + x_pos2 - 1;
         *                                              int y2 = y + Editor.LineHeight - 1;
         *
         *                                              win.DrawLine (rectangleGc, x1, y, x2, y);
         *                                              win.DrawLine (rectangleGc, x1, y2, x2, y2);
         *                                              win.DrawLine (rectangleGc, x1, y, x1, y2);
         *                                              win.DrawLine (rectangleGc, x2, y, x2, y2);
         *                                      }
         *                              }
         *                      }
         *              }
         *      }
         *      startXPos += Editor.GetWidth (Editor.Document.GetTextBetween (startOffset, endOffset));
         * }
         */
        /*	bool Overlaps (TextSegment segment, int start, int end)
         *      {
         *              return segment.Offset <= start && start < segment.EndOffset ||
         *                              segment.Offset <= end && end < segment.EndOffset ||
         *                              start <= segment.Offset && segment.Offset < end ||
         *                              start < segment.EndOffset && segment.EndOffset < end;
         *      }*/

        public bool DrawBackground(TextEditor Editor, Cairo.Context cr, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, double y, double startXPos, double endXPos, ref bool drawBg)
        {
            int caretOffset = Editor.Caret.Offset - BaseOffset;

            foreach (TextLink link in mode.Links)
            {
                if (!link.IsEditable)
                {
                    continue;
                }
                bool isPrimaryHighlighted = link.PrimaryLink.Offset <= caretOffset && caretOffset <= link.PrimaryLink.EndOffset;

                foreach (TextSegment segment in link.Links)
                {
                    if ((BaseOffset + segment.Offset <= startOffset && startOffset < BaseOffset + segment.EndOffset) || (startOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < endOffset))
                    {
                        int strOffset    = BaseOffset + segment.Offset - startOffset;
                        int strEndOffset = BaseOffset + segment.EndOffset - startOffset;

                        int x_pos  = layout.Layout.IndexToPos(strOffset).X;
                        int x_pos2 = layout.Layout.IndexToPos(strEndOffset).X;

                        x_pos  = (int)(x_pos / Pango.Scale.PangoScale);
                        x_pos2 = (int)(x_pos2 / Pango.Scale.PangoScale);
                        drawBg = false;
                        Cairo.Color fillGc, rectangleGc;
                        if (segment == link.PrimaryLink)
                        {
                            fillGc      = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.GetColor("secondcolor") : Editor.ColorStyle.PrimaryTemplate.GetColor("secondcolor");
                            rectangleGc = isPrimaryHighlighted ? Editor.ColorStyle.PrimaryTemplateHighlighted.GetColor("secondcolor") : Editor.ColorStyle.PrimaryTemplate.GetColor("secondcolor");
                        }
                        else
                        {
                            fillGc      = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.GetColor("secondcolor") : Editor.ColorStyle.SecondaryTemplate.GetColor("secondcolor");
                            rectangleGc = isPrimaryHighlighted ? Editor.ColorStyle.SecondaryTemplateHighlighted.GetColor("color") : Editor.ColorStyle.SecondaryTemplate.GetColor("color");
                        }

                        // Draw segment
                        double x1 = startXPos + x_pos - 1;
                        double x2 = startXPos + x_pos2 - 1 + 0.5;

                        cr.Rectangle(x1 + 0.5, y + 0.5, x2 - x1, Editor.LineHeight - 1);

                        cr.Color = fillGc;
                        cr.FillPreserve();

                        cr.Color = rectangleGc;
                        cr.Stroke();
                    }
                }
            }
            return(true);
        }
示例#30
0
        /// <summary>
        /// Draws the rectangle frame into the given cairo context
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="lineWidth">Line width.</param>
        /// <param name="lineColor">Line color.</param>
        /// <param name="fillColor">Fill color.</param>
        protected virtual void DrawFrame(Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
        {
            RectangleD rect = DisplayBox;

            rect.OffsetDot5();
            CairoFigures.CurvedRectangle(context, rect, 8);
            context.Color = fillColor;
            context.FillPreserve();
            context.Color     = lineColor;
            context.LineWidth = lineWidth;
            context.Stroke();
        }