예제 #1
0
 public override void DrawForeground(MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
 {
     if (DrawBookmarkFunc != null)
     {
         DrawBookmarkFunc(editor, cr, LineSegment, metrics.X, metrics.Y, metrics.Width, metrics.Height);
     }
 }
		public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			double size = metrics.Margin.Width;
			double borderLineWidth = cr.LineWidth;

			double x = Math.Floor (metrics.Margin.XOffset - borderLineWidth / 2);
			double y = Math.Floor (metrics.Y + (metrics.Height - size) / 2);

			DrawMarginIcon (cr, x, y, size);
		}
예제 #3
0
파일: IconMargin.cs 프로젝트: wjohnke/CSS18
        internal protected override void Draw(Cairo.Context cr, Cairo.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double lineHeight)
        {
            bool backgroundIsDrawn = false;

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

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

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

            if (line != null && lineNumber <= editor.Document.LineCount)
            {
                foreach (var marker in editor.Document.GetMarkersOrderedByInsertion(line))
                {
                    var marginMarker = marker as MarginMarker;
                    if (marginMarker != null && marginMarker.CanDrawForeground(this))
                    {
                        var metrics = new MarginDrawMetrics(this, area, line, lineNumber, x, y, lineHeight);
                        marginMarker.DrawForeground(editor, cr, metrics);

                        if (markerToAccessible != null)
                        {
                            var accessible = markerToAccessible [marker];
                            if (accessible != null)
                            {
                                accessible.Metrics = metrics;
                                accessible.UpdateAccessibilityDetails();
                            }
                        }
                    }
                }
                if (DrawEvent != null)
                {
                    DrawEvent(this, new BookmarkMarginDrawEventArgs(editor, cr, line, lineNumber, x, y));
                }
            }
        }
예제 #4
0
        public override bool DrawBackground(MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
        {
            var width = metrics.Width;

            cr.Rectangle(metrics.X, metrics.Y, metrics.Width, metrics.Height);
            var lineNumberGC = SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbers);

            cr.SetSourceColor(editor.Caret.Line == metrics.LineNumber ? SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineHighlight) : lineNumberGC);
            cr.Fill();

            return(true);
        }
예제 #5
0
        public override bool DrawBackground(MonoTextEditor editor, Cairo.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);
        }
예제 #6
0
		public override void DrawForeground (MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			double size = metrics.Margin.Width;
			double borderLineWidth = cr.LineWidth;

			double x = Math.Floor (metrics.Margin.XOffset - borderLineWidth / 2);
			double y = Math.Floor (metrics.Y + (metrics.Height - size) / 2);

			var deltaX = size / 2 - DebugIcon.Width / 2 + 0.5f;
			var deltaY = size / 2 - DebugIcon.Height / 2 + 0.5f;

			cr.DrawImage (editor, DebugIcon, Math.Round (x + deltaX), Math.Round (y + deltaY));
		}
        public override void DrawForeground(TextEditor editor, 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 = new TextLayout(editor.TextArea)) {
                    layout.Font  = editor.Options.Font;
                    layout.Width = (int)width;
                    //layout.Alignment = Pango.Alignment.Right;
                    layout.Text = metrics.LineNumber.ToString();
                    cr.Save();
                    cr.SetColor(lineNumberBgGC);
                    cr.DrawTextLayout(layout, metrics.X + (int)width + (editor.Options.ShowFoldMargin ? 0 : -2), metrics.Y);
                    cr.Restore();
                }
            }
        }
예제 #8
0
        public override void DrawForeground(MonoTextEditor editor, Cairo.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.FontDescription = editor.Options.Font;
                    layout.Width           = (int)width;
                    layout.Alignment       = Pango.Alignment.Right;
                    layout.SetText(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();
                }
            }
        }
		public override void DrawForeground (MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			var tx = Math.Round (metrics.X + (metrics.Width - cache.errorPixbuf.Width) / 2) - 1;
			var ty = Math.Floor (metrics.Y + (metrics.Height - cache.errorPixbuf.Height) / 2);

			cr.Save ();
			cr.Translate (tx, ty);
			cr.DrawImage (editor, errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0);
			cr.Restore ();
		}
		public override bool DrawBackground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			if (metrics.Margin is FoldMarkerMargin || metrics.Margin is GutterMargin || metrics.Margin is ActionMargin)
				return DrawMarginBackground (editor, metrics.Margin, cr, metrics.Area, lineSegment, metrics.LineNumber, metrics.X, metrics.Y, metrics.Height);
			if (metrics.Margin is IconMargin) {
				DrawIconMarginBackground (editor, cr, metrics);
				return true;
			}
			return false;
		}
		public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			cr.Save ();
			cr.Translate (
				metrics.X + 0.5 + (metrics.Width - 2 - cache.errorPixbuf.Width) / 2,
				metrics.Y + 0.5 + (metrics.Height - cache.errorPixbuf.Height) / 2
				);
			Gdk.CairoHelper.SetSourcePixbuf (
				cr,
				errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0);
			cr.Paint ();
			cr.Restore ();

		}
		void DrawIconMarginBackground (TextEditor ed, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			cr.Rectangle (metrics.X, metrics.Y, metrics.Width, metrics.Height);
			cr.SetSourceColor (IconMarginColor.Color);
			cr.Fill ();
			cr.MoveTo (metrics.Right - 0.5, metrics.Y);
			cr.LineTo (metrics.Right - 0.5, metrics.Bottom);
			cr.SetSourceColor (IconMarginColor.BorderColor);
			cr.Stroke ();
			if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) {
				cr.Rectangle (metrics.X, metrics.Y, metrics.Width, metrics.Height);
				cr.SetSourceRGBA (ed.ColorStyle.IndicatorMargin.Color.R, ed.ColorStyle.IndicatorMargin.Color.G, ed.ColorStyle.IndicatorMargin.Color.B, 0.5);
				cr.Fill ();
			}
		}
예제 #13
0
 public override void DrawForeground(TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
 {
     DrawIcon(editor, cr, LineSegment, metrics.X, metrics.Y, metrics.Width, metrics.Height);
 }
예제 #14
0
		public override void DrawForeground (MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			DrawBookmarkFunc (editor, cr, LineSegment, metrics.X, metrics.Y, metrics.Width, metrics.Height);
		}
예제 #15
0
		/// <summary>
		/// Draws the background of the specified margin.
		/// </summary>
		/// <returns>true, if the background is drawn. false if the margin should fallback to the default background renderer. </returns>
		public virtual bool DrawBackground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			return false;
		}
예제 #16
0
		/// <summary>
		/// Draws the foreground of the specified margin.
		/// </summary>
		public virtual void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
		}
예제 #17
0
 public override void DrawForeground(TextEditor editor, Xwt.Drawing.Context cr, MarginDrawMetrics metrics)
 {
     DrawBookmarkFunc(editor, cr, LineSegment, metrics.X, metrics.Y, metrics.Width, metrics.Height);
 }
예제 #18
0
		public override void DrawForeground (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			isFailed = false;
			bool searchCases = false;

			Xwt.Drawing.Image icon = host.GetStatusIcon (unitTest.UnitTestIdentifier);
			if (icon != null) {
				if (host.HasResult (unitTest.UnitTestIdentifier)) {
					searchCases = true;
				} else if (host.IsFailure (unitTest.UnitTestIdentifier)) {
					failMessage = host.GetMessage (unitTest.UnitTestIdentifier);
					isFailed = true;
				}
			} else {
				searchCases = true;
			}

			if (searchCases) {
				foreach (var caseId in unitTest.TestCases) {
					icon = host.GetStatusIcon (unitTest.UnitTestIdentifier, caseId);
					if (host.IsFailure (unitTest.UnitTestIdentifier, caseId)) {
						failMessage = host.GetMessage (unitTest.UnitTestIdentifier, caseId);
						isFailed = true;
						break;
					} 
				}
			}

			if (icon != null) {
				if (icon.Width > metrics.Width || icon.Height > metrics.Height)
					icon = icon.WithBoxSize (metrics.Width, metrics.Height);
				cr.DrawImage (editor, icon, Math.Truncate (metrics.X + metrics.Width / 2 - icon.Width / 2), Math.Truncate (metrics.Y + metrics.Height / 2 - icon.Height / 2));
			}
		}
			public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
			{
				isFailed = false;
				var test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier);
				bool searchCases = false;

				Xwt.Drawing.Image icon = null;

				if (test != null) {
					icon = test.StatusIcon;
					var result = test.GetLastResult ();
					if (result == null) {
						searchCases = true;
					} else if (result.IsFailure) {
						failMessage = result.Message;
						isFailed = true;
					}
				} else {
					searchCases = true;
				}

				if (searchCases) {
					foreach (var caseId in unitTest.TestCases) {
						test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier + caseId);
						if (test != null) {
							icon = test.StatusIcon;
							var result = test.GetLastResult ();
							if (result != null && result.IsFailure) {
								failMessage = result.Message;
								isFailed = true;
								break;
							} 
						}
					}
				}

				if (icon != null) {
					if (icon.Width > metrics.Width || icon.Height > metrics.Height)
						icon = icon.WithBoxSize (metrics.Width, metrics.Height);
					cr.DrawImage (editor, icon, Math.Truncate (metrics.X + metrics.Width / 2 - icon.Width / 2), Math.Truncate (metrics.Y + metrics.Height / 2 - icon.Height / 2));
				}
			}
예제 #20
0
 /// <summary>
 /// Draws the background of the specified margin.
 /// </summary>
 /// <returns>true, if the background is drawn. false if the margin should fallback to the default background renderer. </returns>
 public virtual bool DrawBackground(TextEditor editor, Context cr, MarginDrawMetrics metrics)
 {
     return(false);
 }
예제 #21
0
 /// <summary>
 /// Draws the foreground of the specified margin.
 /// </summary>
 public virtual void DrawForeground(TextEditor editor, Context cr, MarginDrawMetrics metrics)
 {
 }
			public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
			{
				cr.Arc (metrics.X + metrics.Width / 2 + 2, metrics.Y + metrics.Height / 2, 7 * editor.Options.Zoom, 0, Math.PI * 2);
				isFailed = false;
				var test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier);
				bool searchCases = false;

				if (unitTest.IsIgnored) {
					cr.SetSourceRGB (0.9, 0.9, 0);
				} else {

					if (test != null) {
						var result = test.GetLastResult ();
						if (result == null) {
							cr.SetSourceRGB (0.5, 0.5, 0.5);
							searchCases = true;

						} else if (result.IsNotRun) {
							cr.SetSourceRGBA (0.9, 0.9, 0, test.IsHistoricResult ? 0.5 : 1.0);
						} else if (result.IsSuccess) {
							cr.SetSourceRGBA (0, 1, 0, test.IsHistoricResult ? 0.2 : 1.0);
						} else if (result.IsFailure) {
							cr.SetSourceRGBA (1, 0, 0, test.IsHistoricResult ? 0.2 : 1.0);
							failMessage = result.Message;
							isFailed = true;
						} else if (result.IsInconclusive) {
							cr.SetSourceRGBA (0, 1, 1, test.IsHistoricResult ? 0.2 : 1.0);
						} else {
							cr.SetSourceRGB (0.5, 0.5, 0.5);
						}
					} else {
						cr.SetSourceRGB (0.5, 0.5, 0.5);
						searchCases = true;
					}
					if (searchCases) {
						foreach (var caseId in unitTest.TestCases) {
							test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier + caseId);
							if (test != null) {
								var result = test.GetLastResult ();
								if (result == null || result.IsNotRun || test.IsHistoricResult) {
								} else if (result.IsNotRun) {
									cr.SetSourceRGB (0.9, 0.9, 0);
								} else if (result.IsSuccess) {
									cr.SetSourceRGB (0, 1, 0);
								} else if (result.IsFailure) {
									cr.SetSourceRGB (1, 0, 0);
									failMessage = result.Message;
									isFailed = true;
									break;
								} else if (result.IsInconclusive) {
									cr.SetSourceRGB (0, 1, 1);
								} 
							}
						}
					}
				}

				cr.FillPreserve ();
				if (unitTest.IsIgnored) {
					cr.SetSourceRGB (0.4, 0.4, 0);
					cr.Stroke ();

				} else {
					if (test != null) {
						var result = test.GetLastResult ();
						if (result == null) {
							cr.SetSourceRGB (0.2, 0.2, 0.2);
							cr.Stroke ();
						} else if (result.IsNotRun && !test.IsHistoricResult) {
							cr.SetSourceRGB (0.4, 0.4, 0);
							cr.Stroke ();
						} else if (result.IsSuccess && !test.IsHistoricResult) {
							cr.SetSourceRGB (0, 0.5, 0);
							cr.Stroke ();
						} else if (result.IsFailure && !test.IsHistoricResult) {
							cr.SetSourceRGB (0.5, 0, 0);
							cr.Stroke ();
						} else if (result.IsInconclusive && !test.IsHistoricResult) {
							cr.SetSourceRGB (0, 0.7, 0.7);
							cr.Stroke ();
						} 
					}
				}
				cr.NewPath ();
			}