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));
		}
Example #2
0
			protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g)
			{
				g.Rectangle (0, 0, Allocation.Width, Allocation.Height);
				g.SetSourceColor (marker.TooltipColor.Color);
				g.Fill ();

				using (var drawingLayout = new Pango.Layout (this.PangoContext)) {
					drawingLayout.FontDescription = cache.tooltipFontDescription;

					double y = verticalTextBorder;
					var showBulletedList = marker.Errors.Count > 1;

					foreach (var msg in marker.Errors) {
						var icon = msg.IsError ? errorPixbuf : warningPixbuf;
						int w, h;

						if (!showBulletedList)
							drawingLayout.Width = maxTextWidth;

						drawingLayout.SetText (GetFirstLine (msg));
						drawingLayout.GetPixelSize (out w, out h);

						if (showBulletedList) {
							g.Save ();

							g.Translate (textBorder, y + verticalTextSpace / 2 + Math.Max (0, (h - icon.Height) / 2));
							g.DrawImage (this, icon, 0, 0);
							g.Restore ();
						}

						g.Save ();

						g.Translate (showBulletedList ? textBorder + iconTextSpacing + icon.Width: textBorder, y + verticalTextSpace / 2);
						g.SetSourceColor (marker.TagColor.SecondColor);
						g.ShowLayout (drawingLayout);

						g.Restore ();

						y += h + verticalTextSpace;
					}
				}
			}
		void DrawChangeSymbol (Cairo.Context ctx, Widget widget, double x, int width, BlockInfo block)
		{
			if (!IsChangeBlock (block.Type))
				return;

			if (block.Type == BlockType.Added) {
				var ix = x + (LeftPaddingBlock/2) - (gutterAdded.Width / 2);
				var iy = block.YStart + ((block.YEnd - block.YStart) / 2 - gutterAdded.Height / 2);
				ctx.DrawImage (widget, gutterAdded, ix, iy);
			} else {
				var ix = x + (LeftPaddingBlock/2) - (gutterRemoved.Width / 2);
				var iy = block.YStart + ((block.YEnd - block.YStart) / 2 - gutterRemoved.Height / 2);
				ctx.DrawImage (widget, gutterRemoved, ix, iy);
			}
		}
Example #4
0
		void RenderIcon (Cairo.Context context, Xwt.Drawing.Image surface, double opacity)
		{
			context.DrawImage (this, surface.WithAlpha (opacity),
			                          Allocation.X + (Allocation.Width - surface.Width) / 2,
			                          Allocation.Y + (Allocation.Height - surface.Height) / 2);
		}
		protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context context)
		{
			context.LineWidth = 1;
			var alloc = ChildAllocation;
			var adjustedMarginSize = alloc.X - Allocation.X  + headerMarginSize;

			var r = results.Where (res => res.Item2.ItemCount > 0).ToArray ();
			if (r.Any ()) {
				context.SetSourceColor (lightSearchBackground);
				context.Rectangle (Allocation.X, Allocation.Y, adjustedMarginSize, Allocation.Height);
				context.Fill ();

				context.SetSourceColor (darkSearchBackground);
				context.Rectangle (Allocation.X + adjustedMarginSize, Allocation.Y, Allocation.Width - adjustedMarginSize, Allocation.Height);
				context.Fill ();
				context.MoveTo (0.5 + Allocation.X + adjustedMarginSize, 0);
				context.LineTo (0.5 + Allocation.X + adjustedMarginSize, Allocation.Height);
				context.SetSourceColor (separatorLine);
				context.Stroke ();
			} else {
				context.SetSourceRGB (1, 1, 1);
				context.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
				context.Fill ();
			}

			double y = alloc.Y + yMargin;
			int w, h;
			if (topItem != null) {
				headerLayout.SetText (GettextCatalog.GetString ("Top Result"));
				headerLayout.GetPixelSize (out w, out h);
				context.MoveTo (alloc.Left + headerMarginSize - w - xMargin, y);
				context.SetSourceColor (headerColor);
				Pango.CairoHelper.ShowLayout (context, headerLayout);

				var category = topItem.Category;
				var dataSrc = topItem.DataSource;
				var i = topItem.Item;

				double x = alloc.X + xMargin + headerMarginSize;
				context.SetSourceRGB (0, 0, 0);
				layout.SetMarkup (GetRowMarkup (dataSrc, i));
				layout.GetPixelSize (out w, out h);
				if (selectedItem != null && selectedItem.Category == category && selectedItem.Item == i) {
					context.SetSourceColor (selectionBackgroundColor);
					context.Rectangle (alloc.X + headerMarginSize, y, Allocation.Width - adjustedMarginSize, h);
					context.Fill ();
					context.SetSourceRGB (1, 1, 1);
				}

				var px = dataSrc.GetIcon (i);
				if (px != null) {
					context.DrawImage (this, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2);
					x += px.Width + iconTextSpacing + marginIconSpacing;
				}

				context.MoveTo (x, y);
				context.SetSourceRGB (0, 0, 0);
				Pango.CairoHelper.ShowLayout (context, layout);

				y += h + itemSeparatorHeight;

			}

			foreach (var result in r) {
				var category = result.Item1;
				var dataSrc = result.Item2;
				if (dataSrc.ItemCount == 0)
					continue;
				if (dataSrc.ItemCount == 1 && topItem != null && topItem.DataSource == dataSrc)
					continue;
				headerLayout.SetText (category.Name);
				headerLayout.GetPixelSize (out w, out h);

				if (y + h > Allocation.Height)
					break;

				context.MoveTo (alloc.X + headerMarginSize - w - xMargin, y);
				context.SetSourceColor (headerColor);
				Pango.CairoHelper.ShowLayout (context, headerLayout);

				layout.Width = Pango.Units.FromPixels (Allocation.Width - adjustedMarginSize - 35);

				for (int i = 0; i < maxItems && i < dataSrc.ItemCount; i++) {
					if (topItem != null && topItem.Category == category && topItem.Item == i)
						continue;
					double x = alloc.X + xMargin + headerMarginSize;
					context.SetSourceRGB (0, 0, 0);
					layout.SetMarkup (GetRowMarkup (dataSrc, i));
					layout.GetPixelSize (out w, out h);
					if (y + h + itemSeparatorHeight > Allocation.Height)
						break;
					if (selectedItem != null && selectedItem.Category == category && selectedItem.Item == i) {
						context.SetSourceColor (selectionBackgroundColor);
						context.Rectangle (alloc.X + headerMarginSize, y, Allocation.Width - adjustedMarginSize, h);
						context.Fill ();
						context.SetSourceRGB (1, 1, 1);
					}

					var px = dataSrc.GetIcon (i);
					if (px != null) {
						context.DrawImage (this, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2);
						x += px.Width + iconTextSpacing + marginIconSpacing;
					}

					context.MoveTo (x, y);
					context.SetSourceRGB (0, 0, 0);
					Pango.CairoHelper.ShowLayout (context, layout);

					y += h + itemSeparatorHeight;
				}
				if (result != r.Last ()) {
					y += categorySeparatorHeight;
				}
			}
			if (y == alloc.Y + yMargin) {
				context.SetSourceRGB (0, 0, 0);
				layout.SetMarkup (isInSearch ? GettextCatalog.GetString ("Searching...") : GettextCatalog.GetString ("No matches"));
				context.MoveTo (alloc.X + xMargin, y);
				Pango.CairoHelper.ShowLayout (context, layout);
			}
		}
		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 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));
			}
		}
 protected virtual void DrawIcon(Cairo.Context ctx)
 {
     int x = Allocation.X + InternalPadding;
     int y = Allocation.Y + (Allocation.Height - (int)icon.Height) / 2;
     ctx.DrawImage (this, icon, x, y);
     if (AllowPinning && (mouseOver || pinned)) {
         Xwt.Drawing.Image star;
         if (pinned) {
             if (mouseOverStar)
                 star = starPinnedHover;
             else
                 star = starPinned;
         }
         else {
             if (mouseOverStar)
                 star = starNormalHover;
             else
                 star = starNormal;
         }
         x = x + (int)icon.Width - (int)star.Width + 3;
         y = y + (int)icon.Height - (int)star.Height + 3;
         ctx.DrawImage (this, star, x, y);
         starRect = new Gdk.Rectangle (x, y, (int)star.Width, (int)star.Height);
     }
 }
Example #9
0
        void Draw(Cairo.Context ctx, List<TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
                return;

            Pango.Layout layout = new Pango.Layout (PangoContext);
            TableRow lastCategory = null;

            foreach (var r in rowList) {
                int w,h;
                layout.SetText (r.Label);
                layout.GetPixelSize (out w, out h);
                int indent = 0;

                if (r.IsCategory) {
                    var rh = h + CategoryTopBottomPadding*2;
                    ctx.Rectangle (0, y, Allocation.Width, rh);
                    using (var gr = new LinearGradient (0, y, 0, rh)) {
                        gr.AddColorStop (0, new Cairo.Color (248d/255d, 248d/255d, 248d/255d));
                        gr.AddColorStop (1, new Cairo.Color (240d/255d, 240d/255d, 240d/255d));
                        ctx.SetSource (gr);
                        ctx.Fill ();
                    }

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand) {
                        ctx.MoveTo (0, y + 0.5);
                        ctx.LineTo (Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo (0, y + rh - 0.5);
                    ctx.LineTo (Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceColor (DividerColor);
                    ctx.Stroke ();

                    ctx.MoveTo (x, y + CategoryTopBottomPadding);
                    ctx.SetSourceColor (CategoryLabelColor);
                    Pango.CairoHelper.ShowLayout (ctx, layout);

                    var img = r.Expanded ? discloseUp : discloseDown;
                    ctx.DrawImage (this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round ((rh - img.Height) / 2));

                    y += rh;
                    lastCategory = r;
                }
                else {
                    var cell = GetCell (r);
                    r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save ();
                    ctx.Rectangle (0, y, dividerX, h + PropertyTopBottomPadding*2);
                    ctx.Clip ();
                    ctx.MoveTo (x, y + PropertyTopBottomPadding);
                    ctx.SetSourceColor (Style.Text (state).ToCairoColor ());
                    Pango.CairoHelper.ShowLayout (ctx, layout);
                    ctx.Restore ();

                    if (r != currentEditorRow)
                        cell.Render (GdkWindow, ctx, r.EditorBounds, state);

                    y += r.EditorBounds.Height;
                    indent = PropertyIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand)) {
                    int py = y;

                    ctx.Save ();
                    if (r.AnimatingExpand)
                        ctx.Rectangle (0, y, Allocation.Width, r.AnimationHeight);
                    else
                        ctx.Rectangle (0, 0, Allocation.Width, Allocation.Height);

                    ctx.Clip ();
                    Draw (ctx, r.ChildRows, dividerX, x + indent, ref y);
                    ctx.Restore ();

                    if (r.AnimatingExpand) {
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle (0, y, dx, Allocation.Height - y);
                        ctx.SetSourceColor (LabelBackgroundColor);
                        ctx.Fill ();
                        ctx.Rectangle (dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceRGB (1, 1, 1);
                        ctx.Fill ();
                    }
                }
            }
        }
		void DrawIndicator (Cairo.Context cr, Xwt.Drawing.Image img)
		{
			cr.DrawImage (this, img, Math.Round ((Allocation.Width - img.Width) / 2), -1);
		}
Example #11
0
		void RenderPreview (Cairo.Context context, Gdk.Point position, double opacity)
		{
			if (brandedIcon != null) {
				/*				if (previewSurface == null) {
					previewSurface = new SurfaceWrapper (context, brandedIcon);
				}
				double scale = PreviewSize / previewSurface.Width;

				context.Save ();
				context.Translate (position.X, position.Y);
				context.Scale (scale * IconScale, scale * IconScale);
				context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2);
				context.PaintWithAlpha (opacity);
				context.Restore ();
				*/

				double scale = PreviewSize / brandedIcon.Width;
				context.Save ();
				context.Translate (position.X, position.Y);
				context.Scale (scale * IconScale, scale * IconScale);
				context.DrawImage (this, brandedIcon.WithAlpha (opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2);
				context.Restore ();
			}
		}
		public void Render (Cairo.Context context, StatusArea.RenderArg arg, Gtk.Widget widget)
		{
			context.CachedDraw (surface: ref backgroundSurface, 
			                    region: arg.Allocation,
			                    draw: (c, o) => DrawBackground (c, new Gdk.Rectangle (0, 0, arg.Allocation.Width, arg.Allocation.Height)));

			if (arg.BuildAnimationOpacity > 0.001f)
				DrawBuildEffect (context, arg.Allocation, arg.BuildAnimationProgress, arg.BuildAnimationOpacity);

			if (arg.ErrorAnimationProgress > 0.001 && arg.ErrorAnimationProgress < .999) {
				DrawErrorAnimation (context, arg);
			}

			DrawBorder (context, arg.Allocation);

			if (arg.HoverProgress > 0.001f)
			{
				context.Clip ();
				int x1 = arg.Allocation.X + arg.MousePosition.X - 200;
				int x2 = x1 + 400;
				using (Cairo.LinearGradient gradient = new LinearGradient (x1, 0, x2, 0))
				{
					Cairo.Color targetColor = Styles.StatusBarFill1Color;
					Cairo.Color transparentColor = targetColor;
					targetColor.A = .7;
					transparentColor.A = 0;

					targetColor.A = .7 * arg.HoverProgress;

					gradient.AddColorStop (0.0, transparentColor);
					gradient.AddColorStop (0.5, targetColor);
					gradient.AddColorStop (1.0, transparentColor);

					context.SetSource (gradient);

					context.Rectangle (x1, arg.Allocation.Y, x2 - x1, arg.Allocation.Height);
					context.Fill ();
				}
				context.ResetClip ();
			} else {
				context.NewPath ();
			}

			int progress_bar_x = arg.ChildAllocation.X;
			int progress_bar_width = arg.ChildAllocation.Width;

			if (arg.CurrentPixbuf != null) {
				int y = arg.Allocation.Y + (arg.Allocation.Height - (int)arg.CurrentPixbuf.Size.Height) / 2;
				context.DrawImage (widget, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
				progress_bar_x += (int)arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
				progress_bar_width -= (int)arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
			}

			int center = arg.Allocation.Y + arg.Allocation.Height / 2;

			Gdk.Rectangle progressArea = new Gdk.Rectangle (progress_bar_x, center - Styles.ProgressBarHeight / 2, progress_bar_width, Styles.ProgressBarHeight);
			if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0) {
				DrawProgressBar (context, arg.ProgressBarFraction, progressArea, arg);
				ClipProgressBar (context, progressArea);
			}

			int text_x = progress_bar_x + Styles.ProgressBarInnerPadding;
			int text_width = progress_bar_width - (Styles.ProgressBarInnerPadding * 2);

			double textTweenValue = arg.TextAnimationProgress;

			if (arg.LastText != null) {
				double opacity = Math.Max (0.0f, 1.0f - textTweenValue);
				DrawString (arg.LastText, arg.LastTextIsMarkup, context, text_x, 
				            center - (int)(textTweenValue * arg.Allocation.Height * 0.3), text_width, opacity, arg.Pango, arg);
			}

			if (arg.CurrentText != null) {
				DrawString (arg.CurrentText, arg.CurrentTextIsMarkup, context, text_x, 
				            center + (int)((1.0f - textTweenValue) * arg.Allocation.Height * 0.3), text_width, Math.Min (textTweenValue, 1.0), arg.Pango, arg);
			}

			if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
				context.ResetClip ();
		}
Example #13
0
		void DrawBackground (Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
		{
			int x = region.X + region.Width / 2;
			int y = region.Y + region.Height / 2;

			var img = btnNormal;
			switch (state) {
			case StateType.Insensitive:
				img = btnInactive; break;
			case StateType.Prelight:
				img = btnHover; break;
			case StateType.Selected:
				img = btnPressed; break;
			}

			x -= (int) img.Width / 2;
			y -= (int) img.Height / 2;

			context.DrawImage (this, img, x, y);
		}
			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));
				}
			}
Example #15
0
		protected void DrawImage (Cairo.Context cr, Image image, double x, double y, double size)
		{
			var deltaX = size / 2 - image.Width / 2 + 0.5f;
			var deltaY = size / 2 - image.Height / 2 + 0.5f;

			cr.DrawImage (Editor, image, Math.Round (x + deltaX), Math.Round (y + deltaY));
		}
		void RenderBackground (Cairo.Context context, Gdk.Rectangle region)
		{
			region.Inflate (-Padding, -Padding);
			context.RenderOuterShadow (new Gdk.Rectangle (region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25);

			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5);
			using (var lg = new LinearGradient (0, region.Y, 0, region.Bottom)) {
				lg.AddColorStop (0, new Cairo.Color (.36, .53, .73));
				lg.AddColorStop (1, new Cairo.Color (.21, .37, .54));

				context.SetSource (lg);
				context.FillPreserve ();
			}

			context.Save ();
			context.Translate (IconPosition.X, IconPosition.Y);
			context.Scale (0.75, 0.75);
			context.DrawImage (this, starburst, -starburst.Width / 2, -starburst.Height / 2);
			context.Restore ();

			context.LineWidth = 1;
			context.SetSourceRGB (.29, .47, .67);
			context.Stroke ();

		}