Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2013-10-15 18:54:40 +0400
committerLluis Sanchez <lluis@xamarin.com>2013-10-15 18:55:23 +0400
commitf3626d7405d977d79aa5b68301273155284cad90 (patch)
treea041248881c1d6ebf9c88ea0ec469105a1fc9514 /Xwt.WPF
parent1b443364ccbf6f499fbade1f7331f6294b6d0432 (diff)
[WPF] Fix padding and alignment of TextEntry widget
Diffstat (limited to 'Xwt.WPF')
-rw-r--r--Xwt.WPF/Xwt.WPFBackend/PlaceholderTextAdorner.cs11
-rw-r--r--Xwt.WPF/Xwt.WPFBackend/TextEntryBackend.cs13
2 files changed, 20 insertions, 4 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/PlaceholderTextAdorner.cs b/Xwt.WPF/Xwt.WPFBackend/PlaceholderTextAdorner.cs
index 9f90393c..8ecdfcfb 100644
--- a/Xwt.WPF/Xwt.WPFBackend/PlaceholderTextAdorner.cs
+++ b/Xwt.WPF/Xwt.WPFBackend/PlaceholderTextAdorner.cs
@@ -10,7 +10,7 @@ using System.Windows.Media;
namespace Xwt.WPFBackend
{
- class PlaceholderTextAdorner :Adorner
+ class PlaceholderTextAdorner: Adorner
{
public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register ("PlaceholderText", typeof (string), typeof (PlaceholderTextAdorner), new PropertyMetadata (OnPlaceHolderTextChanged));
@@ -57,21 +57,26 @@ namespace Xwt.WPFBackend
Typeface typeFace;
TextAlignment alignment;
FlowDirection flowDirection;
+ double padding;
if (AdornedPasswordBox != null) {
alignment = ConvertAlignment (AdornedPasswordBox.HorizontalContentAlignment);
flowDirection = AdornedPasswordBox.FlowDirection;
fontSize = AdornedPasswordBox.FontSize;
typeFace = AdornedPasswordBox.FontFamily.GetTypefaces ().FirstOrDefault ();
- } else {
+ padding = 6;
+ }
+ else {
alignment = AdornedTextBox.ReadLocalValue (TextBox.TextAlignmentProperty) !=DependencyProperty.UnsetValue ? AdornedTextBox.TextAlignment : ConvertAlignment (AdornedTextBox.HorizontalContentAlignment);
flowDirection = AdornedTextBox.FlowDirection;
fontSize = AdornedTextBox.FontSize;
typeFace = AdornedTextBox.FontFamily.GetTypefaces ().FirstOrDefault ();
+ padding = 6;
}
var text = new System.Windows.Media.FormattedText (PlaceholderText ?? "", CultureInfo.CurrentCulture, flowDirection, typeFace, fontSize, System.Windows.Media.Brushes.LightGray) {
TextAlignment = alignment
};
- drawingContext.DrawText(text, new System.Windows.Point (4, 0));
+
+ drawingContext.DrawText (text, new System.Windows.Point (padding, (RenderSize.Height - text.Height) / 2));
}
private TextAlignment ConvertAlignment(System.Windows.HorizontalAlignment horizontalAlignment)
diff --git a/Xwt.WPF/Xwt.WPFBackend/TextEntryBackend.cs b/Xwt.WPF/Xwt.WPFBackend/TextEntryBackend.cs
index 98023bfd..66e11d97 100644
--- a/Xwt.WPF/Xwt.WPFBackend/TextEntryBackend.cs
+++ b/Xwt.WPF/Xwt.WPFBackend/TextEntryBackend.cs
@@ -38,6 +38,8 @@ namespace Xwt.WPFBackend
public class TextEntryBackend
: WidgetBackend, ITextEntryBackend
{
+ bool multiline;
+
PlaceholderTextAdorner Adorner {
get; set;
}
@@ -48,6 +50,7 @@ namespace Xwt.WPFBackend
TextBox.Loaded += delegate {
AdornerLayer.GetAdornerLayer (TextBox).Add (Adorner);
};
+ TextBox.VerticalContentAlignment = VerticalAlignment.Center;
}
protected override double DefaultNaturalWidth
@@ -87,7 +90,15 @@ namespace Xwt.WPFBackend
// TODO
public bool MultiLine {
- get; set;
+ get { return multiline; }
+ set
+ {
+ multiline = value;
+ if (multiline)
+ TextBox.VerticalContentAlignment = VerticalAlignment.Top;
+ else
+ TextBox.VerticalContentAlignment = VerticalAlignment.Center;
+ }
}
public override void EnableEvent (object eventId)