summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs b/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs
new file mode 100644
index 00000000..0091d253
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs
@@ -0,0 +1,49 @@
+using ElmSharp;
+using System;
+using ELayout = ElmSharp.Layout;
+
+namespace Xamarin.Forms.Platform.Tizen.Native
+{
+ public class EditfieldEntry : Native.Entry, IMeasurable
+ {
+ ELayout _editfieldLayout;
+ int _heightPadding = 0;
+
+ public EditfieldEntry(EvasObject parent) : base(parent)
+ {
+ }
+
+ protected override IntPtr CreateHandle(EvasObject parent)
+ {
+ var bg = new ELayout(parent);
+ bg.SetTheme("layout", "background", "default");
+ _editfieldLayout = new ELayout(parent);
+ _editfieldLayout.SetTheme("layout", "editfield", "singleline");
+
+ Handle = base.CreateHandle(parent);
+ _editfieldLayout.SetPartContent("elm.swallow.content", this);
+ bg.SetPartContent("elm.swallow.content", _editfieldLayout);
+
+ // The minimun size for the Content area of an Editfield. This is used to calculate the size when layouting.
+ _heightPadding = _editfieldLayout.EdjeObject["elm.swallow.content"].Geometry.Height;
+ return bg;
+ }
+
+ public new ElmSharp.Size Measure(int availableWidth, int availableHeight)
+ {
+ var textBlockSize = base.Measure(availableWidth, availableHeight);
+
+ // Calculate the minimum size by adding the width of a TextBlock and an Editfield.
+ textBlockSize.Width += _editfieldLayout.MinimumWidth;
+
+ // If the height of a TextBlock is shorter than Editfield, use the minimun height of the Editfield.
+ // Or add the height of the EditField to the TextBlock
+ if (textBlockSize.Height < _editfieldLayout.MinimumHeight)
+ textBlockSize.Height = _editfieldLayout.MinimumHeight;
+ else
+ textBlockSize.Height += _heightPadding;
+
+ return textBlockSize;
+ }
+ }
+} \ No newline at end of file