internal DockItemToolbar (DockItem parentItem, PositionType position) { this.parentItem = parentItem; frame = new CustomFrame (); switch (position) { case PositionType.Top: frame.SetMargins (0, 0, 1, 1); frame.SetPadding (0, 2, 2, 0); break; case PositionType.Bottom: frame.SetMargins (0, 1, 1, 1); frame.SetPadding (2, 2, 2, 0); break; case PositionType.Left: frame.SetMargins (0, 1, 1, 0); frame.SetPadding (0, 0, 2, 2); break; case PositionType.Right: frame.SetMargins (0, 1, 0, 1); frame.SetPadding (0, 0, 2, 2); break; } this.position = position; if (position == PositionType.Top || position == PositionType.Bottom) box = new HBox (false, 3); else box = new VBox (false, 3); box.Show (); frame.Add (box); frame.GradientBackround = true; }
public AutoHideBox (DockFrame frame, DockItem item, Gtk.PositionType pos, int size) { this.position = pos; this.frame = frame; this.targetSize = size; horiz = pos == PositionType.Left || pos == PositionType.Right; startPos = pos == PositionType.Top || pos == PositionType.Left; Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask; Box fr; CustomFrame cframe = new CustomFrame (); switch (pos) { case PositionType.Left: cframe.SetMargins (1, 1, 0, 1); break; case PositionType.Right: cframe.SetMargins (1, 1, 1, 0); break; case PositionType.Top: cframe.SetMargins (0, 1, 1, 1); break; case PositionType.Bottom: cframe.SetMargins (1, 0, 1, 1); break; } EventBox sepBox = new EventBox (); cframe.Add (sepBox); if (horiz) { fr = new HBox (); sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorW; }; sepBox.WidthRequest = gripSize; } else { fr = new VBox (); sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorH; }; sepBox.HeightRequest = gripSize; } sepBox.Events = EventMask.AllEventsMask; if (pos == PositionType.Left || pos == PositionType.Top) fr.PackEnd (cframe, false, false, 0); else fr.PackStart (cframe, false, false, 0); Add (fr); ShowAll (); Hide (); scrollable = new ScrollableContainer (); scrollable.ScrollMode = false; scrollable.Show (); if (item.Widget.Parent != null) { ((Gtk.Container)item.Widget.Parent).Remove (item.Widget); } item.Widget.Show (); scrollable.Add (item.Widget); fr.PackStart (scrollable, true, true, 0); sepBox.ButtonPressEvent += OnSizeButtonPress; sepBox.ButtonReleaseEvent += OnSizeButtonRelease; sepBox.MotionNotifyEvent += OnSizeMotion; sepBox.ExposeEvent += OnGripExpose; sepBox.EnterNotifyEvent += delegate { insideGrip = true; sepBox.QueueDraw (); }; sepBox.LeaveNotifyEvent += delegate { insideGrip = false; sepBox.QueueDraw (); }; }
public DockItemContainer (DockFrame frame, DockItem item) { this.item = item; mainBox = new VBox (); Add (mainBox); mainBox.ResizeMode = Gtk.ResizeMode.Queue; mainBox.Spacing = 0; ShowAll (); mainBox.PackStart (item.GetToolbar (PositionType.Top).Container, false, false, 0); HBox hbox = new HBox (); hbox.Show (); hbox.PackStart (item.GetToolbar (PositionType.Left).Container, false, false, 0); contentBox = new HBox (); contentBox.Show (); hbox.PackStart (contentBox, true, true, 0); hbox.PackStart (item.GetToolbar (PositionType.Right).Container, false, false, 0); mainBox.PackStart (hbox, true, true, 0); mainBox.PackStart (item.GetToolbar (PositionType.Bottom).Container, false, false, 0); }
public DockBarItem (DockBar bar, DockItem it, int size) { Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask; this.size = size; this.bar = bar; this.it = it; VisibleWindow = false; UpdateTab (); }
public void Initialize(DockFrame dockframe){ m_dockFrame = dockframe; m_experimentPad = m_dockFrame.AddItem ("ExperimentPad"); m_experimentPad.Label = Catalog.GetString ("ExperimentPad"); m_experimentPad.Behavior = DockItemBehavior.Locked; m_experimentPad.Expand = true; m_experimentPad.DrawFrame = false; m_initialized = true; }
public DockBarItem (DockBar bar, DockItem it, int size) { Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask; this.size = size; this.bar = bar; this.it = it; VisibleWindow = false; UpdateTab (); lastFrameSize = bar.Frame.Allocation.Size; bar.Frame.SizeAllocated += HandleBarFrameSizeAllocated; }
public DockItemTitleTab (DockItem item, DockFrame frame) { this.item = item; this.frame = frame; this.VisibleWindow = false; UpdateVisualStyle (); NoShowAll = true; Events |= Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask; KeyPressEvent += HeaderKeyPress; KeyReleaseEvent += HeaderKeyRelease; this.SubscribeLeaveEvent (OnLeave); }
public DockGroupItem AddObject (DockItem obj, DockPosition pos, string relItemId) { int npos = -1; if (relItemId != null) { for (int n=0; n<dockObjects.Count; n++) { DockGroupItem it = dockObjects [n] as DockGroupItem; if (it != null && it.Id == relItemId) npos = n; } } if (npos == -1) { if (pos == DockPosition.Left || pos == DockPosition.Top) npos = 0; else npos = dockObjects.Count - 1; } DockGroupItem gitem = null; if (pos == DockPosition.Left || pos == DockPosition.Right) { if (type != DockGroupType.Horizontal) gitem = Split (DockGroupType.Horizontal, pos == DockPosition.Left, obj, npos); else gitem = InsertObject (obj, npos, pos); } else if (pos == DockPosition.Top || pos == DockPosition.Bottom) { if (type != DockGroupType.Vertical) gitem = Split (DockGroupType.Vertical, pos == DockPosition.Top, obj, npos); else gitem = InsertObject (obj, npos, pos); } else if (pos == DockPosition.CenterBefore || pos == DockPosition.Center) { if (type != DockGroupType.Tabbed) gitem = Split (DockGroupType.Tabbed, pos == DockPosition.CenterBefore, obj, npos); else { if (pos == DockPosition.Center) npos++; gitem = new DockGroupItem (Frame, obj); dockObjects.Insert (npos, gitem); gitem.ParentGroup = this; } } ResetVisibleGroups (); return gitem; }
internal void Present(DockItem it, bool giveFocus) { if (type == DockGroupType.Tabbed) { for (int n = 0; n < VisibleObjects.Count; n++) { DockGroupItem dit = VisibleObjects[n] as DockGroupItem; if (dit.Item == it) { currentTabPage = n; if (boundTabStrip != null) { boundTabStrip.CurrentPage = it.Widget; } break; } } } if (giveFocus && it.Visible) { it.SetFocus(); } }
public DockItemTitleTab(DockItem item, DockFrame frame) { var actionHandler = new ActionDelegate(this); actionHandler.PerformPress += HandlePress; actionHandler.PerformShowMenu += HandleShowMenu; UpdateRole(false, null); CanFocus = true; this.item = item; this.frame = frame; this.VisibleWindow = false; UpdateVisualStyle(); NoShowAll = true; Events |= Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask; KeyPressEvent += HeaderKeyPress; KeyReleaseEvent += HeaderKeyRelease; subscribedLeaveEvent = this.SubscribeLeaveEvent(OnLeave); }
public DockItemTitleTab(DockItem item, DockFrame frame) { var actionHandler = new ActionDelegate(this); actionHandler.PerformPress += HandlePress; actionHandler.PerformShowMenu += HandleShowMenu; Accessible.SetRole(AtkCocoa.Roles.AXGroup, "pad header"); Accessible.SetSubRole("XAPadHeader"); this.item = item; this.frame = frame; this.VisibleWindow = false; UpdateVisualStyle(); NoShowAll = true; Events |= Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask; KeyPressEvent += HeaderKeyPress; KeyReleaseEvent += HeaderKeyRelease; subscribedLeaveEvent = this.SubscribeLeaveEvent(OnLeave); }
public bool RemoveItemRec(DockItem item) { foreach (DockObject ob in dockObjects) { if (ob is DockGroup) { if (((DockGroup)ob).RemoveItemRec(item)) { return(true); } } else { DockGroupItem dit = ob as DockGroupItem; if (dit != null && dit.Item == item) { Remove(ob); return(true); } } } return(false); }
internal void Present (DockItem item, bool giveFocus) { DockGroupItem gitem = container.FindDockGroupItem (item.Id); if (gitem == null) return; gitem.ParentGroup.Present (item, giveFocus); }
internal bool GetVisible (DockItem item, string layoutName) { DockLayout dl; if (!layouts.TryGetValue (layoutName, out dl)) return false; DockGroupItem gitem = dl.FindDockGroupItem (item.Id); if (gitem == null) return false; return gitem.VisibleFlag; }
internal DockVisualStyle GetRegionStyleForItem (DockItem item) { DockVisualStyle s; if (stylesById.TryGetValue (item.Id, out s)) { var ds = DefaultVisualStyle.Clone (); ds.CopyValuesFrom (s); return ds; } return DefaultVisualStyle; }
public void RemoveItem (DockItem it) { if (container.Layout != null) container.Layout.RemoveItemRec (it); foreach (DockGroup grp in layouts.Values) grp.RemoveItemRec (it); container.Items.Remove (it); }
internal void UpdateStyle(DockItem item) { }
void CreateComponents() { fullViewVBox = new VBox (false, 0); rootWidget = fullViewVBox; InstallMenuBar (); Realize (); toolbar = DesktopService.CreateMainToolbar (this); DesktopService.SetMainWindowDecorations (this); var toolbarBox = new HBox (); fullViewVBox.PackStart (toolbarBox, false, false, 0); toolbarFrame = new CommandFrame (IdeApp.CommandService); fullViewVBox.PackStart (toolbarFrame, true, true, 0); // Create the docking widget and add it to the window. dock = new DockFrame (); dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; IdeApp.Preferences.WorkbenchCompactnessChanged += delegate { dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; }; /* Side bar is experimental. Disabled for now HBox hbox = new HBox (); VBox sideBox = new VBox (); sideBox.PackStart (new SideBar (workbench, Orientation.Vertical), false, false, 0); hbox.PackStart (sideBox, false, false, 0); hbox.ShowAll (); sideBox.NoShowAll = true; hbox.PackStart (dock, true, true, 0); DockBar bar = dock.ExtractDockBar (PositionType.Left); bar.AlwaysVisible = true; sideBox.PackStart (bar, true, true, 0); toolbarFrame.AddContent (hbox); */ toolbarFrame.AddContent (dock); // Create the notebook for the various documents. tabControl = new SdiDragNotebook (this); DockNotebook.ActiveNotebookChanged += delegate { OnActiveWindowChanged (null, null); }; Add (fullViewVBox); fullViewVBox.ShowAll (); bottomBar = new MonoDevelopStatusBar (); fullViewVBox.PackEnd (bottomBar, false, true, 0); bottomBar.ShowAll (); toolbarBox.PackStart (this.toolbar, true, true, 0); // In order to get the correct bar height we need to calculate the tab size using the // correct style (the style of the window). At this point the widget is not yet a child // of the window, so its style is not yet the correct one. tabControl.InitSize (); var barHeight = tabControl.BarHeight; // The main document area documentDockItem = dock.AddItem ("Documents"); documentDockItem.Behavior = DockItemBehavior.Locked; documentDockItem.Expand = true; documentDockItem.DrawFrame = false; documentDockItem.Label = GettextCatalog.GetString ("Documents"); documentDockItem.Content = new DockNotebookContainer (tabControl, true); DockVisualStyle style = new DockVisualStyle (); style.PadTitleLabelColor = Styles.PadLabelColor; style.PadBackgroundColor = Styles.PadBackground; style.InactivePadBackgroundColor = Styles.InactivePadBackground; style.PadTitleHeight = barHeight; dock.DefaultVisualStyle = style; style = new DockVisualStyle (); style.PadTitleLabelColor = Styles.PadLabelColor; style.PadTitleHeight = barHeight; style.ShowPadTitleIcon = false; style.UppercaseTitles = false; style.ExpandedTabs = true; style.PadBackgroundColor = Styles.BrowserPadBackground; style.InactivePadBackgroundColor = Styles.InactiveBrowserPadBackground; style.TreeBackgroundColor = Styles.BrowserPadBackground; dock.SetDockItemStyle ("ProjectPad", style); dock.SetDockItemStyle ("ClassPad", style); // dock.SetRegionStyle ("Documents/Left", style); //dock.SetRegionStyle ("Documents/Right", style); // style = new DockVisualStyle (); // style.SingleColumnMode = true; // dock.SetRegionStyle ("Documents/Left;Documents/Right", style); // dock.SetDockItemStyle ("Documents", style); // Add some hiden items to be used as position reference DockItem dit = dock.AddItem ("__left"); dit.DefaultLocation = "Documents/Left"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; dit = dock.AddItem ("__right"); dit.DefaultLocation = "Documents/Right"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; dit = dock.AddItem ("__top"); dit.DefaultLocation = "Documents/Top"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; dit = dock.AddItem ("__bottom"); dit.DefaultLocation = "Documents/Bottom"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; if (MonoDevelop.Core.Platform.IsMac) bottomBar.HasResizeGrip = true; else { if (GdkWindow != null && GdkWindow.State == Gdk.WindowState.Maximized) bottomBar.HasResizeGrip = false; SizeAllocated += delegate { if (GdkWindow != null) bottomBar.HasResizeGrip = GdkWindow.State != Gdk.WindowState.Maximized; }; } // create DockItems for all the pads ExtensionNodeList padCodons = AddinManager.GetExtensionNodes (viewContentPath); foreach (ExtensionNode node in padCodons) ShowPadNode (node); try { if (System.IO.File.Exists (configFile)) { dock.LoadLayouts (configFile); foreach (string layout in dock.Layouts) { if (!layouts.Contains (layout) && !layout.EndsWith (fullViewModeTag)) layouts.Add (layout); } } } catch (Exception ex) { LoggingService.LogError (ex.ToString ()); } }
internal void UpdatePlaceholder(DockItem item, Gdk.Size size, bool allowDocking) { container.UpdatePlaceholder(item, size, allowDocking); }
DockGroupItem AddItemAtLocation (DockGroup grp, DockItem it, string location, bool visible, DockItemStatus status) { string[] positions = location.Split (';'); foreach (string pos in positions) { int i = pos.IndexOf ('/'); if (i == -1) continue; string id = pos.Substring (0,i).Trim (); DockGroup g = grp.FindGroupContaining (id); if (g != null) { DockPosition dpos; try { dpos = (DockPosition) Enum.Parse (typeof(DockPosition), pos.Substring(i+1).Trim(), true); } catch { continue; } DockGroupItem dgt = g.AddObject (it, dpos, id); dgt.SetVisible (visible); dgt.Status = status; return dgt; } } return null; }
DockGroupItem AddDefaultItem(DockGroup grp, DockItem it) { return(AddItemAtLocation(grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus)); }
internal void DockInPlaceholder(DockItem item) { container.DockInPlaceholder(item); }
internal void ShowPlaceholder(DockItem draggedItem) { container.ShowPlaceholder(draggedItem); }
public void UpdateStyle(DockItem item) { QueueResize(); }
internal abstract bool GetDockTarget(DockItem item, int px, int py, out DockDelegate dockDelegate, out Gdk.Rectangle rect);
internal DockItemStatus GetStatus (DockItem item) { DockGroupItem gitem = container.FindDockGroupItem (item.Id); if (gitem == null) return DockItemStatus.Dockable; return gitem.Status; }
internal DockBarItem BarDock(Gtk.PositionType pos, DockItem item, int size) { return(GetDockBar(pos).AddItem(item, size)); }
internal void SetDockLocation (DockItem item, string placement) { bool vis = item.Visible; DockItemStatus stat = item.Status; item.ResetMode (); container.Layout.RemoveItemRec (item); AddItemAtLocation (container.Layout, item, placement, vis, stat); }
internal override bool GetDockTarget(DockItem item, int px, int py, out DockDelegate dockDelegate, out Gdk.Rectangle rect) { if (!Allocation.Contains(px, py) || VisibleObjects.Count == 0) { dockDelegate = null; rect = Gdk.Rectangle.Zero; return(false); } if (type == DockGroupType.Tabbed) { // Tabs can only contain DockGroupItems return(((DockGroupItem)VisibleObjects[0]).GetDockTarget(item, px, py, Allocation, out dockDelegate, out rect)); } else if (type == DockGroupType.Horizontal) { if (px >= Allocation.Right - DockFrame.GroupDockSeparatorSize) { // Dock to the right of the group dockDelegate = delegate(DockItem it) { DockTarget(it, dockObjects.Count); }; rect = new Gdk.Rectangle(Allocation.Right - DockFrame.GroupDockSeparatorSize, Allocation.Y, DockFrame.GroupDockSeparatorSize, Allocation.Height); return(true); } else if (px <= Allocation.Left + DockFrame.GroupDockSeparatorSize) { // Dock to the left of the group dockDelegate = delegate(DockItem it) { DockTarget(it, 0); }; rect = new Gdk.Rectangle(Allocation.Left, Allocation.Y, DockFrame.GroupDockSeparatorSize, Allocation.Height); return(true); } // Dock in a separator for (int n = 0; n < VisibleObjects.Count; n++) { DockObject ob = VisibleObjects [n]; if (n < VisibleObjects.Count - 1 && px >= ob.Allocation.Right - DockFrame.GroupDockSeparatorSize / 2 && px <= ob.Allocation.Right + DockFrame.GroupDockSeparatorSize / 2) { int dn = dockObjects.IndexOf(ob); dockDelegate = delegate(DockItem it) { DockTarget(it, dn + 1); }; rect = new Gdk.Rectangle(ob.Allocation.Right - DockFrame.GroupDockSeparatorSize / 2, Allocation.Y, DockFrame.GroupDockSeparatorSize, Allocation.Height); return(true); } else if (ob.GetDockTarget(item, px, py, out dockDelegate, out rect)) { return(true); } } } else if (type == DockGroupType.Vertical) { if (py >= Allocation.Bottom - DockFrame.GroupDockSeparatorSize) { // Dock to the bottom of the group dockDelegate = delegate(DockItem it) { DockTarget(it, dockObjects.Count); }; rect = new Gdk.Rectangle(Allocation.X, Allocation.Bottom - DockFrame.GroupDockSeparatorSize, Allocation.Width, DockFrame.GroupDockSeparatorSize); return(true); } else if (py <= Allocation.Top + DockFrame.GroupDockSeparatorSize) { // Dock to the top of the group dockDelegate = delegate(DockItem it) { DockTarget(it, 0); }; rect = new Gdk.Rectangle(Allocation.X, Allocation.Top, Allocation.Width, DockFrame.GroupDockSeparatorSize); return(true); } // Dock in a separator for (int n = 0; n < VisibleObjects.Count; n++) { DockObject ob = VisibleObjects [n]; if (n < VisibleObjects.Count - 1 && py >= ob.Allocation.Bottom - DockFrame.GroupDockSeparatorSize / 2 && py <= ob.Allocation.Bottom + DockFrame.GroupDockSeparatorSize / 2) { int dn = dockObjects.IndexOf(ob); dockDelegate = delegate(DockItem it) { DockTarget(it, dn + 1); }; rect = new Gdk.Rectangle(Allocation.X, ob.Allocation.Bottom - DockFrame.GroupDockSeparatorSize / 2, Allocation.Width, DockFrame.GroupDockSeparatorSize); return(true); } else if (ob.GetDockTarget(item, px, py, out dockDelegate, out rect)) { return(true); } } } dockDelegate = null; rect = Gdk.Rectangle.Zero; return(false); }
public AutoHideBox(DockFrame frame, DockItem item, Gtk.PositionType pos, int size) { this.position = pos; this.frame = frame; this.targetSize = size; horiz = pos == PositionType.Left || pos == PositionType.Right; startPos = pos == PositionType.Top || pos == PositionType.Left; Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask; Box fr; CustomFrame cframe = new CustomFrame(); switch (pos) { case PositionType.Left: cframe.SetMargins(0, 0, 1, 1); break; case PositionType.Right: cframe.SetMargins(0, 0, 1, 1); break; case PositionType.Top: cframe.SetMargins(1, 1, 0, 0); break; case PositionType.Bottom: cframe.SetMargins(1, 1, 0, 0); break; } EventBox sepBox = new EventBox(); cframe.Add(sepBox); if (horiz) { fr = new HBox(); sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorW; }; sepBox.WidthRequest = gripSize; } else { fr = new VBox(); sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorH; }; sepBox.HeightRequest = gripSize; } sepBox.Events = EventMask.AllEventsMask; if (pos == PositionType.Left || pos == PositionType.Top) { fr.PackEnd(cframe, false, false, 0); } else { fr.PackStart(cframe, false, false, 0); } Add(fr); ShowAll(); Hide(); #if ANIMATE_DOCKING scrollable = new ScrollableContainer(); scrollable.ScrollMode = false; scrollable.Show(); #endif VBox itemBox = new VBox(); itemBox.Show(); item.TitleTab.Active = true; itemBox.PackStart(item.TitleTab, false, false, 0); itemBox.PackStart(item.Widget, true, true, 0); item.Widget.Show(); #if ANIMATE_DOCKING scrollable.Add(itemBox); fr.PackStart(scrollable, true, true, 0); #else fr.PackStart(itemBox, true, true, 0); #endif sepBox.ButtonPressEvent += OnSizeButtonPress; sepBox.ButtonReleaseEvent += OnSizeButtonRelease; sepBox.MotionNotifyEvent += OnSizeMotion; sepBox.ExposeEvent += OnGripExpose; sepBox.EnterNotifyEvent += delegate { insideGrip = true; sepBox.QueueDraw(); }; sepBox.LeaveNotifyEvent += delegate { insideGrip = false; sepBox.QueueDraw(); }; }
DockGroupItem Split(DockGroupType newType, bool addFirst, DockItem obj, int npos) { DockGroupItem item = new DockGroupItem(Frame, obj); if (npos == -1 || type == DockGroupType.Tabbed) { if (ParentGroup != null && ParentGroup.Type == newType) { // No need to split. Just add the new item as a sibling of this one. int i = ParentGroup.Objects.IndexOf(this); if (addFirst) { ParentGroup.Objects.Insert(i, item); } else { ParentGroup.Objects.Insert(i + 1, item); } item.ParentGroup = ParentGroup; item.ResetDefaultSize(); } else { DockGroup grp = Copy(); dockObjects.Clear(); if (addFirst) { dockObjects.Add(item); dockObjects.Add(grp); } else { dockObjects.Add(grp); dockObjects.Add(item); } item.ParentGroup = this; item.ResetDefaultSize(); grp.ParentGroup = this; grp.ResetDefaultSize(); Type = newType; } } else { DockGroup grp = new DockGroup(Frame, newType); DockObject replaced = dockObjects[npos]; if (addFirst) { grp.AddObject(item); grp.AddObject(replaced); } else { grp.AddObject(replaced); grp.AddObject(item); } grp.CopySizeFrom(replaced); dockObjects [npos] = grp; grp.ParentGroup = this; } return(item); }
void CreatePadContent(bool force, PadCodon padCodon, PadWindow window, DockItem item) { if (force || item.Content == null) { IPadContent newContent = padCodon.InitializePadContent (window); Gtk.Widget pcontent; if (newContent is Widget) { pcontent = newContent.Control; } else { PadCommandRouterContainer crc = new PadCommandRouterContainer (window, newContent.Control, newContent, true); crc.Show (); pcontent = crc; } PadCommandRouterContainer router = new PadCommandRouterContainer (window, pcontent, toolbarFrame, false); router.Show (); item.Content = router; } }
public DockGroupItem AddObject(DockItem obj, DockPosition pos, string relItemId) { int npos = -1; if (relItemId != null) { for (int n = 0; n < dockObjects.Count; n++) { DockGroupItem it = dockObjects [n] as DockGroupItem; if (it != null && it.Id == relItemId) { npos = n; } } } if (npos == -1) { if (pos == DockPosition.Left || pos == DockPosition.Top) { npos = 0; } else { npos = dockObjects.Count - 1; } } DockGroupItem gitem = null; if (pos == DockPosition.Left || pos == DockPosition.Right) { if (type != DockGroupType.Horizontal) { gitem = Split(DockGroupType.Horizontal, pos == DockPosition.Left, obj, npos); } else { gitem = InsertObject(obj, npos, pos); } } else if (pos == DockPosition.Top || pos == DockPosition.Bottom) { if (type != DockGroupType.Vertical) { gitem = Split(DockGroupType.Vertical, pos == DockPosition.Top, obj, npos); } else { gitem = InsertObject(obj, npos, pos); } } else if (pos == DockPosition.CenterBefore || pos == DockPosition.Center) { if (type != DockGroupType.Tabbed) { gitem = Split(DockGroupType.Tabbed, pos == DockPosition.CenterBefore, obj, npos); } else { if (pos == DockPosition.Center) { npos++; } gitem = new DockGroupItem(Frame, obj); dockObjects.Insert(npos, gitem); gitem.ParentGroup = this; } } ResetVisibleGroups(); return(gitem); }
internal void AutoHide (DockItem item, AutoHideBox widget, bool animate) { if (animate) { widget.Hidden += delegate { if (!widget.Disposed) AutoHide (item, widget, false); }; widget.AnimateHide (); } else { // The widget may already be removed from the parent // so 'parent' can be null Gtk.Container parent = (Gtk.Container) item.Widget.Parent; if (parent != null) { //removing the widget from its parent causes it to unrealize without unmapping //so make sure it's unmapped if (item.Widget.IsMapped) { item.Widget.Unmap (); } parent.Remove (item.Widget); } parent = (Gtk.Container) item.TitleTab.Parent; if (parent != null) { //removing the widget from its parent causes it to unrealize without unmapping //so make sure it's unmapped if (item.TitleTab.IsMapped) { item.TitleTab.Unmap (); } parent.Remove (item.TitleTab); } if (widget.ContainerWindow != null) { widget.ContainerWindow.Destroy (); } else RemoveTopLevel (widget); widget.Disposed = true; widget.Destroy (); } }
public DockGroupItem(DockFrame frame, DockItem item) : base(frame) { this.item = item; visibleFlag = item.Visible; }
public DockItem AddItem (string id) { foreach (DockItem dit in container.Items) { if (dit.Id == id) { if (dit.IsPositionMarker) { dit.IsPositionMarker = false; return dit; } throw new InvalidOperationException ("An item with id '" + id + "' already exists."); } } DockItem it = new DockItem (this, id); container.Items.Add (it); return it; }
internal DockBarItem BarDock (Gtk.PositionType pos, DockItem item, int size) { return GetDockBar (pos).AddItem (item, size); }
internal void UpdateStyle (DockItem item) { DockGroupItem gitem = container.FindDockGroupItem (item.Id); if (gitem == null) return; gitem.ParentGroup.UpdateStyle (item); dockBarTop.UpdateStyle (item); dockBarBottom.UpdateStyle (item); dockBarLeft.UpdateStyle (item); dockBarRight.UpdateStyle (item); }
internal void DockInPlaceholder (DockItem item) { container.DockInPlaceholder (item); }
internal bool GetVisible (DockItem item) { DockGroupItem gitem = container.FindDockGroupItem (item.Id); if (gitem == null) return false; return gitem.VisibleFlag; }
public bool GetDockTarget(DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect) { outrect = Gdk.Rectangle.Zero; dockDelegate = null; if (item != this.item && this.item.Visible && rect.Contains(px, py)) { // Check if the item is allowed to be docked here var s = Frame.GetRegionStyleForObject(this); int xdockMargin = (int)((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2; int ydockMargin = (int)((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2; DockPosition pos; /* if (ParentGroup.Type == DockGroupType.Tabbed) { * rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2); * pos = DockPosition.CenterAfter; * }*/ if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) { if (s.SingleColumnMode.Value) { return(false); } outrect = new Gdk.Rectangle(rect.X, rect.Y, xdockMargin, rect.Height); pos = DockPosition.Left; } else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) { if (s.SingleColumnMode.Value) { return(false); } outrect = new Gdk.Rectangle(rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height); pos = DockPosition.Right; } else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical) { if (s.SingleRowMode.Value) { return(false); } outrect = new Gdk.Rectangle(rect.X, rect.Y, rect.Width, ydockMargin); pos = DockPosition.Top; } else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical) { if (s.SingleRowMode.Value) { return(false); } outrect = new Gdk.Rectangle(rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin); pos = DockPosition.Bottom; } else { outrect = new Gdk.Rectangle(rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin * 2, rect.Height - ydockMargin * 2); pos = DockPosition.Center; } dockDelegate = delegate(DockItem dit) { DockGroupItem it = ParentGroup.AddObject(dit, pos, Id); it.SetVisible(true); ParentGroup.FocusItem(it); }; return(true); } return(false); }
internal void SetVisible (DockItem item, bool visible) { if (container.Layout == null) return; DockGroupItem gitem = container.FindDockGroupItem (item.Id); if (gitem == null) { if (visible) { // The item is not present in the layout. Add it now. if (!string.IsNullOrEmpty (item.DefaultLocation)) gitem = AddDefaultItem (container.Layout, item); if (gitem == null) { // No default position gitem = new DockGroupItem (this, item); container.Layout.AddObject (gitem); } } else return; // Already invisible } gitem.SetVisible (visible); container.RelayoutWidgets (); }
internal void ShowPlaceholder(DockItem draggedItem) { padTitleWindow = new PadTitleWindow(frame, draggedItem); placeholderWindow = new PlaceholderWindow(frame); }
internal void SetStatus (DockItem item, DockItemStatus status) { DockGroupItem gitem = container.FindDockGroupItem (item.Id); if (gitem == null) { item.DefaultStatus = status; return; } gitem.StoreAllocation (); gitem.Status = status; container.RelayoutWidgets (); }
internal bool UpdatePlaceholder(DockItem item, Gdk.Size size, bool allowDocking) { if (!Runtime.IsMainThread) { var msg = "UpdatePlaceholder called from background thread."; LoggingService.LogInternalError($"{msg}\n{Environment.StackTrace}", new InvalidOperationException(msg)); } var placeholderWindow = this.placeholderWindow; var padTitleWindow = this.padTitleWindow; if (placeholderWindow == null || padTitleWindow == null) { return(false); } int px, py; GetPointer(out px, out py); placeholderWindow.AllowDocking = allowDocking; int ox, oy; GdkWindow.GetOrigin(out ox, out oy); int tw, th; padTitleWindow.GetSize(out tw, out th); padTitleWindow.Move(ox + px - tw / 2, oy + py - th / 2); padTitleWindow.GdkWindow.KeepAbove = true; DockDelegate dockDelegate; Gdk.Rectangle rect; if (allowDocking && layout.GetDockTarget(item, px, py, out dockDelegate, out rect)) { placeholderWindow.Relocate(ox + rect.X, oy + rect.Y, rect.Width, rect.Height, true); placeholderWindow.Show(); placeholderWindow.SetDockInfo(dockDelegate, rect); return(true); } else { int w, h; var gi = layout.FindDockGroupItem(item.Id); if (gi != null) { w = gi.Allocation.Width; h = gi.Allocation.Height; } else { w = item.DefaultWidth; h = item.DefaultHeight; } placeholderWindow.Relocate(ox + px - w / 2, oy + py - h / 2, w, h, false); placeholderWindow.Show(); placeholderWindow.AllowDocking = false; } return(false); }
DockGroupItem AddDefaultItem (DockGroup grp, DockItem it) { return AddItemAtLocation (grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus); }
void CreateComponents () { fullViewVBox = new VBox (false, 0); rootWidget = fullViewVBox; InstallMenuBar (); toolbarFrame = new CommandFrame (IdeApp.CommandService); fullViewVBox.PackStart (toolbarFrame, true, true, 0); foreach (DockToolbar t in toolbars) toolbarFrame.AddBar (t); // Create the docking widget and add it to the window. dock = new DockFrame (); dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; IdeApp.Preferences.WorkbenchCompactnessChanged += delegate { dock.CompactGuiLevel = ((int)IdeApp.Preferences.WorkbenchCompactness) + 1; }; /* Side bar is experimental. Disabled for now HBox hbox = new HBox (); VBox sideBox = new VBox (); sideBox.PackStart (new SideBar (workbench, Orientation.Vertical), false, false, 0); hbox.PackStart (sideBox, false, false, 0); hbox.ShowAll (); sideBox.NoShowAll = true; hbox.PackStart (dock, true, true, 0); DockBar bar = dock.ExtractDockBar (PositionType.Left); bar.AlwaysVisible = true; sideBox.PackStart (bar, true, true, 0); toolbarFrame.AddContent (hbox); */ toolbarFrame.AddContent (dock); // Create the notebook for the various documents. tabControl = new SdiDragNotebook (dock.ShadedContainer); tabControl.Scrollable = true; tabControl.SwitchPage += OnActiveWindowChanged; tabControl.PageAdded += delegate { OnActiveWindowChanged (null, null); }; tabControl.PageRemoved += delegate { OnActiveWindowChanged (null, null); }; tabControl.ButtonPressEvent += delegate(object sender, ButtonPressEventArgs e) { int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot); if (tab < 0) return; tabControl.CurrentPage = tab; if (e.Event.Type == Gdk.EventType.TwoButtonPress) ToggleFullViewMode (); }; this.tabControl.PopupMenu += delegate { ShowPopup (); }; this.tabControl.ButtonReleaseEvent += delegate (object sender, Gtk.ButtonReleaseEventArgs e) { int tab = tabControl.FindTabAtPosition (e.Event.XRoot, e.Event.YRoot); if (tab < 0) return; if (e.Event.Button == 3) ShowPopup (); }; tabControl.TabsReordered += new TabsReorderedHandler (OnTabsReordered); // The main document area documentDockItem = dock.AddItem ("Documents"); documentDockItem.Behavior = DockItemBehavior.Locked; documentDockItem.Expand = true; documentDockItem.DrawFrame = false; documentDockItem.Label = GettextCatalog.GetString ("Documents"); documentDockItem.Content = tabControl; // Add some hiden items to be used as position reference DockItem dit = dock.AddItem ("__left"); dit.DefaultLocation = "Documents/Left"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; dit = dock.AddItem ("__right"); dit.DefaultLocation = "Documents/Right"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; dit = dock.AddItem ("__top"); dit.DefaultLocation = "Documents/Top"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; dit = dock.AddItem ("__bottom"); dit.DefaultLocation = "Documents/Bottom"; dit.Behavior = DockItemBehavior.Locked; dit.DefaultVisible = false; Add (fullViewVBox); fullViewVBox.ShowAll (); fullViewVBox.PackEnd (this.StatusBar, false, true, 0); if (MonoDevelop.Core.PropertyService.IsMac) this.StatusBar.HasResizeGrip = true; else { if (GdkWindow != null && GdkWindow.State == Gdk.WindowState.Maximized) IdeApp.Workbench.StatusBar.HasResizeGrip = false; SizeAllocated += delegate { if (GdkWindow != null) IdeApp.Workbench.StatusBar.HasResizeGrip = GdkWindow.State != Gdk.WindowState.Maximized; }; } // create DockItems for all the pads foreach (PadCodon content in padContentCollection) AddPad (content, content.DefaultPlacement, content.DefaultStatus); try { if (System.IO.File.Exists (configFile)) { dock.LoadLayouts (configFile); foreach (string layout in dock.Layouts) { if (!layouts.Contains (layout) && !layout.EndsWith (fullViewModeTag)) layouts.Add (layout); } } } catch (Exception ex) { LoggingService.LogError (ex.ToString ()); } }
internal void ShowPlaceholder (DockItem draggedItem) { container.ShowPlaceholder (draggedItem); }
public AutoHideBox(DockFrame frame, DockItem item, Gtk.PositionType pos, int size) : base(frame) { this.position = pos; this.frame = frame; this.targetSize = size; horiz = pos == PositionType.Left || pos == PositionType.Right; startPos = pos == PositionType.Top || pos == PositionType.Left; Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask; Box fr; CustomFrame cframe = new CustomFrame(); switch (pos) { case PositionType.Left: cframe.SetMargins(0, 0, 1, 1); break; case PositionType.Right: cframe.SetMargins(0, 0, 1, 1); break; case PositionType.Top: cframe.SetMargins(1, 1, 0, 0); break; case PositionType.Bottom: cframe.SetMargins(1, 1, 0, 0); break; } if (frame.UseWindowsForTopLevelFrames) { // When using a top level window on mac, clicks on the first 4 pixels next to the border // are not detected. To avoid confusing the user (since the resize cursor is shown), // we make the resize drag area smaller. switch (pos) { case PositionType.Left: cframe.SetPadding(0, 0, 0, 4); gripSize = 4; break; case PositionType.Right: cframe.SetPadding(0, 0, 4, 0); gripSize = 4; break; } } EventBox sepBox = new EventBox(); cframe.Add(sepBox); if (horiz) { fr = new HBox(); sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorW; }; sepBox.WidthRequest = gripSize; } else { fr = new VBox(); sepBox.Realized += delegate { sepBox.GdkWindow.Cursor = resizeCursorH; }; sepBox.HeightRequest = gripSize; } sepBox.Events = EventMask.AllEventsMask; if (pos == PositionType.Left || pos == PositionType.Top) { fr.PackEnd(cframe, false, false, 0); } else { fr.PackStart(cframe, false, false, 0); } Add(fr); ShowAll(); Hide(); #if ANIMATE_DOCKING scrollable = new ScrollableContainer(); scrollable.ScrollMode = false; scrollable.Show(); #endif VBox itemBox = new VBox(); itemBox.Show(); item.TitleTab.Active = true; itemBox.PackStart(item.TitleTab, false, false, 0); itemBox.PackStart(item.Widget, true, true, 0); item.Widget.Show(); #if ANIMATE_DOCKING scrollable.Add(itemBox); fr.PackStart(scrollable, true, true, 0); #else fr.PackStart(itemBox, true, true, 0); #endif sepBox.ButtonPressEvent += OnSizeButtonPress; sepBox.ButtonReleaseEvent += OnSizeButtonRelease; sepBox.MotionNotifyEvent += OnSizeMotion; sepBox.ExposeEvent += OnGripExpose; sepBox.EnterNotifyEvent += delegate { insideGrip = true; sepBox.QueueDraw(); }; sepBox.LeaveNotifyEvent += delegate { insideGrip = false; sepBox.QueueDraw(); }; }
internal void UpdatePlaceholder (DockItem item, Gdk.Size size, bool allowDocking) { container.UpdatePlaceholder (item, size, allowDocking); }
internal override bool GetDockTarget(DockItem item, int px, int py, out DockDelegate dockDelegate, out Gdk.Rectangle rect) { return(GetDockTarget(item, px, py, Allocation, out dockDelegate, out rect)); }
internal AutoHideBox AutoShow (DockItem item, DockBar bar, int size) { AutoHideBox aframe = new AutoHideBox (this, item, bar.Position, size); Gdk.Size sTop = GetBarFrameSize (dockBarTop); Gdk.Size sBot = GetBarFrameSize (dockBarBottom); Gdk.Size sLeft = GetBarFrameSize (dockBarLeft); Gdk.Size sRgt = GetBarFrameSize (dockBarRight); int x,y,w,h; if (bar == dockBarLeft || bar == dockBarRight) { h = Allocation.Height - sTop.Height - sBot.Height; w = size; y = sTop.Height; if (bar == dockBarLeft) x = sLeft.Width; else x = Allocation.Width - size - sRgt.Width; } else { w = Allocation.Width - sLeft.Width - sRgt.Width; h = size; x = sLeft.Width; if (bar == dockBarTop) y = sTop.Height; else y = Allocation.Height - size - sBot.Height; } AddTopLevel (aframe, x, y, w, h); aframe.AnimateShow (); return aframe; }
public DockItemContainer(DockFrame frame, DockItem item) { this.frame = frame; this.item = item; ResizeMode = Gtk.ResizeMode.Queue; Spacing = 0; title = new Gtk.Label(); title.Xalign = 0; title.Xpad = 3; title.UseMarkup = true; title.Ellipsize = Pango.EllipsizeMode.End; btnDock = new Button(new Gtk.Image(pixAutoHide)); btnDock.Relief = ReliefStyle.None; btnDock.CanFocus = false; btnDock.WidthRequest = btnDock.HeightRequest = 17; btnDock.Clicked += OnClickDock; btnClose = new Button(new Gtk.Image(pixClose)); btnClose.TooltipText = Catalog.GetString("Hide"); btnClose.Relief = ReliefStyle.None; btnClose.CanFocus = false; btnClose.WidthRequest = btnClose.HeightRequest = 17; btnClose.Clicked += delegate { item.Visible = false; }; HBox box = new HBox(false, 0); box.PackStart(title, true, true, 0); box.PackEnd(btnClose, false, false, 0); box.PackEnd(btnDock, false, false, 0); headerAlign = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); headerAlign.TopPadding = headerAlign.BottomPadding = headerAlign.RightPadding = headerAlign.LeftPadding = 1; headerAlign.Add(box); header = new EventBox(); header.Events |= Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask; header.ButtonPressEvent += HeaderButtonPress; header.ButtonReleaseEvent += HeaderButtonRelease; header.MotionNotifyEvent += HeaderMotion; header.KeyPressEvent += HeaderKeyPress; header.KeyReleaseEvent += HeaderKeyRelease; header.Add(headerAlign); header.ExposeEvent += HeaderExpose; header.Realized += delegate { header.GdkWindow.Cursor = handCursor; }; foreach (Widget w in new Widget [] { header, btnDock, btnClose }) { w.EnterNotifyEvent += HeaderEnterNotify; w.LeaveNotifyEvent += HeaderLeaveNotify; } PackStart(header, false, false, 0); ShowAll(); PackStart(item.GetToolbar(PositionType.Top).Container, false, false, 0); HBox hbox = new HBox(); hbox.Show(); hbox.PackStart(item.GetToolbar(PositionType.Left).Container, false, false, 0); contentBox = new HBox(); contentBox.Show(); hbox.PackStart(contentBox, true, true, 0); hbox.PackStart(item.GetToolbar(PositionType.Right).Container, false, false, 0); PackStart(hbox, true, true, 0); PackStart(item.GetToolbar(PositionType.Bottom).Container, false, false, 0); UpdateBehavior(); }