コード例 #1
0
        static Window CreatePackageWindow(InfoItem infoItem)
        {
            var window = new TooltipInformationWindow();

            window.ShowArrow = true;
            window.RepositionWindow();

            var cts = new CancellationTokenSource();

            window.Closed += delegate { cts.Cancel(); };

            var packages = infoItem.Packages;
            TooltipInformation ti;
            bool done = CreatePackageTooltipInfo((string)infoItem.ResolveResult.Reference, packages, out ti);

            if (!done)
            {
                packages.ContinueWith(t => {
                    if (!done)
                    {
                        done = CreatePackageTooltipInfo((string)infoItem.ResolveResult.Reference, packages, out ti);
                        if (ti != null)
                        {
                            window.Clear();
                            window.AddOverload(ti);
                        }
                    }
                }, cts.Token, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
            }

            window.AddOverload(ti);
            return(window);
        }
コード例 #2
0
        protected override Gtk.Window CreateTooltipWindow(Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null)
            {
                return(null);
            }

            var titem = (ToolTipData)item.Item;

            var tooltipInformation = CreateTooltip(titem, offset, null, modifierState);

            if (tooltipInformation == null || string.IsNullOrEmpty(tooltipInformation.SignatureMarkup))
            {
                return(null);
            }

            var result = new TooltipInformationWindow();

            result.ShowArrow = true;
            result.AddOverload(tooltipInformation);
            result.RepositionWindow();
            return(result);
        }
コード例 #3
0
        public override Gtk.Window ShowTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            var titem = (ToolTipData)item.Item;

            if (lastNode != null && lastWindow != null && lastWindow.IsRealized && titem.Node != null && lastNode == titem.Node)
            {
                return(lastWindow);
            }

            DestroyLastTooltipWindow();

            var tipWindow = CreateTooltipWindow(editor, offset, modifierState, item) as TooltipInformationWindow;

            if (tipWindow == null)
            {
                return(null);
            }

            var hoverNode      = titem.Node.GetNodeAt(editor.OffsetToLocation(offset)) ?? titem.Node;
            var p1             = editor.LocationToPoint(hoverNode.StartLocation);
            var p2             = editor.LocationToPoint(hoverNode.EndLocation);
            var positionWidget = editor.TextArea;
            var caret          = new Gdk.Rectangle((int)p1.X - positionWidget.Allocation.X, (int)p2.Y - positionWidget.Allocation.Y, (int)(p2.X - p1.X), (int)editor.LineHeight);

            tipWindow.ShowPopup(positionWidget, caret, PopupPosition.Top);
            tipWindow.EnterNotifyEvent += delegate {
                editor.HideTooltip(false);
            };
            lastWindow = tipWindow;
            lastNode   = titem.Node;
            return(tipWindow);
        }
コード例 #4
0
        public virtual void ShowTooltipWindow(TextEditor editor, Window tipWindow, TooltipItem item, Xwt.ModifierKeys modifierState, int mouseX, int mouseY)
        {
            if (tipWindow == null)
            {
                return;
            }

            TooltipInformationWindow tipInfoWindow = (tipWindow as XwtWindowControl)?.Window as TooltipInformationWindow;

            if (tipInfoWindow != null)
            {
                ShowTipInfoWindow(editor, tipInfoWindow, item, modifierState, mouseX, mouseY);
                return;
            }

            var origin = editor.GetContent <ITextEditorImpl> ().GetEditorWindowOrigin();


            var xwtWindow = (Xwt.WindowFrame)tipWindow;

            xwtWindow.Location = CalculateWindowLocation(editor, item, xwtWindow, mouseX, mouseY, origin);

            var gtkWindow = Xwt.Toolkit.Load(Xwt.ToolkitType.Gtk).GetNativeWindow(xwtWindow) as Gtk.Window;

            if (gtkWindow != null)
            {
                gtkWindow.ShowAll();
            }
            else
            {
                xwtWindow.Show();
            }
        }
        /// <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);
        }
コード例 #6
0
        public SearchPopupWidget()
        {
            headerColor = Styles.GlobalSearch.HeaderTextColor;
            selectionBackgroundColor = Styles.GlobalSearch.SelectionBackgroundColor;

            Toolkit.Load(ToolkitType.Gtk).Invoke(() => declarationviewwindow = new TooltipInformationWindow());

            categories.Add(new FileSearchCategory());
            categories.Add(new CommandSearchCategory());
            categories.Add(new SearchInSolutionSearchCategory());
            foreach (var cat in AddinManager.GetExtensionObjects <SearchCategory> ("/MonoDevelop/Ide/SearchCategories"))
            {
                categories.Add(cat);
                cat.Initialize(ParentWindow as XwtPopup);
            }

            categories.Sort();

            layout       = new TextLayout();
            headerLayout = new TextLayout();

            layout.Trimming       = TextTrimming.WordElipsis;
            headerLayout.Trimming = TextTrimming.WordElipsis;

            ItemActivated += (sender, e) => OpenFile();
        }
コード例 #7
0
 static void DestroyLastTooltipWindow()
 {
     if (lastWindow != null)
     {
         lastWindow.Destroy();
         lastWindow = null;
     }
 }
コード例 #8
0
        public override Window ShowTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            var titem = (item.Item as TTI).sr;

            DestroyLastTooltipWindow();

            var tipWindow = CreateTooltipWindow(editor, offset, modifierState, item) as TooltipInformationWindow;

            if (tipWindow == null)
            {
                return(null);
            }

            var positionWidget = editor.TextArea;

            Cairo.Point p1, p2;

            var dn = titem as INode;

            if (dn != null)
            {
                if (dn.NameLocation.IsEmpty)
                {
                    p1 = p2 = editor.LocationToPoint(dn.Location.Line, dn.Location.Column);
                }
                else
                {
                    p1 = editor.LocationToPoint(dn.NameLocation.Line, dn.NameLocation.Column);
                    p2 = editor.LocationToPoint(dn.NameLocation.Line, dn.NameLocation.Column + (dn.Name ?? "").Length);
                }
            }
            else
            {
                p1 = editor.LocationToPoint(editor.OffsetToLocation(item.ItemSegment.Offset));
                p2 = editor.LocationToPoint(editor.OffsetToLocation(item.ItemSegment.EndOffset));
            }

            var caret = new Gdk.Rectangle(p1.X - positionWidget.Allocation.X, p2.Y - positionWidget.Allocation.Y, (p2.X - p1.X), (int)editor.LineHeight);

            tipWindow.ShowPopup(positionWidget, caret, PopupPosition.Top);


            lastWindow = tipWindow;

            tipWindow.EnterNotifyEvent += delegate {
                editor.HideTooltip(false);
            };

            //lastNode = titem.Result;
            return(tipWindow);
        }
        public override Window CreateTooltipWindow(
            TextEditor editor,
            DocumentContext ctx,
            TooltipItem item,
            int offset,
            Xwt.ModifierKeys modifierState)
        {
            var result = new TooltipInformationWindow();

            result.ShowArrow = true;
            result.AddOverload((TooltipInformation)item.Item);
            result.RepositionWindow();

            return(result);
        }
コード例 #10
0
        public override Components.Window CreateTooltipWindow(Ide.Editor.TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState)
        {
            var doc = ctx;

            if (doc == null)
            {
                return(null);
            }

            var result = new TooltipInformationWindow();

            result.ShowArrow = true;
            result.AddOverload((TooltipInformation)item.Item);
            result.RepositionWindow();
            return(result);
        }
コード例 #11
0
        static Window CreateItemWindow(InfoItem infoItem)
        {
            TooltipInformation ti = null;

            ti = CreateTooltipInformation(infoItem.Doc, infoItem.Info, infoItem.ResolveResult);
            if (ti == null)
            {
                return(null);
            }

            var window = new TooltipInformationWindow();

            window.AddOverload(ti);
            window.ShowArrow = true;
            window.RepositionWindow();
            return(window);
        }
コード例 #12
0
        public override Window ShowTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            var titems = item.Item as AbstractType;            /*
                                                                * if (lastNode != null && lastWindow != null && lastWindow.IsRealized && titem.Result != null && lastNode == titem.Result)
                                                                * return lastWindow;*/

            DestroyLastTooltipWindow();

            var tipWindow = CreateTooltipWindow(editor, offset, modifierState, item) as TooltipInformationWindow;

            if (tipWindow == null)
            {
                return(null);
            }

            var titem          = titems.DeclarationOrExpressionBase;
            var positionWidget = editor.TextArea;

            Cairo.Point p1, p2;

            if (titem != null)
            {
                p1 = editor.LocationToPoint(titem.Location.Line, titem.Location.Column);
                p2 = editor.LocationToPoint(titem.EndLocation.Line, titem.EndLocation.Column);
            }
            else
            {
                p1 = editor.LocationToPoint(editor.OffsetToLocation(item.ItemSegment.Offset));
                p2 = editor.LocationToPoint(editor.OffsetToLocation(item.ItemSegment.EndOffset));
            }

            var caret = new Gdk.Rectangle(p1.X - positionWidget.Allocation.X, p2.Y - positionWidget.Allocation.Y, (p2.X - p1.X), (int)editor.LineHeight);

            tipWindow.ShowPopup(positionWidget, caret, PopupPosition.Top);


            lastWindow = tipWindow;

            tipWindow.EnterNotifyEvent += delegate {
                editor.HideTooltip(false);
            };

            //lastNode = titem.Result;
            return(tipWindow);
        }
コード例 #13
0
        private async Task UpdateDescription()
        {
            if (descriptionWindow != null)
            {
                descriptionWindow.Destroy();
                descriptionWindow = null;
            }
            descriptionCts.Cancel();
            if (SelectedItemIndex == -1)
            {
                return;
            }
            var completionItem = SelectedItem;

            descriptionCts = new CancellationTokenSource();
            var token = descriptionCts.Token;


            TooltipInformation description = null;

            try {
                var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChangesSafe();
                description = await RoslynCompletionData.CreateTooltipInformation(document, completionItem, false, token);
            } catch {
            }
            if (token.IsCancellationRequested)
            {
                return;
            }
            if (descriptionWindow != null)
            {
                descriptionWindow.Destroy();
                descriptionWindow = null;
            }
            if (description == null)
            {
                return;
            }
            var window = new TooltipInformationWindow();

            window.AddOverload(description);
            descriptionWindow = window;
            ShowDescription();
        }
コード例 #14
0
        void ShowDescription(TooltipInformation description)
        {
            HideDescription();

            if (description == null)
            {
                return;
            }

            var window = new TooltipInformationWindow();

            window.AddOverload(description);
            descriptionWindow = window;
            var rect = GetRowArea(SelectedItemIndex);
            int y    = rect.Y + Theme.Padding - (int)vadj.Value;

            descriptionWindow.ShowPopup(this, new Gdk.Rectangle(0, Math.Min(Allocation.Height, Math.Max(0, y)), Allocation.Width, rect.Height), PopupPosition.Left);
            descriptionWindow.Show();
        }
コード例 #15
0
        protected override Window CreateTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null)
            {
                return(null);
            }

            var titem = item.Item as AbstractType;

            if (titem == null)
            {
                return(null);
            }

            var result = new TooltipInformationWindow();

            result.ShowArrow = true;

            foreach (var i in AmbiguousType.TryDissolve(titem))
            {
                if (i == null)
                {
                    continue;
                }
                var tooltipInformation = TooltipInfoGen.Create(i, editor.ColorStyle);
                if (tooltipInformation != null && !string.IsNullOrEmpty(tooltipInformation.SignatureMarkup))
                {
                    result.AddOverload(tooltipInformation);
                }
            }

            if (result.Overloads < 1)
            {
                result.Dispose();
                return(null);
            }

            result.RepositionWindow();
            return(result);
        }
コード例 #16
0
        void ShowTipInfoWindow(TextEditor editor, TooltipInformationWindow tipWindow, TooltipItem item, Xwt.ModifierKeys modifierState, int mouseX, int mouseY)
        {
            Gtk.Widget editorWidget = editor;

            var startLoc = editor.OffsetToLocation(item.Offset);
            var endLoc   = editor.OffsetToLocation(item.EndOffset);
            var p1       = editor.LocationToPoint(startLoc);
            var p2       = editor.LocationToPoint(endLoc);

            int w = (int)(p2.X - p1.X);

            var caret = new Gdk.Rectangle(
                (int)p1.X,
                (int)p1.Y,
                (int)w,
                (int)editor.LineHeight
                );

            tipWindow.ShowPopup(editorWidget, caret, PopupPosition.Top);
        }
コード例 #17
0
        public override Control CreateTooltipWindow(TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Gdk.ModifierType modifierState)
        {
            var doc = ctx;

            if (doc == null)
            {
                return(null);
            }

            var titem = (ToolTipData)item.Item;

            var tooltipInformation = CreateTooltip(titem, editor, ctx, offset, modifierState);

            if (tooltipInformation == null || string.IsNullOrEmpty(tooltipInformation.SignatureMarkup))
            {
                return(null);
            }
            var result = new TooltipInformationWindow();

            result.ShowArrow = true;
            result.AddOverload(tooltipInformation);
            result.RepositionWindow();
            return(result);
        }
コード例 #18
0
        public virtual void ShowTooltipWindow(TextEditor editor, Window tipWindow, TooltipItem item, Xwt.ModifierKeys modifierState, int mouseX, int mouseY)
        {
            if (tipWindow == null)
            {
                return;
            }

            TooltipInformationWindow tipInfoWindow = (tipWindow as XwtWindowControl)?.Window as TooltipInformationWindow;

            if (tipInfoWindow != null)
            {
                ShowTipInfoWindow(editor, tipInfoWindow, item, modifierState, mouseX, mouseY);
                return;
            }

            var origin = editor.GetContent <ITextEditorImpl> ().GetEditorWindowOrigin();

            int    w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, 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;
            }

            var xwtWindow = (Xwt.WindowFrame)tipWindow;
            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;
            }

            xwtWindow.Location = new Xwt.Point(x, y);
            var gtkWindow = Xwt.Toolkit.Load(Xwt.ToolkitType.Gtk).GetNativeWindow(xwtWindow) as Gtk.Window;

            if (gtkWindow != null)
            {
                gtkWindow.ShowAll();
            }
            else
            {
                xwtWindow.Show();
            }
        }