Beispiel #1
0
        internal void Present(DockItem item, bool giveFocus)
        {
            DockGroupItem gitem = container.FindDockGroupItem(item.Id);

            if (gitem == null)
            {
                return;
            }

            gitem.ParentGroup.Present(item, giveFocus);
        }
Beispiel #2
0
        internal void SetStatus(DockItem item, DockItemStatus status)
        {
            DockGroupItem gitem = container.FindDockGroupItem(item.Id);

            if (gitem == null)
            {
                item.DefaultStatus = status;
                return;
            }
            gitem.StoreAllocation();
            gitem.Status = status;
            container.RelayoutWidgets();
        }
Beispiel #3
0
        DockLayout GetDefaultLayout()
        {
            DockLayout group = new DockLayout(this);

            // Add items which don't have relative defaut positions

            List <DockItem> todock = new List <DockItem> ();

            foreach (DockItem item in container.Items)
            {
                if (string.IsNullOrEmpty(item.DefaultLocation))
                {
                    DockGroupItem dgt = new DockGroupItem(this, item);
                    dgt.SetVisible(item.DefaultVisible);
                    group.AddObject(dgt);
                }
                else
                {
                    todock.Add(item);
                }
            }

            // Add items with relative positions.
            int lastCount = 0;

            while (lastCount != todock.Count)
            {
                lastCount = todock.Count;
                for (int n = 0; n < todock.Count; n++)
                {
                    DockItem it = todock [n];
                    if (AddDefaultItem(group, it) != null)
                    {
                        todock.RemoveAt(n);
                        n--;
                    }
                }
            }

            // Items which could not be docked because of an invalid default location
            foreach (DockItem item in todock)
            {
                DockGroupItem dgt = new DockGroupItem(this, item);
                dgt.SetVisible(false);
                group.AddObject(dgt);
            }
//			group.Dump ();
            return(group);
        }
Beispiel #4
0
        internal void UpdateStyle(DockItem item)
        {
            DockGroupItem gitem = container.FindDockGroupItem(item.Id);

            if (gitem == null)
            {
                return;
            }

            gitem.ParentGroup.UpdateStyle(item);
            dockBarTop.UpdateStyle(item);
            dockBarBottom.UpdateStyle(item);
            dockBarLeft.UpdateStyle(item);
            dockBarRight.UpdateStyle(item);
        }
Beispiel #5
0
        public void LoadLayout(DockLayout dl)
        {
            HidePlaceholder();

            // Sticky items currently selected in notebooks will remain
            // selected after switching the layout
            List <DockItem> sickyOnTop = new List <DockItem> ();

            foreach (DockItem it in items)
            {
                if ((it.Behavior & DockItemBehavior.Sticky) != 0)
                {
                    DockGroupItem gitem = FindDockGroupItem(it.Id);
                    if (gitem != null && gitem.ParentGroup.IsSelectedPage(it))
                    {
                        sickyOnTop.Add(it);
                    }
                }
            }

            if (layout != null)
            {
                layout.StoreAllocation();
            }
            layout = dl;
            layout.RestoreAllocation();

            // Make sure items not present in this layout are hidden
            foreach (DockItem it in items)
            {
                if ((it.Behavior & DockItemBehavior.Sticky) != 0)
                {
                    it.Visible = it.StickyVisible;
                }
                if (layout.FindDockGroupItem(it.Id) == null)
                {
                    it.HideWidget();
                }
            }

            RelayoutWidgets();

            foreach (DockItem it in sickyOnTop)
            {
                it.Present(false);
            }
        }
Beispiel #6
0
        internal bool GetVisible(DockItem item, string layoutName)
        {
            DockLayout dl;

            if (!layouts.TryGetValue(layoutName, out dl))
            {
                return(false);
            }

            DockGroupItem gitem = dl.FindDockGroupItem(item.Id);

            if (gitem == null)
            {
                return(false);
            }
            return(gitem.VisibleFlag);
        }
Beispiel #7
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 #8
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 #9
0
		void DockTarget (DockItem item, int n)
		{
			DockGroupItem gitem = new DockGroupItem (Frame, item);
			dockObjects.Insert (n, gitem);
			gitem.ParentGroup = this;
			gitem.SetVisible (true);
			ResetVisibleGroups ();
			CalcNewSizes ();
		}
Beispiel #10
0
		public DockGroupItem AddObject (DockItem obj, DockPosition pos, string relItemId)
		{
			int npos = -1;
			if (relItemId != null) {
				for (int n=0; n<dockObjects.Count; n++) {
					DockGroupItem it = dockObjects [n] as DockGroupItem;
					if (it != null && it.Id == relItemId)
						npos = n;
				}
			}
			
			if (npos == -1) {
				if (pos == DockPosition.Left || pos == DockPosition.Top)
					npos = 0;
				else
					npos = dockObjects.Count - 1;
			}
			
			DockGroupItem gitem = null;
			
			if (pos == DockPosition.Left || pos == DockPosition.Right) {
				if (type != DockGroupType.Horizontal)
					gitem = Split (DockGroupType.Horizontal, pos == DockPosition.Left, obj, npos);
				else
					gitem = InsertObject (obj, npos, pos);
			}
			else if (pos == DockPosition.Top || pos == DockPosition.Bottom) {
				if (type != DockGroupType.Vertical)
					gitem = Split (DockGroupType.Vertical, pos == DockPosition.Top, obj, npos);
				else
					gitem = InsertObject (obj, npos, pos);
			}
			else if (pos == DockPosition.CenterBefore || pos == DockPosition.Center) {
				if (type != DockGroupType.Tabbed)
					gitem = Split (DockGroupType.Tabbed, pos == DockPosition.CenterBefore, obj, npos);
				else {
					if (pos == DockPosition.Center)
						npos++;
					gitem = new DockGroupItem (Frame, obj);
					dockObjects.Insert (npos, gitem);
					gitem.ParentGroup = this;
				}
			}
			ResetVisibleGroups ();
			return gitem;
		}
Beispiel #11
0
		internal void FocusItem (DockGroupItem it)
		{
			tabFocus = it;
		}
Beispiel #12
0
		internal void UpdateNotebook (TabStrip ts)
		{
			Gtk.Widget oldpage = null;
			int oldtab = -1;
			
			if (tabFocus != null) {
				oldpage = tabFocus.Item.Widget;
				tabFocus = null;
			} else if (boundTabStrip != null) {
				oldpage = boundTabStrip.CurrentPage;
				oldtab = boundTabStrip.CurrentTab;
			}
			
			ts.Clear ();
			
			// Add missing pages
			foreach (DockObject ob in VisibleObjects) {
				DockGroupItem it = ob as DockGroupItem;
				ts.AddTab (it.Item.TitleTab);
			}

			boundTabStrip = ts;
			
			if (oldpage != null) {
				boundTabStrip.CurrentPage = oldpage;
			}
			else if (currentTabPage != -1 && currentTabPage < boundTabStrip.TabCount) {
				boundTabStrip.CurrentTab = currentTabPage;
			}

			// Discard the currentTabPage value. Current page is now tracked by the tab strip
			currentTabPage = -1;

			if (boundTabStrip.CurrentTab == -1) {
				if (oldtab != -1) {
					if (oldtab < boundTabStrip.TabCount)
						boundTabStrip.CurrentTab = oldtab;
					else
						boundTabStrip.CurrentTab = boundTabStrip.TabCount - 1;
				} else
					boundTabStrip.CurrentTab = 0;
			}
			if (Frame.CompactGuiLevel == 3 && IsNextToMargin (PositionType.Bottom, true))
				boundTabStrip.BottomPadding = 3;
			else
				boundTabStrip.BottomPadding = 0;
		}
Beispiel #13
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 #14
0
		DockGroupItem InsertObject (DockItem obj, int npos, DockPosition pos)
		{
			if (pos == DockPosition.Bottom || pos == DockPosition.Right)
				npos++;
				
			DockGroupItem gitem = new DockGroupItem (Frame, obj);
			dockObjects.Insert (npos, gitem);
			gitem.ParentGroup = this;
			return gitem;
		}
Beispiel #15
0
        public bool GetDockTarget(DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect)
        {
            outrect      = Gdk.Rectangle.Zero;
            dockDelegate = null;

            if (item != this.item && this.item.Visible && rect.Contains(px, py))
            {
                // Check if the item is allowed to be docked here
                var s = Frame.GetRegionStyleForObject(this);

                int          xdockMargin = (int)((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2;
                int          ydockMargin = (int)((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2;
                DockPosition pos;

/*				if (ParentGroup.Type == DockGroupType.Tabbed) {
 *                                      rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);
 *                                      pos = DockPosition.CenterAfter;
 *                              }*/
                if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal)
                {
                    if (s.SingleColumnMode.Value)
                    {
                        return(false);
                    }
                    outrect = new Gdk.Rectangle(rect.X, rect.Y, xdockMargin, rect.Height);
                    pos     = DockPosition.Left;
                }
                else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal)
                {
                    if (s.SingleColumnMode.Value)
                    {
                        return(false);
                    }
                    outrect = new Gdk.Rectangle(rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height);
                    pos     = DockPosition.Right;
                }
                else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical)
                {
                    if (s.SingleRowMode.Value)
                    {
                        return(false);
                    }
                    outrect = new Gdk.Rectangle(rect.X, rect.Y, rect.Width, ydockMargin);
                    pos     = DockPosition.Top;
                }
                else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical)
                {
                    if (s.SingleRowMode.Value)
                    {
                        return(false);
                    }
                    outrect = new Gdk.Rectangle(rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin);
                    pos     = DockPosition.Bottom;
                }
                else
                {
                    outrect = new Gdk.Rectangle(rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin * 2, rect.Height - ydockMargin * 2);
                    pos     = DockPosition.Center;
                }

                dockDelegate = delegate(DockItem dit) {
                    DockGroupItem it = ParentGroup.AddObject(dit, pos, Id);
                    it.SetVisible(true);
                    ParentGroup.FocusItem(it);
                };
                return(true);
            }
            return(false);
        }
Beispiel #16
0
		internal void SetVisible (DockItem item, bool visible)
		{
			if (container.Layout == null)
				return;
			DockGroupItem gitem = container.FindDockGroupItem (item.Id);
			
			if (gitem == null) {
				if (visible) {
					// The item is not present in the layout. Add it now.
					if (!string.IsNullOrEmpty (item.DefaultLocation))
						gitem = AddDefaultItem (container.Layout, item);
						
					if (gitem == null) {
						// No default position
						gitem = new DockGroupItem (this, item);
						container.Layout.AddObject (gitem);
					}
				} else
					return; // Already invisible
			}
			gitem.SetVisible (visible);
			container.RelayoutWidgets ();
		}
Beispiel #17
0
		DockLayout GetDefaultLayout ()
		{
			DockLayout group = new DockLayout (this);
			
			// Add items which don't have relative defaut positions
			
			List<DockItem> todock = new List<DockItem> ();
			foreach (DockItem item in container.Items) {
				if (string.IsNullOrEmpty (item.DefaultLocation)) {
					DockGroupItem dgt = new DockGroupItem (this, item);
					dgt.SetVisible (item.DefaultVisible);
					group.AddObject (dgt);
				}
				else
					todock.Add (item);
			}
			
			// Add items with relative positions.
			int lastCount = 0;
			while (lastCount != todock.Count) {
				lastCount = todock.Count;
				for (int n=0; n<todock.Count; n++) {
					DockItem it = todock [n];
					if (AddDefaultItem (group, it) != null) {
						todock.RemoveAt (n);
						n--;
					}
				}
			}
			
			// Items which could not be docked because of an invalid default location
			foreach (DockItem item in todock) {
				DockGroupItem dgt = new DockGroupItem (this, item);
				dgt.SetVisible (false);
				group.AddObject (dgt);
			}
//			group.Dump ();
			return group;
		}
Beispiel #18
0
		internal void DockInPlaceholder (DockItem item)
		{
			if (placeholderWindow == null || !placeholderWindow.Visible)
				return;
			
			if (placeholderWindow.AllowDocking && placeholderWindow.DockDelegate != null) {
				item.Status = DockItemStatus.Dockable;
				DockGroupItem dummyItem = new DockGroupItem (frame, new DockItem (frame, "__dummy"));
				DockGroupItem gitem = layout.FindDockGroupItem (item.Id);
				gitem.ParentGroup.ReplaceItem (gitem, dummyItem);
				placeholderWindow.DockDelegate (item);
				dummyItem.ParentGroup.Remove (dummyItem);
				RelayoutWidgets ();
			} else {
				int px, py;
				GetPointer (out px, out py);
				DockGroupItem gi = FindDockGroupItem (item.Id);
				int pw, ph;
				placeholderWindow.GetPosition (out px, out py);
				placeholderWindow.GetSize (out pw, out ph);
				gi.FloatRect = new Rectangle (px, py, pw, ph);
				item.Status = DockItemStatus.Floating;
			}
		}
Beispiel #19
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;
		}