Inheritance: MonoDevelop.Components.Docking.DockObject
Beispiel #1
0
 void GetTabbedGroups(DockGroup grp, List <DockGroup> tabbedGroups)
 {
     if (grp.Type == DockGroupType.Tabbed)
     {
         if (grp.VisibleObjects.Count > 1)
         {
             tabbedGroups.Add(grp);
         }
         else
         {
             grp.ResetNotebook();
         }
     }
     else
     {
         // Make sure it doesn't have a notebook bound to it
         grp.ResetNotebook();
         foreach (DockObject ob in grp.Objects)
         {
             if (ob is DockGroup)
             {
                 GetTabbedGroups((DockGroup)ob, tabbedGroups);
             }
         }
     }
 }
Beispiel #2
0
        internal bool InRegion(string location, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition)
        {
            // Checks if the object is in the specified region.
            // A region is a collection with the format: "ItemId1/Position1;ItemId2/Position2..."
            string[] positions = location.Split(';');
            foreach (string pos in positions)
            {
                // We individually check each entry in the region specification
                int i = pos.IndexOf('/');
                if (i == -1)
                {
                    continue;
                }
                string    id = pos.Substring(0, i).Trim();
                DockGroup g  = container.Layout.FindGroupContaining(id);
                if (g != null)
                {
                    DockPosition dpos;
                    try {
                        dpos = (DockPosition)Enum.Parse(typeof(DockPosition), pos.Substring(i + 1).Trim(), true);
                    }
                    catch {
                        continue;
                    }

                    var refItem = g.FindDockGroupItem(id);
                    if (InRegion(g, dpos, refItem, objToFindParent, objToFindIndex, insertingPosition))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        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);
        }
Beispiel #4
0
 DockGroupItem AddItemAtLocation(DockGroup grp, DockItem it, string location, bool visible, DockItemStatus status)
 {
     string[] positions = location.Split(';');
     foreach (string pos in positions)
     {
         int i = pos.IndexOf('/');
         if (i == -1)
         {
             continue;
         }
         string    id = pos.Substring(0, i).Trim();
         DockGroup g  = grp.FindGroupContaining(id);
         if (g != null)
         {
             DockPosition dpos;
             try
             {
                 dpos = (DockPosition)Enum.Parse(typeof(DockPosition), pos.Substring(i + 1).Trim(), true);
             }
             catch
             {
                 continue;
             }
             DockGroupItem dgt = g.AddObject(it, dpos, id);
             dgt.SetVisible(visible);
             dgt.Status = status;
             return(dgt);
         }
     }
     return(null);
 }
        internal override void Read(XmlReader reader)
        {
            base.Read(reader);
            type = (DockGroupType)Enum.Parse(typeof(DockGroupType), reader.GetAttribute("type"));
            if (type == DockGroupType.Tabbed)
            {
                string s = reader.GetAttribute("currentTabPage");
                if (s != null)
                {
                    currentTabPage = int.Parse(s);
                }
            }

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

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

                        reader.MoveToElement();
                        reader.Skip();
                    }
                    else if (reader.LocalName == "group")
                    {
                        DockGroup grp = new DockGroup(Frame);
                        grp.Read(reader);
                        AddObject(grp);
                    }
                }
                else
                {
                    reader.Skip();
                }
                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }
 void ResetHandleHighlight()
 {
     this.GdkWindow.Cursor = null;
     currentHandleGrp      = null;
     currentHandleIndex    = -1;
     if (layout != null)
     {
         layout.DrawSeparators(Allocation, null, -1, true, null);
     }
 }
Beispiel #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;
 }
        DockGroup Copy()
        {
            DockGroup grp = new DockGroup(Frame, type);

            grp.dockObjects = new List <MonoDevelop.Components.Docking.DockObject> (dockObjects);
            foreach (DockObject obj in grp.dockObjects)
            {
                obj.ParentGroup = grp;
            }

            grp.CopySizeFrom(this);
            return(grp);
        }
 public void Draw(Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex)
 {
     if (type != DockGroupType.Tabbed)
     {
         DrawSeparators(exposedArea, currentHandleGrp, currentHandleIndex, false, false, null);
         foreach (DockObject it in VisibleObjects)
         {
             DockGroup grp = it as DockGroup;
             if (grp != null)
             {
                 grp.Draw(exposedArea, currentHandleGrp, currentHandleIndex);
             }
         }
     }
 }
Beispiel #10
0
        void LayoutWidgets()
        {
            if (!needsRelayout)
            {
                return;
            }
            needsRelayout = false;

            // Create the needed notebooks and place the widgets in there

            List <DockGroup> tabbedGroups = new List <DockGroup> ();

            GetTabbedGroups(layout, tabbedGroups);

            for (int n = 0; n < tabbedGroups.Count; n++)
            {
                DockGroup grp = tabbedGroups [n];
                TabStrip  ts;
                if (n < notebooks.Count)
                {
                    ts = notebooks [n];
                }
                else
                {
                    ts = new TabStrip(frame);
                    ts.Show();
                    notebooks.Add(ts);
                    ts.Parent = this;
                }
                grp.UpdateNotebook(ts);
            }

            // Remove spare tab strips
            for (int n = notebooks.Count - 1; n >= tabbedGroups.Count; n--)
            {
                TabStrip ts = notebooks [n];
                notebooks.RemoveAt(n);
                ts.Clear();
                ts.Unparent();
                ts.Destroy();
            }

            // Add widgets to the container

            layout.LayoutWidgets();
            NotifySeparatorsChanged();
        }
Beispiel #11
0
        /// <summary>
        /// Gets the style assigned to a specific position of the layout
        /// </summary>
        /// <returns>
        /// The region style for position.
        /// </returns>
        /// <param name='parentGroup'>
        /// Group which contains the position
        /// </param>
        /// <param name='childIndex'>
        /// Index of the position inside the group
        /// </param>
        /// <param name='insertingPosition'>
        /// If true, the position will be inserted (meaning that the objects in childIndex will be shifted 1 position)
        /// </param>
        internal DockVisualStyle GetRegionStyleForPosition(DockGroup parentGroup, int childIndex, bool insertingPosition)
        {
            DockVisualStyle mergedStyle = null;

            foreach (var e in regionStyles)
            {
                if (InRegion(e.Item1, parentGroup, childIndex, insertingPosition))
                {
                    if (mergedStyle == null)
                    {
                        mergedStyle = DefaultVisualStyle.Clone();
                    }
                    mergedStyle.CopyValuesFrom(e.Item2);
                }
            }
            return(mergedStyle ?? DefaultVisualStyle);
        }
        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;
        }
Beispiel #13
0
        internal void AllocateSplitter(DockGroup grp, int index, Gdk.Rectangle a)
        {
            var s = splitters[usedSplitters++];

            if (a.Height > a.Width)
            {
                a.Width = 5;
                a.X    -= 2;
            }
            else
            {
                a.Height = 5;
                a.Y     -= 2;
            }
            s.SizeAllocate(a);
            s.Init(grp, index);
        }
Beispiel #14
0
 int CountRequiredSplitters(DockGroup grp)
 {
     if (grp.Type == DockGroupType.Tabbed)
     {
         return(0);
     }
     else
     {
         int num = grp.VisibleObjects.Count - 1;
         if (num < 0)
         {
             return(0);
         }
         foreach (var c in grp.VisibleObjects.OfType <DockGroup> ())
         {
             num += CountRequiredSplitters(c);
         }
         return(num);
     }
 }
Beispiel #15
0
 protected override bool OnMotionNotifyEvent(Gdk.EventMotion e)
 {
     if (dragging)
     {
         NotifySeparatorsChanged();
         int newpos = (currentHandleGrp.Type == DockGroupType.Horizontal) ? (int)e.XRoot : (int)e.YRoot;
         if (newpos != dragPos)
         {
             int nsize = dragSize + (newpos - dragPos);
             currentHandleGrp.ResizeItem(currentHandleIndex, nsize);
             layout.DrawSeparators(Allocation, currentHandleGrp, currentHandleIndex, true, null);
         }
     }
     else if (layout != null && placeholderWindow == null)
     {
         int       index;
         DockGroup grp;
         if (FindHandle(layout, (int)e.X, (int)e.Y, out grp, out index))
         {
             if (currentHandleGrp != grp || currentHandleIndex != index)
             {
                 if (grp.Type == DockGroupType.Horizontal)
                 {
                     this.GdkWindow.Cursor = hresizeCursor;
                 }
                 else
                 {
                     this.GdkWindow.Cursor = vresizeCursor;
                 }
                 currentHandleGrp   = grp;
                 currentHandleIndex = index;
                 layout.DrawSeparators(Allocation, currentHandleGrp, currentHandleIndex, true, null);
             }
         }
         else if (currentHandleGrp != null)
         {
             ResetHandleHighlight();
         }
     }
     return(base.OnMotionNotifyEvent(e));
 }
 internal DockGroupItem FindDockGroupItem(string id)
 {
     foreach (DockObject ob in dockObjects)
     {
         DockGroupItem it = ob as DockGroupItem;
         if (it != null && it.Id == id)
         {
             return(it);
         }
         DockGroup g = ob as DockGroup;
         if (g != null)
         {
             it = g.FindDockGroupItem(id);
             if (it != null)
             {
                 return(it);
             }
         }
     }
     return(null);
 }
Beispiel #17
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);
 }
Beispiel #18
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);
		}
Beispiel #19
0
		DockGroupItem AddDefaultItem (DockGroup grp, DockItem it)
		{
			return AddItemAtLocation (grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus);
		}
Beispiel #20
0
 int CountRequiredSplitters(DockGroup grp)
 {
     if (grp.Type == DockGroupType.Tabbed)
         return 0;
     else {
         int num = grp.VisibleObjects.Count - 1;
         if (num < 0)
             return 0;
         foreach (var c in grp.VisibleObjects.OfType<DockGroup> ())
             num += CountRequiredSplitters (c);
         return num;
     }
 }
Beispiel #21
0
		/// <summary>
		/// Gets the style assigned to a specific position of the layout
		/// </summary>
		/// <returns>
		/// The region style for position.
		/// </returns>
		/// <param name='parentGroup'>
		/// Group which contains the position
		/// </param>
		/// <param name='childIndex'>
		/// Index of the position inside the group
		/// </param>
		/// <param name='insertingPosition'>
		/// If true, the position will be inserted (meaning that the objects in childIndex will be shifted 1 position)
		/// </param>
		internal DockVisualStyle GetRegionStyleForPosition (DockGroup parentGroup, int childIndex, bool insertingPosition)
		{
			DockVisualStyle mergedStyle = null;
			foreach (var e in regionStyles) {
				if (InRegion (e.Item1, parentGroup, childIndex, insertingPosition)) {
					if (mergedStyle == null)
						mergedStyle = DefaultVisualStyle.Clone ();
					mergedStyle.CopyValuesFrom (e.Item2);
				}
			}
			return mergedStyle ?? DefaultVisualStyle;
		}
Beispiel #22
0
		void GetTabbedGroups (DockGroup grp, List<DockGroup> tabbedGroups)
		{
			if (grp.Type == DockGroupType.Tabbed) {
				if (grp.VisibleObjects.Count > 1)
					tabbedGroups.Add (grp);
				else
					grp.ResetNotebook ();
			}
			else {
				// Make sure it doesn't have a notebook bound to it
				grp.ResetNotebook ();
				foreach (DockObject ob in grp.Objects) {
					if (ob is DockGroup)
						GetTabbedGroups ((DockGroup) ob, tabbedGroups);
				}
			}
		}
Beispiel #23
0
        void LayoutWidgets()
        {
            if (!needsRelayout)
            {
                return;
            }
            needsRelayout = false;

            // Create the needed notebooks and place the widgets in there

            List <DockGroup> tabbedGroups = new List <DockGroup> ();

            GetTabbedGroups(layout, tabbedGroups);

            for (int n = 0; n < tabbedGroups.Count; n++)
            {
                DockGroup grp = tabbedGroups [n];
                TabStrip  ts;
                if (n < notebooks.Count)
                {
                    ts = notebooks [n];
                }
                else
                {
                    ts = new TabStrip(frame);
                    ts.Show();
                    notebooks.Add(ts);
                    ts.Parent = this;

                    GtkWorkarounds.EmitAddSignal(this, ts);
                }
                frame.UpdateRegionStyle(grp);
                ts.VisualStyle = grp.VisualStyle;
                grp.UpdateNotebook(ts);
            }

            // Remove spare tab strips
            for (int n = notebooks.Count - 1; n >= tabbedGroups.Count; n--)
            {
                TabStrip ts = notebooks [n];
                notebooks.RemoveAt(n);
                ts.Clear();
                ts.Unparent();
                ts.Destroy();
            }

            // Create and add the required splitters

            int reqSpliters = CountRequiredSplitters(layout);

            for (int n = 0; n < splitters.Count; n++)
            {
                var s = splitters [n];
                if (s.Parent != null)
                {
                    Remove(s);
                }
            }

            // Hide the splitters that are not required

            for (int n = reqSpliters; n < splitters.Count; n++)
            {
                splitters[n].Hide();
            }

            // Add widgets to the container

            layout.LayoutWidgets();

            // Create and add the required splitters

            for (int n = 0; n < reqSpliters; n++)
            {
                if (n < splitters.Count)
                {
                    var s = splitters [n];
                    if (!s.Visible)
                    {
                        s.Show();
                    }
                    Add(s);
                }
                else
                {
                    var s = new SplitterWidget();
                    splitters.Add(s);
                    s.Show();
                    Add(s);
                }
            }
        }
Beispiel #24
0
 internal void AllocateSplitter(DockGroup grp, int index, Gdk.Rectangle a)
 {
     var s = splitters[usedSplitters++];
     if (a.Height > a.Width) {
         a.Width = 5;
         a.X -= 2;
     }
     else {
         a.Height = 5;
         a.Y -= 2;
     }
     s.SizeAllocate (a);
     s.Init (grp, index);
 }
        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);
        }
Beispiel #26
0
 bool ObjectHasAncestor(DockObject obj, DockGroup ancestorToFind)
 {
     return(obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor(obj.ParentGroup, ancestorToFind)));
 }
Beispiel #27
0
 DockGroupItem AddDefaultItem(DockGroup grp, DockItem it)
 {
     return(AddItemAtLocation(grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus));
 }
Beispiel #28
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));
        }
Beispiel #29
0
		DockGroup Copy ()
		{
			DockGroup grp = new DockGroup (Frame, type);
			grp.dockObjects = new List<MonoDevelop.Components.Docking.DockObject> (dockObjects);
			foreach (DockObject obj in grp.dockObjects)
				obj.ParentGroup = grp;
			
			grp.CopySizeFrom (this);
			return grp;
		}
Beispiel #30
0
		public void Draw (Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex)
		{
			if (type != DockGroupType.Tabbed) {
				DrawSeparators (exposedArea, currentHandleGrp, currentHandleIndex, DrawSeparatorOperation.Draw, false, null);
				foreach (DockObject it in VisibleObjects) {
					DockGroup grp = it as DockGroup;
					if (grp != null)
						grp.Draw (exposedArea, currentHandleGrp, currentHandleIndex);
				}
			}
		}
Beispiel #31
0
		public void DrawSeparators (Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex, DrawSeparatorOperation oper, List<Gdk.Rectangle> areasList)
		{
			DrawSeparators (exposedArea, currentHandleGrp, currentHandleIndex, oper, true, areasList);
		}
Beispiel #32
0
		DockGroupItem Split (DockGroupType newType, bool addFirst, DockItem obj, int npos)
		{
			DockGroupItem item = new DockGroupItem (Frame, obj);
			if (npos == -1 || type == DockGroupType.Tabbed) {
				if (ParentGroup != null && ParentGroup.Type == newType) {
					// No need to split. Just add the new item as a sibling of this one.
					int i = ParentGroup.Objects.IndexOf (this);
					if (addFirst)
						ParentGroup.Objects.Insert (i, item);
					else
						ParentGroup.Objects.Insert (i+1, item);
					item.ParentGroup = ParentGroup;
					item.ResetDefaultSize ();
				}
				else {
					DockGroup grp = Copy ();
					dockObjects.Clear ();
					if (addFirst) {
						dockObjects.Add (item);
						dockObjects.Add (grp);
					} else {
						dockObjects.Add (grp);
						dockObjects.Add (item);
					}
					item.ParentGroup = this;
					item.ResetDefaultSize ();
					grp.ParentGroup = this;
					grp.ResetDefaultSize ();
					Type = newType;
				}
			}
			else {
				DockGroup grp = new DockGroup (Frame, newType);
				DockObject replaced = dockObjects[npos];
				if (addFirst) {
					grp.AddObject (item);
					grp.AddObject (replaced);
				} else {
					grp.AddObject (replaced);
					grp.AddObject (item);
				}
				grp.CopySizeFrom (replaced);
				dockObjects [npos] = grp;
				grp.ParentGroup = this;
			}
			return item;
		}
Beispiel #33
0
		void ResetHandleHighlight ()
		{
			this.GdkWindow.Cursor = null;
			currentHandleGrp = null;
			currentHandleIndex = -1;
			if (layout != null)
				layout.DrawSeparators (Allocation, null, -1, true, null);
		}
Beispiel #34
0
		internal override void Read (XmlReader reader)
		{
			base.Read (reader);
			type = (DockGroupType) Enum.Parse (typeof(DockGroupType), reader.GetAttribute ("type"));
			if (type == DockGroupType.Tabbed) {
				string s = reader.GetAttribute ("currentTabPage");
				if (s != null)
					currentTabPage = int.Parse (s);
			}
			
			reader.MoveToElement ();
			if (reader.IsEmptyElement) {
				reader.Skip ();
				return;
			}
			
			reader.ReadStartElement ();
			reader.MoveToContent ();
			while (reader.NodeType != XmlNodeType.EndElement) {
				if (reader.NodeType == XmlNodeType.Element) {
					if (reader.LocalName == "item") {
						string id = reader.GetAttribute ("id");
						DockItem it = Frame.GetItem (id);
						if (it == null) {
							it = Frame.AddItem (id);
							it.IsPositionMarker = true;
						}
						DockGroupItem gitem = new DockGroupItem (Frame, it);
						gitem.Read (reader);
						AddObject (gitem);
						
						reader.MoveToElement ();
						reader.Skip ();
					}
					else if (reader.LocalName == "group") {
						DockGroup grp = new DockGroup (Frame);
						grp.Read (reader);
						AddObject (grp);
					}
				}
				else
					reader.Skip ();
				reader.MoveToContent ();
			}
			reader.ReadEndElement ();
		}
Beispiel #35
0
		protected override bool OnMotionNotifyEvent (Gdk.EventMotion e)
		{
			if (dragging) {
				NotifySeparatorsChanged ();
				int newpos = (currentHandleGrp.Type == DockGroupType.Horizontal) ? (int)e.XRoot : (int)e.YRoot;
				if (newpos != dragPos) {
					int nsize = dragSize + (newpos - dragPos);
					currentHandleGrp.ResizeItem (currentHandleIndex, nsize);
					layout.DrawSeparators (Allocation, currentHandleGrp, currentHandleIndex, true, null);
				}
			}
			else if (layout != null && placeholderWindow == null) {
				int index;
				DockGroup grp;
				if (FindHandle (layout, (int)e.X, (int)e.Y, out grp, out index)) {
					if (currentHandleGrp != grp || currentHandleIndex != index) {
						if (grp.Type == DockGroupType.Horizontal)
							this.GdkWindow.Cursor = hresizeCursor;
						else
							this.GdkWindow.Cursor = vresizeCursor;
						currentHandleGrp = grp;
						currentHandleIndex = index;
						layout.DrawSeparators (Allocation, currentHandleGrp, currentHandleIndex, true, null);
					}
				}
				else if (currentHandleGrp != null) {
					ResetHandleHighlight ();
				}
			}
			return base.OnMotionNotifyEvent (e);
		}
Beispiel #36
0
 public void DrawSeparators(Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex, bool invalidateOnly, List<Gdk.Rectangle> areasList)
 {
     DrawSeparators (exposedArea, currentHandleGrp, currentHandleIndex, invalidateOnly, true, areasList);
 }
Beispiel #37
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;
		}
Beispiel #38
0
        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;
                }
            }
        }
Beispiel #39
0
 public void Init(DockGroup grp, int index)
 {
     dockGroup = grp;
     dockIndex = index;
 }
		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;
		}
Beispiel #41
0
 public void Init(DockGroup grp, int index)
 {
     dockGroup = grp;
     dockIndex = index;
 }
 public void DrawSeparators(Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex, bool invalidateOnly, List <Gdk.Rectangle> areasList)
 {
     DrawSeparators(exposedArea, currentHandleGrp, currentHandleIndex, invalidateOnly, true, areasList);
 }
Beispiel #43
0
		internal bool InRegion (string location, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition)
		{
			// Checks if the object is in the specified region.
			// A region is a collection with the format: "ItemId1/Position1;ItemId2/Position2..."
			string[] positions = location.Split (';');
			foreach (string pos in positions) {
				// We individually check each entry in the region specification
				int i = pos.IndexOf ('/');
				if (i == -1) continue;
				string id = pos.Substring (0,i).Trim ();
				DockGroup g = container.Layout.FindGroupContaining (id);
				if (g != null) {
					DockPosition dpos;
					try {
						dpos = (DockPosition) Enum.Parse (typeof(DockPosition), pos.Substring(i+1).Trim(), true);
					}
					catch {
						continue;
					}

					var refItem = g.FindDockGroupItem (id);
					if (InRegion (g, dpos, refItem, objToFindParent, objToFindIndex, insertingPosition))
						return true;
				}
			}
			return false;
		}
        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;
                    }
                }
            }
        }
Beispiel #45
0
		bool ObjectHasAncestor (DockObject obj, DockGroup ancestorToFind)
		{
			return obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor (obj.ParentGroup, ancestorToFind));
		}
Beispiel #46
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;
		}
Beispiel #47
0
		DockGroupItem AddItemAtLocation (DockGroup grp, DockItem it, string location, bool visible, DockItemStatus status)
		{
			string[] positions = location.Split (';');
			foreach (string pos in positions) {
				int i = pos.IndexOf ('/');
				if (i == -1) continue;
				string id = pos.Substring (0,i).Trim ();
				DockGroup g = grp.FindGroupContaining (id);
				if (g != null) {
					DockPosition dpos;
					try {
						dpos = (DockPosition) Enum.Parse (typeof(DockPosition), pos.Substring(i+1).Trim(), true);
					}
					catch {
						continue;
					}
					DockGroupItem dgt = g.AddObject (it, dpos, id);
					dgt.SetVisible (visible);
					dgt.Status = status;
					return dgt;
				}
			}
			return null;
		}
Beispiel #48
0
		void DrawSeparators (Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex, DrawSeparatorOperation oper, 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;

			Gdk.GC hgc = null;

			if (areasList == null && oper == DrawSeparatorOperation.Draw) {
				hgc = new Gdk.GC (Frame.Container.GdkWindow);
				hgc.RgbFgColor = Styles.DockFrameBackground.ToGdkColor ();
			}

			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, oper, areasList);
				if (ob != last) {
					if (horiz)
						x += ob.Allocation.Width + Frame.HandlePadding;
					else
						y += ob.Allocation.Height + Frame.HandlePadding;

					switch (oper) {
					case DrawSeparatorOperation.CollectAreas:
						if (Frame.ShadedSeparators)
							areasList.Add (new Gdk.Rectangle (x, y, hw, hh));
						break;
					case DrawSeparatorOperation.Invalidate:
						Frame.Container.QueueDrawArea (x, y, hw, hh);
						break;
					case DrawSeparatorOperation.Draw:
						Frame.Container.GdkWindow.DrawRectangle (hgc, true, x, y, hw, hh);
						break;
					case DrawSeparatorOperation.Allocate:
						Frame.Container.AllocateSplitter (this, n, new Gdk.Rectangle (x, y, hw, hh));
						break;
					}
					
					if (horiz)
						x += Frame.HandleSize + Frame.HandlePadding;
					else
						y += Frame.HandleSize + Frame.HandlePadding;
				}
			}
			if (hgc != null)
				hgc.Dispose ();
		}