public override void DrawForeground(MonoTextEditor editor, 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 icon = GetIcon(SmartTagSeverity); var deltaX = size / 2 - icon.Width / 2 + 0.5f; var deltaY = size / 2 - icon.Height / 2 + 0.5f; cr.DrawImage(editor, icon, Math.Round(x + deltaX), Math.Round(y + deltaY)); Height = (int)(Math.Round(deltaY) + icon.Height); if (editor.TextArea.QuickFixMargin.HoveredSmartTagMarker == this) { const int triangleWidth = 8; const int triangleHeight = 4; cr.SetSourceColor(SyntaxHighlightingService.GetColor(editor.EditorTheme, EditorThemeColors.LineNumbers)); cr.MoveTo(metrics.X + metrics.Width - triangleWidth, metrics.Y + metrics.Height - triangleHeight); cr.LineTo(metrics.X + metrics.Width, metrics.Y + metrics.Height - triangleHeight); cr.LineTo(metrics.X + metrics.Width - triangleWidth / 2, metrics.Y + metrics.Height); cr.LineTo(metrics.X + metrics.Width - triangleWidth, metrics.Y + metrics.Height - triangleHeight); cr.Fill(); } PopupPosition = new Xwt.Point(metrics.X, metrics.Y); }
/// <summary> /// No text range returned from the language server so the tooltip will /// be shown based on the mouse cursor position. The arrow from the /// tooltip should be pointing to the mouse cursor. /// </summary> void ShowTooltipWindowAtMouseLocation( TextEditor editor, TooltipInformationWindow tooltipWindow, int mouseX, int mouseY) { // mouseX here does not seem to produce the correct text editor column // so only Point.Y is used from the TextEditor's LocationToPoint. Point.X // is incorrect and cannot be used to determine the tooltip rectangle // location. DocumentLocation location = editor.PointToLocation(mouseX, mouseY); Xwt.Point point = editor.LocationToPoint(location); // The target rectangle should be a segment of text in the text editor. Since // this does not exist the width of the tooltip window is used as the rectangle // width and the X position is taken from the mouseX but shifted to the left by // half the width of the tooltip window so the middle of the tooltip window // appears under the mouse position so the arrow from the tooltip should be // pointing to where the mouse cursor is. The mouseX and mouseY are captured by // the tooltip provider at the time the tooltip is initially requested and so // this is not necessarily the current mouse position. var targetRectangle = new Xwt.Rectangle( mouseX - (tooltipWindow.Width / 2), // Arrow from tooltip should point to mouse cursor. point.Y, // The top of the line where the mouse cursor is tooltipWindow.Width, editor.GetLineHeight(editor.CaretLine) ); tooltipWindow.ShowPopup(editor, targetRectangle, PopupPosition.Top); }
void PositionPopup() { if (popup == null) { return; } popup.IgnoreRepositionWindow = false; var anchor = ToolbarView.PopupAnchor; if (IdeApp.Workbench.RootWindow.Visible) { popup.ShowPopup(anchor, PopupPosition.TopRight); } if (anchor.GdkWindow == null) { var location = new Xwt.Point(anchor.Allocation.Width - popup.Size.Width, anchor.Allocation.Y); // Need to hard lock the location because Xwt doesn't know that the allocation might be coming from a // Cocoa control and thus has been changed to take macOS monitor layout into consideration popup.IgnoreRepositionWindow = true; popup.Location = location; } }
internal async void UpdateParameterInfoLocation() { var isCompletionWindowVisible = (CompletionWindowManager.Wnd?.Visible ?? false); var ctx = Widget?.CurrentCodeCompletionContext; if (ctx == null) { return; } var lineHeight = (int)Ext.Editor.LineHeight; var geometry = Xwt.MessageDialog.RootWindow.Screen.VisibleBounds; var cmg = ParameterInformationWindowManager.CurrentMethodGroup; int cparam = Ext != null ? await Ext.GetCurrentParameterIndex(cmg.MethodProvider.ApplicableSpan.Start) : 0; var lastW = (int)Width; var lastH = (int)Height; int X, Y; X = cmg.CompletionContext.TriggerXCoord; if (isCompletionWindowVisible) { // place above Y = ctx.TriggerYCoord - lineHeight - (int)lastH - 10; } else { // place below Y = ctx.TriggerYCoord; } if (X + lastW > geometry.Right) { X = (int)geometry.Right - (int)lastW; } if (Y < geometry.Top) { Y = ctx.TriggerYCoord; } if (Y + lastH > geometry.Bottom) { Y = Y - lineHeight - (int)lastH - 4; } if (isCompletionWindowVisible) { var completionWindow = new Xwt.Rectangle(CompletionWindowManager.X, CompletionWindowManager.Y - lineHeight, CompletionWindowManager.Wnd.Allocation.Width, CompletionWindowManager.Wnd.Allocation.Height + lineHeight * 2); if (completionWindow.IntersectsWith(new Xwt.Rectangle(X, Y, lastW, lastH))) { X = (int)completionWindow.X; Y = (int)completionWindow.Y - (int)lastH - 6; if (Y < 0) { Y = (int)completionWindow.Bottom + 6; } } } Location = new Xwt.Point(X, Y); }
private WindowPositionProvider() { #if PLATFORM_WINDOWS nextPosition = new Point(SystemParameters.BorderWidth, SystemParameters.WindowCaptionHeight + SystemParameters.ResizeFrameHorizontalBorderHeight); #else nextPosition = new Point(0, 0); #endif offset = new Point(30, 50); innerLock = new object(); }
public static Gdk.Point ToScreenCoordinates(this Xwt.Widget widget, Xwt.Point point) { var spoint = widget.ConvertToScreenCoordinates(point).ToGdkPoint(); #if MAC // Xwt.Widget.ScreenBounds is toolkit specific and Cocoa uses a different screen coordinate system. var view = widget.Surface.NativeWidget as AppKit.NSView; if (view != null) { spoint = ConvertToGdkCoordinates(view.Window?.Screen, spoint); } #endif return(spoint); }
public override Xwt.Point ConvertToWindowCoordinates(Xwt.Point widgetCoordinates) { throw new NotImplementedException(); }
public virtual override Xwt.Point ConvertToScreenCoordinates(Xwt.Point widgetCoordinates) { throw new NotImplementedException(); }
public virtual Xwt.TreePosition GetRowAtPosition(Xwt.Point p) { throw new NotImplementedException(); }
public static PopupWindow Show(Widget reference, Xwt.Rectangle positionRect, Widget child) { var popup = new PopupWindow(child); var topLevel = (Window)reference.Toplevel; popup.DestroyWithParent = true; popup.BorderWidth = topLevel.BorderWidth; // bounds of reference widget in screen coordinates var referenceBounds = Xwt.Rectangle.Zero; // position of popup Func <Xwt.Point> calcPosition = () => { referenceBounds = new Xwt.Rectangle( GtkBackendHelper.ConvertToScreenCoordinates(reference, Xwt.Point.Zero), new Xwt.Size(reference.Allocation.Width, reference.Allocation.Height)); if (positionRect == Xwt.Rectangle.Zero) { positionRect = new Xwt.Rectangle(Xwt.Point.Zero, referenceBounds.Size); } positionRect = positionRect.Offset(referenceBounds.Location); return(new Xwt.Point(positionRect.X, positionRect.Bottom)); }; var popupPosition = calcPosition(); if (child == null) { popup.SetSizeRequest((int)referenceBounds.Width, (int)referenceBounds.Height); } else { popup.DefaultWidth = 10; child.ShowAll(); } var topLevelPos = GtkBackendHelper.ConvertToScreenCoordinates(topLevel, Xwt.Point.Zero); popup.TransientPosition = popupPosition.Offset(-topLevelPos.X, -topLevelPos.Y); Gtk.SizeAllocatedHandler sizeAllocated = (o, args) => { popup.Move((int)popupPosition.X, (int)popupPosition.Y); popup.GrabFocus(); }; popup.SizeAllocated += sizeAllocated; topLevel.AddEvents((int)Gdk.EventMask.StructureMask); topLevel.ConfigureEvent -= popup.TopLevelConfigureEvent; topLevel.ConfigureEvent += popup.TopLevelConfigureEvent; // if the mouse is moved in toplevel-window: Gtk.MotionNotifyEventHandler topLevelMotion = (s, args) => { if (topLevel == null) { return; } topLevelPos = GtkBackendHelper.ConvertToScreenCoordinates(topLevel, Xwt.Point.Zero); var referencePos = GtkBackendHelper.ConvertToScreenCoordinates(reference, Xwt.Point.Zero); // take args in sceen coordinates: var motionPos = new Xwt.Point(args.Event.XRoot, args.Event.YRoot);//topLevelPos.Offset (args.Event.X, args.Event.Y); var tolerance = popup.Tolerance; var popupSize = new Xwt.Size(popup.Allocation.Width, popup.Allocation.Height); // var refBounds = new Xwt.Rectangle (refPos, screenBounds.Size); var motionBounds = new Xwt.Rectangle( referencePos.X - tolerance.Left, referencePos.Y - tolerance.Top, popupSize.Width + tolerance.HorizontalSpacing, popupSize.Height + tolerance.VerticalSpacing); // TODO: hide if other event than move-event occurs outside of popup window // TODO: something is wrong with referencepos; maybe ConvertToScreenCoordinates has an error if (!motionBounds.Contains(motionPos)) { popup.HideAll(); } }; topLevel.MotionNotifyEvent += topLevelMotion; //ClientEvent: a message has been received from another application. popup.ShowAll(); popup.Hidden += (o, args) => { topLevel.ConfigureEvent -= popup.TopLevelConfigureEvent; topLevel.MotionNotifyEvent -= topLevelMotion; popup.ReleaseInnerWidget(); popup.Destroy(); }; return(popup); }
public static Gdk.Point ToGdkPoint(this Xwt.Point point) { return(new Gdk.Point((int)point.X, (int)point.Y)); }
protected override Xwt.Point CalculateWindowLocation(TextEditor editor, TooltipItem item, Xwt.WindowFrame xwtWindow, int mouseX, int mouseY, Xwt.Point origin) { int w; double xalign; GetRequiredPosition(editor, xwtWindow, out w, out xalign); w += 10; var allocation = GetAllocation(editor); var info = (TaggedTooltipInformation <CodeActions.CodeActionContainer>)item.Item; var loc = editor.OffsetToLocation(info.Tag.Span.Start); var p = editor.LocationToPoint(loc); var view = editor.GetContent <SourceEditorView> (); int x = (int)(p.X + origin.X + allocation.X + xPadding); int y = (int)(p.Y + view.TextEditor.GetLineHeight(loc.Line) + origin.Y + allocation.Y + yPadding); Gtk.Widget widget = editor; var geometry = widget.Screen.GetUsableMonitorGeometry(widget.Screen.GetMonitorAtPoint(x, y)); if (x + w >= geometry.X + geometry.Width) { x = geometry.X + geometry.Width - w; } if (x < geometry.Left) { x = geometry.Left; } if (info.Tag?.FloatingWidgetShown == true) { x += windowSize; } int h = (int)xwtWindow.Size.Height; if (y + h >= geometry.Y + geometry.Height) { y = geometry.Y + geometry.Height - h; } if (y < geometry.Top) { y = geometry.Top; } return(new Xwt.Point(x, y)); }
public Xwt.Point ConvertToParentCoordinates(Xwt.Point widgetCoordinates) { throw new NotImplementedException(); }
public static CoreGraphics.CGPoint ToCGPoint(this Xwt.Point r) { throw new NotImplementedException(); }
protected virtual Xwt.Point CalculateWindowLocation(TextEditor editor, TooltipItem item, Xwt.WindowFrame xwtWindow, int mouseX, int mouseY, Xwt.Point origin) { int w; double xalign; GetRequiredPosition(editor, xwtWindow, out w, out xalign); w += 10; var allocation = GetAllocation(editor); int x = (int)(mouseX + origin.X + allocation.X); int y = (int)(mouseY + origin.Y + allocation.Y); Gtk.Widget widget = editor; var geometry = widget.Screen.GetUsableMonitorGeometry(widget.Screen.GetMonitorAtPoint(x, y)); x -= (int)((double)w * xalign); y += 10; if (x + w >= geometry.X + geometry.Width) { x = geometry.X + geometry.Width - w; } if (x < geometry.Left) { x = geometry.Left; } int h = (int)xwtWindow.Size.Height; if (y + h >= geometry.Y + geometry.Height) { y = geometry.Y + geometry.Height - h; } if (y < geometry.Top) { y = geometry.Top; } return(new Xwt.Point(x, y)); }
public virtual override int GetRowAtPosition(Xwt.Point p) { throw new NotImplementedException(); }