Add a Placeholder struct to pass data of DALi Placeholder PropertyMap.
The Placeholder struct can be used as an argument to
SetPlaceholder and GetPlaceholder methods.
// example
var placeholder = new Tizen.NUI.Text.Placeholder();
placeholder.Text = "placeholder text";
placeholder.TextFocused = "placeholder textFocused";
placeholder.Color = new Color("#45B39D");
placeholder.FontFamily = "BreezeSans";
placeholder.FontStyle = new Tizen.NUI.Text.FontStyle()
{
Width = FontWidthType.Expanded,
Weight = FontWeightType.ExtraLight,
Slant = FontSlantType.Italic,
};
placeholder.PointSize = 25.0f;
//placeholder.PixelSize = 50.0f;
placeholder.Ellipsis = true;
field.SetPlaceholder(placeholder);
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
/// </code>
/// </example>
/// <since_tizen> 3 </since_tizen>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
public Tizen.NUI.PropertyMap Placeholder
{
get
}
/// <summary>
+ /// Set Placeholder to TextEditor. <br />
+ /// </summary>
+ /// <param name="placeholder">The Placeholder</param>
+ /// <remarks>
+ /// SetPlaceholder specifies the attributes of the placeholder property through <see cref="Tizen.NUI.Text.Placeholder"/>. <br />
+ /// </remarks>
+ /// <example>
+ /// The following example demonstrates how to use the SetPlaceholder method.
+ /// <code>
+ /// var placeholder = new Tizen.NUI.Text.Placeholder();
+ /// placeholder.Text = "placeholder text";
+ /// placeholder.TextFocused = "placeholder textFocused";
+ /// placeholder.Color = new Color("#45B39D");
+ /// placeholder.FontFamily = "BreezeSans";
+ /// placeholder.FontStyle = new Tizen.NUI.Text.FontStyle()
+ /// {
+ /// Width = FontWidthType.Expanded,
+ /// Weight = FontWeightType.ExtraLight,
+ /// Slant = FontSlantType.Italic,
+ /// };
+ /// placeholder.PointSize = 25.0f;
+ /// //placeholder.PixelSize = 50.0f;
+ /// placeholder.Ellipsis = true;
+ /// editor.SetPlaceholder(placeholder);
+ /// </code>
+ /// </example>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetPlaceholder(Placeholder placeholder)
+ {
+ SetProperty(TextEditor.Property.PLACEHOLDER, new PropertyValue(TextUtils.GetPlaceholderMap(placeholder)));
+ }
+
+ /// <summary>
+ /// Get Placeholder from TextEditor. <br />
+ /// </summary>
+ /// <returns>The Placeholder</returns>
+ /// <remarks>
+ /// <see cref="Tizen.NUI.Text.Placeholder"/>
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Placeholder GetPlaceholder()
+ {
+ var map = new PropertyMap();
+ GetProperty(TextEditor.Property.PLACEHOLDER).Get(map);
+ return TextUtils.GetPlaceholderStruct(map);
+ }
+
+ /// <summary>
/// The Ellipsis property.<br />
/// Enable or disable the ellipsis.<br />
/// </summary>
/// </code>
/// </example>
/// <since_tizen> 3 </since_tizen>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
public Tizen.NUI.PropertyMap Placeholder
{
get
}
/// <summary>
+ /// Set Placeholder to TextField. <br />
+ /// </summary>
+ /// <param name="placeholder">The Placeholder</param>
+ /// <remarks>
+ /// SetPlaceholder specifies the attributes of the placeholder property through <see cref="Tizen.NUI.Text.Placeholder"/>. <br />
+ /// </remarks>
+ /// <example>
+ /// The following example demonstrates how to use the SetPlaceholder method.
+ /// <code>
+ /// var placeholder = new Tizen.NUI.Text.Placeholder();
+ /// placeholder.Text = "placeholder text";
+ /// placeholder.TextFocused = "placeholder textFocused";
+ /// placeholder.Color = new Color("#45B39D");
+ /// placeholder.FontFamily = "BreezeSans";
+ /// placeholder.FontStyle = new Tizen.NUI.Text.FontStyle()
+ /// {
+ /// Width = FontWidthType.Expanded,
+ /// Weight = FontWeightType.ExtraLight,
+ /// Slant = FontSlantType.Italic,
+ /// };
+ /// placeholder.PointSize = 25.0f;
+ /// //placeholder.PixelSize = 50.0f;
+ /// placeholder.Ellipsis = true;
+ /// field.SetPlaceholder(placeholder);
+ /// </code>
+ /// </example>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetPlaceholder(Placeholder placeholder)
+ {
+ SetProperty(TextField.Property.PLACEHOLDER, new PropertyValue(TextUtils.GetPlaceholderMap(placeholder)));
+ }
+
+ /// <summary>
+ /// Get Placeholder from TextField. <br />
+ /// </summary>
+ /// <returns>The Placeholder</returns>
+ /// <remarks>
+ /// <see cref="Tizen.NUI.Text.Placeholder"/>
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Placeholder GetPlaceholder()
+ {
+ var map = new PropertyMap();
+ GetProperty(TextField.Property.PLACEHOLDER).Get(map);
+ return TextUtils.GetPlaceholderStruct(map);
+ }
+
+ /// <summary>
/// The Ellipsis property.<br />
/// Enable or disable the ellipsis.<br />
/// Placeholder PropertyMap is used to add ellipsis to placeholder text.
}
/// <summary>
+ /// This method converts a Placeholder struct to a PropertyMap and returns it.
+ /// The returned map can be used for set Placeholder PropertyMap in the SetPlaceholder method.
+ /// <param name="placeholder">The Placeholder struct value.</param>
+ /// <returns> A PropertyMap for Placeholder property. </returns>
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static PropertyMap GetPlaceholderMap(Placeholder placeholder)
+ {
+ var map = new PropertyMap();
+
+ if (placeholder.Text != null)
+ map.Add("text", new PropertyValue(placeholder.Text));
+
+ if (placeholder.TextFocused != null)
+ map.Add("textFocused", new PropertyValue(placeholder.TextFocused));
+
+ if (placeholder.Color != null)
+ map.Add("color", new PropertyValue(placeholder.Color));
+
+ if (placeholder.FontFamily != null)
+ map.Add("fontFamily", new PropertyValue(placeholder.FontFamily));
+
+ if (placeholder.FontStyle != null)
+ map.Add("fontStyle", new PropertyValue(GetFontStyleMap((FontStyle)placeholder.FontStyle)));
+
+ if (placeholder.PointSize != null && placeholder.PixelSize != null)
+ map.Add("pointSize", new PropertyValue((float)placeholder.PointSize));
+
+ else if (placeholder.PointSize != null)
+ map.Add("pointSize", new PropertyValue((float)placeholder.PointSize));
+
+ else if (placeholder.PixelSize != null)
+ map.Add("pixelSize", new PropertyValue((float)placeholder.PixelSize));
+
+ map.Add("ellipsis", new PropertyValue(placeholder.Ellipsis));
+
+ return map;
+ }
+
+ /// <summary>
+ /// This method converts a Placeholder map to a struct and returns it.
+ /// The returned struct can be returned to the user as a Placeholder in the GetPlaceholder method.
+ /// <param name="map">The Placeholder PropertyMap.</param>
+ /// <returns> A Placeholder struct. </returns>
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Placeholder GetPlaceholderStruct(PropertyMap map)
+ {
+ string text = "";
+ string textFocused = "";
+ Color color = new Color();
+ string fontFamily = null;
+ var fontStyle = new PropertyMap();
+ PropertyValue pointSizeValue = null;
+ PropertyValue pixelSizeValue = null;
+ bool ellipsis = false;
+
+ map.Find(0)?.Get(out text);
+ map.Find(1)?.Get(out textFocused);
+ map.Find(2).Get(color);
+ map.Find(3)?.Get(out fontFamily);
+ map.Find(4).Get(fontStyle);
+ pointSizeValue = map.Find(5);
+ pixelSizeValue = map.Find(6);
+ map.Find(7)?.Get(out ellipsis);
+
+ var placeholder = new Placeholder();
+ placeholder.Text = text;
+ placeholder.TextFocused = textFocused;
+ placeholder.Color = color;
+ placeholder.FontFamily = fontFamily;
+ placeholder.Ellipsis = ellipsis;
+ placeholder.FontStyle = GetFontStyleStruct(fontStyle);
+
+ if (pointSizeValue != null)
+ {
+ pointSizeValue.Get(out float pointSize);
+ placeholder.PointSize = pointSize;
+ }
+
+ if (pixelSizeValue != null)
+ {
+ pixelSizeValue.Get(out float pixelSize);
+ placeholder.PixelSize = pixelSize;
+ }
+
+ return placeholder;
+ }
+
+ /// <summary>
/// Copy the previously selected text into the clipboard and return the copied value.
/// </summary>
/// <param name="textEditor">The textEditor control from which the text is copied.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public FontSizeType FontSizeType { get; set; }
}
+
+ /// <summary>
+ /// A struct to pass data of Placeholder PropertyMap. <br />
+ /// </summary>
+ /// <remarks>
+ /// The Placeholder struct is used as an argument to SetPlaceholder and GetPlaceholder methods. <br />
+ /// See <see cref="Tizen.NUI.BaseComponents.TextField.SetPlaceholder"/>, <see cref="Tizen.NUI.BaseComponents.TextField.SetPlaceholder"/>, <see cref="Tizen.NUI.BaseComponents.TextEditor.SetPlaceholder"/> and <see cref="Tizen.NUI.BaseComponents.TextEditor.SetPlaceholder"/>. <br />
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public struct Placeholder
+ {
+ /// <summary>
+ /// The text to display when the TextField is empty and inactive.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Text { get; set; }
+
+ /// <summary>
+ /// The text to display when the placeholder has focus.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string TextFocused { get; set; }
+
+ /// <summary>
+ /// The color of the placeholder text.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color Color { get; set; }
+
+ /// <summary>
+ /// The FontFamily of the placeholder text.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string FontFamily { get; set; }
+
+ /// <summary>
+ /// The FontStyle of the placeholder text (if null, the text control FontStyle is used).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public FontStyle? FontStyle { get; set; }
+
+ /// <summary>
+ /// The PointSize of the placeholder text. <br />
+ /// Not required if PixelSize provided. <br />
+ /// If both provided or neither provided then the text control point size is used. <br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float? PointSize { get; set; }
+
+ /// <summary>
+ /// The PiexSize of the placeholder text.
+ /// Not required if PointSize provided. <br />
+ /// If both provided or neither provided then the text control point size is used. <br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float? PixelSize { get; set; }
+
+ /// <summary>
+ /// The ellipsis of the placeholder text (the default value is false).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool Ellipsis { get; set; }
+ }
}
}