예제 #1
0
        protected override void ReplaceChild(Gtk.Widget oldChild, Gtk.Widget newChild)
        {
            int index = tabs.IndexOf(oldChild);

            if (index != -1)
            {
                tabs[index] = newChild;
                Gtk.Widget page = notebook.GetNthPage(index);
                notebook.SetTabLabel(page, newChild);
            }
            else
            {
                Gtk.Widget tab        = notebook.GetTabLabel(oldChild);
                int        current    = notebook.CurrentPage;
                int        oldPageNum = ((Gtk.Notebook.NotebookChild)notebook [oldChild]).Position;
                base.ReplaceChild(oldChild, newChild);
                // Get the widget again because it may have changed (for example, if it is a text view
                // and has the ShowScrollbars option set.
                newChild             = notebook.GetNthPage(oldPageNum);
                notebook.CurrentPage = current;
                notebook.SetTabLabel(newChild, tab);
                Widget ww = Widget.Lookup(tab);
                if (ww != null)
                {
                    ww.RequiresUndoStatusUpdate = true;
                }
            }
        }
예제 #2
0
파일: GtkEngine.cs 프로젝트: lanicon/xwt-1
        public static void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget)
        {
            Gtk.Container cont = oldWidget.Parent as Gtk.Container;
            if (cont == null)
            {
                return;
            }

            if (cont is IGtkContainer)
            {
                ((IGtkContainer)cont).ReplaceChild(oldWidget, newWidget);
            }
            else if (cont is Gtk.Notebook)
            {
                Gtk.Notebook notebook         = (Gtk.Notebook)cont;
                Gtk.Notebook.NotebookChild nc = (Gtk.Notebook.NotebookChild)notebook [oldWidget];
                var detachable  = nc.Detachable;
                var pos         = nc.Position;
                var reorderable = nc.Reorderable;
                var tabExpand   = nc.TabExpand;
                var tabFill     = nc.TabFill;
                var label       = notebook.GetTabLabel(oldWidget);
                notebook.Remove(oldWidget);
                notebook.InsertPage(newWidget, label, pos);

                nc             = (Gtk.Notebook.NotebookChild)notebook [newWidget];
                nc.Detachable  = detachable;
                nc.Reorderable = reorderable;
                nc.TabExpand   = tabExpand;
                nc.TabFill     = tabFill;
            }
            else if (cont is Gtk.Paned)
            {
                var paned  = (Gtk.Paned)cont;
                var pc     = (Gtk.Paned.PanedChild)paned[oldWidget];
                var resize = pc.Resize;
                var shrink = pc.Shrink;
                var pos    = paned.Position;
                if (paned.Child1 == oldWidget)
                {
                    paned.Remove(oldWidget);
                    paned.Pack1(newWidget, resize, shrink);
                }
                else
                {
                    paned.Remove(oldWidget);
                    paned.Pack2(newWidget, resize, shrink);
                }
                paned.Position = pos;
            }
            else if (cont is Gtk.Bin)
            {
                ((Gtk.Bin)cont).Remove(oldWidget);
                ((Gtk.Bin)cont).Child = newWidget;
            }
        }
예제 #3
0
        public static void ReplaceChild(Gtk.Widget oldWidget, Gtk.Widget newWidget)
        {
            Gtk.Container cont = oldWidget.Parent as Gtk.Container;
            if (cont == null)
            {
                return;
            }

            if (cont is IGtkContainer)
            {
                ((IGtkContainer)cont).ReplaceChild(oldWidget, newWidget);
            }
            else if (cont is Gtk.Notebook)
            {
                Gtk.Notebook notebook         = (Gtk.Notebook)cont;
                Gtk.Notebook.NotebookChild nc = (Gtk.Notebook.NotebookChild)notebook[oldWidget];
                var detachable  = nc.Detachable;
                var pos         = nc.Position;
                var reorderable = nc.Reorderable;
                var tabExpand   = nc.TabExpand;
                var tabFill     = nc.TabFill;
                var label       = notebook.GetTabLabel(oldWidget);
                notebook.Remove(oldWidget);
                notebook.InsertPage(newWidget, label, pos);

                nc             = (Gtk.Notebook.NotebookChild)notebook[newWidget];
                nc.Detachable  = detachable;
                nc.Reorderable = reorderable;
                nc.TabExpand   = tabExpand;
                nc.TabFill     = tabFill;
            }
            else if (cont is Gtk.Bin)
            {
                ((Gtk.Bin)cont).Remove(oldWidget);
                ((Gtk.Bin)cont).Child = newWidget;
            }
        }
예제 #4
0
        protected override void ReplaceChild(Gtk.Widget oldChild, Gtk.Widget newChild)
        {
            int index = tabs.IndexOf(oldChild);

            if (index != -1)
            {
                tabs[index] = newChild;
                Gtk.Widget page = notebook.GetNthPage(index);
                notebook.SetTabLabel(page, newChild);
            }
            else
            {
                Gtk.Widget tab     = notebook.GetTabLabel(oldChild);
                int        current = notebook.CurrentPage;
                base.ReplaceChild(oldChild, newChild);
                notebook.CurrentPage = current;
                notebook.SetTabLabel(newChild, tab);
                Widget ww = Widget.Lookup(tab);
                if (ww != null)
                {
                    ww.RequiresUndoStatusUpdate = true;
                }
            }
        }