Пример #1
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));
		}
Пример #2
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            if (!Sensitive)
            {
                ctx.GlobalAlpha = .5d;
            }
            if (image == null)
            {
                ctx.SetColor(bg);
                ctx.Rectangle(dirtyRect);
                ctx.Fill();
            }
            else
                ctx.DrawImage(image, new Rectangle(0, 0, WidthRequest, HeightRequest));

            if (mOver && Sensitive)
            {
                ctx.SetColor(mOverColor);
                ctx.Rectangle(dirtyRect);
                ctx.Fill();
            }

            if (mDown)
            {
                ctx.SetColor(mOverColor);
                ctx.Rectangle(dirtyRect);
                ctx.Fill();
            }

            //ctx.SetColor(Colors.Red);
            //ctx.Rectangle(0, 0, WidthRequest, HeightRequest);
            //ctx.Stroke();
        }
Пример #3
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);
        }
Пример #4
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;

            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
 void ICanvasCellViewFrontend.Draw(object ctxBackend, Rectangle cellArea)
 {
     using (var ctx = new Context (ctxBackend, Toolkit.CurrentEngine)) {
         ctx.Reset (null);
         OnDraw (ctx, cellArea);
     }
 }
Пример #6
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));
        }
        TextLayout DrawText(Context ctx, Xwt.Rectangle cellArea, double x, string text, double padding, Font font, double width = 0, TextTrimming trimming = TextTrimming.WordElipsis, bool underline = false)
        {
            if (width < 0)
            {
                throw new Exception("width cannot be negative");
            }

            var descriptionTextLayout = new TextLayout();

            descriptionTextLayout.Font     = font;
            descriptionTextLayout.Text     = text;
            descriptionTextLayout.Trimming = trimming;

            if (underline)
            {
                descriptionTextLayout.SetUnderline(0, text.Length);
            }

            if (width != 0)
            {
                descriptionTextLayout.Width = width;
            }

            descriptionTextLayout.Height = cellArea.Height;

            ctx.DrawTextLayout(descriptionTextLayout, x, cellArea.Y + padding);
            return(descriptionTextLayout);
        }
Пример #8
0
        protected override void OnReallocate()
        {
            base.OnReallocate();

            int margin         = BorderVisible ? 1 : 0;
            var vwidth         = vScrollBar.Visible ? vScrollBar.WidthRequest : 0D;
            var hheight        = hScrollBar.Visible ? hScrollBar.HeightRequest : 0D;
            var childRectangle = new Xwt.Rectangle(Bounds.X + margin, Bounds.Y + margin, Bounds.Width - vwidth - margin * 2, Bounds.Height - hheight - margin * 2);

            if (vScrollBar.Visible)
            {
                double vChildTopHeight = -1;
                foreach (var child in positions)
                {
                    if (child.Value == ChildPosition.Top)
                    {
                        SetChildBounds(child.Key, new Rectangle(childRectangle.RightInside(), childRectangle.Y + vChildTopHeight, Bounds.Width - vwidth, child.Key.HeightRequest));
                        vChildTopHeight += child.Key.HeightRequest;
                    }
                }
                var v = vScrollBar is Scrollbar && hScrollBar.Visible ? hScrollBar.HeightRequest : 0;
                SetChildBounds(vScrollBar, new Rectangle(childRectangle.X + childRectangle.Width + margin, childRectangle.Y + vChildTopHeight, vwidth, Bounds.Height - v - vChildTopHeight - margin));
                Vadjustment.Value = System.Math.Max(System.Math.Min(Vadjustment.UpperValue - Vadjustment.PageSize, Vadjustment.Value), Vadjustment.LowerValue);
            }

            if (hScrollBar.Visible)
            {
                var v = vScrollBar.Visible ? vScrollBar.WidthRequest : 0;
                SetChildBounds(hScrollBar, new Rectangle(Bounds.X, childRectangle.Y + childRectangle.Height + margin, Bounds.Width - v, hheight));
                hScrollBar.Value = System.Math.Max(System.Math.Min(Hadjustment.UpperValue - Hadjustment.PageSize, hScrollBar.Value), Hadjustment.LowerValue);
            }
        }
Пример #9
0
        internal static Rect GetLocation(PopupStyles style, Size desiredSize, Rect spanRectInScreenCoordinates, Rect reservedRect, Rect screenRect)
        {
            if ((style & PopupStyles.PositionLeftOrRight) != 0)
            {
                //Position left or right
                double xPosition = ((style & PopupStyles.PreferLeftOrTopPosition) != 0)
                                   ? (reservedRect.Left - desiredSize.Width)                    //To the left
                                   : reservedRect.Right;                                        //To the right

                double yPosition = ((style & PopupStyles.RightOrBottomJustify) != 0)
                                   ? (spanRectInScreenCoordinates.Bottom - desiredSize.Height)  //Bottom justified
                                   : spanRectInScreenCoordinates.Top;                           //Top justified

                return(ShiftVerticallyToFitScreen(xPosition, yPosition,
                                                  desiredSize, screenRect));
            }
            else
            {
                //Position above or below.
                double xPosition = ((style & PopupStyles.RightOrBottomJustify) != 0)
                                   ? (spanRectInScreenCoordinates.Right - desiredSize.Width)    //Right justified
                                   : spanRectInScreenCoordinates.Left;                          //Left justified

                double yPosition = ((style & PopupStyles.PreferLeftOrTopPosition) != 0)
                                   ? (reservedRect.Top - desiredSize.Height)                    //Above
                                   : reservedRect.Bottom;                                       //Below

                return(ShiftHorizontallyToFitScreen(xPosition, yPosition,
                                                    desiredSize, screenRect));
            }
        }
Пример #10
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);
        }
Пример #11
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);
     }
 }
Пример #12
0
		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));
		}
Пример #13
0
 protected override void OnDraw(Context ctx, Rectangle dirtyRect)
 {
     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 ();
 }
Пример #14
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);
        }
Пример #15
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            //ctx.SetColor(PluginType.GetColor());
            ctx.SetLineDash(0, 4d, 4d);
            ctx.Rectangle(0, 0, PluginWidget.Size.Width, PluginWidget.Size.Height);
            ctx.Stroke();
        }
Пример #16
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);
     }
 }
Пример #17
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));
				}
			}
		}
		static TextLayout DrawText (Context ctx, Xwt.Rectangle cellArea, double x, string text, double padding, Font font, double width = 0, TextTrimming trimming = TextTrimming.WordElipsis, bool underline = false) 
		{
			if (width < 0) {
				throw new Exception ("width cannot be negative");
			}

			var textLayout = CreateTextLayout (cellArea, text, font, trimming, underline);
			DrawText (ctx, textLayout, cellArea, x, padding);
			return textLayout;
		}
Пример #19
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            ctx.SetColor(Colors.DarkGray);
            ctx.SetLineWidth(1);
            ctx.MoveTo(0, 0);
            ctx.LineTo(0, Bounds.Height);
            ctx.Stroke();
        }
Пример #20
0
 public void SetAllocation(IWidgetBackend[] widgets, Rectangle[] rects)
 {
     bool changed = false;
     for (int n=0; n<widgets.Length; n++) {
         var w = GetWidget (widgets[n]);
         if (Widget.SetAllocation (w, rects[n]))
             changed = true;
     }
     if (changed && !Widget.IsReallocating)
         Widget.QueueResize ();
 }
Пример #21
0
 protected override void OnMouseMoved(MouseMovedEventArgs args)
 {
     // Clear previous overlay
     Rectangle focus = new Rectangle (lastCursor.X - 32, lastCursor.Y - 32, 64, 64);
     QueueDraw (focus);
     lastCursor.X = args.X;
     lastCursor.Y = args.Y;
     // Queue new overlay drawing
     focus = new Rectangle (lastCursor.X - 32, lastCursor.Y - 32, 64, 64);
     QueueDraw (focus);
     base.OnMouseMoved (args);
 }
Пример #22
0
			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 ();
				}
			}
Пример #23
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();
 }
Пример #24
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);
		}
Пример #25
0
        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 ();
        }
Пример #26
0
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            ctx.Save();
            ctx.SetColor(editor.Options.Background);
            ctx.Rectangle(dirtyRect);
            ctx.Fill();
            ctx.Restore();

            UpdateMarginXOffsets();
            RenderMargins(ctx, dirtyRect);
        }
Пример #27
0
        protected override void OnBoundsChanged()
        {
            bounds = this.Bounds;

            if (plotCache != null ) {
                plotCache.Dispose ();
            }
            plotCache = new ImageBuilder ((int)bounds.Width, (int)bounds.Height, ImageFormat.ARGB32);
            cacheContext = plotCache.Context;
            UpdateCache (cacheContext);
            plotImage = plotCache.ToImage ();

            base.OnBoundsChanged ();
        }
Пример #28
0
        private Xwt.Rectangle RecalibrateChildRectangle(Xwt.Rectangle bounds)
        {
            switch (this.arrowPosition)
            {
            case Popover.Position.Top:
                return(new Xwt.Rectangle(bounds.X, bounds.Y + 10.0, bounds.Width, bounds.Height - 10.0));

            case Popover.Position.Bottom:
                return(new Xwt.Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height - 10.0));

            default:
                return(bounds);
            }
        }
Пример #29
0
		internal protected override void Draw (Context ctx, Rectangle area, long line, double x, double y)
		{
			ctx.Rectangle (x, y, Width, Editor.LineHeight);
			ctx.SetColor (Style.HexOffsetBg);
			ctx.Fill ();

			if (line >= 0 && line * Editor.BytesInRow < Data.Length) {
				LayoutWrapper layout = GetLayout (line);
				var sz = layout.Layout.GetSize ();
				ctx.SetColor (line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted);
				ctx.DrawTextLayout (layout.Layout, x + Width - sz.Width - 4, y);
				if (layout.IsUncached)
					layout.Dispose ();
			}
		}
Пример #30
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 ();
        }
Пример #31
0
        public void Show(Widget reference)
        {
            Gdk.Window    parentWindow = reference.ParentWindow;
            Xwt.Rectangle rectangle1   = new Xwt.Rectangle(this.ConvertToScreenCoordinates(reference, new Xwt.Point(0.0, 0.0)), new Xwt.Size((double)reference.Allocation.Width, (double)reference.Allocation.Height));
            Xwt.Rectangle rectangle2   = new Xwt.Rectangle(Xwt.Point.Zero, rectangle1.Size);
            rectangle2 = rectangle2.Offset(rectangle1.Location);
            Xwt.Point position = rectangle2.Location;
            this.ShowAll();
            int width;
            int height;

            this.GetSize(out width, out height);
            this.Move((int)(position.X + this.margin.Left), (int)(position.Y + this.margin.Top));
            this.SizeAllocated += (SizeAllocatedHandler)((o, args) => this.Move((int)position.X, (int)position.Y));
        }
Пример #32
0
        private void RoundRectangle(Context ctx, Xwt.Rectangle rect, double radius)
        {
            double num    = Math.PI / 180.0;
            double x      = rect.X;
            double y      = rect.Y;
            double height = rect.Height;
            double width  = rect.Width;

            ctx.NewSubPath();
            ctx.Arc(x + width - radius, y + radius, radius, -90.0 * num, 0.0 * num);
            ctx.Arc(x + width - radius, y + height - radius, radius, 0.0 * num, 90.0 * num);
            ctx.Arc(x + radius, y + height - radius, radius, 90.0 * num, 180.0 * num);
            ctx.Arc(x + radius, y + radius, radius, 180.0 * num, 270.0 * num);
            ctx.ClosePath();
        }
Пример #33
0
			protected override void OnDraw (Context ctx, Rectangle dirtyRect)
			{
				base.OnDraw (ctx, dirtyRect);

				ctx.Rectangle (0, 0, Size.Width, Size.Height);
				ctx.SetColor (Colors.LightGray);
				ctx.Fill ();

				ctx.SetColor (Colors.Black);
				using (var layout = new TextLayout (this))
				{
					layout.Text = text;
					ctx.DrawTextLayout (layout, new Point (0, 20));
				}
			}
Пример #34
0
        void ResizeChild(Rectangle allocation, EditorContainerChild child)
        {
            var req            = child.Child.Surface.GetPreferredSize();
            var childRectangle = new Xwt.Rectangle(Bounds.X + child.X, Bounds.Y + child.Y, req.Width, req.Height);

            if (!child.FixedPosition)
            {
                double zoom = Options.Zoom;
                childRectangle.X = Bounds.X + (int)(child.X * zoom - HAdjustment.Value);
                childRectangle.Y = Bounds.Y + (int)(child.Y * zoom - VAdjustment.Value);
            }
            //			childRectangle.X += allocation.X;
            //			childRectangle.Y += allocation.Y;
            SetChildBounds(child.Child, childRectangle);
        }
Пример #35
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            if (HasBorder)
            {
                ctx.SetColor(PluginType.GetColor());
                ctx.SetLineWidth(1);

                if (HasBorderLineDash)
                    ctx.SetLineDash(0, 4d, 4d);

                ctx.Rectangle(0, 0, WidthRequest, HeightRequest);
                ctx.Stroke();
            }
        }
Пример #36
0
        internal static bool DisjointWithPadding(Geometry reserved, Rect location)
        {
            double left   = location.Left + 0.1;
            double top    = location.Top + 0.1;
            double width  = location.Right - 0.1 - left;
            double height = location.Bottom - 0.1 - top;

            if ((width > 0.0) && (height > 0.0))
            {
                Geometry insetLocation = new RectangleGeometry(new System.Windows.Rect(left, top, width, height));
                return(!reserved.Bounds.IntersectsWith(insetLocation.Bounds));//TODO: This was simpliefied
            }
            else
            {
                return(true);
            }
        }
Пример #37
0
		internal protected override void Draw (Context win, Rectangle area, long line, double x, double y)
		{
			win.Rectangle (x, y, Width, Editor.LineHeight);
			win.SetColor (Style.IconBarBg);
			win.Fill ();
			win.MoveTo (x + Width - 1, y);
			win.LineTo (x + Width - 1, y + Editor.LineHeight);
			win.SetColor (Style.IconBarSeperator);
			win.Stroke ();

			foreach (long bookmark in Data.Bookmarks) {
				if (line * Editor.BytesInRow <= bookmark && bookmark < line * Editor.BytesInRow + Editor.BytesInRow) {
					DrawBookmark (win, x, y);
					return;
				}
			}
		}
Пример #38
0
        private void DrawAxisTests(Context ctx, Rectangle bounds)
        {
            LinearAxis a = new LinearAxis (0, 10);
            Rectangle boundingBox;

            a.Draw (ctx, new Point (30,10), new Point (30, 200), 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 on positive X-axis, ie Ticks below X-axis
            LinearAxis aX = new LinearAxis (0, 10);
            aX.Draw (ctx, new Point(30,240), new Point(380, 240), out boundingBox);

            // Set TicksAngle to PI/4 anti-clockwise from positive X-axis direction
            aX.TicksAngle = Math.PI / 4.0;
            aX.Draw (ctx, new Point (30,280), new Point (380, 280), out boundingBox);
        }
Пример #39
0
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            if (Image != null) {
                double width = Bounds.Width == 1 ? Image.Width : Bounds.Width;
                if (Bounds.Width == 1)
                    WidthRequest = width;

                // Scale height respect width
                double height = (Bounds.Width / Image.Width) * Image.Height;
                if (HeightRequest != height)
                    HeightRequest = height;
                else
                    height = Bounds.Height;

                ctx.DrawImage(Image, 0, 0, width, height);
            }
        }
		static TextLayout CreateTextLayout (Xwt.Rectangle cellArea, string text, Font font, TextTrimming trimming = TextTrimming.WordElipsis, bool underline = false, double width = 0) 
		{
			var descriptionTextLayout = new TextLayout {
				Font = font,
				Text = text,
				Trimming = trimming
			};

			if (underline) {
				descriptionTextLayout.SetUnderline (0, text.Length);
			}

			if (width != 0) {
				descriptionTextLayout.Width = width;
			}

			descriptionTextLayout.Height = cellArea.Height;

			return descriptionTextLayout;
		}
Пример #41
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
        {
            popover = MakePopover(child);
            ViewBackend backend   = (ViewBackend)Toolkit.GetBackend(referenceWidget);
            var         reference = backend.Widget;

            popover.Show(positionRect.ToRectangleF(),
                         reference,
                         ToRectEdge(orientation));
        }
 void DrawImage(Context ctx, Xwt.Rectangle cellArea, Image image, double x, int imageSize, bool isSelected, double topPadding = 0)
 {
     ctx.DrawImage(isSelected ? image.WithStyles("sel") : image, x, cellArea.Top + (cellArea.Height / 2 - imageSize / 2), imageSize, imageSize);
 }
 static void DrawText(Context ctx, TextLayout textLayout, Xwt.Rectangle cellArea, double x, double padding)
 {
     ctx.DrawTextLayout(textLayout, x, cellArea.Y + padding);
 }
Пример #44
0
 public virtual void QueueDraw(Xwt.Rectangle rect)
 {
     Widget.VidgetBackendInvalidate(rect);
 }
Пример #45
0
 void DrawImage(Context ctx, Xwt.Rectangle cellArea, Image image, double x, int imageSize, bool isSelected)
 {
     DrawImage(ctx, cellArea, image, x, imageSize, isSelected, (cellArea.Height / 2 - imageSize / 2));
 }
Пример #46
0
 public virtual void QueueDraw(Xwt.Rectangle rect)
 {
     Control.Invalidate(rect.ToGdi());
 }
Пример #47
0
        internal static Rect ShiftVerticallyToFitScreen(double x, double y, Size desiredSize, Rect screenRect)
        {
            if ((y + desiredSize.Height) > screenRect.Bottom)
            {
                y = screenRect.Bottom - desiredSize.Height;
            }

            if (y < screenRect.Top)
            {
                y = screenRect.Top;
            }

            return(new Rect(x, y, desiredSize.Width, desiredSize.Height));
        }
Пример #48
0
        internal static Rect ShiftHorizontallyToFitScreen(double x, double y, Size desiredSize, Rect screenRect)
        {
            if ((x + desiredSize.Width) > screenRect.Right)
            {
                x = screenRect.Right - desiredSize.Width;
            }

            if (x < screenRect.Left)
            {
                x = screenRect.Left;
            }

            return(new Rect(x, y, desiredSize.Width, desiredSize.Height));
        }
Пример #49
0
 static System.Windows.Rect FromXwtRect(Xwt.Rectangle r) => new System.Windows.Rect(r.X, r.Y, r.Width, r.Height);
Пример #50
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
        {
            var controller = new FactoryViewController(child);

            popover          = new NSPopover();
            popover.Behavior = NSPopoverBehavior.Transient;
            popover.ContentViewController = controller;
            ViewBackend backend   = (ViewBackend)Toolkit.GetBackend(referenceWidget);
            var         reference = backend.Widget;

            popover.Show(System.Drawing.RectangleF.Empty,
                         reference,
                         ToRectEdge(orientation));
        }
Пример #51
0
 internal static bool ContainsWithPadding(Rect outer, Rect inner)
 {
     return((outer.Left - 0.01 <= inner.Left) && (inner.Right <= outer.Right + 0.01) &&
            (outer.Top - 0.01 <= inner.Top) && (inner.Bottom <= outer.Bottom + 0.01));
 }
Пример #52
0
        private Rect?GetViewSpanRect(ITrackingSpan viewSpan)
        {
            var view = WpfTextView;

            if (view == null || view.TextViewLines == null || view.IsClosed)
            {
                return(null);
            }

            SnapshotSpan visualSpan = viewSpan.GetSpan(view.TextSnapshot);

            Rect?spanRectangle = null;

            if (visualSpan.Length > 0)
            {
                double left   = double.MaxValue;
                double top    = double.MaxValue;
                double right  = double.MinValue;
                double bottom = double.MinValue;

                var bounds = view.TextViewLines.GetNormalizedTextBounds(visualSpan);
                foreach (var bound in bounds)
                {
                    left   = Math.Min(left, bound.Left);
                    top    = Math.Min(top, bound.TextTop);
                    right  = Math.Max(right, bound.Right);
                    bottom = Math.Max(bottom, bound.TextBottom + ToolTipVerticalOffset);
                }

                // If the start of the span lies within the view, use that instead of the left-bound of the span as a whole.
                // This will cause popups to be left-aligned with the start of their span, if at all possible.
                var startLine = view.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.Start);
                if (startLine != null)
                {
                    var startPointBounds = startLine.GetExtendedCharacterBounds(visualSpan.Start);
                    if ((startPointBounds.Left < right) &&
                        (startPointBounds.Left >= view.ViewportLeft) &&
                        (startPointBounds.Left < view.ViewportRight))
                    {
                        left = startPointBounds.Left;
                    }
                }

                //Special case handling for when the end of the span is at the start of a line.
                ITextViewLine line = view.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.End);
                if ((line != null) && (line.Start == visualSpan.End))
                {
                    bottom = Math.Max(bottom, line.TextBottom + ToolTipVerticalOffset);
                }

                if (left < right)
                {
                    spanRectangle = new Rect(left, top, right - left, bottom - top);
                }
            }
            else
            {
                // visualSpan is zero length so the default MarkerGeometry will be null. Create a custom marker geometry based on
                // the location.
                ITextViewLine line = view.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.Start);
                if (line != null)
                {
                    TextBounds bounds = line.GetCharacterBounds(visualSpan.Start);
                    spanRectangle = new Rect(bounds.Left, bounds.TextTop, 0.0, bounds.TextHeight + ToolTipVerticalOffset);
                }
            }

            if (spanRectangle.HasValue && !spanRectangle.Value.IsEmpty)
            {
                //Get the portion of the span geometry that is inside the view.
                Rect viewRect = new Rect(view.ViewportLeft,
                                         view.ViewportTop,
                                         view.ViewportWidth,
                                         view.ViewportHeight);

                Rect spanRect = spanRectangle.Value;
                spanRect.Intersect(viewRect);

                Rect spanRectInScreenCoordinates =
                    new Rect(this.GetScreenPointFromTextXY(spanRect.Left, spanRect.Top),
                             this.GetScreenPointFromTextXY(spanRect.Right, spanRect.Bottom));

                return(spanRectInScreenCoordinates);
            }

            return(null);
        }
Пример #53
0
        public Geometry PositionAndDisplay(Geometry reservedSpace)
        {
            //This method should only be called from the popup manager (which should never call it when the containing
            //view is hidden or in the middle of a layout).

            //This method does not support virtual whitespace positioning.  An attempt to support it by using caret position was introduced, but
            //regressed the behavior that popup should stay in place as the caret moves.  If in the future we need to support virtual whitespace,
            //consider using virtual span instead.

            //Update the visual span to the current snapshot.
            SnapshotSpan visualSpan = _visualSpan.GetSpan(_textView.TextSnapshot);

            // If the style indicates that we should dismiss when the mouse leaves the span of the text, then we should make an
            // initial check to make sure the mouse starts-off in the span.  If not, we should fail to position.
            if ((_style & (PopupStyles.DismissOnMouseLeaveText | PopupStyles.DismissOnMouseLeaveTextOrContent)) != 0)
            {
                _textView.VisualElement.GetPointer(out int x, out int y);
                if (this.ShouldClearToolTipOnMouseMove(new Point(x, y)))
                {
                    return(null);
                }
            }

            Rect?spanRectangle = null;

            if (visualSpan.Length > 0)
            {
                double left   = double.MaxValue;
                double top    = double.MaxValue;
                double right  = double.MinValue;
                double bottom = double.MinValue;

                var bounds = _textView.TextViewLines.GetNormalizedTextBounds(visualSpan);
                foreach (var bound in bounds)
                {
                    left   = Math.Min(left, bound.Left);
                    top    = Math.Min(top, bound.TextTop);
                    right  = Math.Max(right, bound.Right);
                    bottom = Math.Max(bottom, bound.TextBottom);
                }

                // If the start of the span lies within the view, use that instead of the left-bound of the span as a whole.
                // This will cause popups to be left-aligned with the start of their span, if at all possible.
                var startLine = _textView.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.Start);
                if (startLine != null)
                {
                    var startPointBounds = startLine.GetExtendedCharacterBounds(visualSpan.Start);
                    if ((startPointBounds.Left < right) && (startPointBounds.Left >= _textView.ViewportLeft) && (startPointBounds.Left < _textView.ViewportRight))
                    {
                        left = startPointBounds.Left;
                    }
                }

                //Special case handling for when the end of the span is at the start of a line.
                ITextViewLine line = _textView.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.End);
                if ((line != null) && (line.Start == visualSpan.End))
                {
                    bottom = Math.Max(bottom, line.TextBottom);
                }

                if (left < right)
                {
                    spanRectangle = new Rect(left, top, right - left, bottom - top);
                }
            }
            else
            {
                //visualSpan is zero length so the default MarkerGeometry will be null. Create a custom marker geometry based on the location.
                ITextViewLine line = _textView.TextViewLines.GetTextViewLineContainingBufferPosition(visualSpan.Start);
                if (line != null)
                {
                    TextBounds bounds = line.GetCharacterBounds(visualSpan.Start);
                    spanRectangle = new Rect(bounds.Left, bounds.TextTop, 0.0, bounds.TextHeight);
                }
            }

            if (spanRectangle.HasValue)
            {
                //Get the portion of the span geometry that is inside the view.
                Rect viewRect = new Rect(_textView.ViewportLeft, _textView.ViewportTop, _textView.ViewportWidth, _textView.ViewportHeight);

                Rect spanRect = spanRectangle.Value;
                spanRect = spanRect.Intersect(viewRect);

                if (spanRect != default(Rect))
                {
                    // Determine two different rectangles for the span.  One is the span in its raw form.  The other is a "guess" at
                    // what the already-reserved space around the span will be.  We have a very-prevalent space reservation agent (the
                    // current line agent) that reserves the current line plus a 3-pixel buffer below the line.  We'll optimistically
                    // guess that this agent might be in-play and attempt to avoid it.
                    Rect spanRectWithBuffer = new Rect(spanRect.Left, spanRect.Top, spanRect.Right - spanRect.Left, spanRect.Bottom - spanRect.Top + BelowTheLineBufferHint);

                    //Some of the text associated with the popup is visible, show the popup.
                    Rect spanRectInScreenCoordinates = new Rect(this.GetScreenPointFromTextXY(spanRect.Left, spanRect.Top),
                                                                this.GetScreenPointFromTextXY(spanRect.Right, spanRect.Bottom));
                    Rect spanRectWithBufferInScreenCoordinates = new Rect(this.GetScreenPointFromTextXY(spanRectWithBuffer.Left, spanRectWithBuffer.Top),
                                                                          this.GetScreenPointFromTextXY(spanRectWithBuffer.Right, spanRectWithBuffer.Bottom));
                    Rect screenRect = Xwt.Desktop.GetScreenAtLocation(spanRectInScreenCoordinates.TopLeft).Bounds;//TODO: Check if we should use VisualBounds

                    Size desiredSize = _popup.Size;
                    //The popup size specified in deivice pixels. Convert these to logical
                    //pixels for purposes of calculating the actual size of the popup.
                    //TODO desiredSize = new Size (desiredSize.Width / WpfHelper.DeviceScaleX, desiredSize.Height / WpfHelper.DeviceScaleY);
                    desiredSize = new Size(desiredSize.Width, desiredSize.Height);

                    PopupStyles alternateStyle = _style ^ PopupStyles.PreferLeftOrTopPosition;

                    var   tr      = reservedSpace.Bounds;
                    Point topLeft = new Point(Math.Min(spanRectInScreenCoordinates.Left, tr.Left),
                                              Math.Min(spanRectInScreenCoordinates.Top, tr.Top));
                    Point bottomRight = new Point(Math.Max(spanRectInScreenCoordinates.Right, tr.Right),
                                                  Math.Max(spanRectInScreenCoordinates.Bottom, tr.Bottom));
                    var reservedRect = new Rect(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y);

                    //There are 6 possible locations for the popup.  The order of preference is determined by the presence of the
                    //'PositionClosest' PopupStyle.
                    //
                    //  Without 'PositionClosest':
                    //  1 .. On the desired side of the span.
                    //  2 .. On the desired side of the span with a bit of buffer.
                    //  3 .. on the desired side of the reserved rectangle.
                    //  4 .. On the alternate side of the span.
                    //  5 .. On the alternate side of the span with a bit of buffer.
                    //  6 .. on the alternate side of the reserved rectangle.
                    //
                    //  With 'PositionClosest':
                    //  1 .. On the desired side of the span.
                    //  2 .. On the desired side of the span with a bit of buffer.
                    //  3 .. On the alternate side of the span.
                    //  4 .. On the alternate side of the span with a bit of buffer.
                    //  5 .. on the desired side of the reserved rectangle.
                    //  6 .. on the alternate side of the reserved rectangle.
                    //
                    //Try each location till we get a winner.
                    //  A location is a winner if it is disjoint from the original reserved rect and
                    //  the edges of the screen.

                    Tuple <PopupStyles, Rect>[] positionChoices;
                    if (reservedRect != default(Rect))
                    {
                        if ((_style & PopupStyles.PositionClosest) == 0)
                        {
                            positionChoices = new Tuple <PopupStyles, Rect>[]
                            {
                                new Tuple <PopupStyles, Rect>(_style, spanRectInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(_style, spanRectWithBufferInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(_style, reservedRect),
                                new Tuple <PopupStyles, Rect>(alternateStyle, spanRectInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(alternateStyle, spanRectWithBufferInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(alternateStyle, reservedRect),
                            };
                        }
                        else
                        {
                            positionChoices = new Tuple <PopupStyles, Rect>[]
                            {
                                new Tuple <PopupStyles, Rect>(_style, spanRectInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(_style, spanRectWithBufferInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(alternateStyle, spanRectInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(alternateStyle, spanRectWithBufferInScreenCoordinates),
                                new Tuple <PopupStyles, Rect>(_style, reservedRect),
                                new Tuple <PopupStyles, Rect>(alternateStyle, reservedRect),
                            };
                        }
                    }
                    else
                    {
                        positionChoices = new Tuple <PopupStyles, Rect>[]
                        {
                            new Tuple <PopupStyles, Rect>(_style, spanRectInScreenCoordinates),
                            new Tuple <PopupStyles, Rect>(_style, spanRectWithBufferInScreenCoordinates),
                            new Tuple <PopupStyles, Rect>(alternateStyle, spanRectInScreenCoordinates),
                            new Tuple <PopupStyles, Rect>(alternateStyle, spanRectWithBufferInScreenCoordinates),
                        };
                    }

                    Rect location = default;
                    foreach (var choice in positionChoices)
                    {
                        Rect locationToTry = GetLocation(choice.Item1, desiredSize, spanRectInScreenCoordinates, choice.Item2, screenRect);
                        if (DisjointWithPadding(reservedSpace, locationToTry) && ContainsWithPadding(screenRect, locationToTry))
                        {
                            location = locationToTry;
                            _style   = choice.Item1;
                            break;
                        }
                    }

                    // If we couldn't locate a place to live, tell the manager we want to go away.
                    if (location == default)
                    {
                        return(null);
                    }

                    if (!_popup.IsVisible)
                    {
                        this.RegisterForEvents();
                    }

                    _popup.DisplayAt(location.TopLeft);

                    GeometryGroup requestedSpace = new GeometryGroup();
                    requestedSpace.Children.Add(new RectangleGeometry(FromXwtRect(spanRectInScreenCoordinates)));
                    requestedSpace.Children.Add(new RectangleGeometry(FromXwtRect(location)));

                    return(requestedSpace);
                }
            }

            //The text associated with the popup visualSpan is not visible: tell the manager we want to go away.
            return(null);
        }
        protected override void OnDraw(Context ctx, Xwt.Rectangle cellArea)
        {
            var buildOutputNode = GetValue(BuildOutputNodeField);
            var isSelected      = Selected;

            var status = GetViewStatus(buildOutputNode);

            //Draw the node background
            FillCellBackground(ctx, buildOutputNode, status);

            //Draw the image row
            DrawImage(ctx, cellArea, buildOutputNode.GetImage(), cellArea.Left, ImageSize, isSelected, ImagePadding);

            // If the height required by the text is not the same as what was calculated in OnGetRequiredSize(), it means that
            // the required height has changed and CalcLayout will return false. In that case call QueueResize(),
            // so that OnGetRequiredSize() is called again and the row is properly resized.
            if (!status.CalculateLayout(cellArea, out var layout, out var layoutBounds, out var expanderRect))
            {
                QueueResize();
            }

            status.LastRenderBounds         = cellArea;
            status.LastRenderLayoutBounds   = layoutBounds;
            status.LastRenderExpanderBounds = expanderRect;

            ctx.SetColor(Styles.GetTextColor(buildOutputNode, UseStrongSelectionColor && isSelected));

            HighlightSearchResults(layout, contextProvider.SearchString, Styles.GetTextColor(buildOutputNode, false), Styles.GetSearchMatchBackgroundColor(isSelected));

            // Render the selection
            if (TextSelection?.IsShown(buildOutputNode) ?? false)
            {
                layout.SetBackground(Styles.CellTextSelectionColorSecundary, TextSelection.Index, TextSelection.Length);
            }

            // Draw the text
            ctx.DrawTextLayout(layout, layoutBounds.X, layoutBounds.Y);

            // Draw right hand expander
            if (!expanderRect.IsEmpty)
            {
                // Draw the image
                Image icon;
                if (status.Expanded)
                {
                    icon = isSelected ? BuildCollapseIconSel : BuildCollapseIcon;
                }
                else
                {
                    icon = isSelected ? BuildExpandIconSel : BuildExpandIcon;
                }
                ctx.DrawImage(icon, expanderRect.X, expanderRect.Y);
            }

            //Information section
            if (!status.IsRootNode)
            {
                DrawNodeInformation(ctx, cellArea, buildOutputNode, status.LayoutYPadding, isSelected, ImageSize, ImagePadding, status);
            }
            else if (buildOutputNode.NodeType == BuildOutputNodeType.BuildSummary)
            {
                // For build summary, display error/warning summary
                var startX = layoutBounds.X + layout.GetSize().Width + 24;

                status.ErrorsRectangle.X = startX;
                status.ErrorsRectangle.Y = cellArea.Y;
                DrawImage(ctx, cellArea, Resources.ErrorIconSmall, startX, ImageSize, isSelected, ImagePadding);

                startX += ImageSize + 2;
                var errors = GettextCatalog.GetString("{0} errors", buildOutputNode.ErrorCount.ToString());
                layout = DrawText(ctx, cellArea, startX, errors, status.LayoutYPadding, defaultFont, layoutBounds.Width);

                var size = layout.GetSize();
                //Our error rectangle includes text + image + margin
                status.ErrorsRectangle.Width  = size.Width + ImageSize + 2;
                status.ErrorsRectangle.Height = size.Height;

                startX += size.Width + 24;

                status.WarningsRectangle.X = startX;
                status.WarningsRectangle.Y = cellArea.Y;

                DrawImage(ctx, cellArea, Resources.WarningIconSmall, startX, ImageSize, isSelected, ImagePadding);

                var warnings = GettextCatalog.GetString("{0} warnings", buildOutputNode.WarningCount.ToString());
                startX += ImageSize + 2;
                layout  = DrawText(ctx, cellArea, startX, warnings, status.LayoutYPadding, font: defaultFont);

                size = layout.GetSize();
                status.WarningsRectangle.Width  = size.Width + ImageSize + 2;
                status.WarningsRectangle.Height = size.Height;
            }
            else if (buildOutputNode.NodeType == BuildOutputNodeType.Build)
            {
                var textStartX = layoutBounds.X + layout.GetSize().Width + 24;
                DrawText(ctx, cellArea, textStartX, GetInformationMessage(buildOutputNode), status.LayoutYPadding, defaultFont, cellArea.Width - textStartX);
            }
        }
        void DrawNodeInformation(Context ctx, Xwt.Rectangle cellArea, BuildOutputNode buildOutputNode, double padding, bool isSelected, int imageSize, int imagePadding, ViewStatus status)
        {
            if (!buildOutputNode.HasChildren)
            {
                if (buildOutputNode.NodeType == BuildOutputNodeType.Error || buildOutputNode.NodeType == BuildOutputNodeType.Warning)
                {
                    if (isSelected)
                    {
                        ctx.SetColor(Styles.CellTextSelectionColor);
                    }
                    else
                    {
                        ctx.SetColor(Styles.LinkForegroundColor);
                    }
                    var text = string.Format("{0}, line {1}", buildOutputNode.File, buildOutputNode.LineNumber);

                    status.TaskLinkRenderRectangle.X = lastErrorPanelStartX + 5;
                    status.TaskLinkRenderRectangle.Y = cellArea.Y + padding;

                    //TODO: we can do a cache of the text layout and only resize
                    //Our link text layoud needs to be created with real size
                    var layout = CreateTextLayout(cellArea, text, defaultFont, trimming: TextTrimming.WordElipsis, underline: true);
                    status.TaskLinkRenderRectangle.Size = layout.GetSize();

                    //Now we calculate if fits the content and readjust
                    var maxSize = cellArea.Width + cellArea.X + padding - status.TaskLinkRenderRectangle.X;
                    status.TaskLinkRenderRectangle.Width = layout.Width = maxSize;

                    DrawText(ctx, layout, cellArea, status.TaskLinkRenderRectangle.X, padding);
                    return;
                }
                return;
            }

            UpdateInformationTextColor(ctx, isSelected);

            var textStartX = cellArea.X + (cellArea.Width - DefaultInformationContainerWidth);

            Size size = Size.Zero;

            //Duration text
            var duration = status.Duration;

            if (duration != "")
            {
                size        = DrawText(ctx, cellArea, textStartX, duration, padding, defaultFont, DefaultInformationContainerWidth).GetSize();
                textStartX += size.Width + 10;
            }

            if (textStartX > lastErrorPanelStartX)
            {
                lastErrorPanelStartX = textStartX;
            }
            else
            {
                textStartX = lastErrorPanelStartX;
            }

            status.TaskLinkRenderRectangle.X = status.TaskLinkRenderRectangle.Y = status.TaskLinkRenderRectangle.Width = status.TaskLinkRenderRectangle.Height = 0;

            //Error and Warnings count
            if (!IsRowExpanded(buildOutputNode) &&
                (buildOutputNode.NodeType == BuildOutputNodeType.Task || buildOutputNode.NodeType == BuildOutputNodeType.Target) &&
                (buildOutputNode.ErrorCount > 0 || buildOutputNode.WarningCount > 0))
            {
                if (buildOutputNode.ErrorCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.ErrorIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    var errors = buildOutputNode.ErrorCount.ToString();

                    var layout = DrawText(ctx, cellArea, textStartX, errors, padding, defaultFont, trimming: TextTrimming.Word);
                    textStartX += layout.GetSize().Width;
                }

                if (buildOutputNode.WarningCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.WarningIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    DrawText(ctx, cellArea, textStartX, buildOutputNode.WarningCount.ToString(), padding, defaultFont, 10, trimming: TextTrimming.Word);
                }
            }
        }
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
        {
            popover = MakePopover(child, BackgroundColor);
            ViewBackend backend   = (ViewBackend)Toolkit.GetBackend(referenceWidget);
            var         reference = backend.Widget;

            // If the position rect is empty, the coordinates of the rect will be ignored.
            // Width and Height of the rect must be > Epsilon, for the positioning to function correctly.
            if (Math.Abs(positionRect.Width) < double.Epsilon)
            {
                positionRect.Width = 1;
            }
            if (Math.Abs(positionRect.Height) < double.Epsilon)
            {
                positionRect.Height = 1;
            }

            popover.Show(positionRect.ToCGRect(),
                         reference,
                         ToRectEdge(orientation));
        }
        void DrawNodeInformation(Context ctx, Xwt.Rectangle cellArea, BuildOutputNode buildOutputNode, double padding, bool isSelected, int imageSize, int imagePadding, ViewStatus status)
        {
            if (!buildOutputNode.HasChildren)
            {
                if (buildOutputNode.NodeType == BuildOutputNodeType.Error || buildOutputNode.NodeType == BuildOutputNodeType.Warning)
                {
                    if (isSelected)
                    {
                        ctx.SetColor(Styles.CellTextSelectionColor);
                    }
                    else
                    {
                        ctx.SetColor(Styles.LinkForegroundColor);
                    }
                    var text = string.Format("{0}, line {1}", buildOutputNode.File, buildOutputNode.LineNumber);

                    status.TaskLinkRenderRectangle.X = lastErrorPanelStartX + 5;
                    status.TaskLinkRenderRectangle.Y = cellArea.Y + padding;

                    var layout = DrawText(ctx, cellArea, status.TaskLinkRenderRectangle.X, text, padding, font: defaultFont, trimming: TextTrimming.Word, underline: true);
                    status.TaskLinkRenderRectangle.Size = layout.GetSize();
                    return;
                }
                return;
            }

            UpdateInformationTextColor(ctx, isSelected);

            var textStartX = cellArea.X + (cellArea.Width - DefaultInformationContainerWidth);

            Size size = Size.Zero;

            //Duration text
            var duration = buildOutputNode.GetDurationAsString(contextProvider.IsShowingDiagnostics);

            if (duration != "")
            {
                size        = DrawText(ctx, cellArea, textStartX, duration, padding, defaultFont, DefaultInformationContainerWidth).GetSize();
                textStartX += size.Width + 10;
            }

            if (textStartX > lastErrorPanelStartX)
            {
                lastErrorPanelStartX = textStartX;
            }
            else
            {
                textStartX = lastErrorPanelStartX;
            }

            status.TaskLinkRenderRectangle.X = status.TaskLinkRenderRectangle.Y = status.TaskLinkRenderRectangle.Width = status.TaskLinkRenderRectangle.Height = 0;

            //Error and Warnings count
            if (!IsRowExpanded(buildOutputNode) &&
                (buildOutputNode.NodeType == BuildOutputNodeType.Task || buildOutputNode.NodeType == BuildOutputNodeType.Target) &&
                (buildOutputNode.ErrorCount > 0 || buildOutputNode.WarningCount > 0))
            {
                if (buildOutputNode.ErrorCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.ErrorIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    var errors = buildOutputNode.ErrorCount.ToString();

                    var layout = DrawText(ctx, cellArea, textStartX, errors, padding, defaultFont, trimming: TextTrimming.Word);
                    textStartX += layout.GetSize().Width;
                }

                if (buildOutputNode.WarningCount > 0)
                {
                    DrawImage(ctx, cellArea, Resources.WarningIconSmall, textStartX, imageSize, isSelected, imagePadding);
                    textStartX += ImageSize + 2;
                    DrawText(ctx, cellArea, textStartX, buildOutputNode.WarningCount.ToString(), padding, defaultFont, 10, trimming: TextTrimming.Word);
                }
            }
        }