示例#1
0
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            // Line arround
            ctx.SetColor(Colors.DarkGray);

            // Drive line arround
            ctx.Rectangle(Bounds);
            ctx.Fill();

            ctx.SetColor(Colors.Gray);
            ctx.Rectangle(Bounds.Inflate(-margin, -margin));
            ctx.Fill();

            // Draw image
            ctx.DrawImage(Image.FromResource(Logo), 5.0, 5.0);

            // Draw text
            ctx.SetColor(Colors.White);
            TextLayout _layout = new TextLayout();
            _layout.Font = Font.WithSize(22);
            _layout.Text = Label;
            _layout.SetFontWeight(FontWeight.Bold, 0, Label.Length);

            // Cocoa layouts
            ctx.DrawTextLayout(_layout, 45, ((Config.Cocoa || Config.Gtk) ? 5 : 2));
        }
示例#2
0
 internal protected override void Draw(Xwt.Drawing.Context cr, Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
 {
     cr.MoveTo(x + 0.5, y);
     cr.LineTo(x + 0.5, y + lineHeight);
     cr.SetSourceColor(color);
     cr.Stroke();
 }
示例#3
0
		protected override void OnDraw (Context ctx, Rectangle dirtyRect)
		{
			Image image = new CustomImage ();
			int x = 0;
			for (int n=4; n < 50; n += 4) {
				ctx.DrawImage (image.WithSize (n, n), x, 0);
				x += n;
			}

			int maxSize = 48;
			var warn = StockIcons.Error;
			x = 0;
			for (int n=8; n <= maxSize; n += 2) {
				ctx.DrawImage (warn, x, 50, n, n);
				x += n;
			}
			
			warn = StockIcons.Error.WithSize (maxSize).ToBitmap ();
			x = 0;
			for (int n=8; n <= maxSize; n += 2) {
				ctx.DrawImage (warn, x, 100, n, n);
				x += n;
			}

			ctx.DrawImage (image.WithSize (1000), new Rectangle (400, 0, 200, 1000), new Rectangle (0, 200, 200, 200));
			ctx.DrawImage (image.WithSize (1000), new Rectangle (400, 0, 200, 50), new Rectangle (210, 200, 200, 200));
		}
        private void DrawAxisTests(Context ctx, Rectangle bounds)
        {
            Rectangle boundingBox;
            Point tl = Point.Zero;
            Point br = Point.Zero;

            tl.X = bounds.Left + 30;	tl.Y = bounds.Top + 20;
            br.X = bounds.Right - 30;	br.Y = bounds.Top + 20;

            DateTime timeMin = new DateTime (2003, 10, 22, 15, 00, 00);
            DateTime timeMax = new DateTime (2004, 03, 12, 13, 30, 00);

            TradingDateTimeAxis axis = new TradingDateTimeAxis ();
            axis.WorldMin = (double)timeMin.Ticks;
            axis.WorldMax = (double)timeMax.Ticks;
            axis.Draw (ctx, tl, br, out boundingBox);

            timeMin = new DateTime (2013, 09, 17, 12, 30, 10);
            timeMax = new DateTime (2014, 01, 23, 12, 59, 30);
            axis.WorldMin = (double)timeMin.Ticks;
            axis.WorldMax = (double)timeMax.Ticks;

            tl.Y += 50;		br.Y += 50;
            axis.Draw (ctx, tl, br, out boundingBox);
        }
示例#5
0
        public virtual void SpeedTest(Xwt.Drawing.Context ctx, double sx, double sy)
        {
            ctx.Save();

            ctx.Translate(sx, sy);

            var n  = 1000;
            var ll = 80;
            var p  = new Point(0, 0);

            for (double i = 1; i < n; i++)
            {
                ctx.MoveTo(p.X, p.Y);

                ctx.SetColor(new Color(i / n, i / n, i / n));

                ctx.LineTo(p.X + ll, p.Y + ll);
                ctx.Stroke();

                if (p.Y + ll > this.Bounds.Bottom)
                {
                    p.Y  = 0;
                    p.X += ll + 5;
                }
                else
                {
                    p.Y++;
                }
            }

            ctx.Restore();
        }
示例#6
0
        public virtual void Rotate(Xwt.Drawing.Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x + 30, y + 30);
            ctx.SetLineWidth(3);

            // Rotation

            double end = 270;

            for (double n = 0; n <= end; n += 5)
            {
                ctx.Save();
                ctx.Rotate(n);
                ctx.MoveTo(0, 0);
                ctx.RelLineTo(30, 0);
                double c = n / end;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();
                ctx.Restore();
            }

            //ctx.ResetTransform();
            ctx.Restore();
        }
示例#7
0
 public static void DrawLine(this Xwt.Drawing.Context cr, Color color, double x1, double y1, double x2, double y2)
 {
     cr.SetSourceColor(color);
     cr.MoveTo(x1, y1);
     cr.LineTo(x2, y2);
     cr.Stroke();
 }
示例#8
0
        private void DrawAxisTests(Context ctx, Rectangle bounds)
        {
            Rectangle boundingBox;
            Point tl = Point.Zero;
            Point br = Point.Zero;;

            tl.X = bounds.Left + 30;	tl.Y = bounds.Top + 20;
            br.X = bounds.Right - 30;	br.Y = bounds.Top + 20;

            LogAxis log = new LogAxis (1, 10000);

            log.Draw (ctx, tl, br, out boundingBox);

            log.Reversed = true;
            tl.Y += 50;	br.Y += 50;

            log.Draw (ctx, br, tl, out boundingBox);

            // Test for default TicksAngle on positive X-axis, ie Ticks below X-axis
            LogAxis lx = new LogAxis (100, 100000);
            lx.NumberFormat = "{0:0.0E+0}";

            tl.X = bounds.Left + 30;	tl.Y = bounds.Bottom - 60;
            br.X = bounds.Right - 30;	br.Y = bounds.Bottom - 60;

            lx.Draw (ctx, tl, br, out boundingBox);
        }
示例#9
0
        void DrawFoldSegment(Xwt.Drawing.Context ctx, double x, double y, bool isOpen, bool isSelected)
        {
            var drawArea = new 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.SetSourceColor(isOpen ? foldBgGC : foldToggleMarkerBackground);
            ctx.FillPreserve();
            ctx.SetSourceColor(isSelected ? foldLineHighlightedGC : foldLineGC);
            ctx.Stroke();

            ctx.DrawLine(isSelected ? foldLineHighlightedGC : 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(isSelected ? foldLineHighlightedGC : 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);
            }
        }
示例#10
0
 void ICanvasCellViewFrontend.Draw(object ctxBackend, Rectangle cellArea)
 {
     using (var ctx = new Context (ctxBackend, Toolkit.CurrentEngine)) {
         ctx.Reset (null);
         OnDraw (ctx, cellArea);
     }
 }
示例#11
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            if (Bounds.IsEmpty)
            {
                return;
            }

            ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height);
            Gradient g = null;

            if (Linear)
            {
                g = new LinearGradient(0, 0, Bounds.Width, Bounds.Height);
            }
            else
            {
                g = new RadialGradient(Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 2, Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 4);
            }
            g.AddColorStop(0, new Color(1, 0, 0));
            g.AddColorStop(1, new Color(0, 1, 0));
            ctx.Pattern = g;
            ctx.Fill();

            Rectangle r = rect.Inflate(5, 5);

            ctx.Rectangle(r);
            ctx.SetColor(new Color(0, 0, 1));
            ctx.SetLineWidth(1);
            ctx.Stroke();
        }
示例#12
0
        public virtual void Curves2(Context ctx, double sx, double sy)
        {
            ctx.Save ();
            ctx.Translate (sx, sy);
            ctx.SetColor (Colors.Black);

            double x = 0, y = 40;
            double x1 = y - x, y1 = x1 + y, x2 = x + y, y2 = x, x3 = y1, y3 = y;

            ctx.MoveTo (x, y);
            ctx.CurveTo (x1, y1, x2, y2, x3, y3);

            ctx.SetLineWidth (2.0);
            ctx.Stroke ();

            ctx.SetColor (new Color (1, 0.2, 0.2, 0.6));
            ctx.SetLineWidth (1.0);
            ctx.MoveTo (x, y);
            ctx.LineTo (x1, y1);
            ctx.MoveTo (x2, y2);
            ctx.LineTo (x3, y3);
            ctx.Stroke ();

            ctx.Restore ();
        }
示例#13
0
 public ImageBuilder(int width, int height, ImageFormat format)
 {
     this.width = width;
     this.height = height;
     backend = handler.CreateImageBuilder (width, height, format);
     ctx = new Context (handler.CreateContext (backend));
 }
示例#14
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            this.Toolkit = Toolkit.CurrentEngine;

            base.OnPaint(e);

            this.BackColor = SD.Color.White;

            var graphics = new GdiContext(e.Graphics);

            var context = new Xwt.Drawing.Context(graphics, this.Toolkit);


            if (TestCase == PaintContextTestCase.XwtSample)
            {
                XwtSample(context);
            }
            else if (TestCase == PaintContextTestCase.SpeedTest)
            {
                Stopwatch.Start();
                SpeedTest(context);
                Stopwatch.Stop();
            }
            else if (TestCase == PaintContextTestCase.AwesomeIcons)
            {
                AwesomeIcons(context);
            }

            graphics.Dispose();
            Frames++;
        }
示例#15
0
 public ImageBuilder(double width, double height)
 {
     backend = new VectorContextBackend ();
     ctx = new Context (backend, ToolkitEngine, vectorImageRecorderContextHandler);
     ctx.Reset (null);
     this.width = width;
     this.height = height;
 }
示例#16
0
 public object Create(Context context)
 {
     if (context != null) {
         GtkContext c = (GtkContext) WidgetRegistry.GetBackend (context);
         return Pango.CairoHelper.CreateLayout (c.Context);
     } else
         return Pango.CairoHelper.CreateLayout (SharedContext);
 }
 protected internal override void DrawBackground(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height)
 {
     cr.Save();
     cr.SetColor(Colors.LightGray);
     cr.Rectangle(x, y, Width, height + 1);
     cr.Fill();
     cr.Restore();
 }
示例#18
0
		protected override void OnDraw (Context ctx, Rectangle bounds)
		{
			ctx.Save ();
			ctx.Translate (bounds.Location);
			ctx.Scale (bounds.Width / Size.Width, bounds.Height / Size.Height);
			ToolkitEngine.VectorImageRecorderContextHandler.Draw (ctx.Handler, Toolkit.GetBackend (ctx), data);
			ctx.Restore ();
		}
示例#19
0
        protected virtual void SpeedTest(Xwt.Drawing.Context ctx)
        {
            var p = new ReferencePainter();

            p.Font   = Toolkit.CreateFrontend <Font>(this.Font);
            p.Bounds = this.Bounds.ToXwt();
            p.SpeedTest(ctx, 0, 0);
        }
示例#20
0
 public ImageBuilder(int width, int height, ImageFormat format)
 {
     handler = ToolkitEngine.ImageBuilderBackendHandler;
     this.width = width;
     this.height = height;
     backend = handler.CreateImageBuilder (width, height, format);
     ctx = new Context (handler.CreateContext (backend), ToolkitEngine);
 }
示例#21
0
 public void Init()
 {
     ib = new ImageBuilder (1, 1);
     context = ib.Context;
     Matrix m1 = Matrix.Identity;
     Matrix m2 = context.GetCTM ();
     CheckMatrix (m1, m2);
 }
示例#22
0
        //Action<Context> icon = c => iconMethod.Invoke(font, new object[] { c });
        //var ix = Expression.Constant(font);
        //var ic = Expression.Parameter(typeof(Context), "it");
        //icon = Expression.Lambda<Action<Context>>(
        //    Expression.Call(ix, iconMethod,ic), ic).Compile();

        protected virtual void XwtSample(Xwt.Drawing.Context ctx)
        {
            var p = new ReferencePainter();

            p.Font   = Toolkit.CreateFrontend <Font>(this.Font);
            p.Bounds = this.Bounds.ToXwt();
            p.All(ctx);
        }
示例#23
0
        private void DrawAxisTests(Context ctx, Rectangle bounds)
        {
            Rectangle boundingBox;
            Point tl = Point.Zero;
            Point br = Point.Zero;;

            tl.X = bounds.Left + 30;	tl.Y = bounds.Top + 10;
            br.X = tl.X;				br.Y = bounds.Bottom - 100;

            LinearAxis a = new LinearAxis (0, 10);

            a.Draw (ctx, tl, br, out boundingBox);

            a.Reversed = true;
            a.Draw (ctx, new Point (60,10), new Point (60, 200), out boundingBox);

            a.SmallTickSize = 0;
            a.Draw (ctx, new Point(90,10), new Point(90, 200), out boundingBox);

            a.LargeTickStep = 2.5;
            a.Draw (ctx, new Point(120,10), new Point(120,200), out boundingBox);

            a.NumberOfSmallTicks = 5;
            a.SmallTickSize = 2;
            a.Draw (ctx, new Point(150,10), new Point(150,200), out boundingBox);

            a.LineColor = Colors.DarkBlue;
            a.Draw (ctx, new Point(180,10), new Point(180,200), out boundingBox);

            a.TickTextColor= Colors.DarkBlue;
            a.Draw (ctx, new Point(210,10), new Point(210,200), out boundingBox);

            a.TickTextColor = Colors.Black;
            a.Draw (ctx, new Point(240,10), new Point(300,200), out boundingBox);

            a.WorldMax = 100000;
            a.WorldMin = -3;
            a.LargeTickStep = double.NaN;
            a.Draw (ctx, new Point(330,10), new Point(330,200), out boundingBox);

            a.NumberFormat = "{0:0.0E+0}";
            a.Draw (ctx, new Point(380,10), new Point(380,200), out boundingBox);

            // Test for default TicksAngle (+90) on positive X-axis, ie Ticks below X-axis
            LinearAxis aX = new LinearAxis (0, 10);

            tl.X = bounds.Left + 30;	tl.Y = bounds.Bottom - 60;
            br.X = bounds.Right - 20;	br.Y = bounds.Bottom - 60;

            aX.Draw (ctx, tl, br, out boundingBox);

            // Set TicksAngle to -45 anti-clockwise from positive X-axis direction
            aX.TicksAngle = Math.PI / 4.0;
            tl.Y += 50;		br.Y += 50;

            aX.Draw (ctx, tl, br, out boundingBox);
        }
示例#24
0
        protected internal override void Draw(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height)
        {
            if (line != null)
            {
                TextLayout layout;
                if (!layoutDict.TryGetValue(line, out layout))
                {
                    var mode = editor.Document.SyntaxMode;
                    var style = SyntaxModeService.DefaultColorStyle;
                    var chunks = GetCachedChunks(mode, editor.Document, style, line, line.Offset, line.Length);

                    layout = new TextLayout();
                    layout.Font = editor.Options.EditorFont;
                    string lineText = editor.Document.GetLineText(lineNumber);
                    var stringBuilder = new StringBuilder(lineText.Length);

                    int currentVisualColumn = 1;
                    for (int i = 0; i < lineText.Length; ++i)
                    {
                        char chr = lineText[i];
                        if (chr == '\t')
                        {
                            int length = GetNextTabstop(editor, currentVisualColumn) - currentVisualColumn;
                            stringBuilder.Append(' ', length);
                            currentVisualColumn += length;
                        }
                        else
                        {
                            stringBuilder.Append(chr);
                            if (!char.IsLowSurrogate(chr))
                            {
                                ++currentVisualColumn;
                            }
                        }
                    }
                    layout.Text = stringBuilder.ToString();

                    int visualOffset = 1;
                    foreach (var chunk in chunks)
                    {
                        var chunkStyle = style.GetChunkStyle(chunk);
                        visualOffset = DrawLinePortion(cr, chunkStyle, layout, line, visualOffset, chunk.Length);
                    }

                    //layoutDict[line] = layout;
                }

                cr.DrawTextLayout(layout, x, y);

                if (editor.CaretVisible && editor.Caret.Line == lineNumber)
                {
                    cr.SetColor(Colors.Black);
                    cr.Rectangle(x + ColumnToX(line, editor.Caret.Column), y, caretWidth, LineHeight);
                    cr.Fill();
                }
            }
        }
示例#25
0
 protected override void OnDraw(Context ctx)
 {
     ctx.SetLineWidth (5);
     ctx.SetColor (new Color (1.0f, 0f, 0.5f));
     ctx.Rectangle (5, 5, 200, 100);
     ctx.FillPreserve ();
     ctx.SetColor (new Color (0f, 0f, 1f));
     ctx.Stroke ();
 }
示例#26
0
 public BookmarkMarginDrawEventArgs(TextEditor editor, Xwt.Drawing.Context context, DocumentLine line, int lineNumber, double xPos, double yPos)
 {
     this.Editor      = editor;
     this.Context     = context;
     this.LineSegment = line;
     this.Line        = lineNumber;
     this.X           = xPos;
     this.Y           = yPos;
 }
示例#27
0
        /// <summary>
        /// Handles OnDraw Events by drawing AxisTests to the canvas
        /// </summary>
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            // Get Canvas Bounds as region to draw into
            Rectangle bounds = this.Bounds;

            DrawAxisTests (ctx, bounds);

            base.OnDraw (ctx, dirtyRect);
        }
示例#28
0
 protected override void OnDrawOverlay(Context ctx, Rectangle dirtyArea)
 {
     // check if sufficiently inside Canvas
     // only draw once inside focusRadius
     if (lastCursor.X > focusRadius && lastCursor.X < Bounds.Right  - focusRadius &&
         lastCursor.Y > focusRadius && lastCursor.Y < Bounds.Bottom - focusRadius) {
         DrawFocus (ctx, lastCursor);
     }
 }
示例#29
0
文件: Image9Patch.cs 项目: m13253/xwt
		protected override void OnDraw (Context ctx, Rectangle dirtyRect)
		{
			var w = Math.Truncate (Bounds.Width / 2);
			var h = Math.Truncate (Bounds.Height / 2);
			ctx.DrawImage (img_ss, new Rectangle (0, 0, w, h).Inflate (-10, -10));
			ctx.DrawImage (img_tt, new Rectangle (w, 0, w, h).Inflate (-10, -10));
			ctx.DrawImage (img_st, new Rectangle (0, h, w, h).Inflate (-10, -10));
			ctx.DrawImage (img_ts, new Rectangle (w, h, w, h).Inflate (-10, -10));
		}
示例#30
0
		public void PatternsAndImages (Context ctx, double x, double y)
		{
			ctx.Save ();
			ctx.Translate (x, y);
			
			ctx.SetColor (Colors.Black);
			// Dashed lines

			ctx.SetLineWidth (2);
			ctx.SetLineDash (15, 10, 10, 5, 5);
			ctx.Rectangle (10, 10, 100, 100);
			ctx.Stroke ();
			ctx.SetLineDash (0);
			
			// Image
			var arcColor = new Color (1, 0, 1);
			ImageBuilder ib = new ImageBuilder (30, 30);
			ib.Context.Arc (15, 15, 15, 0, 360);
			ib.Context.SetColor (arcColor);
			ib.Context.Fill ();
			ib.Context.SetColor (Colors.DarkKhaki);
			ib.Context.Rectangle (0, 0, 5, 5);
			ib.Context.Fill ();
			var img = ib.ToVectorImage ();
			ctx.DrawImage (img, 0, 0);
			ctx.DrawImage (img, 0, 50, 50, 10);
			
			ctx.Arc (100, 100, 15, 0, 360);
			arcColor.Alpha = 0.4;
			ctx.SetColor (arcColor);
			ctx.Fill ();
			
			// ImagePattern
			
			ctx.Save ();
			
			ctx.Translate (x + 130, y);
			ctx.Pattern = new ImagePattern (img);
			ctx.Rectangle (0, 0, 100, 100);
			ctx.Fill ();
			ctx.Restore ();
			
			ctx.Restore ();
			
			// Setting pixels
			
			ctx.SetLineWidth (1);
			for (int i=0; i<50;i++) {
				for (var j=0; j<50;j++) {
					Color c = Color.FromHsl (0.5, (double)i / 50d, (double)j / 50d);
					ctx.Rectangle (i, j, 1, 1);
					ctx.SetColor (c);
					ctx.Fill ();
				}
			}
		}	
示例#31
0
		public virtual void Figures (Context ctx, double x, double y)
		{
			Lines (ctx);

			Rectangles (ctx, x, y + 20);
			Curves1 (ctx, x, y + 80);
			Curves2 (ctx, x + 100, y + 80);

			Path (ctx, x + 210, y + 20);
		}
示例#32
0
		protected override void OnDraw (Context ctx, Rectangle dirtyRect)
		{
			base.OnDraw (ctx, dirtyRect);
			
			for (int y = 0; y < img.Size.Height / 50; ++y) {
				for (int x = 0; x < img.Size.Width / 50; ++x) {
					ctx.DrawImage (img, new Rectangle (x*50, y*50, 50, 50), new Rectangle (x*55, y*55, 50, 50));
				}
			}
		}
示例#33
0
 protected override void OnDraw(Context ctx, Rectangle dirtyRect)
 {
     if (Window?.DrawRedDebugOutline ?? false)
     {
         ctx.SetColor(Colors.Blue);
         ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height);
         ctx.Stroke();
         ctx.SetColor(Colors.Black);
     }
 }
示例#34
0
        void InternalDraw(int markerStart, int markerEnd, TextEditor editor, Xwt.Drawing.Context cr, TextLayout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            if (markerStart >= markerEnd)
            {
                return;
            }
            double @from;
            double to;

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

                x_pos = layout.GetCoordinateFromIndex(start - startOffset).X;
                @from = startXPos + (int)(x_pos);

                x_pos = layout.GetCoordinateFromIndex(end - startOffset).X;

                to = startXPos + (int)(x_pos);
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from >= to)
            {
                return;
            }
            double height = editor.LineHeight / 5;

            if (selected)
            {
                cr.SetSourceColor(editor.ColorStyle.SelectedText.Foreground);
            }
            else
            {
                cr.SetSourceColor(ColorName == null ? Color : editor.ColorStyle.GetChunkStyle(ColorName).Foreground);
            }
            if (Wave)
            {
                //Pango.CairoHelper.ShowErrorUnderline(cr, @from, y + editor.LineHeight - height, to - @from, height);
            }
            else
            {
                cr.SetLineWidth(1);
                cr.MoveTo(@from, y + editor.LineHeight - 1.5);
                cr.LineTo(to, y + editor.LineHeight - 1.5);
                cr.Stroke();
            }
        }
示例#35
0
        public ImageBuilder(double width, double height)
        {
            backend = new VectorContextBackend (ToolkitEngine, width, height);

            // Don't set the global styles to the context. The global styles will be used when rendering the image
            ctx = new Context (backend, ToolkitEngine, ToolkitEngine.VectorImageRecorderContextHandler, false);

            ctx.Reset (null);
            this.width = width;
            this.height = height;
        }
示例#36
0
 void Draw(object ctx, Rectangle bounds, ImageDescription idesc, Toolkit toolkit)
 {
     var c = new Context (ctx, toolkit);
     if (idesc.Styles != StyleSet.Empty)
         c.SetStyles (idesc.Styles);
     c.Reset (null);
     c.Save ();
     c.GlobalAlpha = idesc.Alpha;
     OnDraw (c, bounds);
     c.Restore ();
 }
示例#37
0
 public override bool DrawBackground(TextEditor editor, Xwt.Drawing.Context cr, double y, LineMetrics metrics)
 {
     if (metrics.SelectionStart > 0)
     {
         return(true);
     }
     cr.SetSourceColor(color);
     cr.Rectangle(metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
     cr.Fill();
     return(true);
 }
示例#38
0
 void DrawGutterBackground(Xwt.Drawing.Context cr, int line, double x, double y, double lineHeight)
 {
     if (editor.Caret.Line == line)
     {
         editor.TextViewMargin.DrawCaretLineMarker(cr, x, y, Width, lineHeight);
         return;
     }
     cr.Rectangle(x, y, Width, lineHeight);
     cr.SetSourceColor(lineNumberBgGC);
     cr.Fill();
 }
示例#39
0
文件: Canvas.cs 项目: m13253/xwt
			public void OnDraw (object context, Rectangle dirtyRect)
			{
				Context ctx = null;
				try {
					ctx = new Context (context, ToolkitEngine);
					ctx.Reset (Parent);
					((Canvas)Parent).OnDraw (ctx, dirtyRect);
				}
				finally {
					ctx.Dispose ();
				}
			}
示例#40
0
        public override bool DrawBackground(TextEditor editor, Xwt.Drawing.Context cr, MarginDrawMetrics metrics)
        {
            var width = metrics.Width;

            cr.Rectangle(metrics.X, metrics.Y, metrics.Width, metrics.Height);
            var lineNumberGC = editor.ColorStyle.LineNumbers.Foreground;

            cr.SetSourceColor(editor.Caret.Line == metrics.LineNumber ? editor.ColorStyle.LineMarker.Color : lineNumberGC);
            cr.Fill();

            return(true);
        }
示例#41
0
 protected override void OnDraw(Context ctx, Rectangle dirtyRect)
 {
     ctx.SetColor(new Color(0.5, 0.5, 0.5));
     ctx.Rectangle(Bounds);
     ctx.Fill();
     ctx.SetColor(new Color(0.8, 0.8, 0.8));
     ctx.Rectangle(Bounds.Inflate(-margin, -margin));
     ctx.Fill();
     ctx.SetColor(highlight ? Color.BlendWith(Xwt.Drawing.Colors.White, 0.5) : Color);
     ctx.Rectangle(Bounds.Width / 2 - coreSize.Width / 2, Bounds.Height / 2 - coreSize.Height / 2, coreSize.Width, coreSize.Height);
     ctx.Fill();
 }
示例#42
0
		protected override void OnDraw (Context ctx, Rectangle cellArea)
		{
			PackageViewModel packageViewModel = GetValue (PackageField);
			if (packageViewModel == null) {
				return;
			}

			FillCellBackground (ctx);
			UpdateTextColor (ctx);

			DrawCheckBox (ctx, packageViewModel, cellArea);
			DrawPackageImage (ctx, cellArea);

			double packageIdWidth = cellArea.Width - packageDescriptionPadding.HorizontalSpacing - packageDescriptionLeftOffset;

			// Package download count.
			if (packageViewModel.HasDownloadCount) {
				var downloadCountTextLayout = new TextLayout ();
				downloadCountTextLayout.Text = packageViewModel.GetDownloadCountOrVersionDisplayText ();
				Size size = downloadCountTextLayout.GetSize ();
				Point location = new Point (cellArea.Right - packageDescriptionPadding.Right, cellArea.Top + packageDescriptionPadding.Top);
				Point downloadLocation = location.Offset (-size.Width, 0);
				ctx.DrawTextLayout (downloadCountTextLayout, downloadLocation);

				packageIdWidth = downloadLocation.X - cellArea.Left - packageIdRightHandPaddingWidth - packageDescriptionPadding.HorizontalSpacing - packageDescriptionLeftOffset;
			}

			// Package Id.
			var packageIdTextLayout = new TextLayout ();
			packageIdTextLayout.Font = packageIdTextLayout.Font.WithSize (12);
			packageIdTextLayout.Markup = packageViewModel.GetNameMarkup ();
			packageIdTextLayout.Trimming = TextTrimming.WordElipsis;
			Size packageIdTextSize = packageIdTextLayout.GetSize ();
			packageIdTextLayout.Width = packageIdWidth;
			ctx.DrawTextLayout (
				packageIdTextLayout,
				cellArea.Left + packageDescriptionPadding.Left + packageDescriptionLeftOffset,
				cellArea.Top + packageDescriptionPadding.Top);

			// Package description.
			var descriptionTextLayout = new TextLayout ();
			descriptionTextLayout.Font = descriptionTextLayout.Font.WithSize (11);
			descriptionTextLayout.Width = cellArea.Width - packageDescriptionPadding.HorizontalSpacing - packageDescriptionLeftOffset;
			descriptionTextLayout.Height = cellArea.Height - packageIdTextSize.Height - packageDescriptionPadding.VerticalSpacing;
			descriptionTextLayout.Text = packageViewModel.Summary;
			descriptionTextLayout.Trimming = TextTrimming.Word;

			ctx.DrawTextLayout (
				descriptionTextLayout,
				cellArea.Left + packageDescriptionPadding.Left + packageDescriptionLeftOffset,
				cellArea.Top + packageIdTextSize.Height + packageDescriptionPaddingHeight + packageDescriptionPadding.Top);
		}
示例#43
0
        protected override void OnDraw(Xwt.Drawing.Context cr, Rectangle bound)
        {
            {
                cr.Rectangle(bound.X, bound.Y, bound.Width, bound.Height);
                cr.SetSourceColor(editor.ColorStyle.PlainText.Background);
                cr.Fill();
                using (var layout = PangoUtil.CreateLayout(editor))
                {
                    layout.Font = editor.Options.Font;

                    layout.Text = "000,00-00";
                    var mins = layout.GetSize();

                    var line      = editor.GetLine(editor.Caret.Line);
                    var visColumn = line.GetVisualColumn(editor.GetTextEditorData(), editor.Caret.Column);

                    if (visColumn != editor.Caret.Column)
                    {
                        layout.Text = editor.Caret.Line + "," + editor.Caret.Column + "-" + visColumn;
                    }
                    else
                    {
                        layout.Text = editor.Caret.Line + "," + editor.Caret.Column;
                    }

                    var statuss = layout.GetSize();

                    statuss.Width = System.Math.Max(statuss.Width, mins.Width);

                    statuss.Width += 8;
                    cr.MoveTo(Size.Width - statuss.Width, 0);
                    statuss.Width += 8;
                    cr.SetSourceColor(editor.ColorStyle.PlainText.Foreground);
                    cr.ShowLayout(layout);

                    layout.Text = statusText ?? "";
                    var size = layout.GetSize();
                    var x    = System.Math.Min(0, -size.Width + Size.Width - editor.TextViewMargin.CharWidth - statuss.Width);
                    cr.MoveTo(x, 0);
                    cr.SetSourceColor(editor.ColorStyle.PlainText.Foreground);
                    cr.ShowLayout(layout);
                    if (ShowCaret)
                    {
                        if (editor.TextViewMargin.caretBlink)
                        {
                            cr.Rectangle(size.Width + x, 0, (int)editor.TextViewMargin.CharWidth, (int)editor.LineHeight);
                            cr.Fill();
                        }
                    }
                }
            }
        }
示例#44
0
		protected void InitBlank (int width = 50, int height = 50)
		{
			if (builder != null)
				builder.Dispose ();

			builder = new ImageBuilder (width, height);
			context = builder.Context;
			context.Rectangle (0, 0, width, height);
			context.SetColor (Colors.White);
			context.Fill ();
			context.SetColor (Colors.Black);
			context.SetLineWidth (1);
		}
示例#45
0
文件: ListView1.cs 项目: nbros/xwt
        protected override void OnDraw(Context ctx, Rectangle cellArea)
        {
            var pct = GetValue (ValueField);
            var size = (cellArea.Width * pct) / 100f;
            cellArea.Width = (int) size;

            ctx.SetLineWidth (1);
            ctx.Rectangle (cellArea.Inflate (-0.5, -0.5));
            ctx.SetColor (Colors.LightBlue);
            ctx.FillPreserve ();
            ctx.SetColor (Colors.Gray);
            ctx.Stroke ();
        }
示例#46
0
        public override bool DrawBackground(TextEditor editor, Xwt.Drawing.Context cr, double y, LineMetrics metrics)
        {
            var caretOffset = editor.Caret.Offset - BaseOffset;

            foreach (var 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 <= metrics.TextStartOffset && metrics.TextStartOffset < BaseOffset + segment.EndOffset) || (metrics.TextStartOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < metrics.TextEndOffset))
                    {
                        int strOffset    = BaseOffset + segment.Offset - metrics.TextStartOffset;
                        int strEndOffset = BaseOffset + segment.EndOffset - metrics.TextStartOffset;

                        var x_pos  = metrics.Layout.Layout.IndexToPos(strOffset).X;
                        var x_pos2 = metrics.Layout.Layout.IndexToPos(strEndOffset).X;

                        x_pos  = (int)(x_pos);
                        x_pos2 = (int)(x_pos2);
                        Color fillGc, rectangleGc;
                        if (segment == link.PrimaryLink)
                        {
                            fillGc      = isPrimaryHighlighted ? editor.ColorStyle.PrimaryTemplateHighlighted.SecondColor : editor.ColorStyle.PrimaryTemplate.SecondColor;
                            rectangleGc = isPrimaryHighlighted ? editor.ColorStyle.PrimaryTemplateHighlighted.SecondColor : editor.ColorStyle.PrimaryTemplate.SecondColor;
                        }
                        else
                        {
                            fillGc      = isPrimaryHighlighted ? editor.ColorStyle.SecondaryTemplateHighlighted.SecondColor : editor.ColorStyle.SecondaryTemplate.SecondColor;
                            rectangleGc = isPrimaryHighlighted ? editor.ColorStyle.SecondaryTemplateHighlighted.Color : editor.ColorStyle.SecondaryTemplate.Color;
                        }

                        // Draw segment
                        double x1 = metrics.TextRenderStartPosition + x_pos - 1;
                        double x2 = metrics.TextRenderStartPosition + x_pos2 - 1 + 0.5;

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

                        cr.SetSourceColor(fillGc);
                        cr.FillPreserve();

                        cr.SetSourceColor(rectangleGc);
                        cr.Stroke();
                    }
                }
            }
            return(true);
        }
示例#47
0
        protected void TestDrawing(Xwt.Drawing.Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x, y);

            var tl = new TextLayout(ctx);

            tl.Text  = "\nX\n";
            tl.Width = 200;

            new ReferencePainter().DrawText(ctx, tl, ref y);

            ctx.Restore();
        }
示例#48
0
        protected void TestDrawing2(Xwt.Drawing.Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x, y);
            var arcColor = new Color(1, 0, 1);

            ctx.Arc(100, 100, 15, 0, 360);
            ctx.ClosePath();
            arcColor.Alpha = 0.4;
            ctx.SetColor(arcColor);
            ctx.StrokePreserve();
            ctx.Fill();

            ctx.Restore();
        }
示例#49
0
        public virtual void Rotate(Xwt.Drawing.Context ctx, double x, double y)
        {
            // draws a line along the x-axis from (0,0) to (r,0) with a constant translation and an increasing
            // rotational component. This composite transform is then applied to a vertical line, with inverse
            // color, and an additional x-offset, to form a mirror image figure for easy visual comparison.
            // These transformed points must be drawn with the identity CTM, hence the Restore() each time.

            ctx.Save();                 // save caller's context (assumed to be the Identity CTM)
            ctx.SetLineWidth(3);        // should align exactly if drawn with half-pixel coordinates

            // Vector length (pixels) and rotation limit (degrees)
            double r   = 30;
            double end = 270;

            for (double n = 0; n <= end; n += 5)
            {
                ctx.Save();                     // save context and identity CTM for each line

                // Set up translation to centre point of first figure, ensuring pixel alignment
                ctx.Translate(x + 30.5, y + 30.5);
                ctx.Rotate(n);
                ctx.MoveTo(0, 0);
                ctx.RelLineTo(r, 0);
                double c = n / end;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();                   // stroke first figure with composite Translation and Rotation CTM

                // Generate mirror image figure as a visual test of TransformPoints
                Point   p0 = new Point(0, 0);
                Point   p1 = new Point(0, -r);
                Point[] p  = new Point[] { p0, p1 };
                ctx.TransformPoints(p);         // using composite transformation

                ctx.Restore();                  // restore identity CTM
                ctx.Save();                     // save again (to restore after additional Translation)

                ctx.Translate(2 * r + 1, 0);    // extra x-offset to clear first figure
                ctx.MoveTo(p[0]);
                ctx.LineTo(p[1]);
                c = 1 - c;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();           // stroke transformed points with offset in CTM

                ctx.Restore();          // restore identity CTM for next line
            }
            ctx.Restore();              // restore caller's context
        }
示例#50
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height);
            var g = new LinearGradient(0, 0, Bounds.Width, Bounds.Height);

            g.AddColorStop(0, new Color(1, 0, 0));
            g.AddColorStop(1, new Color(0, 1, 0));
            ctx.Pattern = g;
            ctx.Fill();

            Rectangle r = rect.Inflate(5, 5);

            ctx.Rectangle(r);
            ctx.SetColor(new Color(0, 0, 1));
            ctx.SetLineWidth(1);
            ctx.Stroke();
        }
示例#51
0
        public override void Draw(TextEditor editor, Xwt.Drawing.Context cr, double y, LineMetrics metrics)
        {
            var    startOffset = metrics.TextStartOffset;
            int    endOffset   = metrics.TextEndOffset;
            double startXPos   = metrics.TextRenderStartPosition;
            double endXPos     = metrics.TextRenderEndPosition;
            var    layout      = metrics.Layout.Layout;
            int    markerStart = line.Offset + startColumn;
            int    markerEnd   = line.Offset + endColumn;

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

            double @from;
            double to;

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

                int curIndex = 0, byteIndex = 0;
                var x_pos = layout.IndexToPos((int)metrics.Layout.TranslateToUTF8Index(start - startOffset, ref curIndex, ref byteIndex)).X;

                @from = startXPos + (int)(x_pos);

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

                to = startXPos + (int)(x_pos);
            }

            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (@from < to)
            {
                cr.DrawLine(editor.ColorStyle.GetForeground(editor.ColorStyle.GetChunkStyle(style)), @from + 0.5, y + editor.LineHeight - 1.5, to + 0.5, y + editor.LineHeight - 1.5);
            }
        }
示例#52
0
        protected override void OnDraw(Xwt.Drawing.Context ctx)
        {
            base.OnDraw(ctx);
            ctx.Translate(30, 30);
            double end = 270;

            for (double n = 0; n <= end; n += 5)
            {
                ctx.Save();
                ctx.Rotate(n);
                ctx.MoveTo(0, 0);
                ctx.RelLineTo(30, 0);
                double c = n / end;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();
                ctx.Restore();
            }
        }
示例#53
0
        internal protected override void Draw(Xwt.Drawing.Context ctx, Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
        {
            bool backgroundIsDrawn = false;

            if (lineSegment != null)
            {
                foreach (var marker in lineSegment.Markers)
                {
                    var marginMarker = marker as MarginMarker;
                    if (marginMarker != null && marginMarker.CanDrawBackground(this))
                    {
                        backgroundIsDrawn = marginMarker.DrawBackground(editor, ctx, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight));
                    }
                }
            }

            if (!backgroundIsDrawn)
            {
                ctx.Rectangle(x, y, Width, lineHeight);
                ctx.SetSourceColor(backgroundColor);
                ctx.Fill();

                ctx.MoveTo(x + Width - 0.5, y);
                ctx.LineTo(x + Width - 0.5, y + lineHeight);
                ctx.SetSourceColor(separatorColor);
                ctx.Stroke();
            }

            if (lineSegment != null && line <= editor.Document.LineCount)
            {
                foreach (var marker in lineSegment.Markers)
                {
                    var marginMarker = marker as MarginMarker;
                    if (marginMarker != null && marginMarker.CanDrawForeground(this))
                    {
                        marginMarker.DrawForeground(editor, ctx, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight));
                    }
                }
                if (DrawEvent != null)
                {
                    DrawEvent(this, new BookmarkMarginDrawEventArgs(editor, ctx, lineSegment, line, x, y));
                }
            }
        }
示例#54
0
        public override void Draw(TextEditor editor, Xwt.Drawing.Context cr, double y, LineMetrics metrics)
        {
            var    startOffset = metrics.TextStartOffset;
            int    endOffset   = metrics.TextEndOffset;
            double startXPos   = metrics.TextRenderStartPosition;
            double endXPos     = metrics.TextRenderEndPosition;
            var    layout      = metrics.Layout.Layout;

            int markerStart = LineSegment.Offset + System.Math.Max(StartCol - 1, 0);
            int markerEnd   = LineSegment.Offset + (EndCol < 1 ? LineSegment.Length : EndCol - 1);

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

            if (editor.IsSomethingSelected)
            {
                var range = editor.SelectionRange;
                if (range.Contains(markerStart))
                {
                    int end = System.Math.Min(markerEnd, range.EndOffset);
                    InternalDraw(markerStart, end, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.EndOffset, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    return;
                }
                if (range.Contains(markerEnd))
                {
                    InternalDraw(markerStart, range.Offset, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.Offset, markerEnd, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
                    return;
                }
                if (markerStart <= range.Offset && range.EndOffset <= markerEnd)
                {
                    InternalDraw(markerStart, range.Offset, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.Offset, range.EndOffset, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.EndOffset, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    return;
                }
            }

            InternalDraw(markerStart, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
        }
示例#55
0
        protected void TestDrawing1(Xwt.Drawing.Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x, y);

            var r = 5;
            var l = 10;
            var t = 10;
            var w = 50;
            var h = 30;


            // top left
            //ctx.Arc(l + r, t + r, r, 180, 270);
            ctx.Rectangle(l, t, w, h);
            ctx.SetColor(Colors.Black);
            ctx.Stroke();

            ctx.Restore();
        }
示例#56
0
        internal protected override void Draw(Xwt.Drawing.Context cr, Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
        {
            var gutterMarker = lineSegment != null ? (MarginMarker)lineSegment.Markers.FirstOrDefault(marker => marker is MarginMarker && ((MarginMarker)marker).CanDraw(this)) : null;

            if (gutterMarker != null && gutterMarker.CanDrawBackground(this))
            {
                bool hasDrawn = gutterMarker.DrawBackground(editor, cr, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight));
                if (!hasDrawn)
                {
                    DrawGutterBackground(cr, line, x, y, lineHeight);
                }
            }
            else
            {
                DrawGutterBackground(cr, line, x, y, lineHeight);
            }

            if (gutterMarker != null && gutterMarker.CanDrawForeground(this))
            {
                gutterMarker.DrawForeground(editor, cr, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight));
                return;
            }

            if (line <= editor.Document.LineCount)
            {
                // Due to a mac? gtk bug I need to re-create the layout here
                // otherwise I get pango exceptions.
                using (var layout = editor.LayoutCache.RequestLayout())
                {
                    layout.Font      = gutterFont;
                    layout.Width     = (int)Width;
                    layout.Alignment = Alignment.End;
                    layout.SetText(line.ToString());
                    cr.Save();
                    cr.Translate(x + (int)Width + (editor.Options.ShowFoldMargin ? 0 : -2), y);
                    cr.SetSourceColor(lineNumberGC);
                    cr.ShowLayout(layout);
                    cr.Restore();
                }
            }
        }
示例#57
0
        protected override void OnDraw(Xwt.Drawing.Context cr, Rectangle rect)
        {
            if (BorderVisible)
            {
                {
                    cr.SetLineWidth(1);

                    var alloc  = rect;
                    var right  = alloc.RightInside();
                    var bottom = alloc.BottomInside();

                    cr.SharpLineX(alloc.X, alloc.Y, alloc.X, bottom);
                    cr.SharpLineX(right, alloc.Y, right, bottom);

                    cr.SharpLineY(alloc.X, alloc.Y, right, alloc.Y);
                    cr.SharpLineY(alloc.X, bottom, right, bottom);

                    cr.SetColor(Colors.Gray);
                    cr.Stroke();
                }
            }
        }
示例#58
0
        public override void Draw(TextEditor editor, Xwt.Drawing.Context cr, TextLayout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            int markerStart = Segment.Offset;
            int markerEnd   = Segment.EndOffset;

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


            if (editor.IsSomethingSelected)
            {
                var range = editor.SelectionRange;
                if (range.Contains(markerStart))
                {
                    int end = System.Math.Min(markerEnd, range.EndOffset);
                    InternalDraw(markerStart, end, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.EndOffset, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    return;
                }
                if (range.Contains(markerEnd))
                {
                    InternalDraw(markerStart, range.Offset, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.Offset, markerEnd, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
                    return;
                }
                if (markerStart <= range.Offset && range.EndOffset <= markerEnd)
                {
                    InternalDraw(markerStart, range.Offset, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.Offset, range.EndOffset, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
                    InternalDraw(range.EndOffset, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
                    return;
                }
            }

            InternalDraw(markerStart, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
        }
示例#59
0
        public override void DrawForeground(TextEditor editor, Xwt.Drawing.Context cr, MarginDrawMetrics metrics)
        {
            var width          = metrics.Width;
            var lineNumberBgGC = editor.ColorStyle.LineNumbers.Background;

            if (metrics.LineNumber <= editor.Document.LineCount)
            {
                // Due to a mac? gtk bug I need to re-create the layout here
                // otherwise I get pango exceptions.
                using (var layout = PangoUtil.CreateLayout(editor))
                {
                    layout.Font          = editor.Options.Font;
                    layout.Width         = (int)width;
                    layout.TextAlignment = Alignment.End;
                    layout.Text          = metrics.LineNumber.ToString();
                    cr.Save();
                    cr.Translate(metrics.X + (int)width + (editor.Options.ShowFoldMargin ? 0 : -2), metrics.Y);
                    cr.SetSourceColor(lineNumberBgGC);
                    cr.ShowLayout(layout);
                    cr.Restore();
                }
            }
        }
示例#60
0
        public virtual void Rotate(Xwt.Drawing.Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x + 30, y + 30);
            ctx.SetLineWidth(3);

            // Rotation

            double end = 270;
            double r   = 30;

            for (double n = 0; n <= end; n += 5)
            {
                ctx.Save();
                ctx.Rotate(n);
                ctx.MoveTo(0, 0);
                ctx.RelLineTo(r, 0);
                double c = n / end;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();

                // Visual test for TransformPoints
                Point   p0 = new Point(0, 0);
                Point   p1 = new Point(0, -r);
                Point[] p  = new Point[] { p0, p1 };
                ctx.TransformPoints(p);
                ctx.ResetTransform();
                ctx.Translate(2 * r + 1, 0);
                ctx.MoveTo(p[0]);
                ctx.LineTo(p[1]);
                c = 1 - c;
                ctx.SetColor(new Color(c, c, c));
                ctx.Stroke();
                ctx.Restore();
            }
            ctx.Restore();
        }