From 2e73258ab0dfb8b3b0930b278b0029503256a176 Mon Sep 17 00:00:00 2001 From: Vsevolod Kukol Date: Fri, 3 Mar 2017 21:52:40 +0100 Subject: [PATCH] Add WindowFrame.BackgroundColor property --- Xwt.Gtk/Xwt.GtkBackend/WindowBackend.cs | 13 +++++++++++++ Xwt.WPF/Xwt.WPFBackend/WindowBackend.cs | 5 +++++ Xwt.XamMac/Xwt.Mac/WindowBackend.cs | 10 ++++++++++ Xwt/Xwt.Backends/IWindowBackend.cs | 2 ++ Xwt/Xwt/Window.cs | 7 ++++++- 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Xwt.Gtk/Xwt.GtkBackend/WindowBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/WindowBackend.cs index cf8e1454d..e78915576 100755 --- a/Xwt.Gtk/Xwt.GtkBackend/WindowBackend.cs +++ b/Xwt.Gtk/Xwt.GtkBackend/WindowBackend.cs @@ -27,6 +27,7 @@ using System; using Xwt.Backends; +using Xwt.Drawing; namespace Xwt.GtkBackend { @@ -121,6 +122,18 @@ public void GetConstraints (Gtk.Widget target, out SizeConstraint width, out Siz width = RequestedSize.Width; height = RequestedSize.Height; } + + Color? backgroundColor; + + Color IWindowBackend.BackgroundColor { + get { + return backgroundColor ?? Window.GetBackgroundColor (); + } + set { + backgroundColor = value; + Window.SetBackgroundColor (value); + } + } } class RootWindowAlignment: Gtk.Alignment, IConstraintProvider diff --git a/Xwt.WPF/Xwt.WPFBackend/WindowBackend.cs b/Xwt.WPF/Xwt.WPFBackend/WindowBackend.cs index bc59f6ab7..c0e211621 100644 --- a/Xwt.WPF/Xwt.WPFBackend/WindowBackend.cs +++ b/Xwt.WPF/Xwt.WPFBackend/WindowBackend.cs @@ -188,6 +188,11 @@ protected override void OnResizeModeChanged () { Window.ResetBorderSize (); } + + public Xwt.Drawing.Color BackgroundColor { + get { return Window.Background.ToXwtColor (); } + set { Window.Background = ResPool.GetSolidBrush (value); } + } } class WpfWindow : System.Windows.Window diff --git a/Xwt.XamMac/Xwt.Mac/WindowBackend.cs b/Xwt.XamMac/Xwt.Mac/WindowBackend.cs index d900cfd5b..2fc1bde8b 100644 --- a/Xwt.XamMac/Xwt.Mac/WindowBackend.cs +++ b/Xwt.XamMac/Xwt.Mac/WindowBackend.cs @@ -34,6 +34,7 @@ using Foundation; using ObjCRuntime; using Xwt.Backends; +using Xwt.Drawing; namespace Xwt.Mac { @@ -133,6 +134,15 @@ public void Present () set { AlphaValue = (float)value; } } + Color IWindowBackend.BackgroundColor { + get { + return BackgroundColor.ToXwtColor (); + } + set { + BackgroundColor = value.ToNSColor (); + } + } + public bool Sensitive { get { return sensitive; diff --git a/Xwt/Xwt.Backends/IWindowBackend.cs b/Xwt/Xwt.Backends/IWindowBackend.cs index 066404a6c..0d2a16a09 100755 --- a/Xwt/Xwt.Backends/IWindowBackend.cs +++ b/Xwt/Xwt.Backends/IWindowBackend.cs @@ -26,11 +26,13 @@ using System; using Xwt; +using Xwt.Drawing; namespace Xwt.Backends { public interface IWindowBackend: IWindowFrameBackend, IChildPlacementHandler { + Color BackgroundColor { get; set; } void SetChild (IWidgetBackend child); void SetMainMenu (IMenuBackend menu); void SetPadding (double left, double top, double right, double bottom); diff --git a/Xwt/Xwt/Window.cs b/Xwt/Xwt/Window.cs index bb1dbbcee..048390fc0 100644 --- a/Xwt/Xwt/Window.cs +++ b/Xwt/Xwt/Window.cs @@ -26,7 +26,7 @@ using System; using Xwt.Backends; - +using Xwt.Drawing; namespace Xwt { @@ -61,6 +61,11 @@ public Window () set { initialLocation = value; } } + public Color BackgroundColor { + get { return Backend.BackgroundColor; } + set { Backend.BackgroundColor = value; } + } + public WidgetSpacing Padding { get { return padding; } set {