Browse Source

Added FontSize/VisualParent.

pull/4/head
grokys 12 years ago
parent
commit
3cdda17ef6
  1. 8
      Perspex.Windows/Window.cs
  2. 5
      Perspex/Controls/ContentPresenter.cs
  3. 12
      Perspex/Controls/Decorator.cs
  4. 1
      Perspex/Controls/TemplatedControl.cs
  5. 13
      Perspex/Controls/TextBlock.cs
  6. 19
      Perspex/Visual.cs

8
Perspex.Windows/Window.cs

@ -10,12 +10,20 @@
public class Window : ContentControl, ILayoutRoot
{
public static PerspexProperty<double> FontSizeProperty =
TextBlock.FontSizeProperty.AddOwner<Window>();
private UnmanagedMethods.WndProc wndProcDelegate;
private string className;
private Renderer renderer;
static Window()
{
FontSizeProperty.OverrideDefaultValue(typeof(Window), 18.0);
}
public Window()
{
this.CreateWindow();

5
Perspex/Controls/ContentPresenter.cs

@ -50,6 +50,11 @@
Text = content.ToString(),
};
}
if (this.visualChild != null)
{
this.visualChild.VisualParent = this;
}
}
return Enumerable.Repeat(this.visualChild, this.visualChild != null ? 1 : 0);

12
Perspex/Controls/Decorator.cs

@ -9,6 +9,18 @@
public static readonly PerspexProperty<Control> ContentProperty =
PerspexProperty.Register<ContentControl, Control>("Content");
public Decorator()
{
// TODO: Unset old content's visual parent.
this.GetObservable(ContentProperty).Subscribe(x =>
{
if (x != null)
{
x.VisualParent = this;
}
});
}
public Control Content
{
get { return this.GetValue(ContentProperty); }

1
Perspex/Controls/TemplatedControl.cs

@ -32,6 +32,7 @@
if (this.visualChild == null && template != null)
{
this.visualChild = template(this);
this.visualChild.VisualParent = this;
}
return Enumerable.Repeat(this.visualChild, this.visualChild != null ? 1 : 0);

13
Perspex/Controls/TextBlock.cs

@ -7,6 +7,11 @@
public static readonly PerspexProperty<Brush> BackgroundProperty =
Border.BackgroundProperty.AddOwner<TextBlock>();
public static readonly PerspexProperty<double> FontSizeProperty =
PerspexProperty.Register<TextBlock, double>(
"FontSize",
inherits: true);
public static readonly PerspexProperty<Brush> ForegroundProperty =
PerspexProperty.Register<TextBlock, Brush>(
"Foreground",
@ -22,6 +27,12 @@
set { this.SetValue(BackgroundProperty, value); }
}
public double FontSize
{
get { return this.GetValue(FontSizeProperty); }
set { this.SetValue(FontSizeProperty, value); }
}
public Brush Foreground
{
get { return this.GetValue(ForegroundProperty); }
@ -41,7 +52,7 @@
return new FormattedText
{
FontFamilyName = "Segoe UI",
FontSize = 18,
FontSize = this.FontSize,
Text = this.Text,
};
}

19
Perspex/Visual.cs

@ -14,6 +14,8 @@
private static readonly PerspexProperty<Rect> BoundsPropertyW =
PerspexProperty.Register<Visual, Rect>("Bounds", new Rect());
private Visual visualParent;
public Rect Bounds
{
get { return this.GetValue(BoundsPropertyW); }
@ -25,6 +27,23 @@
get { return Enumerable.Empty<Visual>(); }
}
public Visual VisualParent
{
get
{
return this.visualParent;
}
set
{
if (this.visualParent != value)
{
this.visualParent = value;
this.InheritanceParent = value;
}
}
}
public virtual void Render(IDrawingContext context)
{
Contract.Requires<ArgumentNullException>(context != null);

Loading…
Cancel
Save