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

            if (gitem == null)
            {
                return;
            }

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

            if (it != null)
            {
                return(it.ParentGroup);
            }
            else
            {
                return(null);
            }
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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;
        }
Exemple #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);
        }
Exemple #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);
            }
        }
Exemple #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);
 }
Exemple #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();
         }
     }
 }
Exemple #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);
 }
Exemple #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();
     }
 }
Exemple #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);
 }
Exemple #16
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;
 }
Exemple #17
0
 internal void FocusItem(DockGroupItem it)
 {
     tabFocus = it;
 }
Exemple #18
0
        internal override void Read(XmlReader reader)
        {
            base.Read (reader);
            type = (DockGroupType) Enum.Parse (typeof(DockGroupType), reader.GetAttribute ("type"));
            if (type == DockGroupType.Tabbed) {
                string s = reader.GetAttribute ("currentTabPage");
                if (s != null)
                    currentTabPage = int.Parse (s);
            }

            reader.MoveToElement ();
            if (reader.IsEmptyElement) {
                reader.Skip ();
                return;
            }

            reader.ReadStartElement ();
            reader.MoveToContent ();
            while (reader.NodeType != XmlNodeType.EndElement) {
                if (reader.NodeType == XmlNodeType.Element) {
                    if (reader.LocalName == "item") {
                        string id = reader.GetAttribute ("id");
                        DockItem it = Frame.GetItem (id);
                        if (it == null) {
                            it = Frame.AddItem (id);
                            it.IsPositionMarker = true;
                        }
                        DockGroupItem gitem = new DockGroupItem (Frame, it);
                        gitem.Read (reader);
                        AddObject (gitem);

                        reader.MoveToElement ();
                        reader.Skip ();
                    }
                    else if (reader.LocalName == "group") {
                        DockGroup grp = new DockGroup (Frame);
                        grp.Read (reader);
                        AddObject (grp);
                    }
                }
                else
                    reader.Skip ();
                reader.MoveToContent ();
            }
            reader.ReadEndElement ();
        }
Exemple #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;
        }
Exemple #20
0
 void DockTarget(DockItem item, int n)
 {
     DockGroupItem gitem = new DockGroupItem (Frame, item);
     dockObjects.Insert (n, gitem);
     gitem.ParentGroup = this;
     gitem.SetVisible (true);
     ResetVisibleGroups ();
     CalcNewSizes ();
 }
Exemple #21
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;
        }
Exemple #22
0
        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 ();
        }
Exemple #23
0
 internal void FocusItem(DockGroupItem it)
 {
     tabFocus = it;
 }
Exemple #24
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;
            }
        }
Exemple #25
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);
        }
Exemple #26
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;
        }
Exemple #27
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;
        }
Exemple #28
0
        internal void DockInPlaceholder(DockItem item)
        {
            if (placeholderWindow == null || !placeholderWindow.Visible)
                return;

            item.Status = DockItemStatus.Dockable;

            int px, py;
            GetPointer (out px, out py);

            DockDelegate dockDelegate;
            Gdk.Rectangle rect;
            if (placeholderWindow.AllowDocking && layout.GetDockTarget (item, px, py, out dockDelegate, out rect)) {
                DockGroupItem dummyItem = new DockGroupItem (frame, new DockItem (frame, "__dummy"));
                DockGroupItem gitem = layout.FindDockGroupItem (item.Id);
                gitem.ParentGroup.ReplaceItem (gitem, dummyItem);
                dockDelegate (item);
                dummyItem.ParentGroup.Remove (dummyItem);
                RelayoutWidgets ();
            } else {
                DockGroupItem gi = FindDockGroupItem (item.Id);
                int pw, ph;
                placeholderWindow.GetPosition (out px, out py);
                placeholderWindow.GetSize (out pw, out ph);
                gi.FloatRect = new Rectangle (px, py, pw, ph);
                item.Status = DockItemStatus.Floating;
            }
        }
Exemple #29
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;
        }
Exemple #30
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);
        }