diff --git a/src/Eto.Gtk/CustomControls/DateComboBoxDialog.cs b/src/Eto.Gtk/CustomControls/DateComboBoxDialog.cs index 2fd4bfbf3..738abc8b1 100644 --- a/src/Eto.Gtk/CustomControls/DateComboBoxDialog.cs +++ b/src/Eto.Gtk/CustomControls/DateComboBoxDialog.cs @@ -138,9 +138,7 @@ void UpdateClock () Gtk.Widget CalendarControls () { - var vbox = new Gtk.VBox { - Spacing = 5 - }; + var vbox = new Gtk.Box(Gtk.Orientation.Vertical, 5); calendar = new Gtk.Calendar { @@ -158,8 +156,8 @@ Gtk.Widget CalendarControls () }; vbox.PackStart(calendar, false, false, 0); - - var hbox = new Gtk.HBox (true, 6); + + var hbox = new Gtk.Box(Gtk.Orientation.Horizontal, 6) { Homogeneous = true }; var todayButton = new Gtk.Button { CanFocus = true, @@ -217,13 +215,12 @@ Gtk.SpinButton CreateSpinner (int max, int increment, Gtk.SpinButton parent) Gtk.Widget ClockControls () { - #if GTK2 var vbox = new Gtk.VBox (); var spinners = new Gtk.HBox (); #else - var vbox = new Gtk.HBox (); - var spinners = new Gtk.VBox (); + var vbox = new Gtk.Box(Gtk.Orientation.Vertical, 0); + var spinners = new Gtk.Box(Gtk.Orientation.Vertical, 0); #endif vbox.Spacing = 6; spinners.Spacing = 6; @@ -270,8 +267,7 @@ void CreateControls () SkipPagerHint = true; SkipTaskbarHint = true; - var hbox = new Gtk.HBox { - Spacing = 5, + var hbox = new Gtk.Box(Gtk.Orientation.Horizontal, 5) { BorderWidth = 3 }; diff --git a/src/Eto.Gtk/Forms/Controls/ButtonHandler.gtk3.cs b/src/Eto.Gtk/Forms/Controls/ButtonHandler.gtk3.cs index e178b109a..ac43749b1 100644 --- a/src/Eto.Gtk/Forms/Controls/ButtonHandler.gtk3.cs +++ b/src/Eto.Gtk/Forms/Controls/ButtonHandler.gtk3.cs @@ -89,29 +89,28 @@ void SetImagePosition() var showLabel = !string.IsNullOrEmpty(label.Text); if (showImage && showLabel) { - Gtk.VBox vbox; - Gtk.HBox hbox; + Gtk.Box box; switch (ImagePosition) { case ButtonImagePosition.Above: - child = vbox = new Gtk.VBox(false, 2); - vbox.PackStart(gtkimage, true, true, 0); - vbox.PackEnd(label, false, true, 0); + child = box = new Gtk.Box(Gtk.Orientation.Vertical, 2); + box.PackStart(gtkimage, true, true, 0); + box.PackEnd(label, false, true, 0); break; case ButtonImagePosition.Below: - child = vbox = new Gtk.VBox(false, 2); - vbox.PackStart(label, false, true, 0); - vbox.PackEnd(gtkimage, true, true, 0); + child = box = new Gtk.Box(Gtk.Orientation.Vertical, 2); + box.PackStart(label, false, true, 0); + box.PackEnd(gtkimage, true, true, 0); break; case ButtonImagePosition.Left: - child = hbox = new Gtk.HBox(false, 2); - hbox.PackStart(gtkimage, false, true, 0); - hbox.PackStart(label, true, true, 0); + child = box = new Gtk.Box(Gtk.Orientation.Horizontal, 2); + box.PackStart(gtkimage, false, true, 0); + box.PackStart(label, true, true, 0); break; case ButtonImagePosition.Right: - child = hbox = new Gtk.HBox(false, 2); - hbox.PackStart(label, true, true, 0); - hbox.PackEnd(gtkimage, false, true, 0); + child = box = new Gtk.Box(Gtk.Orientation.Horizontal, 2); + box.PackStart(label, true, true, 0); + box.PackEnd(gtkimage, false, true, 0); break; case ButtonImagePosition.Overlay: #if GTK2 diff --git a/src/Eto.Gtk/Forms/Controls/CalendarHandler.cs b/src/Eto.Gtk/Forms/Controls/CalendarHandler.cs index 8a802d009..f6ed75f48 100644 --- a/src/Eto.Gtk/Forms/Controls/CalendarHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/CalendarHandler.cs @@ -57,7 +57,7 @@ void SetContent() suppressRangeChanged--; if (box == null) - box = new Gtk.HBox(); + box = new Gtk.Box(Gtk.Orientation.Horizontal, 0); else box.Remove(endCalendar); box.PackStart(Control, true, true, 0); diff --git a/src/Eto.Gtk/Forms/Controls/DocumentPageHandler.cs b/src/Eto.Gtk/Forms/Controls/DocumentPageHandler.cs index 286427366..b546c9d0f 100644 --- a/src/Eto.Gtk/Forms/Controls/DocumentPageHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/DocumentPageHandler.cs @@ -1,12 +1,12 @@ using Eto.GtkSharp.Drawing; namespace Eto.GtkSharp.Forms.Controls { - public class DocumentPageHandler : GtkPanel, DocumentPage.IHandler + public class DocumentPageHandler : GtkPanel, DocumentPage.IHandler { Gtk.Label label; internal Gtk.Button closeButton; - readonly Gtk.HBox tab; + readonly Gtk.Box tab; Gtk.Image gtkimage; Image image; public static Size MaxImageSize = new Size(16, 16); @@ -27,8 +27,8 @@ private static Gdk.Pixbuf LoadCloseImage() public DocumentPageHandler() { - Control = new Gtk.VBox(); - tab = new Gtk.HBox(); + Control = new Gtk.Box(Gtk.Orientation.Vertical, 0); + tab = new Gtk.Box(Gtk.Orientation.Horizontal, 0); closeButton = new Gtk.Button(); closeButton.Relief = Gtk.ReliefStyle.None; closeButton.CanFocus = false; diff --git a/src/Eto.Gtk/Forms/Controls/DrawableHandler.cs b/src/Eto.Gtk/Forms/Controls/DrawableHandler.cs index 23552a003..488d2d994 100644 --- a/src/Eto.Gtk/Forms/Controls/DrawableHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/DrawableHandler.cs @@ -3,7 +3,7 @@ namespace Eto.GtkSharp.Forms.Controls { public class DrawableHandler : GtkPanel, Drawable.IHandler { - Gtk.VBox content; + Gtk.Box content; public bool SupportsCreateGraphics { get { return true; } } @@ -17,7 +17,7 @@ public void Create() Control.CanDefault = true; Control.Events |= Gdk.EventMask.ButtonPressMask; - content = new Gtk.VBox(); + content = new Gtk.Box(Gtk.Orientation.Vertical, 0); Control.Add(content); } diff --git a/src/Eto.Gtk/Forms/Controls/FilePickerHandler.cs b/src/Eto.Gtk/Forms/Controls/FilePickerHandler.cs index 7622b5570..d45a4a792 100644 --- a/src/Eto.Gtk/Forms/Controls/FilePickerHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/FilePickerHandler.cs @@ -4,7 +4,7 @@ public class FilePickerHandler : GtkControl, Scrollable.IHandler { readonly Gtk.Viewport vp; - readonly Gtk.HBox hbox; - readonly Gtk.VBox vbox; + readonly Gtk.Box hbox; + readonly Gtk.Box vbox; BorderType border; bool expandWidth = true; bool expandHeight = true; @@ -64,8 +64,11 @@ protected override void OnAdjustSizeRequest(Gtk.Orientation orientation, out int #endif } - public class EtoVBox : Gtk.VBox + public class EtoVBox : Gtk.Box { + public EtoVBox() : base(Gtk.Orientation.Vertical, 0) + { + } #if GTK3 protected override void OnAdjustSizeRequest(Gtk.Orientation orientation, out int minimum_size, out int natural_size) { @@ -86,7 +89,7 @@ public ScrollableHandler() Control.SetSizeRequest(10, 10); #endif // ensure things are top-left and not centered - hbox = new Gtk.HBox(); + hbox = new Gtk.Box(Gtk.Orientation.Horizontal, 0); vbox = new EtoVBox(); vbox.PackStart(hbox, true, true, 0); diff --git a/src/Eto.Gtk/Forms/Controls/SliderHandler.cs b/src/Eto.Gtk/Forms/Controls/SliderHandler.cs index 8e92e7020..c9250b2f4 100644 --- a/src/Eto.Gtk/Forms/Controls/SliderHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/SliderHandler.cs @@ -6,12 +6,13 @@ public class SliderHandler : GtkControl, int max = 100; int tick = 1; Gtk.Scale scale; + Orientation orientation; public SliderHandler() { this.Control = new Gtk.EventBox(); //Control.VisibleWindow = false; - scale = new Gtk.HScale(min, max, 1); + scale = new Gtk.Scale(Gtk.Orientation.Horizontal, min, max, 1); this.Control.Child = scale; } @@ -107,14 +108,12 @@ public int TickFrequency public Orientation Orientation { - get - { - return (scale is Gtk.HScale) ? Orientation.Horizontal : Orientation.Vertical; - } + get => orientation; set { if (Orientation != value) { + orientation = value; scale.ValueChanged -= Connector.HandleScaleValueChanged; Control.Remove(scale); #if !GTKCORE @@ -122,9 +121,9 @@ public Orientation Orientation #endif scale.Dispose(); if (value == Orientation.Horizontal) - scale = new Gtk.HScale(min, max, 1); + scale = new Gtk.Scale(Gtk.Orientation.Horizontal, min, max, 1); else - scale = new Gtk.VScale(min, max, 1); + scale = new Gtk.Scale(Gtk.Orientation.Vertical, min, max, 1); scale.ValueChanged += Connector.HandleScaleValueChanged; Control.Child = scale; scale.ShowAll(); diff --git a/src/Eto.Gtk/Forms/Controls/SplitterHandler.cs b/src/Eto.Gtk/Forms/Controls/SplitterHandler.cs index d046751a3..e772fd1f0 100644 --- a/src/Eto.Gtk/Forms/Controls/SplitterHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/SplitterHandler.cs @@ -39,10 +39,14 @@ int GetPreferredPanelSize(int width1, int width2) return width1 + width2 + SplitterWidth; } - class EtoHPaned : Gtk.HPaned + class EtoHPaned : Gtk.Paned { WeakReference handler; + public EtoHPaned() : base(Gtk.Orientation.Horizontal) + { + } + public SplitterHandler Handler { get => handler?.Target as SplitterHandler; @@ -98,10 +102,14 @@ protected override void OnSizeAllocated(Gdk.Rectangle allocation) } } - class EtoVPaned : Gtk.VPaned + class EtoVPaned : Gtk.Paned { WeakReference handler; + public EtoVPaned() : base(Gtk.Orientation.Vertical) + { + } + public SplitterHandler Handler { get => handler?.Target as SplitterHandler; @@ -551,7 +559,7 @@ void EnsurePosition() static Gtk.Widget EmptyContainer() { - var bin = new Gtk.VBox(); + var bin = new Gtk.Box(Gtk.Orientation.Horizontal, 0); bin.Visible = false; bin.NoShowAll = true; return bin; diff --git a/src/Eto.Gtk/Forms/Controls/TabPageHandler.cs b/src/Eto.Gtk/Forms/Controls/TabPageHandler.cs index dd92a48ae..3d4b29e21 100644 --- a/src/Eto.Gtk/Forms/Controls/TabPageHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/TabPageHandler.cs @@ -2,18 +2,18 @@ namespace Eto.GtkSharp.Forms.Controls { - public class TabPageHandler : GtkPanel, TabPage.IHandler + public class TabPageHandler : GtkPanel, TabPage.IHandler { Gtk.Label label; - readonly Gtk.HBox tab; + readonly Gtk.Box tab; Gtk.Image gtkimage; Image image; public static Size MaxImageSize = new Size(16, 16); public TabPageHandler() { - Control = new Gtk.VBox(); - tab = new Gtk.HBox(); + Control = new Gtk.Box(Gtk.Orientation.Vertical, 0); + tab = new Gtk.Box(Gtk.Orientation.Horizontal, 0); label = new Gtk.Label(); tab.PackEnd(label, true, true, 0); tab.ShowAll(); diff --git a/src/Eto.Gtk/Forms/CursorHandler.cs b/src/Eto.Gtk/Forms/CursorHandler.cs index e9338eca1..6f2910e96 100644 --- a/src/Eto.Gtk/Forms/CursorHandler.cs +++ b/src/Eto.Gtk/Forms/CursorHandler.cs @@ -5,7 +5,7 @@ public class CursorHandler : WidgetHandler, Cursor.IHandler public void Create(CursorType cursor) { - Control = new Gdk.Cursor(cursor.ToGdk()); + Control = new Gdk.Cursor(Gdk.Display.Default, cursor.ToGdk()); } public void Create(Bitmap image, PointF hotspot) diff --git a/src/Eto.Gtk/Forms/DialogHandler.cs b/src/Eto.Gtk/Forms/DialogHandler.cs index de61e7683..e9a10e75e 100644 --- a/src/Eto.Gtk/Forms/DialogHandler.cs +++ b/src/Eto.Gtk/Forms/DialogHandler.cs @@ -20,7 +20,7 @@ protected override void Initialize() base.Initialize(); Control.KeyPressEvent += Connector.Control_KeyPressEvent; - var vbox = new EtoVBox { Handler = this }; + var vbox = new EtoBox(Gtk.Orientation.Vertical, 0) { Handler = this }; vbox.PackStart(WindowActionControl, false, true, 0); vbox.PackStart(WindowContentControl, true, true, 0); diff --git a/src/Eto.Gtk/Forms/EtoControls.cs b/src/Eto.Gtk/Forms/EtoControls.cs index 0250188fc..e35026078 100644 --- a/src/Eto.Gtk/Forms/EtoControls.cs +++ b/src/Eto.Gtk/Forms/EtoControls.cs @@ -200,7 +200,7 @@ protected override void OnAdjustSizeRequest(Gtk.Orientation orientation, out int } - public partial class EtoVBox : Gtk.VBox + public partial class EtoBox : Gtk.Box { WeakReference _handler; public IGtkControl Handler @@ -208,6 +208,11 @@ public IGtkControl Handler get => _handler?.Target as IGtkControl; set => _handler = new WeakReference(value); } + public EtoBox(Gtk.Orientation orientation, int spacing) + : base(orientation, spacing) + { + + } #if GTK3 protected override void OnGetPreferredWidth(out int minimum_width, out int natural_width) diff --git a/src/Eto.Gtk/Forms/EtoControls.tt b/src/Eto.Gtk/Forms/EtoControls.tt index 9e670573f..d4ee8e353 100644 --- a/src/Eto.Gtk/Forms/EtoControls.tt +++ b/src/Eto.Gtk/Forms/EtoControls.tt @@ -9,7 +9,7 @@ using Eto; namespace Eto.GtkSharp.Forms { <# -var controls = new[] { "Fixed", "EventBox", "VBox", "ScrolledWindow" }; +var controls = new[] { "Fixed", "EventBox", "Box", "ScrolledWindow" }; foreach (var control in controls) { @@ -22,6 +22,18 @@ foreach (var control in controls) get => _handler?.Target as IGtkControl; set => _handler = new WeakReference(value); } +<# + if (control == "Box") + { +#> + public EtoBox(Gtk.Orientation orientation, int spacing) + : base(orientation, spacing) + { + + } +<# + } +#> #if GTK3 protected override void OnGetPreferredWidth(out int minimum_width, out int natural_width) diff --git a/src/Eto.Gtk/Forms/FormHandler.cs b/src/Eto.Gtk/Forms/FormHandler.cs index 11485eaba..679e647b0 100644 --- a/src/Eto.Gtk/Forms/FormHandler.cs +++ b/src/Eto.Gtk/Forms/FormHandler.cs @@ -16,7 +16,7 @@ public FormHandler() Resizable = true; Control.SetPosition(Gtk.WindowPosition.Center); - var vbox = new EtoVBox { Handler = this }; + var vbox = new EtoBox(Gtk.Orientation.Vertical, 0) { Handler = this }; vbox.PackStart(WindowActionControl, false, true, 0); vbox.PackStart(WindowContentControl, true, true, 0); Control.Child = vbox; diff --git a/src/Eto.Gtk/Forms/GtkWindow.cs b/src/Eto.Gtk/Forms/GtkWindow.cs index 5b47dc8c4..ccc07d279 100644 --- a/src/Eto.Gtk/Forms/GtkWindow.cs +++ b/src/Eto.Gtk/Forms/GtkWindow.cs @@ -13,11 +13,12 @@ public interface IGtkWindow Size UserPreferredSize { get; } } - public class GtkShrinkableVBox : Gtk.VBox + public class GtkShrinkableVBox : Gtk.Box { public bool Resizable { get; set; } public GtkShrinkableVBox() + : base(Gtk.Orientation.Vertical, 0) { } @@ -69,8 +70,8 @@ public abstract class GtkWindow : GtkPanel : GtkPanel