Skip to content

Commit

Permalink
Merge pull request #649 from sevoku/add-window-background-color
Browse files Browse the repository at this point in the history
Add WindowFrame.BackgroundColor property
  • Loading branch information
sevoku committed Mar 28, 2017
2 parents a1849ce + 2e73258 commit 8a58fff
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Xwt.Gtk/Xwt.GtkBackend/WindowBackend.cs
Expand Up @@ -27,6 +27,7 @@

using System;
using Xwt.Backends;
using Xwt.Drawing;

namespace Xwt.GtkBackend
{
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Xwt.WPF/Xwt.WPFBackend/WindowBackend.cs
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Xwt.XamMac/Xwt.Mac/WindowBackend.cs
Expand Up @@ -34,6 +34,7 @@
using Foundation;
using ObjCRuntime;
using Xwt.Backends;
using Xwt.Drawing;

namespace Xwt.Mac
{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Xwt/Xwt.Backends/IWindowBackend.cs
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion Xwt/Xwt/Window.cs
Expand Up @@ -26,7 +26,7 @@

using System;
using Xwt.Backends;

using Xwt.Drawing;

namespace Xwt
{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8a58fff

Please sign in to comment.