Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public DockObject Clone()
        {
            DockObject ob = (DockObject)this.MemberwiseClone();

            ob.CopyFrom(this);
            return(ob);
        }
Exemplo n.º 3
0
 internal bool InRegion(string location, DockObject obj)
 {
     if (obj.ParentGroup == null)
     {
         return(false);
     }
     return(InRegion(location, obj.ParentGroup, obj.ParentGroup.GetObjectIndex(obj), false));
 }
Exemplo n.º 4
0
 public virtual void CopySizeFrom(DockObject obj)
 {
     size           = obj.size;
     allocSize      = obj.allocSize;
     defaultHorSize = obj.defaultHorSize;
     defaultVerSize = obj.defaultVerSize;
     prefSize       = obj.prefSize;
 }
Exemplo n.º 5
0
        public override void CopyFrom(DockObject ob)
        {
            base.CopyFrom(ob);
            DockGroupItem it = (DockGroupItem)ob;

            item        = it.item;
            visibleFlag = it.visibleFlag;
            floatRect   = it.floatRect;
        }
Exemplo n.º 6
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));
            }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
0
 bool EstimateBarDocPosition(DockGroup grp, DockObject ignoreChild, out PositionType pos, out int size)
 {
     foreach (DockObject ob in grp.Objects)
     {
         if (ob == ignoreChild)
         {
             continue;
         }
         if (ob is DockGroup)
         {
             if (EstimateBarDocPosition((DockGroup)ob, null, out pos, out size))
             {
                 return(true);
             }
         }
         else if (ob is DockGroupItem)
         {
             DockGroupItem it = (DockGroupItem)ob;
             if (it.status == DockItemStatus.AutoHide)
             {
                 pos  = it.barDocPosition;
                 size = it.autoHideSize;
                 return(true);
             }
             if (!it.Allocation.IsEmpty)
             {
                 pos  = it.CalcBarDocPosition();
                 size = it.GetAutoHideSize(pos);
                 return(true);
             }
         }
     }
     pos  = PositionType.Bottom;
     size = 0;
     return(false);
 }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
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);
		}
Exemplo n.º 11
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;
		}
Exemplo n.º 12
0
		bool EstimateBarDocPosition (DockGroup grp, DockObject ignoreChild, out PositionType pos, out int size)
		{
			foreach (DockObject ob in grp.Objects) {
				if (ob == ignoreChild)
					continue;
				if (ob is DockGroup) {
					if (EstimateBarDocPosition ((DockGroup)ob, null, out pos, out size))
						return true;
				} else if (ob is DockGroupItem) {
					DockGroupItem it = (DockGroupItem) ob;
					if (it.status == DockItemStatus.AutoHide) {
						pos = it.barDocPosition;
						size = it.autoHideSize;
						return true;
					}
					if (!it.Allocation.IsEmpty) {
						pos = it.CalcBarDocPosition ();
						size = it.GetAutoHideSize (pos);
						return true;
					}
				}
			}
			pos = PositionType.Bottom;
			size = 0;
			return false;
		}
Exemplo n.º 13
0
		public virtual void CopySizeFrom (DockObject obj)
		{
			size = obj.size;
			allocSize = obj.allocSize;
			defaultHorSize = obj.defaultHorSize;
			defaultVerSize = obj.defaultVerSize;
			prefSize = obj.prefSize;
		}
Exemplo n.º 14
0
 internal void UpdateRegionStyle(DockObject obj)
 {
     obj.VisualStyle = GetRegionStyleForObject(obj);
 }
Exemplo n.º 15
0
		bool ObjectHasAncestor (DockObject obj, DockGroup ancestorToFind)
		{
			return obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor (obj.ParentGroup, ancestorToFind));
		}
Exemplo n.º 16
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);
		}
Exemplo n.º 17
0
		internal bool InRegion (string location, DockObject obj)
		{
			if (obj.ParentGroup == null)
				return false;
			return InRegion (location, obj.ParentGroup, obj.ParentGroup.GetObjectIndex (obj), false);
		}
Exemplo n.º 18
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;
		}
Exemplo n.º 19
0
		internal void UpdateRegionStyle (DockObject obj)
		{
			obj.VisualStyle = GetRegionStyleForObject (obj);
		}
Exemplo n.º 20
0
		public void AddObject (DockObject obj)
		{
			obj.ParentGroup = this;
			dockObjects.Add (obj);
			ResetVisibleGroups ();
		}
Exemplo n.º 21
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;
		}
Exemplo n.º 22
0
		public int GetObjectIndex (DockObject obj)
		{
			for (int n=0; n<dockObjects.Count; n++) {
				if (dockObjects [n] == obj)
					return n;
			}
			return -1;
		}
Exemplo n.º 23
0
		public override void CopyFrom (DockObject ob)
		{
			base.CopyFrom (ob);
			DockGroupItem it = (DockGroupItem)ob;
			item = it.item;
			visibleFlag = it.visibleFlag;
			floatRect = it.floatRect;
		}
Exemplo n.º 24
0
		public override void CopyFrom (DockObject other)
		{
			base.CopyFrom (other);
			DockGroup grp = (DockGroup) other;
			dockObjects = new List<DockObject> ();
			foreach (DockObject ob in grp.dockObjects) {
				DockObject cob = ob.Clone ();
				cob.ParentGroup = this;
				dockObjects.Add (cob);
			}
			type = grp.type;
			ResetVisibleGroups ();
			boundTabStrip = null;
			tabFocus = null;
		}
Exemplo n.º 25
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));
        }
Exemplo n.º 26
0
 bool ObjectHasAncestor(DockObject obj, DockGroup ancestorToFind)
 {
     return(obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor(obj.ParentGroup, ancestorToFind)));
 }
Exemplo n.º 27
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 ();
		}
Exemplo n.º 28
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);
		}