Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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);
             }
         }
     }
 }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
 void ResetHandleHighlight()
 {
     this.GdkWindow.Cursor = null;
     currentHandleGrp      = null;
     currentHandleIndex    = -1;
     if (layout != null)
     {
         layout.DrawSeparators(Allocation, null, -1, true, null);
     }
 }
Exemplo n.º 6
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.º 7
0
        DockGroup Copy()
        {
            DockGroup grp = new DockGroup(Frame, type);

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

            grp.CopySizeFrom(this);
            return(grp);
        }
Exemplo n.º 8
0
 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);
             }
         }
     }
 }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
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.º 11
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));
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
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.º 14
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;
                    }
                }
            }
        }
Exemplo n.º 15
0
 DockGroupItem AddDefaultItem(DockGroup grp, DockItem it)
 {
     return(AddItemAtLocation(grp, it, it.DefaultLocation, it.DefaultVisible, it.DefaultStatus));
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
 public void DrawSeparators(Gdk.Rectangle exposedArea, DockGroup currentHandleGrp, int currentHandleIndex, bool invalidateOnly, List <Gdk.Rectangle> areasList)
 {
     DrawSeparators(exposedArea, currentHandleGrp, currentHandleIndex, invalidateOnly, true, areasList);
 }