コード例 #1
0
ファイル: GtkExtensions.cs プロジェクト: philstopford/Eto
 public static void RemoveAllChildren(this Gtk.Container widget)
 {
     foreach (Gtk.Widget w in widget.Children)
     {
         widget.Remove(w);
     }
 }
コード例 #2
0
        // Check if there are entries that should have help buttons
        public void UpdateHelpButtons()
        {
            IList <ValueReference> refs = valueReferenceGroup.GetValueReferences();

            for (int i = 0; i < refs.Count; i++)
            {
                Gtk.Container container = helpButtonContainers[i];
                if (container == null)
                {
                    continue;
                }

                // Remove previous help button
                foreach (Gtk.Widget widget in container.Children)
                {
                    container.Remove(widget);
                    widget.Destroy();
                }

                ValueReference r = refs[i];
                if (r.Documentation != null)
                {
                    Gtk.Button helpButton = new Gtk.Button("?");
                    helpButton.CanFocus = false;
                    helpButton.Clicked += delegate(object sender, EventArgs e) {
                        DocumentationDialog d = new DocumentationDialog(r.Documentation);
                    };
                    container.Add(helpButton);
                }
            }
            this.ShowAll();
        }
コード例 #3
0
        // Check if there are entries that should have help buttons
        public void UpdateHelpButtons()
        {
            IList <ValueReference> refs = valueReferenceGroup.GetValueReferences();

            for (int i = 0; i < refs.Count; i++)
            {
                if (widgetLists[i][1] is ComboBoxFromConstants) // These deal with documentation themselves
                {
                    continue;
                }

                Gtk.Container container = widgetLists[i][2] as Gtk.Container;
                if (container == null)
                {
                    continue;
                }

                bool isHelpButton = true;

                // Remove previous help button
                foreach (Gtk.Widget widget in container.Children)
                {
                    // Really hacky way to check whether this is the help button as we expect, or
                    // whether the "AddWidgetToRight" function was called to replace it, in which
                    // case we don't try to add the help button at all
                    if (!(widget is Gtk.Button && (widget as Gtk.Button).Label == "?"))
                    {
                        isHelpButton = false;
                        continue;
                    }
                    container.Remove(widget);
                    widget.Dispose();
                }

                if (!isHelpButton)
                {
                    continue;
                }

                ValueReference r = refs[i];
                if (r.Documentation != null)
                {
                    Gtk.Button helpButton = new Gtk.Button("?");
                    helpButton.FocusOnClick = false;
                    helpButton.Clicked     += delegate(object sender, EventArgs e) {
                        DocumentationDialog d = new DocumentationDialog(r.Documentation);
                    };
                    container.Add(helpButton);
                }
            }
            this.ShowAll();
        }
コード例 #4
0
        // Call this from a DragEnd event to check if the widget wasn't dropped
        public static Gtk.Widget Cancel()
        {
            if (dragWidget == null)
            {
                return(null);
            }

            Gtk.Widget w = dragWidget;
            dragWidget = null;

            // Remove the widget from its dragWindow
            Gtk.Container parent = w.Parent as Gtk.Container;
            if (parent != null)
            {
                parent.Remove(w);
                parent.Destroy();
            }
            return(w);
        }
コード例 #5
0
 internal void UpdateScrolledWindow()
 {
     if (ParentWrapper == null)
     {
         return;
     }
     if (boundToScrollWindow)
     {
         if (!(Wrapped.Parent is Gtk.Viewport) && !(Wrapped.Parent is Gtk.ScrolledWindow))
         {
             Gtk.ScrolledWindow scw = new Gtk.ScrolledWindow();
             scw.HscrollbarPolicy = scw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
             scw.ShadowType       = Gtk.ShadowType.In;
             ScrolledWindow wrapper = (ScrolledWindow)ObjectWrapper.Create(Project, scw, ParentWrapper);
             ParentWrapper.ReplaceChild(Wrapped, scw, false);
             if (Wrapped.SetScrollAdjustments(null, null))
             {
                 scw.Add(Wrapped);
             }
             else
             {
                 wrapper.AddWithViewport(Wrapped);
             }
             Select();
         }
     }
     else if (((Wrapped.Parent is Gtk.Viewport) || (Wrapped.Parent is Gtk.ScrolledWindow)) && ParentWrapper.ParentWrapper != null)
     {
         Gtk.Container parent = (Gtk.Container)Wrapped.Parent;
         parent.Remove(Wrapped);
         Container grandParent;
         if (parent is Gtk.Viewport)
         {
             parent      = (Gtk.Container)parent.Parent;
             grandParent = Container.LookupParent(parent);
         }
         else
         {
             grandParent = Container.LookupParent(parent);
         }
         grandParent.ReplaceChild(parent, Wrapped, true);
     }
 }