public DockPlaceholder(string name, DockObject obj,
					DockPlacement position, bool sticky)
        {
            WidgetFlags |= WidgetFlags.NoWindow;
            WidgetFlags &= ~(WidgetFlags.CanFocus);

            Sticky = sticky;
            Name = name;

            if (obj != null) {
                Attach (obj);

                if (position == DockPlacement.None)
                    position = DockPlacement.Center;

                NextPlacement = position;

                //the top placement will be consumed by the toplevel dock, so add a dummy placement
                if (obj is Dock)
                    NextPlacement = DockPlacement.Center;

                // try a recursion
                DoExcursion ();
            }
        }
Esempio n. 2
0
        public Dock(Dock original, bool floating, int x, int y, int width, int height)
        {
            floatX        = x;
            floatY        = y;
            this.width    = width;
            this.height   = height;
            this.floating = floating;

            SetFlag(WidgetFlags.NoWindow);
            if (original != null)
            {
                Bind(original.Master);
            }

            /* create a master for the dock if none was provided */
            if (Master == null)
            {
                DockObjectFlags &= ~(DockObjectFlags.Automatic);
                Bind(new DockMaster());
            }

            if (floating)
            {
                /* create floating window for this dock */
                window = new Window(WindowType.Toplevel);
                Window wnd = window as Window;

                /* set position and default size */
                wnd.WindowPosition = WindowPosition.Mouse;
                wnd.SetDefaultSize(width, height);
                wnd.TypeHint = Gdk.WindowTypeHint.Normal;

                /* metacity ignores this */
                wnd.Move(floatX, floatY);

                /* connect to the configure event so we can track down window geometry */
                wnd.ConfigureEvent += new ConfigureEventHandler(OnFloatingConfigure);

                /* set the title */
                SetWindowTitle();

                /* set transient for the first dock if that is a non-floating dock */
                DockObject controller = Master.Controller;
                if (controller != null && controller is Dock)
                {
                    if (!((Dock)controller).Floating)
                    {
                        if (controller.Toplevel != null && controller.Toplevel is Window)
                        {
                            wnd.TransientFor = (Window)controller.Toplevel;
                        }
                    }
                }

                wnd.Add(this);
                wnd.DeleteEvent += new DeleteEventHandler(OnFloatingDelete);
            }

            DockObjectFlags |= DockObjectFlags.Attached;
        }
Esempio n. 3
0
        public override bool OnChildPlacement(DockObject child, ref DockPlacement placement)
        {
            DockPlacement pos = DockPlacement.None;

            if (this.Child != null)
            {
                Paned paned = this.Child as Paned;
                if (child == paned.Child1)
                {
                    pos = this.Orientation == Orientation.Horizontal ? DockPlacement.Left : DockPlacement.Top;
                }
                else if (child == paned.Child2)
                {
                    pos = this.Orientation == Orientation.Horizontal ? DockPlacement.Right : DockPlacement.Bottom;
                }
            }

            if (pos != DockPlacement.None)
            {
                placement = pos;
                return(true);
            }

            return(base.OnChildPlacement(child, ref pos));
        }
Esempio n. 4
0
        public void Attach(DockObject objekt)
        {
            if (objekt == null)
            {
                return;
            }

            // object binding
            if (!IsBound)
            {
                Bind(objekt.Master);
            }

            if (objekt.Master != Master)
            {
                return;
            }

            Freeze();

            // detach from previous host first
            if (host != null)
            {
                Detach(false);
            }

            ConnectHost(objekt);

            DockObjectFlags |= DockObjectFlags.Attached;
            Thaw();
        }
Esempio n. 5
0
        public DockPlaceholder(string name, DockObject obj,
                               DockPlacement position, bool sticky)
        {
            WidgetFlags |= WidgetFlags.NoWindow;
            WidgetFlags &= ~(WidgetFlags.CanFocus);

            Sticky = sticky;
            Name   = name;

            if (obj != null)
            {
                Attach(obj);

                if (position == DockPlacement.None)
                {
                    position = DockPlacement.Center;
                }

                NextPlacement = position;

                //the top placement will be consumed by the toplevel dock, so add a dummy placement
                if (obj is Dock)
                {
                    NextPlacement = DockPlacement.Center;
                }

                // try a recursion
                DoExcursion();
            }
        }
Esempio n. 6
0
        public void Dock(DockObject requestor, DockPlacement position, object data)
        {
            if (requestor == null || requestor == this)
            {
                return;
            }

            if (master == null)
            {
                Console.WriteLine("Dock operation requested in a non-bound object {0}.", this);
                Console.WriteLine("This might break.");
            }

            if (!requestor.IsBound)
            {
                requestor.Bind(Master);
            }

            if (requestor.Master != Master)
            {
                Console.WriteLine("Cannot dock {0} to {1} as they belong to different masters.",
                                  requestor, this);
                return;
            }

            /* first, see if we can optimize things by reordering */
            if (position != DockPlacement.None)
            {
                DockObject parent = ParentObject;
                if (OnReorder(requestor, position, data) ||
                    (parent != null && parent.OnReorder(requestor, position, data)))
                {
                    return;
                }
            }

            /* freeze the object, since under some conditions it might
             * be destroyed when detaching the requestor */
            Freeze();

            /* detach the requestor before docking */
            if (requestor.IsAttached)
            {
                requestor.Detach(false);
            }

            /* notify interested parties that an object has been docked. */
            if (position != DockPlacement.None)
            {
                OnDocked(requestor, position, data);
                DockedHandler handler = Docked;
                if (handler != null)
                {
                    DockedArgs args = new DockedArgs(requestor, position);
                    handler(this, args);
                }
            }

            Thaw();
        }
Esempio n. 7
0
 void AddPlaceholder(DockObject obj)
 {
     if (obj is DockPlaceholder)
     {
         // FIXME: add the current placeholder to the list of placeholders for that host
     }
 }
Esempio n. 8
0
        void ForeachObjectSave(DockObject obj, XmlNode parent)
        {
            if (obj == null)
            {
                return;
            }

            XmlElement element = obj.ToXml(doc);

            parent.AppendChild(element);

            // FIXME: save placeholders for the object
            if (!(obj is DockPlaceholder))
            {
                //ArrayList list = placeholders[obj] as ArrayList;
                //foreach (DockObject child in list)
                //	ForeachObjectSave (child, element);
            }

            // recurse the object if appropriate
            if (obj.IsCompound)
            {
                DockObject child;
                foreach (Widget w in obj.Children)
                {
                    child = w as DockObject;
                    if (child != null)
                    {
                        ForeachObjectSave(child, element);
                    }
                }
            }
        }
Esempio n. 9
0
 public override void OnPresent(DockObject child)
 {
     if (Floating && window != null && window is Window)
     {
         ((Window)window).Present();
     }
 }
Esempio n. 10
0
        public virtual void OnDetached(bool recursive)
        {
            /* detach children */
            if (recursive && IsCompound)
            {
                foreach (DockObject child in Children)
                {
                    child.Detach(recursive);
                }
            }

            /* detach the object itself */
            flags &= ~(DockObjectFlags.Attached);
            DockObject parent = ParentObject;

            if (Parent != null && Parent is Container)
            {
                ((Container)Parent).Remove(this);
            }

            if (parent != null)
            {
                parent.Reduce();
            }
        }
Esempio n. 11
0
        public bool ChildPlacement(DockObject child, ref DockPlacement placement)
        {
            if (!IsCompound)
            {
                return(false);
            }

            return(OnChildPlacement(child, ref placement));
        }
Esempio n. 12
0
        public void Present(DockObject child)
        {
            if (ParentObject != null)
            {
                /* chain the call to our parent */
                ParentObject.Present(this);
            }

            OnPresent(child);
        }
Esempio n. 13
0
        public static Dock GetTopLevel(DockObject obj)
        {
            DockObject parent = obj;

            while (parent != null && !(parent is Dock))
            {
                parent = parent.ParentObject;
            }

            return(parent != null ? (Dock)parent : null);
        }
Esempio n. 14
0
        private void ConnectHost(DockObject newHost)
        {
            if (host != null)
            {
                DisconnectHost();
            }

            host = newHost;

            host.Detached += new DetachedHandler(OnHostDetached);
            host.Docked   += new DockedHandler(OnHostDocked);
        }
Esempio n. 15
0
        private void DisconnectHost()
        {
            if (host == null)
            {
                return;
            }

            host.Detached -= new DetachedHandler(OnHostDetached);
            host.Docked   -= new DockedHandler(OnHostDocked);

            host = null;
        }
Esempio n. 16
0
        public DockRequest(DockRequest copy)
        {
            applicant = copy.Applicant;
            target    = copy.Target;
            x         = copy.X;
            y         = copy.Y;
            width     = copy.Width;
            height    = copy.Height;
            position  = copy.Position;

            extra = copy.Extra;
        }
Esempio n. 17
0
        public DockRequest(DockRequest copy)
        {
            applicant = copy.Applicant;
            target = copy.Target;
            x = copy.X;
            y = copy.Y;
            width = copy.Width;
            height = copy.Height;
            position = copy.Position;

            extra = copy.Extra;
        }
Esempio n. 18
0
        void OnHostDetached(object sender, DetachedArgs a)
        {
            // skip sticky objects
            if (sticky)
            {
                return;
            }

            // go up in the hierarchy
            DockObject newHost = host.ParentObject;

            while (newHost != null)
            {
                DockPlacement pos = DockPlacement.None;

                // get a placement hint from the new host
                if (newHost.ChildPlacement(host, ref pos))
                {
                    NextPlacement = pos;
                }
                else
                {
                    Console.WriteLine("Something weird happened while getting the child placement for {0} from parent {1}", host, newHost);
                }

                // we found a "stable" dock object
                if (newHost.InDetach)
                {
                    break;
                }

                newHost = newHost.ParentObject;
            }

            // disconnect host
            DisconnectHost();

            // the toplevel was detached: we attach ourselves to the
            // controller with an initial placement of floating
            if (newHost == null)
            {
                newHost       = this.Master.Controller;
                NextPlacement = DockPlacement.Floating;
            }

            if (newHost != null)
            {
                ConnectHost(newHost);
            }

            PrintPlacementStack();
        }
Esempio n. 19
0
        void ForeachToplevelDetach(DockObject obj)
        {
            DockObject child;

            foreach (Widget w in obj.Children)
            {
                child = w as DockObject;
                if (w != null)
                {
                    ForeachDetach(child);
                }
            }
        }
Esempio n. 20
0
        public override void OnPresent(DockObject child)
        {
            Notebook nb = Child as Notebook;

            int i = nb.PageNum(child);

            if (i >= 0)
            {
                nb.CurrentPage = i;
            }

            base.OnPresent(child);
        }
Esempio n. 21
0
        public override void OnDocked(DockObject requestor, DockPlacement position, object data)
        {
            if (Child == null)
            {
                return;
            }

            Paned paned = (Paned)Child;
            bool  done  = false;

            /* see if we can dock the item in our paned */
            switch (Orientation)
            {
            case Orientation.Horizontal:
                if (paned.Child1 == null && position == DockPlacement.Left)
                {
                    paned.Pack1(requestor, false, false);
                    done = true;
                }
                else if (paned.Child2 == null && position == DockPlacement.Right)
                {
                    paned.Pack2(requestor, true, true);
                    done = true;
                }
                break;

            case Orientation.Vertical:
                if (paned.Child1 == null && position == DockPlacement.Top)
                {
                    paned.Pack1(requestor, true, true);
                    done = true;
                }
                else if (paned.Child2 == null && position == DockPlacement.Bottom)
                {
                    paned.Pack2(requestor, false, false);
                    done = true;
                }
                break;
            }

            if (!done)
            {
                /* this will create another paned and reparent us there */
                base.OnDocked(requestor, position, data);
            }
            else
            {
                ((DockItem)requestor).ShowGrip();
                requestor.DockObjectFlags |= DockObjectFlags.Attached;
            }
        }
Esempio n. 22
0
        public override bool OnReorder(DockObject requestor, DockPlacement position, object data)
        {
            if (Floating && position == DockPlacement.Floating && root == requestor)
            {
                if (window != null && data != null && data is Gdk.Rectangle)
                {
                    Gdk.Rectangle rect = (Gdk.Rectangle)data;
                    ((Window)window).Move(rect.X, rect.Y);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 23
0
        public override bool OnChildPlacement(DockObject child, ref DockPlacement placement)
        {
            if (root == child)
            {
                if (placement == DockPlacement.None ||
                    placement == DockPlacement.Floating)
                {
                    placement = DockPlacement.Top;
                }
                return(true);
            }

            return(false);
        }
Esempio n. 24
0
        void OnHostDocked(object sender, DockedArgs a)
        {
            DockObject obj = sender as DockObject;

            // see if the given position is compatible for the stack's top element
            if (!sticky && placementStack != null)
            {
                DockPlacement pos = NextPlacement;
                if (obj.ChildPlacement(a.Requestor, ref pos))
                {
                    DoExcursion();
                }
            }

            PrintPlacementStack();
        }
Esempio n. 25
0
        public virtual void SetDefaultPosition(DockObject reference)
        {
            dockPlaceHolder = null;

            if (reference != null && reference.IsAttached)
            {
                if (reference is DockPlaceholder)
                {
                    dockPlaceHolder = (DockPlaceholder)reference;
                }
                else
                {
                    dockPlaceHolder = new DockPlaceholder(reference, true);
                }
            }
        }
Esempio n. 26
0
        protected override void OnRemoved(Widget widget)
        {
            bool wasVisible = widget.Visible;

            if (root == widget)
            {
                root.DockObjectFlags &= ~(DockObjectFlags.Attached);
                root = null;
                widget.Unparent();

                if (wasVisible && Visible)
                {
                    QueueResize();
                }
            }
        }
Esempio n. 27
0
 public override void OnDocked(DockObject requestor, DockPlacement position, object data)
 {
     if (host != null)
     {
         // we simply act as a placeholder for our host
         host.Dock(requestor, position, data);
     }
     else
     {
         if (!IsBound)
         {
             Console.WriteLine("Attempt to dock a dock object to an unbound placeholder");
             return;
         }
         // dock the item as a floating of the controller
         Master.Controller.Dock(requestor, DockPlacement.Floating, null);
     }
 }
Esempio n. 28
0
        public DockPlaceholder GetPlaceholderByName(string name)
        {
            if (name == null)
            {
                return(null);
            }

            DockObject found = Master.GetObject(name);

            if (found != null && found is DockPlaceholder)
            {
                return((DockPlaceholder)found);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 29
0
        public DockItem GetItemByName(string name)
        {
            if (name == null)
            {
                return(null);
            }

            DockObject found = Master.GetObject(name);

            if (found != null && found is DockItem)
            {
                return((DockItem)found);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 30
0
        DockObject SetupObject(XmlNode node)
        {
            DockObject obj = null;

            if (node.Name == "notebook")
            {
                DockNotebook dn = new DockNotebook();
                dn.Bind(master);
                dn.FromXml(node);
                return(dn);
            }
            if (node.Name == "paned")
            {
                DockPaned dp = new DockPaned();
                dp.Bind(master);
                dp.FromXml(node);
                return(dp);
            }

            string name = null;

            if (node.Attributes["name"] != null)
            {
                name = node.Attributes["name"].Value;
            }

            if (name != null && name.Length > 0)
            {
                obj = master.GetObject(name);
            }
            else
            {
                Console.WriteLine("While loading layout: don't know how to create a dock object whose nick is '{0}'", name);
            }

            if (obj != null)
            {
                obj.FromXml(node);
            }

            return(obj);
        }
Esempio n. 31
0
        public override bool OnReorder(DockObject requestor, DockPlacement position, object other_data)
        {
            bool handled = false;
            int  current_position, new_pos = -1;

            if (Child != null && position == DockPlacement.Center)
            {
                current_position = ((Notebook)Child).PageNum(requestor);
                if (current_position >= 0)
                {
                    handled = true;
                    if (other_data is Int32)
                    {
                        new_pos = Convert.ToInt32(other_data);
                    }
                    ((Notebook)Child).ReorderChild(requestor, new_pos);
                }
            }
            return(handled);
        }
Esempio n. 32
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. 33
0
 public virtual void OnPresent(DockObject child)
 {
     Show ();
 }
Esempio n. 34
0
        public override bool OnReorder(DockObject requestor, DockPlacement position, object other_data)
        {
            bool handled = false;
            int current_position, new_pos = -1;

            if (Child != null && position == DockPlacement.Center) {
                current_position = ((Notebook)Child).PageNum (requestor);
                if (current_position >= 0) {
                    handled = true;
                    if (other_data is Int32)
                        new_pos = Convert.ToInt32 (other_data);
                    ((Notebook)Child).ReorderChild (requestor, new_pos);
                }
            }
            return handled;
        }
Esempio n. 35
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);
            }
        }
 public DockPlaceholder(DockObject obj, bool sticky)
     : this(obj.Name, obj, DockPlacement.None, sticky)
 {
 }
        private void DisconnectHost()
        {
            if (host == null)
                return;

            host.Detached -= new DetachedHandler (OnHostDetached);
            host.Docked -= new DockedHandler (OnHostDocked);

            host = null;
        }
 public override void OnPresent(DockObject child)
 {
     // do nothing
 }
Esempio n. 39
0
        public void Dock(DockObject requestor, DockPlacement position, object data)
        {
            if (requestor == null || requestor == this)
                return;

            if (master == null) {
                Console.WriteLine ("Dock operation requested in a non-bound object {0}.", this);
                Console.WriteLine ("This might break.");
            }

            if (!requestor.IsBound)
                requestor.Bind (Master);

            if (requestor.Master != Master) {
                Console.WriteLine ("Cannot dock {0} to {1} as they belong to different masters.",
                           requestor, this);
                return;
            }

            /* first, see if we can optimize things by reordering */
            if (position != DockPlacement.None) {
                DockObject parent = ParentObject;
                if (OnReorder (requestor, position, data) ||
                    (parent != null && parent.OnReorder (requestor, position, data)))
                    return;
            }

            /* freeze the object, since under some conditions it might
               be destroyed when detaching the requestor */
            Freeze ();

            /* detach the requestor before docking */
            if (requestor.IsAttached)
                requestor.Detach (false);

            /* notify interested parties that an object has been docked. */
            if (position != DockPlacement.None) {
                OnDocked (requestor, position, data);
                DockedHandler handler = Docked;
                if (handler != null) {
                    DockedArgs args = new DockedArgs (requestor, position);
                    handler (this, args);
                }
            }

            Thaw ();
        }
Esempio n. 40
0
        public virtual void SetDefaultPosition(DockObject reference)
        {
            ph = null;

            if (reference != null && reference.IsAttached) {
                if (reference is DockPlaceholder) {
                    ph = (DockPlaceholder)reference;
                } else {
                    ph = new DockPlaceholder (reference, true);
                }
            }
        }
Esempio n. 41
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 ();
        }
Esempio n. 42
0
        public void Remove(DockObject obj)
        {
            if (obj == null)
                return;

            // remove from locked/unlocked hashes and property change if that's the case
            if (obj is DockItem && ((DockItem)obj).HasGrip) {
                int locked = Locked;
                if (lockedItems.Contains (obj)) {
                    lockedItems.Remove (obj);
                    if (Locked != locked)
                        EmitNotifyLocked ();
                }
                if (unlockedItems.Contains (obj)) {
                    unlockedItems.Remove (obj);
                    if (Locked != locked)
                        EmitNotifyLocked ();
                }
            }

            if (obj is Dock) {
                toplevelDocks.Remove (obj);
                obj.Docked -= new DockedHandler (OnItemDocked);

                if (obj == controller) {
                    DockObject newController = null;

                    // now find some other non-automatic toplevel to use as a
                    // new controller.  start from the last dock, since it's
                    // probably a non-floating and manual
                    ArrayList reversed = toplevelDocks;
                    reversed.Reverse ();

                    foreach (DockObject item in reversed) {
                        if (!item.IsAutomatic) {
                            newController = item;
                            break;
                        }
                    }

                    if (newController != null) {
                        controller = newController;
                    } else {
                        // no controller, no master
                        controller = null;
                    }
                }
            }

            // disconnect the signals
            if (obj is DockItem) {
                DockItem item = obj as DockItem;
                item.Detached -= new DetachedHandler (OnItemDetached);
                item.Docked -= new DockedHandler (OnItemDocked);
                item.DockItemDragBegin -= new DockItemDragBeginHandler (OnDragBegin);
                item.DockItemMotion -= new DockItemMotionHandler (OnDragMotion);
                item.DockItemDragEnd -= new DockItemDragEndHandler (OnDragEnd);
                item.PropertyChanged -= new PropertyChangedHandler (OnItemPropertyChanged);
            }

            // remove the object from the hash if it is there
            if (obj.Name != null && dockObjects.Contains (obj.Name))
                dockObjects.Remove (obj.Name);

            /* post a layout_changed emission if the item is not automatic
             * (since it should be removed from the items model) */
            if (!obj.IsAutomatic)
                EmitLayoutChangedEvent ();
        }
Esempio n. 43
0
        public void Add(DockObject obj)
        {
            if (obj == null)
                return;

            if (!obj.IsAutomatic) {
                /* create a name for the object if it doesn't have one */
                if (obj.Name == null)
                    obj.Name = "__dock_" + number++;

                /* add the object to our hash list */
                if (dockObjects.Contains (obj.Name))
                    Console.WriteLine ("Unable to add object, name \"{0}\" taken", obj.Name);
                else
                    dockObjects.Add (obj.Name, obj);
            }

            if (obj is Dock) {
                /* if this is the first toplevel we are adding, name it controller */
                if (toplevelDocks.Count == 0)
                    controller = obj;

                /* add dock to the toplevel list */
                if (((Dock)obj).Floating)
                    toplevelDocks.Insert (0, obj);
                else
                    toplevelDocks.Add (obj);

                /* we are interested in the dock request this toplevel
                 * receives to update the layout */
                obj.Docked += new DockedHandler (OnItemDocked);
            } else if (obj is DockItem) {
                DockItem item = obj as DockItem;

                /* we need to connect the item's events */
                item.Detached += new DetachedHandler (OnItemDetached);
                item.Docked += new DockedHandler (OnItemDocked);
                item.DockItemDragBegin += new DockItemDragBeginHandler (OnDragBegin);
                item.DockItemMotion += new DockItemMotionHandler (OnDragMotion);
                item.DockItemDragEnd += new DockItemDragEndHandler (OnDragEnd);

                /* register to "locked" notification if the item has a grip,
                 * and add the item to the corresponding hash */
                item.PropertyChanged += new PropertyChangedHandler (OnItemPropertyChanged);

                /* post a layout_changed emission if the item is not automatic
                 * (since it should be added to the items model) */
                if (!item.IsAutomatic) {
                    EmitLayoutChangedEvent ();
                }
            }
        }
Esempio n. 44
0
        public void Present(DockObject child)
        {
            if (ParentObject != null)
                /* chain the call to our parent */
                ParentObject.Present (this);

            OnPresent (child);
        }
Esempio n. 45
0
 public virtual bool OnReorder(DockObject child, DockPlacement new_position, object data)
 {
     return false;
 }
        public void Attach(DockObject objekt)
        {
            if (objekt == null)
                return;

            // object binding
            if (!IsBound)
                Bind(objekt.Master);

            if (objekt.Master != Master)
                return;

            Freeze ();

            // detach from previous host first
            if (host != null)
                Detach (false);

            ConnectHost (objekt);

            DockObjectFlags |= DockObjectFlags.Attached;
            Thaw ();
        }
 public override void OnDocked(DockObject requestor, DockPlacement position, object data)
 {
     if (host != null) {
         // we simply act as a placeholder for our host
         host.Dock (requestor, position, data);
     } else {
         if (!IsBound) {
             Console.WriteLine ("Attempt to dock a dock object to an unbound placeholder");
             return;
         }
         // dock the item as a floating of the controller
         Master.Controller.Dock (requestor, DockPlacement.Floating, null);
     }
 }
Esempio n. 48
0
        public bool ChildPlacement(DockObject child, ref DockPlacement placement)
        {
            if (!IsCompound)
                return false;

            return OnChildPlacement (child, ref placement);
        }
        private void ConnectHost(DockObject newHost)
        {
            if (host != null)
                DisconnectHost ();

            host = newHost;

            host.Detached += new DetachedHandler (OnHostDetached);
            host.Docked += new DockedHandler (OnHostDocked);
        }
Esempio n. 50
0
        void RecursiveBuild(XmlNode parentNode, DockObject parent)
        {
            if (master == null || parentNode == null)
                return;

            DockObject obj;

            // FIXME: if parent is null, we should build toplevels
            //if (parent == null)

            foreach (XmlNode node in parentNode.ChildNodes)
            {
                obj = SetupObject (node);
                if (obj != null) {
                    obj.Freeze ();

                    // recurse here to catch placeholders
                    RecursiveBuild (node, obj);

                    // placeholders are later attached to the parent
                    if (obj is DockPlaceholder)
                        obj.Detach (false);

                    // apply "after" parameters
                    obj.FromXmlAfter (node);

                    // add the object to the parent
                    if (parent != null) {
                        if (obj is DockPlaceholder) {
                            ((DockPlaceholder) obj).Attach (parent);
                        }
                        else if (parent.IsCompound) {
                            parent.Add (obj);
                            if (parent.Visible)
                                obj.Show ();
                        }
                    }
                    else {
                        if (master.Controller != obj && master.Controller.Visible)
                            obj.Show ();
                    }

                    // call reduce just in case child is missing
                    if (obj.IsCompound)
                        obj.Reduce ();

                    obj.Thaw ();
                }
            }
        }
Esempio n. 51
0
 void AddPlaceholder(DockObject obj)
 {
     if (obj is DockPlaceholder) {
         // FIXME: add the current placeholder to the list of placeholders for that host
     }
 }
Esempio n. 52
0
 void ForeachToplevelDetach(DockObject obj)
 {
     DockObject child;
     foreach (Widget w in obj.Children) {
         child = w as DockObject;
         if (w != null)
             ForeachDetach (child);
     }
 }
Esempio n. 53
0
 public override bool OnChildPlacement(DockObject child, ref DockPlacement position)
 {
     DockPlacement pos = DockPlacement.None;
     if (Child != null) {
         foreach (Widget widget in ((Notebook)Child).Children) {
             if (widget == child) {
                 pos = DockPlacement.Center;
                 break;
             }
         }
     }
     if (pos != DockPlacement.None) {
         position = pos;
         return true;
     }
     return false;
 }
Esempio n. 54
0
        void ForeachObjectSave(DockObject obj, XmlNode parent)
        {
            if (obj == null)
                return;

            XmlElement element = obj.ToXml (doc);
            parent.AppendChild (element);

            // FIXME: save placeholders for the object
            if (!(obj is DockPlaceholder)) {
                //ArrayList list = placeholders[obj] as ArrayList;
                //foreach (DockObject child in list)
                //	ForeachObjectSave (child, element);
            }

            // recurse the object if appropriate
            if (obj.IsCompound) {
                DockObject child;
                foreach (Widget w in obj.Children)
                {
                    child = w as DockObject;
                    if (child != null)
                        ForeachObjectSave (child, element);
                }
            }
        }
Esempio n. 55
0
        public override void OnPresent(DockObject child)
        {
            Notebook nb = Child as Notebook;

            int i = nb.PageNum (child);
            if (i >= 0)
                nb.CurrentPage = i;

            base.OnPresent (child);
        }
Esempio n. 56
0
 public DockedArgs(DockObject requestor, DockPlacement position)
 {
     this.requestor = requestor;
     this.position = position;
 }
Esempio n. 57
0
        public override void OnDocked(DockObject requestor, DockPlacement position, object data)
        {
            if (Child == null)
                return;

            Paned paned = (Paned)Child;
            bool done = false;

            /* see if we can dock the item in our paned */
            switch (Orientation) {
            case Orientation.Horizontal:
                if (paned.Child1 == null && position == DockPlacement.Left) {
                    paned.Pack1 (requestor, false, false);
                    done = true;
                } else if (paned.Child2 == null && position == DockPlacement.Right) {
                    paned.Pack2 (requestor, true, true);
                    done = true;
                }
                break;
            case Orientation.Vertical:
                if (paned.Child1 == null && position == DockPlacement.Top) {
                    paned.Pack1 (requestor, true, true);
                    done = true;
                } else if (paned.Child2 == null && position == DockPlacement.Bottom) {
                    paned.Pack2 (requestor, false, false);
                    done = true;
                }
                break;
            }

            if (!done) {
                /* this will create another paned and reparent us there */
                base.OnDocked (requestor, position, data);
            } else {
                ((DockItem)requestor).ShowGrip ();
                requestor.DockObjectFlags |= DockObjectFlags.Attached;
            }
        }
Esempio n. 58
0
 void ForeachDetach(DockObject obj)
 {
     obj.Detach (true);
 }
Esempio n. 59
0
 public virtual void OnDocked(DockObject requestor, DockPlacement position, object data)
 {
 }
Esempio n. 60
0
 public virtual bool OnChildPlacement(DockObject child, ref DockPlacement placement)
 {
     return false;
 }