Exemplo n.º 1
0
        internal void Present(DockItem item, bool giveFocus)
        {
            DockGroupItem gitem = container.FindDockGroupItem(item.Id);

            if (gitem == null)
            {
                return;
            }

            gitem.ParentGroup.Present(item, giveFocus);
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        internal DockGroup FindGroupContaining(string id)
        {
            DockGroupItem it = FindDockGroupItem(id);

            if (it != null)
            {
                return(it.ParentGroup);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        DockGroupItem InsertObject(DockItem obj, int npos, DockPosition pos)
        {
            if (pos == DockPosition.Bottom || pos == DockPosition.Right)
            {
                npos++;
            }

            DockGroupItem gitem = new DockGroupItem(Frame, obj);

            dockObjects.Insert(npos, gitem);
            gitem.ParentGroup = this;
            return(gitem);
        }
Exemplo n.º 5
0
        public bool GetDockTarget(DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect)
        {
            dockDelegate = null;

            if (item != this.item && this.item.Visible && rect.Contains(px, py))
            {
                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)
                {
                    outrect = new Gdk.Rectangle(rect.X, rect.Y, xdockMargin, rect.Height);
                    pos     = DockPosition.Left;
                }
                else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal)
                {
                    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)
                {
                    outrect = new Gdk.Rectangle(rect.X, rect.Y, rect.Width, ydockMargin);
                    pos     = DockPosition.Top;
                }
                else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical)
                {
                    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);
            }
            outrect = Gdk.Rectangle.Zero;
            return(false);
        }
Exemplo n.º 6
0
        DockLayout GetDefaultLayout()
        {
            DockLayout group = new DockLayout(this);

            // Add items which don't have relative defaut positions

            List <DockItem> todock = new List <DockItem> ();

            foreach (DockItem item in container.Items)
            {
                if (string.IsNullOrEmpty(item.DefaultLocation))
                {
                    DockGroupItem dgt = new DockGroupItem(this, item);
                    dgt.SetVisible(item.DefaultVisible);
                    group.AddObject(dgt);
                }
                else
                {
                    todock.Add(item);
                }
            }

            // Add items with relative positions.
            int lastCount = 0;

            while (lastCount != todock.Count)
            {
                lastCount = todock.Count;
                for (int n = 0; n < todock.Count; n++)
                {
                    DockItem it = todock [n];
                    if (AddDefaultItem(group, it) != null)
                    {
                        todock.RemoveAt(n);
                        n--;
                    }
                }
            }

            // Items which could not be docked because of an invalid default location
            foreach (DockItem item in todock)
            {
                DockGroupItem dgt = new DockGroupItem(this, item);
                dgt.SetVisible(false);
                group.AddObject(dgt);
            }
//      group.Dump ();
            return(group);
        }
Exemplo n.º 7
0
        internal void UpdateTitle(DockItem item)
        {
            DockGroupItem gitem = container.FindDockGroupItem(item.Id);

            if (gitem == null)
            {
                return;
            }

            gitem.ParentGroup.UpdateTitle(item);
            dockBarTop.UpdateTitle(item);
            dockBarBottom.UpdateTitle(item);
            dockBarLeft.UpdateTitle(item);
            dockBarRight.UpdateTitle(item);
        }
Exemplo n.º 8
0
        public override void CopyFrom(DockObject other)
        {
            base.CopyFrom(other);
            DockGroup grp = (DockGroup)other;

            dockObjects = new List <DockObject> ();
            foreach (DockObject ob in grp.dockObjects)
            {
                DockObject cob = ob.Clone();
                cob.ParentGroup = this;
                dockObjects.Add(cob);
            }
            type = grp.type;
            ResetVisibleGroups();
            boundTabStrip = null;
            tabFocus      = null;
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public void LoadLayout(DockLayout dl)
        {
            // Sticky items currently selected in notebooks will remain
            // selected after switching the layout
            List <DockItem> sickyOnTop = new List <DockItem> ();

            foreach (DockItem it in items)
            {
                if ((it.Behavior & DockItemBehavior.Sticky) != 0)
                {
                    DockGroupItem gitem = FindDockGroupItem(it.Id);
                    if (gitem != null && gitem.ParentGroup.IsSelectedPage(it))
                    {
                        sickyOnTop.Add(it);
                    }
                }
            }

            if (layout != null)
            {
                layout.StoreAllocation();
            }
            layout = dl;
            layout.RestoreAllocation();

            // Make sure items not present in this layout are hidden
            foreach (DockItem it in items)
            {
                if ((it.Behavior & DockItemBehavior.Sticky) != 0)
                {
                    it.Visible = it.StickyVisible;
                }
                if (layout.FindDockGroupItem(it.Id) == null)
                {
                    it.HideWidget();
                }
            }

            RelayoutWidgets();

            foreach (DockItem it in sickyOnTop)
            {
                it.Present(false);
            }
        }
Exemplo n.º 11
0
 internal DockGroupItem FindDockGroupItem(string id)
 {
     foreach (DockObject ob in dockObjects)
     {
         DockGroupItem it = ob as DockGroupItem;
         if (it != null && it.Id == id)
         {
             return(it);
         }
         DockGroup g = ob as DockGroup;
         if (g != null)
         {
             it = g.FindDockGroupItem(id);
             if (it != null)
             {
                 return(it);
             }
         }
     }
     return(null);
 }
Exemplo n.º 12
0
 public void LayoutWidgets()
 {
     foreach (DockObject ob in VisibleObjects)
     {
         DockGroupItem it = ob as DockGroupItem;
         if (it != null)
         {
             if (it.Item.Widget.Parent == null)
             {
                 it.Item.Widget.Parent = Frame.Container;
             }
             if (!it.Item.Widget.Visible && type != DockGroupType.Tabbed)
             {
                 it.Item.Widget.Show();
             }
         }
         else
         {
             ((DockGroup)ob).LayoutWidgets();
         }
     }
 }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 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();
     }
 }
Exemplo n.º 15
0
 bool EstimateBarDocPosition(DockGroup grp, DockObject ignoreChild, out PositionType pos, out int size)
 {
     foreach (DockObject ob in grp.Objects)
     {
         if (ob == ignoreChild)
         {
             continue;
         }
         if (ob is DockGroup)
         {
             if (EstimateBarDocPosition((DockGroup)ob, null, out pos, out size))
             {
                 return(true);
             }
         }
         else if (ob is DockGroupItem)
         {
             DockGroupItem it = (DockGroupItem)ob;
             if (it.status == DockItemStatus.AutoHide)
             {
                 pos  = it.barDocPosition;
                 size = it.autoHideSize;
                 return(true);
             }
             if (!it.Allocation.IsEmpty)
             {
                 pos  = it.CalcBarDocPosition();
                 size = it.GetAutoHideSize(pos);
                 return(true);
             }
         }
     }
     pos  = PositionType.Bottom;
     size = 0;
     return(false);
 }
Exemplo n.º 16
0
 internal void FocusItem(DockGroupItem it)
 {
     tabFocus = it;
 }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        internal void UpdateNotebook(TabStrip ts)
        {
            Gtk.Widget oldpage = null;
            int        oldtab  = -1;

            if (tabFocus != null)
            {
                oldpage  = tabFocus.Item.Widget;
                tabFocus = null;
            }
            else if (boundTabStrip != null)
            {
                oldpage = boundTabStrip.CurrentPage;
                oldtab  = boundTabStrip.CurrentTab;
            }

            ts.Clear();

            // Add missing pages
            foreach (DockObject ob in VisibleObjects)
            {
                DockGroupItem it = ob as DockGroupItem;
                ts.AddTab(it.Item.Widget, it.Item.Icon, it.Item.Label);
            }

            boundTabStrip = ts;

            if (currentTabPage != -1 && currentTabPage < boundTabStrip.TabCount)
            {
                boundTabStrip.CurrentTab = currentTabPage;
                // Discard the currentTabPage value. Current page is now tracked by the tab strip
                currentTabPage = -1;
            }
            else if (oldpage != null)
            {
                boundTabStrip.CurrentPage = oldpage;
            }

            if (boundTabStrip.CurrentTab == -1)
            {
                if (oldtab != -1)
                {
                    if (oldtab < boundTabStrip.TabCount)
                    {
                        boundTabStrip.CurrentTab = oldtab;
                    }
                    else
                    {
                        boundTabStrip.CurrentTab = boundTabStrip.TabCount - 1;
                    }
                }
                else
                {
                    boundTabStrip.CurrentTab = 0;
                }
            }
            if (Frame.CompactGuiLevel == 3 && IsNextToMargin(PositionType.Bottom, true))
            {
                boundTabStrip.BottomPadding = 3;
            }
            else
            {
                boundTabStrip.BottomPadding = 0;
            }
        }