예제 #1
0
        /// <summary>
        /// Gets the style for a dock object, which will inherit values from all region/style definitions
        /// </summary>
        internal DockVisualStyle GetRegionStyleForObject(DockObject obj)
        {
            DockVisualStyle mergedStyle = null;

            if (obj is DockGroupItem)
            {
                DockVisualStyle s;
                if (stylesById.TryGetValue(((DockGroupItem)obj).Id, out s))
                {
                    mergedStyle = DefaultVisualStyle.Clone();
                    mergedStyle.CopyValuesFrom(s);
                }
            }
            foreach (var e in regionStyles)
            {
                if (InRegion(e.Item1, obj))
                {
                    if (mergedStyle == null)
                    {
                        mergedStyle = DefaultVisualStyle.Clone();
                    }
                    mergedStyle.CopyValuesFrom(e.Item2);
                }
            }
            return(mergedStyle ?? DefaultVisualStyle);
        }
예제 #2
0
        bool FindHandle(DockGroup grp, int x, int y, out DockGroup foundGrp, out int objectIndex)
        {
            if (grp.Type != DockGroupType.Tabbed && grp.Allocation.Contains(x, y))
            {
                for (int n = 0; n < grp.VisibleObjects.Count; n++)
                {
                    DockObject obj = grp.VisibleObjects [n];
                    if (n < grp.Objects.Count - 1)
                    {
                        if ((grp.Type == DockGroupType.Horizontal && x > obj.Allocation.Right && x < obj.Allocation.Right + frame.TotalHandleSize) ||
                            (grp.Type == DockGroupType.Vertical && y > obj.Allocation.Bottom && y < obj.Allocation.Bottom + frame.TotalHandleSize))
                        {
                            foundGrp    = grp;
                            objectIndex = n;
                            return(true);
                        }
                    }
                    if (obj is DockGroup)
                    {
                        if (FindHandle((DockGroup)obj, x, y, out foundGrp, out objectIndex))
                        {
                            return(true);
                        }
                    }
                }
            }

            foundGrp    = null;
            objectIndex = 0;
            return(false);
        }
        public void ResizeItem(int index, int newSize)
        {
            DockObject o1 = VisibleObjects [index];
            DockObject o2 = VisibleObjects [index + 1];

            int dsize;

            dsize = newSize - o1.AllocSize;
            if (dsize < 0 && o1.AllocSize + dsize < o1.MinSize)
            {
                dsize = o1.MinSize - o1.AllocSize;
            }
            else if (dsize > 0 && o2.AllocSize - dsize < o2.MinSize)
            {
                dsize = o2.AllocSize - o2.MinSize;
            }

            // Assign the new sizes, applying the current ratio
            double sizeDif = (double)dsize;

            o1.AllocSize += dsize;
            o2.AllocSize -= dsize;

            o1.DefaultSize += (o1.DefaultSize * sizeDif) / o1.Size;
            o1.Size         = o1.AllocSize;
            o1.PrefSize     = o1.Size;

            o2.DefaultSize -= (o2.DefaultSize * sizeDif) / o2.Size;
            o2.Size         = o2.AllocSize;
            o2.PrefSize     = o2.Size;

            o1.QueueResize();
            o2.QueueResize();
        }
예제 #4
0
        public DockObject Clone()
        {
            DockObject ob = (DockObject)this.MemberwiseClone();

            ob.CopyFrom(this);
            return(ob);
        }
예제 #5
0
 public virtual void CopySizeFrom(DockObject obj)
 {
     size           = obj.size;
     allocSize      = obj.allocSize;
     defaultHorSize = obj.defaultHorSize;
     defaultVerSize = obj.defaultVerSize;
     prefSize       = obj.prefSize;
 }
예제 #6
0
 internal bool InRegion(string location, DockObject obj)
 {
     if (obj.ParentGroup == null)
     {
         return(false);
     }
     return(InRegion(location, obj.ParentGroup, obj.ParentGroup.GetObjectIndex(obj), false));
 }
예제 #7
0
        public override void CopyFrom(DockObject ob)
        {
            base.CopyFrom(ob);
            DockGroupItem it = (DockGroupItem)ob;

            item        = it.item;
            visibleFlag = it.visibleFlag;
            floatRect   = it.floatRect;
        }
예제 #8
0
            protected override bool OnButtonPressEvent(Gdk.EventButton ev)
            {
                dragging = true;
                dragPos  = (dockGroup.Type == DockGroupType.Horizontal) ? (int)ev.XRoot : (int)ev.YRoot;
                DockObject obj = dockGroup.VisibleObjects [dockIndex];

                dragSize = (dockGroup.Type == DockGroupType.Horizontal) ? obj.Allocation.Width : obj.Allocation.Height;
                return(base.OnButtonPressEvent(ev));
            }
예제 #9
0
 public virtual void CopyFrom(DockObject ob)
 {
     parentGroup    = null;
     frame          = ob.frame;
     rect           = ob.rect;
     size           = ob.size;
     allocSize      = ob.allocSize;
     defaultHorSize = ob.defaultHorSize;
     defaultVerSize = ob.defaultVerSize;
     prefSize       = ob.prefSize;
 }
 public int GetObjectIndex(DockObject obj)
 {
     for (int n = 0; n < dockObjects.Count; n++)
     {
         if (dockObjects [n] == obj)
         {
             return(n);
         }
     }
     return(-1);
 }
        public void ReplaceItem(DockObject ob1, DockObject ob2)
        {
            int i = dockObjects.IndexOf(ob1);

            dockObjects [i] = ob2;
            ob2.ParentGroup = this;
            ob2.ResetDefaultSize();
            ob2.Size        = ob1.Size;
            ob2.DefaultSize = ob1.DefaultSize;
            ob2.AllocSize   = ob1.AllocSize;
            ResetVisibleGroups();
        }
        internal void CalcNewSizes()
        {
            // Calculates the size assigned by default to each child item.
            // Size is proportionally assigned to each item, taking into account
            // the available space, and the default size of each item.

            // If there are items with the Expand flag set, those will proportionally
            // take the space left after allocating the other (not exandable) items.

            // This is the space available for the child items (excluding size
            // required for the resize handles)
            double realSize = (double)GetRealSize(VisibleObjects);

            bool   hasExpandItems    = false;
            double noexpandSize      = 0;
            double minExpandSize     = 0;
            double defaultExpandSize = 0;

            for (int n = 0; n < VisibleObjects.Count; n++)
            {
                DockObject ob = VisibleObjects [n];
                if (ob.Expand)
                {
                    minExpandSize     += ob.MinSize;
                    defaultExpandSize += ob.DefaultSize;
                    hasExpandItems     = true;
                }
                else
                {
                    ob.Size       = ob.DefaultSize;
                    noexpandSize += ob.DefaultSize;
                }
            }

            double expandSize = realSize - noexpandSize;

            foreach (DockObject ob in VisibleObjects)
            {
                if (!hasExpandItems)
                {
                    ob.Size = (ob.DefaultSize / noexpandSize) * realSize;
                }
                else if (ob.Expand)
                {
                    ob.Size = (ob.DefaultSize / defaultExpandSize) * expandSize;
                }
                ob.PrefSize = ob.Size;
            }

            CheckMinSizes();
        }
 public void Reduce()
 {
     if (ParentGroup != null && dockObjects.Count == 1)
     {
         DockObject obj = dockObjects [0];
         int        n   = ParentGroup.GetObjectIndex(this);
         ParentGroup.dockObjects [n] = obj;
         obj.ParentGroup             = ParentGroup;
         obj.CopySizeFrom(this);
         dockObjects.Clear();
         ResetVisibleGroups();
         ParentGroup.ResetVisibleGroups();
     }
 }
        internal void UpdateVisible(DockObject child)
        {
            visibleObjects = null;
            bool visChanged;

            CalcNewSizes();
            MarkForRelayout();

            visChanged = child.Visible ? VisibleObjects.Count == 1 : VisibleObjects.Count == 0;

            if (visChanged && ParentGroup != null)
            {
                ParentGroup.UpdateVisible(this);
            }
        }
        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;
        }
        public void Remove(DockObject obj)
        {
            dockObjects.Remove(obj);
            Reduce();
            obj.ParentGroup = null;
            visibleObjects  = null;

            if (VisibleObjects.Count > 0)
            {
                CalcNewSizes();
                MarkForRelayout();
            }
            else
            {
                ParentGroup.UpdateVisible(this);
            }
        }
 public bool IsChildNextToMargin(Gtk.PositionType margin, DockObject obj, bool visibleOnly)
 {
     if (type == DockGroupType.Tabbed)
     {
         return(true);
     }
     else if (type == DockGroupType.Horizontal)
     {
         if (margin == PositionType.Top || margin == PositionType.Bottom)
         {
             return(true);
         }
         int i = visibleOnly ? VisibleObjects.IndexOf(obj) : Objects.IndexOf(obj);
         if (margin == PositionType.Left && i == 0)
         {
             return(true);
         }
         if (margin == PositionType.Right && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1))
         {
             return(true);
         }
     }
     else if (type == DockGroupType.Vertical)
     {
         if (margin == PositionType.Left || margin == PositionType.Right)
         {
             return(true);
         }
         int i = visibleOnly ? VisibleObjects.IndexOf(obj) : Objects.IndexOf(obj);
         if (margin == PositionType.Top && i == 0)
         {
             return(true);
         }
         if (margin == PositionType.Bottom && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #18
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);
 }
예제 #19
0
		public bool IsChildNextToMargin (Gtk.PositionType margin, DockObject obj, bool visibleOnly)
		{
			if (type == DockGroupType.Tabbed)
				return true;
			else if (type == DockGroupType.Horizontal) {
				if (margin == PositionType.Top || margin == PositionType.Bottom)
					return true;
				int i = visibleOnly ? VisibleObjects.IndexOf (obj) : Objects.IndexOf (obj);
				if (margin == PositionType.Left && i == 0)
					return true;
				if (margin == PositionType.Right && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1))
					return true;
			}
			else if (type == DockGroupType.Vertical) {
				if (margin == PositionType.Left || margin == PositionType.Right)
					return true;
				int i = visibleOnly ? VisibleObjects.IndexOf (obj) : Objects.IndexOf (obj);
				if (margin == PositionType.Top && i == 0)
					return true;
				if (margin == PositionType.Bottom && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1))
					return true;
			}
			return false;
		}
        internal override bool GetDockTarget(DockItem item, int px, int py, out DockDelegate dockDelegate, out Gdk.Rectangle rect)
        {
            if (!Allocation.Contains(px, py) || VisibleObjects.Count == 0)
            {
                dockDelegate = null;
                rect         = Gdk.Rectangle.Zero;
                return(false);
            }

            if (type == DockGroupType.Tabbed)
            {
                // Tabs can only contain DockGroupItems
                return(((DockGroupItem)VisibleObjects[0]).GetDockTarget(item, px, py, Allocation, out dockDelegate, out rect));
            }
            else if (type == DockGroupType.Horizontal)
            {
                if (px >= Allocation.Right - DockFrame.GroupDockSeparatorSize)
                {
                    // Dock to the right of the group
                    dockDelegate = delegate(DockItem it)
                    {
                        DockTarget(it, dockObjects.Count);
                    };
                    rect = new Gdk.Rectangle(Allocation.Right - DockFrame.GroupDockSeparatorSize, Allocation.Y, DockFrame.GroupDockSeparatorSize, Allocation.Height);
                    return(true);
                }
                else if (px <= Allocation.Left + DockFrame.GroupDockSeparatorSize)
                {
                    // Dock to the left of the group
                    dockDelegate = delegate(DockItem it)
                    {
                        DockTarget(it, 0);
                    };
                    rect = new Gdk.Rectangle(Allocation.Left, Allocation.Y, DockFrame.GroupDockSeparatorSize, Allocation.Height);
                    return(true);
                }
                // Dock in a separator
                for (int n = 0; n < VisibleObjects.Count; n++)
                {
                    DockObject ob = VisibleObjects [n];
                    if (n < VisibleObjects.Count - 1 &&
                        px >= ob.Allocation.Right - DockFrame.GroupDockSeparatorSize / 2 &&
                        px <= ob.Allocation.Right + DockFrame.GroupDockSeparatorSize / 2)
                    {
                        int dn = dockObjects.IndexOf(ob);
                        dockDelegate = delegate(DockItem it)
                        {
                            DockTarget(it, dn + 1);
                        };
                        rect = new Gdk.Rectangle(ob.Allocation.Right - DockFrame.GroupDockSeparatorSize / 2, Allocation.Y, DockFrame.GroupDockSeparatorSize, Allocation.Height);
                        return(true);
                    }
                    else if (ob.GetDockTarget(item, px, py, out dockDelegate, out rect))
                    {
                        return(true);
                    }
                }
            }
            else if (type == DockGroupType.Vertical)
            {
                if (py >= Allocation.Bottom - DockFrame.GroupDockSeparatorSize)
                {
                    // Dock to the bottom of the group
                    dockDelegate = delegate(DockItem it)
                    {
                        DockTarget(it, dockObjects.Count);
                    };
                    rect = new Gdk.Rectangle(Allocation.X, Allocation.Bottom - DockFrame.GroupDockSeparatorSize, Allocation.Width, DockFrame.GroupDockSeparatorSize);
                    return(true);
                }
                else if (py <= Allocation.Top + DockFrame.GroupDockSeparatorSize)
                {
                    // Dock to the top of the group
                    dockDelegate = delegate(DockItem it)
                    {
                        DockTarget(it, 0);
                    };
                    rect = new Gdk.Rectangle(Allocation.X, Allocation.Top, Allocation.Width, DockFrame.GroupDockSeparatorSize);
                    return(true);
                }
                // Dock in a separator
                for (int n = 0; n < VisibleObjects.Count; n++)
                {
                    DockObject ob = VisibleObjects [n];
                    if (n < VisibleObjects.Count - 1 &&
                        py >= ob.Allocation.Bottom - DockFrame.GroupDockSeparatorSize / 2 &&
                        py <= ob.Allocation.Bottom + DockFrame.GroupDockSeparatorSize / 2)
                    {
                        int dn = dockObjects.IndexOf(ob);
                        dockDelegate = delegate(DockItem it)
                        {
                            DockTarget(it, dn + 1);
                        };
                        rect = new Gdk.Rectangle(Allocation.X, ob.Allocation.Bottom - DockFrame.GroupDockSeparatorSize / 2, Allocation.Width, DockFrame.GroupDockSeparatorSize);
                        return(true);
                    }
                    else if (ob.GetDockTarget(item, px, py, out dockDelegate, out rect))
                    {
                        return(true);
                    }
                }
            }
            dockDelegate = null;
            rect         = Gdk.Rectangle.Zero;
            return(false);
        }
예제 #21
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;
		}
예제 #22
0
		internal void UpdateVisible (DockObject child)
		{
			visibleObjects = null;
			bool visChanged;
			MarkForRelayout ();
			
			visChanged = child.Visible ? VisibleObjects.Count == 1 : VisibleObjects.Count == 0;
			
			if (visChanged && ParentGroup != null)
				ParentGroup.UpdateVisible (this);
		}
예제 #23
0
		public void Remove (DockObject obj)
		{
			dockObjects.Remove (obj);
			Reduce ();
			obj.ParentGroup = null;
			visibleObjects = null;
			
			if (VisibleObjects.Count > 0) {
				CalcNewSizes ();
				MarkForRelayout ();
			} else
				ParentGroup.UpdateVisible (this);
		}
예제 #24
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;
		}
예제 #25
0
 internal void UpdateRegionStyle(DockObject obj)
 {
     obj.VisualStyle = GetRegionStyleForObject(obj);
 }
예제 #26
0
		public virtual void CopyFrom (DockObject ob)
		{
			parentGroup = null;
			frame = ob.frame;
			rect = ob.rect;
			size = ob.size;
			allocSize = ob.allocSize;
			defaultHorSize = ob.defaultHorSize;
			defaultVerSize = ob.defaultVerSize;
			prefSize = ob.prefSize;
		}
예제 #27
0
		public virtual void CopySizeFrom (DockObject obj)
		{
			size = obj.size;
			allocSize = obj.allocSize;
			defaultHorSize = obj.defaultHorSize;
			defaultVerSize = obj.defaultVerSize;
			prefSize = obj.prefSize;
		}
        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);
        }
예제 #29
0
		public int GetObjectIndex (DockObject obj)
		{
			for (int n=0; n<dockObjects.Count; n++) {
				if (dockObjects [n] == obj)
					return n;
			}
			return -1;
		}
예제 #30
0
		/// <summary>
		/// Gets the style for a dock object, which will inherit values from all region/style definitions
		/// </summary>
		internal DockVisualStyle GetRegionStyleForObject (DockObject obj)
		{
			DockVisualStyle mergedStyle = null;
			if (obj is DockGroupItem) {
				DockVisualStyle s;
				if (stylesById.TryGetValue (((DockGroupItem)obj).Id, out s)) {
					mergedStyle = DefaultVisualStyle.Clone ();
					mergedStyle.CopyValuesFrom (s);
				}
			}
			foreach (var e in regionStyles) {
				if (InRegion (e.Item1, obj)) {
					if (mergedStyle == null)
						mergedStyle = DefaultVisualStyle.Clone ();
					mergedStyle.CopyValuesFrom (e.Item2);
				}
			}
			return mergedStyle ?? DefaultVisualStyle;
		}
예제 #31
0
		public void AddObject (DockObject obj)
		{
			obj.ParentGroup = this;
			dockObjects.Add (obj);
			ResetVisibleGroups ();
		}
예제 #32
0
		bool InRegion (DockGroup grp, DockPosition pos, DockObject refObject, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition)
		{
			if (grp == null)
				return false;

			if (grp.Type == DockGroupType.Tabbed) {
				if (pos != DockPosition.Center &&  pos != DockPosition.CenterBefore)
					return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
			}
			if (grp.Type == DockGroupType.Horizontal) {
				if (pos != DockPosition.Left && pos != DockPosition.Right)
					return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
			}
			if (grp.Type == DockGroupType.Vertical) {
				if (pos != DockPosition.Top && pos != DockPosition.Bottom)
					return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
			}

			bool foundAtLeftSide = true;
			bool findingLeft = pos == DockPosition.Left || pos == DockPosition.Top || pos == DockPosition.CenterBefore;

			if (objToFindParent == grp) {
				// Check positions beyond the current range of items
				if (objToFindIndex < 0 && findingLeft)
					return true;
				if (objToFindIndex >= grp.Objects.Count && !findingLeft)
					return true;
			}

			for (int n=0; n<grp.Objects.Count; n++) {
				var ob = grp.Objects[n];

				bool foundRefObject = ob == refObject;
				bool foundTargetObject = objToFindParent == grp && objToFindIndex == n;

				if (foundRefObject) {
					// Found the reference object, but if insertingPosition=true it is in the position that the new item will have,
					// so this position still has to be considered to be at the left side
					if (foundTargetObject && insertingPosition)
						return foundAtLeftSide == findingLeft;
					foundAtLeftSide = false;
				}
				else if (foundTargetObject)
					return foundAtLeftSide == findingLeft;
				else if (ob is DockGroup) {
					DockGroup gob = (DockGroup)ob;
					if (gob == objToFindParent || ObjectHasAncestor (objToFindParent, gob))
						return foundAtLeftSide == findingLeft;
				}
			}
			return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
		}
예제 #33
0
        void SetBarDocPosition()
        {
            // Determine the best position for docking the item

            if (Allocation.IsEmpty)
            {
                int uniqueTrue  = -1;
                int uniqueFalse = -1;
                for (int n = 0; n < 4; n++)
                {
                    bool inMargin = IsNextToMargin((PositionType)n, false);
                    if (inMargin)
                    {
                        if (uniqueTrue == -1)
                        {
                            uniqueTrue = n;
                        }
                        else
                        {
                            uniqueTrue = -2;
                        }
                    }
                    else
                    {
                        if (uniqueFalse == -1)
                        {
                            uniqueFalse = n;
                        }
                        else
                        {
                            uniqueFalse = -2;
                        }
                    }
                }

                if (uniqueTrue >= 0)
                {
                    barDocPosition = (PositionType)uniqueTrue;
                    autoHideSize   = 200;
                    return;
                }
                else if (uniqueFalse >= 0)
                {
                    barDocPosition = (PositionType)uniqueFalse;
                    switch (barDocPosition)
                    {
                    case PositionType.Left: barDocPosition = PositionType.Right; break;

                    case PositionType.Right: barDocPosition = PositionType.Left; break;

                    case PositionType.Top: barDocPosition = PositionType.Bottom; break;

                    case PositionType.Bottom: barDocPosition = PositionType.Top; break;
                    }
                    autoHideSize = 200;
                    return;
                }

                // If the item is in a group, use the dock location of other items
                DockObject current = this;
                do
                {
                    if (EstimateBarDocPosition(current.ParentGroup, current, out barDocPosition, out autoHideSize))
                    {
                        return;
                    }
                    current = current.ParentGroup;
                } while (current.ParentGroup != null);

                // Can't find a good location. Just guess.
                barDocPosition = PositionType.Bottom;
                autoHideSize   = 200;
                return;
            }
            barDocPosition = CalcBarDocPosition();
        }
        public override void SizeAllocate(Gdk.Rectangle newAlloc)
        {
            Gdk.Rectangle oldAlloc = Allocation;
            base.SizeAllocate(newAlloc);

            if (type == DockGroupType.Tabbed)
            {
                if (boundTabStrip != null)
                {
                    int tabsHeight = boundTabStrip.SizeRequest().Height;
                    boundTabStrip.SizeAllocate(new Gdk.Rectangle(newAlloc.X, newAlloc.Bottom - tabsHeight, newAlloc.Width, tabsHeight));
                }
                if (allocStatus == AllocStatus.Valid && newAlloc == oldAlloc)
                {
                    // Even if allocation has not changed, SizeAllocation has to be called on all items to avoid redrawing issues.
                    foreach (DockObject ob in VisibleObjects)
                    {
                        ob.SizeAllocate(ob.Allocation);
                    }
                    return;
                }
                if (VisibleObjects.Count > 1 && boundTabStrip != null)
                {
                    int tabsHeight = boundTabStrip.SizeRequest().Height;
                    newAlloc.Height -= tabsHeight;
                    boundTabStrip.QueueDraw();
                }
                else if (VisibleObjects.Count != 0)
                {
                    ((DockGroupItem)VisibleObjects [0]).Item.Widget.Show();
                }
                allocStatus = AllocStatus.Valid;
                foreach (DockObject ob in VisibleObjects)
                {
                    ob.Size = ob.PrefSize = -1;
                    ob.SizeAllocate(newAlloc);
                }
                return;
            }

            bool horiz = type == DockGroupType.Horizontal;
            int  pos   = horiz ? Allocation.Left : Allocation.Top;

            if (allocStatus == AllocStatus.Valid && newAlloc == oldAlloc)
            {
                // The layout of this group (as a whole) has not changed, but the layout
                // of child items may have changed. Assign the new sizes.

                if (CheckMinSizes())
                {
                    allocStatus = AllocStatus.NewSizeRequest;
                }
                else
                {
                    foreach (DockObject ob in VisibleObjects)
                    {
                        Gdk.Rectangle rect;
                        int           ins = ob.AllocSize;
                        if (horiz)
                        {
                            rect = new Gdk.Rectangle(pos, Allocation.Y, ins, Allocation.Height);
                        }
                        else
                        {
                            rect = new Gdk.Rectangle(Allocation.X, pos, Allocation.Width, ins);
                        }
                        ob.SizeAllocate(rect);
                        pos += ins + Frame.TotalHandleSize;
                    }
                    return;
                }
            }

            // This is the space available for the child items (excluding size
            // required for the resize handles)
            int realSize = GetRealSize(VisibleObjects);

            if (allocStatus == AllocStatus.NotSet /* || allocStatus == AllocStatus.RestorePending*/)
            {
                // It is the first size allocation. Calculate all sizes.
                CalcNewSizes();
            }
            else if (allocStatus != AllocStatus.NewSizeRequest)
            {
                // Available space has changed, so the size of the items must be changed.
                // First of all, get the change fraction
                double change;
                if (horiz)
                {
                    change = (double)newAlloc.Width / (double)oldAlloc.Width;
                }
                else
                {
                    change = (double)newAlloc.Height / (double)oldAlloc.Height;
                }

                // Get the old total size of the visible objects. Used to calculate the
                // proportion of size of each item.
                double tsize = 0;
                double rsize = 0;
                foreach (DockObject ob in VisibleObjects)
                {
                    tsize += ob.PrefSize;
                    rsize += ob.Size;
                }

                foreach (DockObject ob in dockObjects)
                {
                    if (ob.Visible)
                    {
                        // Proportionally spread the new available space among all visible objects
                        ob.Size = ob.PrefSize = (ob.PrefSize / tsize) * (double)realSize;
                    }
                    else
                    {
                        // For non-visible objects, change the size by the same grow fraction. In this
                        // way, when the item is shown again, it size will have the correct proportions.
                        ob.Size     = ob.Size * change;
                        ob.PrefSize = ob.PrefSize * change;
                    }
                    ob.DefaultSize = ob.DefaultSize * change;
                }
                CheckMinSizes();
            }

            allocStatus = AllocStatus.Valid;

            // Sizes for all items have been set.
            // Sizes are real numbers to ensure that the values are not degradated when resizing
            // pixel by pixel. Now those have to be converted to integers, that is, actual allocated sizes.

            int ts = 0;

            for (int n = 0; n < VisibleObjects.Count; n++)
            {
                DockObject ob = VisibleObjects [n];

                int ins = (int)Math.Truncate(ob.Size);

                if (n == VisibleObjects.Count - 1)
                {
                    ins = realSize - ts;
                }

                ts += ins;

                if (ins < 0)
                {
                    ins = 0;
                }

                ob.AllocSize = ins;

                if (horiz)
                {
                    ob.SizeAllocate(new Gdk.Rectangle(pos, Allocation.Y, ins, Allocation.Height));
                }
                else
                {
                    ob.SizeAllocate(new Gdk.Rectangle(Allocation.X, pos, Allocation.Width, ins));
                }

                pos += ins + Frame.TotalHandleSize;
            }
        }
예제 #35
0
		public override void CopyFrom (DockObject ob)
		{
			base.CopyFrom (ob);
			DockGroupItem it = (DockGroupItem)ob;
			item = it.item;
			visibleFlag = it.visibleFlag;
			floatRect = it.floatRect;
		}
 public void AddObject(DockObject obj)
 {
     obj.ParentGroup = this;
     dockObjects.Add(obj);
     ResetVisibleGroups();
 }
        void DrawSeparators(Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex, bool invalidateOnly, bool drawChildrenSep, List <Gdk.Rectangle> areasList)
        {
            if (type == DockGroupType.Tabbed || VisibleObjects.Count == 0)
            {
                return;
            }

            DockObject last = VisibleObjects [VisibleObjects.Count - 1];

            bool horiz = type == DockGroupType.Horizontal;
            int  x     = Allocation.X;
            int  y     = Allocation.Y;
            int  hw    = horiz ? Frame.HandleSize : Allocation.Width;
            int  hh    = horiz ? Allocation.Height : Frame.HandleSize;

            Gtk.Orientation or = horiz ? Gtk.Orientation.Vertical : Gtk.Orientation.Horizontal;

            for (int n = 0; n < VisibleObjects.Count; n++)
            {
                DockObject ob  = VisibleObjects [n];
                DockGroup  grp = ob as DockGroup;
                if (grp != null && drawChildrenSep)
                {
                    grp.DrawSeparators(exposedArea, currentHandleGrp, currentHandleIndex, invalidateOnly, areasList);
                }
                if (ob != last)
                {
                    if (horiz)
                    {
                        x += ob.Allocation.Width + Frame.HandlePadding;
                    }
                    else
                    {
                        y += ob.Allocation.Height + Frame.HandlePadding;
                    }

                    if (areasList != null)
                    {
                        if (Frame.ShadedSeparators)
                        {
                            areasList.Add(new Gdk.Rectangle(x, y, hw, hh));
                        }
                    }
                    else if (invalidateOnly)
                    {
                        Frame.Container.QueueDrawArea(x, y, hw, hh);
                    }
                    else
                    {
                        if (Frame.ShadedSeparators)
                        {
                            Frame.ShadedContainer.DrawBackground(Frame.Container, new Gdk.Rectangle(x, y, hw, hh));
                        }
                        else
                        {
                            StateType state = (currentHandleGrp == this && currentHandleIndex == n) ? StateType.Prelight : StateType.Normal;
                            if (!DockFrame.IsWindows)
                            {
                                Gtk.Style.PaintHandle(Frame.Style, Frame.Container.GdkWindow, state, ShadowType.None, exposedArea, Frame, "paned", x, y, hw, hh, or);
                            }
                        }
                    }

                    if (horiz)
                    {
                        x += Frame.HandleSize + Frame.HandlePadding;
                    }
                    else
                    {
                        y += Frame.HandleSize + Frame.HandlePadding;
                    }
                }
            }
        }
예제 #38
0
		internal void UpdateRegionStyle (DockObject obj)
		{
			obj.VisualStyle = GetRegionStyleForObject (obj);
		}
예제 #39
0
		public void ReplaceItem (DockObject ob1, DockObject ob2)
		{
			int i = dockObjects.IndexOf (ob1);
			dockObjects [i] = ob2;
			ob2.ParentGroup = this;
			ob2.ResetDefaultSize ();
			ob2.Size = ob1.Size;
			ob2.DefaultSize = ob1.DefaultSize;
			ob2.AllocSize = ob1.AllocSize;
			ResetVisibleGroups ();
		}
예제 #40
0
		internal bool InRegion (string location, DockObject obj)
		{
			if (obj.ParentGroup == null)
				return false;
			return InRegion (location, obj.ParentGroup, obj.ParentGroup.GetObjectIndex (obj), false);
		}
예제 #41
0
        bool InRegion(DockGroup grp, DockPosition pos, DockObject refObject, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition)
        {
            if (grp == null)
            {
                return(false);
            }

            if (grp.Type == DockGroupType.Tabbed)
            {
                if (pos != DockPosition.Center && pos != DockPosition.CenterBefore)
                {
                    return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
                }
            }
            if (grp.Type == DockGroupType.Horizontal)
            {
                if (pos != DockPosition.Left && pos != DockPosition.Right)
                {
                    return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
                }
            }
            if (grp.Type == DockGroupType.Vertical)
            {
                if (pos != DockPosition.Top && pos != DockPosition.Bottom)
                {
                    return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
                }
            }

            bool foundAtLeftSide = true;
            bool findingLeft     = pos == DockPosition.Left || pos == DockPosition.Top || pos == DockPosition.CenterBefore;

            if (objToFindParent == grp)
            {
                // Check positions beyond the current range of items
                if (objToFindIndex < 0 && findingLeft)
                {
                    return(true);
                }
                if (objToFindIndex >= grp.Objects.Count && !findingLeft)
                {
                    return(true);
                }
            }

            for (int n = 0; n < grp.Objects.Count; n++)
            {
                var ob = grp.Objects[n];

                bool foundRefObject    = ob == refObject;
                bool foundTargetObject = objToFindParent == grp && objToFindIndex == n;

                if (foundRefObject)
                {
                    // Found the reference object, but if insertingPosition=true it is in the position that the new item will have,
                    // so this position still has to be considered to be at the left side
                    if (foundTargetObject && insertingPosition)
                    {
                        return(foundAtLeftSide == findingLeft);
                    }
                    foundAtLeftSide = false;
                }
                else if (foundTargetObject)
                {
                    return(foundAtLeftSide == findingLeft);
                }
                else if (ob is DockGroup)
                {
                    DockGroup gob = (DockGroup)ob;
                    if (gob == objToFindParent || ObjectHasAncestor(objToFindParent, gob))
                    {
                        return(foundAtLeftSide == findingLeft);
                    }
                }
            }
            return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
        }
예제 #42
0
		bool ObjectHasAncestor (DockObject obj, DockGroup ancestorToFind)
		{
			return obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor (obj.ParentGroup, ancestorToFind));
		}
예제 #43
0
 bool ObjectHasAncestor(DockObject obj, DockGroup ancestorToFind)
 {
     return(obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor(obj.ParentGroup, ancestorToFind)));
 }