public IWpfTextView CreateTextView(MonoDevelop.Ide.Editor.TextEditor textEditor, ITextViewRoleSet roles = null, IEditorOptions parentOptions = null) { if (textEditor == null) { throw new ArgumentNullException("textEditor"); } if (roles == null) { roles = _defaultRoles; } ITextBuffer textBuffer = textEditor.GetContent <Mono.TextEditor.ITextEditorDataProvider>().GetTextEditorData().Document.TextBuffer; ITextDataModel dataModel = new VacuousTextDataModel(textBuffer); ITextViewModel viewModel = UIExtensionSelector.InvokeBestMatchingFactory (TextViewModelProviders, dataModel.ContentType, roles, (provider) => (provider.CreateTextViewModel(dataModel, roles)), ContentTypeRegistryService, this.GuardedOperations, this) ?? new VacuousTextViewModel(dataModel); TextView view = new TextView(textEditor, viewModel, roles ?? this.DefaultRoles, parentOptions ?? this.EditorOptionsFactoryService.GlobalOptions, this); view.Properties.AddProperty(typeof(MonoDevelop.Ide.Editor.TextEditor), textEditor); this.TextViewCreated?.Invoke(this, new TextViewCreatedEventArgs(view)); return(view); }
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(); } }
public ITextView CreateTextView(MonoDevelop.Ide.Editor.TextEditor textEditor) { if (textEditor == null) { throw new ArgumentNullException("textEditor"); } var roles = _defaultRoles; ITextBuffer textBuffer = textEditor.GetContent <Mono.TextEditor.ITextEditorDataProvider>().GetTextEditorData().Document.TextBuffer; ITextDataModel dataModel = new VacuousTextDataModel(textBuffer); var providers = TextViewModelProviders .Where(t => allowedTextViewModelProviders.Contains(t.Value.ToString())) .ToArray(); ITextViewModel viewModel = UIExtensionSelector.InvokeBestMatchingFactory (providers, dataModel.ContentType, roles, (provider) => (provider.CreateTextViewModel(dataModel, roles)), ContentTypeRegistryService, this.GuardedOperations, this) ?? new VacuousTextViewModel(dataModel); var view = ((MonoDevelop.SourceEditor.SourceEditorView)textEditor.Implementation).TextEditor; view.Initialize(viewModel, roles, this.EditorOptionsFactoryService.GlobalOptions, this); view.Properties.AddProperty(typeof(MonoDevelop.Ide.Editor.TextEditor), textEditor); this.TextViewCreated?.Invoke(this, new TextViewCreatedEventArgs(view)); return(view); }
public virtual void ShowTooltipWindow(TextEditor editor, Control tipWindow, TooltipItem item, Xwt.ModifierKeys modifierState, int mouseX, int mouseY) { if (tipWindow == null) { return; } var tipInfoWindow = ((Gtk.Widget)tipWindow) 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 gtkWindow = (Gtk.Window)tipWindow; int h = gtkWindow.SizeRequest().Height; if (y + h >= geometry.Y + geometry.Height) { y = geometry.Y + geometry.Height - h; } if (y < geometry.Top) { y = geometry.Top; } gtkWindow.Move(x, y); gtkWindow.ShowAll(); }
protected Xwt.Rectangle GetAllocation(TextEditor editor) { return(editor.GetContent <ITextEditorImpl> ().GetEditorAllocation()); }
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(); } }