Esempio n. 1
0
        public virtual void OnReduce()
        {
            if (!IsCompound)
            {
                return;
            }

            DockObject parent = ParentObject;

            Widget[] children = Children;
            if (children.Length <= 1)
            {
                if (parent != null)
                {
                    parent.Freeze();
                }

                Freeze();
                Detach(false);

                foreach (Widget widget in children)
                {
                    DockObject child = widget as DockObject;
                    child.flags |= DockObjectFlags.InReflow;
                    child.Detach(false);
                    if (parent != null)
                    {
                        parent.Add(child);
                    }
                    child.flags &= ~(DockObjectFlags.InReflow);
                }

                reducePending = false;

                Thaw();
                if (parent != null)
                {
                    parent.Thaw();
                }
            }
        }
Esempio n. 2
0
        public override void OnDocked(DockObject requestor, DockPlacement position, object data)
        {
            /* we only add support for DockPlacement.Center docking
             * strategy here... for the rest use our parent class' method */
            if (position == DockPlacement.Center)
            {
                /* we can only dock simple (not compound) items */
                if (requestor.IsCompound)
                {
                    requestor.Freeze();
                    dockInfo = new DockInfo(position, data);
                    requestor.Foreach(new Callback(DockChild));
                    requestor.Thaw();
                }
                else
                {
                    DockItem requestorItem = requestor as DockItem;
                    Widget   label         = requestorItem.TabLabel;
                    if (label == null)
                    {
                        label = new Label(requestorItem.LongName);
                        requestorItem.TabLabel = label;
                    }

                    int tabPosition = -1;
                    if (data is Int32)
                    {
                        tabPosition = Convert.ToInt32(data);
                    }
                    ((Notebook)Child).InsertPage(requestor, label, tabPosition);
                    requestor.DockObjectFlags |= DockObjectFlags.Attached;
                }
            }
            else
            {
                base.OnDocked(requestor, position, data);
            }
        }
Esempio n. 3
0
        public override void OnDocked(DockObject requestor, DockPlacement position, object data)
        {
            /* we only add support for DockPlacement.Center docking
               strategy here... for the rest use our parent class' method */
            if (position == DockPlacement.Center) {
                /* we can only dock simple (not compound) items */
                if (requestor.IsCompound) {
                    requestor.Freeze ();
                    dockInfo = new DockInfo (position, data);
                    requestor.Foreach (new Callback (DockChild));
                    requestor.Thaw ();
                } else {
                    DockItem requestorItem = requestor as DockItem;
                    Widget label = requestorItem.TabLabel;
                    if (label == null) {
                        label = new Label (requestorItem.LongName);
                        requestorItem.TabLabel = label;
                    }

                    int tabPosition = -1;
                    if (data is Int32)
                        tabPosition = Convert.ToInt32 (data);
                    ((Notebook)Child).InsertPage (requestor, label, tabPosition);
                    requestor.DockObjectFlags |= DockObjectFlags.Attached;
                }
            } else {
                base.OnDocked (requestor, position, data);
            }
        }
Esempio n. 4
0
        public override void OnDocked(DockObject requestor, DockPlacement position, object data)
        {
            DockObject parent    = ParentObject;
            DockObject newParent = null;
            bool       addOurselvesFirst;

            switch (position)
            {
            case DockPlacement.Top:
            case DockPlacement.Bottom:
                newParent         = new DockPaned(Orientation.Vertical);
                addOurselvesFirst = (position == DockPlacement.Bottom);
                break;

            case DockPlacement.Left:
            case DockPlacement.Right:
                newParent         = new DockPaned(Orientation.Horizontal);
                addOurselvesFirst = (position == DockPlacement.Right);
                break;

            case DockPlacement.Center:
                newParent         = new DockNotebook();
                addOurselvesFirst = true;
                break;

            default:
                Console.WriteLine("Unsupported docking strategy");
                return;
            }

            if (parent != null)
            {
                parent.Freeze();
            }

            DockObjectFlags |= DockObjectFlags.InReflow;
            Detach(false);
            newParent.Freeze();
            newParent.Bind(Master);

            if (addOurselvesFirst)
            {
                newParent.Add(this);
                newParent.Add(requestor);
            }
            else
            {
                newParent.Add(requestor);
                newParent.Add(this);
            }

            if (parent != null)
            {
                parent.Add(newParent);
            }

            if (Visible)
            {
                newParent.Show();
            }

            if (position != DockPlacement.Center && data != null && data is System.Int32)
            {
                if (newParent is DockPaned)
                {
                    ((DockPaned)newParent).Position = (int)data;
                }
            }

            DockObjectFlags &= ~(DockObjectFlags.InReflow);

            newParent.Thaw();
            if (parent != null)
            {
                parent.Thaw();
            }
        }