public virtual Gtk.Window ShowTooltipWindow (MonoTextEditor editor, Gtk.Window tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			int ox = 0, oy = 0;
			if (editor.GdkWindow != null)
				editor.GdkWindow.GetOrigin (out ox, out oy);
			
			int w;
			double xalign;
			GetRequiredPosition (editor, tipWindow, out w, out xalign);
			w += 10;

			int x = mouseX + ox + editor.Allocation.X;
			int y = mouseY + oy + editor.Allocation.Y;
			Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry (editor.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 = tipWindow.SizeRequest ().Height;
			if (y + h >= geometry.Y + geometry.Height)
				y = geometry.Y + geometry.Height - h;
			if (y < geometry.Top)
				y = geometry.Top;
			
			tipWindow.Move (x, y);
			
			tipWindow.ShowAll ();

			return tipWindow;
		}
		protected override Gtk.Window CreateTooltipWindow (Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			LanguageItemWindow result = new LanguageItemWindow ((ExtensibleTextEditor) editor, modifierState, null, (string)item.Item, null);
			if (result.IsEmpty)
				return null;
			return result;
		}
		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 TTI;

			if (titem == null)
				return null;

			var result = new TooltipInformationWindow ();
			result.ShowArrow = true;

			foreach(var i in AmbiguousType.TryDissolve(titem.t))
			{
				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;
		}
Exemple #4
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;

            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 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;
        }
		public Gtk.Window CreateTooltipWindow (Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			ExtensibleTextEditor ed = (ExtensibleTextEditor) editor;
			ParsedDocument doc = ProjectDomService.GetParsedDocument (null, ed.Document.FileName);
			
			ResolveResult resolveResult = (ResolveResult)item.Item;
			if (lastResult != null && lastResult.ResolvedExpression != null && lastWindow.IsRealized && 
			    resolveResult != null && resolveResult.ResolvedExpression != null &&  lastResult.ResolvedExpression.Expression == resolveResult.ResolvedExpression.Expression)
				return lastWindow;
			LanguageItemWindow result = new LanguageItemWindow (ed, modifierState, resolveResult, null, doc != null ? doc.CompilationUnit : null);
			lastWindow = result;
			lastResult = resolveResult;
			if (result.IsEmpty)
				return null;
			return result;
		}
		public Gtk.Window CreateTooltipWindow (Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			var ed = (ExtensibleTextEditor)editor;
			var doc = ed.ParsedDocument;
			if (doc == null)
				return null;
			
			var resolveResult = (ResolveResult)item.Item;
			if (lastResult != null && lastWindow.IsRealized && 
			    resolveResult != null && lastResult.Type.Equals (resolveResult.Type))
				return lastWindow;
			var result = new LanguageItemWindow (ed, modifierState, resolveResult, null, doc.ParsedFile);
			lastWindow = result;
			lastResult = resolveResult;
			if (result.IsEmpty)
				return null;
			return result;
		}
Exemple #7
0
        public Window CreateTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            //create a message string from all the results
            var results = item.Item as AbstractTooltipContent[];

            var win = new DToolTipWindow();

            // Set white background
            win.ModifyBg(StateType.Normal,new Gdk.Color(0xff,0xff,0xff));

            var pack = new Gtk.VBox();

            foreach (var r in results)
            {
                var titleLabel = new Label(r.Title);

                // Make left-bound
                titleLabel.SetAlignment(0, 0);

                // Set bold font
                titleLabel.ModifyFont(new Pango.FontDescription() {Weight=Weight.Bold, AbsoluteSize=12*(int)Pango.Scale.PangoScale});

                pack.Add(titleLabel);

                if (!string.IsNullOrEmpty( r.Description))
                {
                    const int maximumDescriptionLength = 300;
                    var descLabel = new Label(r.Description.Length>maximumDescriptionLength ? (r.Description.Substring(0,maximumDescriptionLength)+"...") : r.Description);

                    descLabel.ModifyFont(new Pango.FontDescription() { AbsoluteSize = 10 * (int)Pango.Scale.PangoScale });
                    descLabel.SetAlignment(0, 0);

                    pack.Add(descLabel);
                }
            }

            win.Add(pack);

            return win;
        }
		protected override Gtk.Window CreateTooltipWindow (TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			//create a message string from all the results
			var results = (IList<Result>)item.Item;
			var sb = new StringBuilder ();
			bool first = false;
			foreach (var r in results) {
				if (!first)
					first = true;
				else
					sb.AppendLine ();
				sb.Append (r.Level.ToString ());
				sb.Append (": ");
				sb.Append (r.Message);
			}
			
			//FIXME: use a nicer, more specialized tooltip window, with results formatting and hints about 
			// commands and stuff
			var win = new LanguageItemWindow ((ExtensibleTextEditor) editor, modifierState, null, sb.ToString (), null);
			if (win.IsEmpty)
				return null;
			return win;
		}
		public override Gtk.Window ShowTooltipWindow (MonoTextEditor editor, Gtk.Window tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			var wrappedEditor = WrapEditor (editor);
			if (wrappedEditor == null) {
				return tipWindow;
			}
			provider.ShowTooltipWindow (wrappedEditor, tipWindow, new MonoDevelop.Ide.Editor.TooltipItem (item.Item, item.ItemSegment.Offset, item.ItemSegment.Length), modifierState, mouseX, mouseY);
			return tipWindow;
		}
		public Gtk.Window CreateTooltipWindow (Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			return new DebugValueWindow (editor, offset, DebuggingService.CurrentFrame, (ObjectValue) item.Item, null);
		}
Exemple #11
0
 public Gtk.Window CreateTooltipWindow(Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
 {
     Mono.TextEditor.PopupWindow.TooltipWindow window = new Mono.TextEditor.PopupWindow.TooltipWindow ();
     window.Markup = item.Item.ToString(); // Tooltip;
     return window;
 }
		public void Dispose ()
		{
			DestroyLastTooltipWindow ();
			lastNode = null;
			lastResult = null;
		}
		public void Dispose ()
		{
			var disposableProvider = provider as IDisposable;
			if (disposableProvider != null) {
				disposableProvider.Dispose ();
			}
			lastWrappedItem = null;
			lastUnwrappedItem = null;
		}
		public override Gtk.Window CreateTooltipWindow (MonoTextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			var wrappedEditor = WrapEditor (editor);
			if (wrappedEditor == null)
				return null;
			var control = provider.CreateTooltipWindow (wrappedEditor, IdeApp.Workbench.ActiveDocument, new MonoDevelop.Ide.Editor.TooltipItem (item.Item, item.ItemSegment.Offset, item.ItemSegment.Length), offset, modifierState);
			if (control == null)
				return null;
			return (Gtk.Window)control;
		}
		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;
		}
        public virtual Window ShowTooltipWindow(TextEditor editor, int offset, ModifierKeys modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            Window tipWindow = CreateTooltipWindow(editor, offset, modifierState, item);

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

            double w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, out w, out xalign);
            w += 10;

            var loc = editor.ConvertToScreenCoordinates(new Point(mouseX, mouseY));

            /*int x = mouseX + ox + editor.Allocation.X;
             * int y = mouseY + oy + editor.Allocation.Y;
             * Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry (editor.Screen.GetMonitorAtPoint (x, y));
             */
            var geometry = editor.ScreenBounds;

            loc.X -= w * xalign;
            loc.Y += 10;

            if (loc.X + w >= geometry.X + geometry.Width)
            {
                loc.X = geometry.X + geometry.Width - w;
            }
            if (loc.X < geometry.Left)
            {
                loc.X = geometry.Left;
            }

            var h = tipWindow.Height;

            if (loc.Y + h >= geometry.Y + geometry.Height)
            {
                loc.Y = geometry.Y + geometry.Height - h;
            }
            if (loc.Y < geometry.Top)
            {
                loc.Y = geometry.Top;
            }

            tipWindow.Location = loc;

            tipWindow.Show();

            return(tipWindow);
        }
 protected virtual Window CreateTooltipWindow(TextEditor editor, int offset, ModifierKeys modifierState, TooltipItem item)
 {
     return(null);
 }
Exemple #18
0
        public virtual Xwt.Window ShowTooltipWindow(TextEditor editor, double offset, Xwt.ModifierKeys modifierState, Point mouse, TooltipItem item)
        {
            Xwt.Window tipWindow = CreateTooltipWindow(editor, offset, modifierState, item);
            if (tipWindow == null)
            {
                return(null);
            }

            var point = editor.ConvertToScreenCoordinates(mouse);

            double w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, out w, out xalign);
            w += 10;

            Rectangle geometry = editor.ParentWindow.Screen.VisibleBounds;

            point.X -= (int)((double)w * xalign);
            point.Y += 10;

            if (point.X + w >= geometry.X + geometry.Width)
            {
                point.X = geometry.X + geometry.Width - w;
            }
            if (point.X < geometry.Left)
            {
                point.X = geometry.Left;
            }

            var h = tipWindow.Size.Height;

            if (point.Y + h >= geometry.Y + geometry.Height)
            {
                point.Y = geometry.Y + geometry.Height - h;
            }
            if (point.Y < geometry.Top)
            {
                point.Y = geometry.Top;
            }

            tipWindow.Location = point;

            tipWindow.Show();

            return(tipWindow);
        }
Exemple #19
0
 protected virtual Xwt.Window CreateTooltipWindow(TextEditor editor, double offset, Xwt.ModifierKeys modifierState, TooltipItem item)
 {
     return(null);
 }
		public Window CreateTooltipWindow (Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			return new LanguageItemWindow (editor as ExtensibleTextEditor, modifierState,  null, item.Item as string, null);
		}
		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);
			if (tooltipInformation == null || string.IsNullOrEmpty (tooltipInformation.SignatureMarkup))
				return null;

			var result = new TooltipInformationWindow ();
			result.ShowArrow = true;
			result.AddOverload (tooltipInformation);
			result.RepositionWindow ();
			return result;
		}
        public Gtk.Window CreateTooltipWindow(TextEditor Editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            TextLink link = item.Item as TextLink;

            if (link == null || string.IsNullOrEmpty(link.Tooltip))
            {
                return(null);
            }

            TooltipWindow window = new TooltipWindow();

            window.Markup = link.Tooltip;
            return(window);
        }
		public override TooltipItem GetItem (Mono.TextEditor.TextEditor editor, int offset)
		{
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null || doc.ParsedDocument == null)
				return null;
			var unit = doc.ParsedDocument.GetAst<SyntaxTree> ();
			if (unit == null)
				return null;

			var file = doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile;
			if (file == null)
				return null;
			
			ResolveResult result;
			AstNode node;
			var loc = editor.OffsetToLocation (offset);
			if (!doc.TryResolveAt (loc, out result, out node)) {
				if (node is CSharpTokenNode) {
					int startOffset2 = editor.LocationToOffset (node.StartLocation);
					int endOffset2 = editor.LocationToOffset (node.EndLocation);

					return new TooltipItem (new ToolTipData (unit, result, node, null), startOffset2, endOffset2 - startOffset2);
				}
				return null;
			}
			if (node == lastNode)
				return lastResult;
			var resolver = new CSharpAstResolver (doc.Compilation, unit, file);
			resolver.ApplyNavigator (new NodeListResolveVisitorNavigator (node), CancellationToken.None);

			var hoverNode = node.GetNodeAt (loc) ?? node;

			int startOffset = editor.LocationToOffset (hoverNode.StartLocation);
			int endOffset = editor.LocationToOffset (hoverNode.EndLocation);
			return lastResult = new TooltipItem (new ToolTipData (unit, result, node, resolver), startOffset, endOffset - startOffset);
		}
		public override async Task<TooltipItem> GetItem (MonoTextEditor editor, int offset, CancellationToken token = default(CancellationToken))
		{
			var wrappedEditor = WrapEditor (editor);
			if (wrappedEditor == null)
				return null;
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null)
				return null;
			var task = provider.GetItem (wrappedEditor, doc, offset, token);
			if (task == null) {
				LoggingService.LogWarning ("Tooltip provider " + provider + " gave back null on GetItem (should always return a non null task).");
				return null;
			}
			var item = await task;
			if (item == null)
				return null;
			if (lastUnwrappedItem != null) {
				if (lastUnwrappedItem.Offset == item.Offset &&
					lastUnwrappedItem.Length == item.Length &&
					lastUnwrappedItem.Item.Equals (item.Item)) {
					return lastWrappedItem;
				}
			}
			lastUnwrappedItem = item;
			return lastWrappedItem = new TooltipItem (item.Item, item.Offset, item.Length);
		}
		public 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;
			string tooltip = null;
			if (titem.Result is UnknownIdentifierResolveResult) {
				tooltip = string.Format ("error CS0103: The name `{0}' does not exist in the current context", ((UnknownIdentifierResolveResult)titem.Result).Identifier);
			} else if (titem.Result is UnknownMemberResolveResult) {
				var ur = (UnknownMemberResolveResult)titem.Result;
				if (ur.TargetType.Kind != TypeKind.Unknown)
					tooltip = string.Format ("error CS0117: `{0}' does not contain a definition for `{1}'", ur.TargetType.FullName, ur.MemberName);
			} else if (titem.Result.IsError) {
				tooltip = "Resolve error.";
			} else if (titem.Result != null) {
				var ev = new ErrorVisitor (titem.Resolver);
				if (titem.Node is AstType && titem.Node.Parent is VariableDeclarationStatement && titem.Node.GetText () == "var") {
					titem.Node.Parent.AcceptVisitor (ev);
				}
				if (ev.ErrorResolveResult != null) {
					Console.WriteLine (ev.ErrorResolveResult);
					tooltip = string.Format ("Error while resolving: '{0}'", ev.ErrorNode.GetText ());
				} else {
					tooltip = CreateTooltip (titem.Result, offset, ambience);
				}
			} else {
				return null;
			}


			if (lastResult != null && lastWindow.IsRealized && 
				titem.Result != null && lastResult.Type.Equals (titem.Result.Type))
				return lastWindow;
			var result = new LanguageItemWindow (tooltip);
			lastWindow = result;
			lastResult = titem.Result;
			if (result.IsEmpty)
				return null;
			return result;
		}
        protected override Window CreateTooltipWindow(TextEditor Editor, int offset, ModifierKeys modifierState, TooltipItem item)
        {
            TextLink link = item.Item as TextLink;

            if (link == null || string.IsNullOrEmpty(link.Tooltip))
            {
                return(null);
            }

            TooltipWindow window = new TooltipWindow();

            window.Markup = link.Tooltip;
            return(window);
        }
		protected virtual Gtk.Window CreateTooltipWindow (TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
		{
			return null;
		}
Exemple #28
0
 public virtual Gtk.Window CreateTooltipWindow(MonoTextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
 {
     return(null);
 }
		public override Gtk.Window ShowTooltipWindow (TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			var location = editor.OffsetToLocation (item.ItemSegment.Offset);
			var point = editor.LocationToPoint (location);
			int lineHeight = (int) editor.LineHeight;
			int y = (int) point.Y;

			// find the top of the line that the mouse is hovering over
			while (y + lineHeight < mouseY)
				y += lineHeight;

			var caret = new Gdk.Rectangle (mouseX - editor.Allocation.X, y - editor.Allocation.Y, 1, lineHeight);

			tooltip = new DebugValueWindow (editor, offset, DebuggingService.CurrentFrame, (ObjectValue) item.Item, null);
			tooltip.ShowPopup (editor, caret, PopupPosition.TopLeft);

			return tooltip;
		}
Exemple #30
0
        public virtual Gtk.Window ShowTooltipWindow(MonoTextEditor editor, Gtk.Window tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            int ox = 0, oy = 0;

            if (editor.GdkWindow != null)
            {
                editor.GdkWindow.GetOrigin(out ox, out oy);
            }

            int    w;
            double xalign;

            GetRequiredPosition(editor, tipWindow, out w, out xalign);
            w += 10;

            int x = mouseX + ox + editor.Allocation.X;
            int y = mouseY + oy + editor.Allocation.Y;

            Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry(editor.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 = tipWindow.SizeRequest().Height;

            if (y + h >= geometry.Y + geometry.Height)
            {
                y = geometry.Y + geometry.Height - h;
            }
            if (y < geometry.Top)
            {
                y = geometry.Top;
            }

            tipWindow.Move(x, y);

            tipWindow.ShowAll();

            return(tipWindow);
        }