public static void ReorderWidgets(Box box) { var items = new ChildPacking[box.Children.Length]; for (int i = 0; i < items.Length; i++) { bool expand, fill; uint padding; PackType packType; box.QueryChildPacking(box.Children[i], out expand, out fill, out padding, out packType); items[i] = new ChildPacking { Expand = expand, Fill = fill, Padding = padding, PackType = packType, Widget = box.Children[i] }; } foreach (var item in items) { box.Remove(item.Widget); } foreach (var item in items) { box.PackEnd(item.Widget); box.SetChildPacking(item.Widget, item.Expand, item.Fill, item.Padding, item.PackType); } }
// TODO: pass in a label which it will update with the name from the combobox? public ComboBoxFromConstants(bool showHelp = true, bool vertical = false, bool showSpin = true) { this.Name = "LynnaLab.ComboBoxFromConstants"; Gtk.Box box2 = new Gtk.HBox(); box2.Spacing = 6; // Container child LynnaLab.ComboBoxFromConstants.Gtk.Container+ContainerChild if (vertical) { this.box1 = new Gtk.VBox(); } else { this.box1 = new Gtk.HBox(); } // Container child box1.Gtk.Box+BoxChild this.spinButton = new LynnaLab.SpinButtonHexadecimal(); this.spinButton.CanFocus = true; this.spinButton.Name = "spinButton"; this.spinButton.Adjustment.Upper = 255D; this.spinButton.Adjustment.PageIncrement = 16D; this.spinButton.Adjustment.StepIncrement = 1D; this.spinButton.ClimbRate = 1D; this.spinButton.Digits = 2; this.spinButton.Numeric = true; if (showSpin) { box2.Add(spinButton); box2.SetChildPacking(spinButton, expand: false, fill: false, padding: 0, pack_type: Gtk.PackType.Start); box1.Add(box2); } // Container child box1.Gtk.Box+BoxChild this.combobox1 = new Gtk.ComboBoxText(); this.combobox1.Name = "combobox1"; this.box1.Add(this.combobox1); box1.SetChildPacking(this.combobox1, false, false, 0, Gtk.PackType.Start); this.spinButton.ValueChanged += new System.EventHandler(this.OnSpinButtonValueChanged); this.combobox1.Changed += new System.EventHandler(this.OnCombobox1Changed); if (showHelp) { // When clicking the "help" button, create a popup with documentation for // possible values. (It checks for a "@values" field in the documentation.) Gtk.Button helpButton = new Gtk.Button("?"); helpButton.CanFocus = false; helpButton.Clicked += delegate(object sender, EventArgs e) { if (DefaultDocumentation == null) { return; } DocumentationDialog d = new DocumentationDialog(DefaultDocumentation); d.Run(); d.Dispose(); }; box2.PackStart(helpButton, false, false, 0); } Gtk.Frame frame = new Gtk.Frame(); frame.Add(box1); this.Add(frame); }