Ejemplo n.º 1
0
        /// <summary>
        /// Adds a new Widget to the box
        /// </summary>
        /// <param name='widget'>
        /// Widget.
        /// </param>
        public void AddItem(Widget widget)
        {
            if (container1.Children.Length == 0)
            {
                //Console.WriteLine("panedbox: no children add: " + widget.Name + " widget: " + widget.Visible);
                //Console.WriteLine("container1: " +container1.Visible);
                if (widget.Parent != null)
                {
                    widget.Reparent(container1);                     //TODO check if parent id not container1
                }

                if (!container1.Visible)
                {
                    container1.Visible = true;
                }
                container1.PackStart(widget, true, true, 0);
            }
            else
            {
                //Console.WriteLine("have children");
                PanedBox lb     = getLastChild(this);
                PanedBox newbox = new PanedBox(lb, widget);
                lb.Append(newbox);
            }
        }
Ejemplo n.º 2
0
        public static Widget removeItem(Widget w)
        {
            PanedBox pb = (w.Parent.Parent as PanedBox);

            if (pb != null)
            {
                if (pb.ParentBox != null)
                {
                    Widget wdg = pb.Widget1;
                    if (w == wdg)
                    {
                        pb.removeItem(w, true);
                        wdg.Reparent(null);

                        PanedBox parent = pb.ParentBox;
                        PanedBox temp   = pb.ChildBox;
                        parent.removeChildbox();
                        if (temp != null)
                        {
                            temp.Reparent(parent);
                            parent.Append(temp);
                            //temp.Visible = true;
                        }

                        pb.Dispose();
                        pb = null;

                        return(w);
                    }
                }
                else
                {
                    return(pb.removeItem(w, false));
                }
            }
            return(null);
        }