public DockNotebookContainer (DockNotebook tabControl, bool isMasterTab = false) { this.isMasterTab = isMasterTab; this.tabControl = tabControl; Child = tabControl; if (!isMasterTab) tabControl.PageRemoved += HandlePageRemoved; }
} = null !; // NRT - Set in Initialize public void Initialize(Dock workspace) { Notebook = new DockNotebook(); var canvas_dock = new DockItem(Notebook, "Canvas", locked: true) { Label = Translations.GetString("Canvas") }; workspace.AddItem(canvas_dock, DockPlacement.Center); }
public SdiWorkspaceWindow(DefaultWorkbench workbench, DocumentController controller, DockNotebook tabControl, DockNotebookTab tabLabel) : base() { this.workbench = workbench; this.tabControl = tabControl; this.controller = controller; this.tab = tabLabel; // The previous WorkbenchWindow property assignement may end with a call to AttachViewContent, // which will add the content control to the subview notebook. In that case, we don't need to add it to box controller.DocumentTitleChanged += SetTitleEvent; controller.HasUnsavedChangesChanged += HandleDirtyChanged; SetTitleEvent(); }
internal void SetDockNotebook(DockNotebook tabControl, DockNotebookTab tabLabel) { var oldNotebook = tabControl; this.tabControl = tabControl; this.tab = tabLabel; SetTitleEvent(); SetDockNotebookTabTitle(); if (oldNotebook != tabControl) { NotebookChanged?.Invoke(this, new NotebookChangeEventArgs { OldNotebook = oldNotebook, NewNotebook = tabControl }); } }
public void Initialize(DockFrame workspace, Menu padMenu) { var tab = new DockNotebook() { NavigationButtonsVisible = false }; NotebookContainer = new DockNotebookContainer(tab, true); tab.InitSize(); var canvas_dock = workspace.AddItem("Canvas"); canvas_dock.Behavior = DockItemBehavior.Locked; canvas_dock.Expand = true; canvas_dock.DrawFrame = false; canvas_dock.Label = Catalog.GetString("Canvas"); canvas_dock.Content = NotebookContainer; }
internal void ShowPopup(DockNotebook notebook, int tabIndex, Gdk.EventButton evt) { notebook.CurrentTabIndex = tabIndex; IdeApp.CommandService.ShowContextMenu (notebook, evt, "/MonoDevelop/Ide/ContextMenu/DocumentTab"); }
internal void RemoveTab(DockNotebook tabControl, int pageNum, bool animate) { try { // Weird switch page events are fired when a tab is removed. // This flag avoids unneeded events. LockActiveWindowChangeEvent (); IWorkbenchWindow w = ActiveWorkbenchWindow; tabControl.RemoveTab (pageNum, animate); } finally { UnlockActiveWindowChangeEvent (); } }
public virtual void ShowView(IViewContent content, bool bringToFront, DockNotebook notebook = null) { var mimeimage = PrepareShowView (content); var addToControl = notebook ?? DockNotebook.ActiveNotebook ?? tabControl; var tab = addToControl.AddTab (); SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, addToControl, tab); sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); }; sdiWorkspaceWindow.Closed += CloseWindowEvent; sdiWorkspaceWindow.Show (); tab.Content = sdiWorkspaceWindow; if (mimeimage != null) tab.Icon = mimeimage; if (content.Project != null) content.Project.NameChanged += HandleProjectNameChanged; if (bringToFront) content.WorkbenchWindow.SelectWindow(); // The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged) OnActiveWindowChanged (null, null); }
public void PlaceWindow (DockNotebook notebook) { try { IdeApp.Workbench.LockActiveWindowChangeEvent (); var allocation = Allocation; Destroy (); if (placementDelegate != null) { var tab = notebook.CurrentTab; notebook.RemoveTab (tab.Index, true); placementDelegate (notebook, tab, allocation, curX, curY); } else { ((SdiWorkspaceWindow)frame.Content).SelectWindow (); } } finally { IdeApp.Workbench.UnlockActiveWindowChangeEvent (); } }
void PlaceInHoverNotebook (DockNotebook notebook, DockNotebookTab tab, Rectangle allocation, int ox, int oy) { var window = (SdiWorkspaceWindow)tab.Content; var newTab = hoverNotebook.AddTab (window); window.SetDockNotebook (hoverNotebook, newTab); window.SelectWindow (); }
static void PlaceInFloatingFrame (DockNotebook notebook, DockNotebookTab tab, Rectangle allocation, int ox, int oy) { var newWindow = new DockWindow (); var newNotebook = newWindow.Container.GetFirstNotebook (); var newTab = newNotebook.AddTab (); var workspaceWindow = (SdiWorkspaceWindow)tab.Content; newTab.Content = workspaceWindow; newWindow.Title = DefaultWorkbench.GetTitle (workspaceWindow); workspaceWindow.SetDockNotebook (newNotebook, newTab); newWindow.Move (ox - w / 2, oy - h / 2); newWindow.Resize (w, h); newWindow.ShowAll (); DockNotebook.ActiveNotebook = newNotebook; }
public void ShowPlaceholder (int x, int y) { hoverNotebook = null; // TODO: Handle z-ordering of floating windows. int ox = 0, oy = 0; foreach (var notebook in allNotebooks) { if (notebook.GdkWindow == null) continue; int ox2, oy2; notebook.ParentWindow.GetOrigin (out ox2, out oy2); var alloc = notebook.Allocation; ox2 += alloc.X; ox2 += alloc.Y; if (ox2 <= x && x <= ox2 + alloc.Width && oy2 <= y && y <= oy2 + alloc.Height) { hoverNotebook = notebook; TransientFor = (Gtk.Window) hoverNotebook.Toplevel; ox = ox2; oy = oy2; break; } } if (CanPlaceInHoverNotebook ()) { var container = hoverNotebook.Container; var alloc = hoverNotebook.Allocation; var targetTabCount = hoverNotebook.TabCount; var overTabStrip = y <= oy + hoverNotebook.BarHeight; if (hoverNotebook.Tabs.Contains (frame)) targetTabCount--; // Current is going to be removed, so it doesn't count if (targetTabCount > 0 && x <= ox + alloc.Width / 3 && !overTabStrip) { if (container.AllowLeftInsert) { Relocate ( ox, oy, alloc.Width / 2, alloc.Height, false ); placementDelegate = delegate(DockNotebook arg1, DockNotebookTab tab, Rectangle allocation2, int x2, int y2) { var window = (SdiWorkspaceWindow)tab.Content; container.InsertLeft (window); window.SelectWindow (); }; return; } } if (targetTabCount > 0 && x >= ox + alloc.Width - alloc.Width / 3 && !overTabStrip) { if (container.AllowRightInsert) { Relocate ( ox + alloc.Width / 2, oy, alloc.Width / 2, alloc.Height, false ); placementDelegate = delegate(DockNotebook arg1, DockNotebookTab tab, Rectangle allocation2, int x2, int y2) { var window = (SdiWorkspaceWindow)tab.Content; container.InsertRight (window); window.SelectWindow (); }; return; } } Relocate ( ox, oy, alloc.Width, alloc.Height, false ); if (!hoverNotebook.Tabs.Contains (frame)) placementDelegate = PlaceInHoverNotebook; else placementDelegate = null; return; } Hide (); placementDelegate = PlaceInFloatingFrame; titleWindow.SetDectorated (true); }
public TabStrip (DockNotebook notebook) { if (notebook == null) throw new ArgumentNullException ("notebook"); TabWidth = 125; TargetWidth = 125; tracker = new MouseTracker (this); GtkWorkarounds.FixContainerLeak (this); this.notebook = notebook; WidgetFlags |= Gtk.WidgetFlags.AppPaintable; Events |= EventMask.PointerMotionMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask; var arr = new Xwt.ImageView (tabbarPrevImage); arr.HeightRequest = arr.WidthRequest = 10; var alignment = new Alignment (0.5f, 0.5f, 0.0f, 0.0f); alignment.Add (arr.ToGtkWidget ()); PreviousButton = new Button (alignment); PreviousButton.Relief = ReliefStyle.None; PreviousButton.CanDefault = PreviousButton.CanFocus = false; arr = new Xwt.ImageView (tabbarNextImage); arr.HeightRequest = arr.WidthRequest = 10; alignment = new Alignment (0.5f, 0.5f, 0.0f, 0.0f); alignment.Add (arr.ToGtkWidget ()); NextButton = new Button (alignment); NextButton.Relief = ReliefStyle.None; NextButton.CanDefault = NextButton.CanFocus = false; DropDownButton = new MenuButton (); DropDownButton.Relief = ReliefStyle.None; DropDownButton.CanDefault = DropDownButton.CanFocus = false; PreviousButton.ShowAll (); NextButton.ShowAll (); DropDownButton.ShowAll (); PreviousButton.Name = "MonoDevelop.DockNotebook.BarButton"; NextButton.Name = "MonoDevelop.DockNotebook.BarButton"; DropDownButton.Name = "MonoDevelop.DockNotebook.BarButton"; PreviousButton.Parent = this; NextButton.Parent = this; DropDownButton.Parent = this; children.Add (PreviousButton); children.Add (NextButton); children.Add (DropDownButton); tracker.HoveredChanged += (sender, e) => { if (!tracker.Hovered) { SetHighlightedTab (null); UpdateTabWidth (tabEndX - tabStartX); QueueDraw (); } }; notebook.PageAdded += (sender, e) => QueueResize (); notebook.PageRemoved += (sender, e) => QueueResize (); closingTabs = new Dictionary<int, DockNotebookTab> (); }
public virtual void ShowView (ViewContent content, bool bringToFront, IViewDisplayBinding binding = null, DockNotebook notebook = null) { bool isFile = content.IsFile; if (!isFile) { try { isFile = File.Exists (content.ContentName); } catch { /*Ignore*/ } } string type; if (isFile) { type = System.IO.Path.GetExtension (content.ContentName); var mt = DesktopService.GetMimeTypeForUri (content.ContentName); if (!string.IsNullOrEmpty (mt)) type += " (" + mt + ")"; } else type = "(not a file)"; var metadata = new Dictionary<string,string> () { { "FileType", type }, { "DisplayBinding", content.GetType ().FullName }, }; if (isFile) metadata ["DisplayBindingAndType"] = type + " | " + content.GetType ().FullName; Counters.DocumentOpened.Inc (metadata); var mimeimage = PrepareShowView (content); var addToControl = notebook ?? DockNotebook.ActiveNotebook ?? tabControl; var tab = addToControl.AddTab (); SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, addToControl, tab); sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); }; sdiWorkspaceWindow.Closed += CloseWindowEvent; sdiWorkspaceWindow.Show (); if (binding != null) DisplayBindingService.AttachSubWindows (sdiWorkspaceWindow, binding); sdiWorkspaceWindow.CreateCommandHandler (); tab.Content = sdiWorkspaceWindow; if (mimeimage != null) tab.Icon = mimeimage; if (content.Project != null) content.Project.NameChanged += HandleProjectNameChanged; if (bringToFront) content.WorkbenchWindow.SelectWindow(); // The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged) OnActiveWindowChanged (null, null); }
/// <summary> /// Returns the previous notebook in the same window /// </summary> public DockNotebook GetPreviousNotebook (DockNotebook current) { var container = (DockNotebookContainer)current.Parent; var rootContainer = current.Container; if (container == rootContainer) return null; Widget curChild = container; var paned = (Paned)container.Parent; do { if (paned.Child2 == curChild) return ((DockNotebookContainer)paned.Child1).GetLastNotebook (); curChild = paned; paned = paned.Parent as Paned; } while (paned != null); return null; }