/// <since_tizen> 3 </since_tizen>
public partial class TextLabel : View
{
- private class TextLayout : LayoutItem
+ internal class TextLabelLayout : LayoutItem
{
protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
static TextLabel() { }
+ private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged();
+ private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged();
+ static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextLabel";
+ static private string defaultFontFamily = "BreezeSans";
private string textLabelSid = null;
- private bool systemlangTextFlag = false;
private TextLabelSelectorData selectorData;
+ private string fontFamily = defaultFontFamily;
private float fontSizeScale = 1.0f;
- private bool hasFontSizeChangedCallback = false;
+ private bool hasSystemLanguageChanged = false;
+ private bool hasSystemFontSizeChanged = false;
+ private bool hasSystemFontTypeChanged = false;
+
+ private Color internalTextColor;
+ private Color internalAnchorColor;
+ private Color internalAnchorClickedColor;
/// <summary>
/// Creates the TextLabel control.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- public TextLabel() : this(Interop.TextLabel.New(), true)
+ public TextLabel() : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
[EditorBrowsable(EditorBrowsableState.Never)]
- public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle)
+ public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true, viewStyle)
{
}
/// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
/// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
[EditorBrowsable(EditorBrowsableState.Never)]
- public TextLabel(bool shown) : this(Interop.TextLabel.New(), true)
+ public TextLabel(bool shown) : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
/// </summary>
/// <param name="text">The text to display</param>
/// <since_tizen> 3 </since_tizen>
- public TextLabel(string text) : this(Interop.TextLabel.New(text), true)
+ public TextLabel(string text) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
/// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
[EditorBrowsable(EditorBrowsableState.Never)]
- public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text), true)
+ public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
}
}
+ private bool HasStyle()
+ {
+ return ThemeManager.GetStyle(this.GetType()) == null ? false : true;
+ }
+
/// <summary>
/// The TranslatableText property.<br />
/// The text can set the SID value.<br />
if (translatableText != null)
{
Text = translatableText;
- if (systemlangTextFlag == false)
+ if (hasSystemLanguageChanged == false)
{
- SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
- systemlangTextFlag = true;
+ systemLocaleLanguageChanged.Add(SystemSettingsLocaleLanguageChanged);
+ hasSystemLanguageChanged = true;
}
}
else
}
}
+ private string InternalFontFamily
+ {
+ get
+ {
+ if (HasStyle())
+ return fontFamily;
+ else
+ return Object.InternalGetPropertyString(this.SwigCPtr, TextLabel.Property.FontFamily);
+ }
+ set
+ {
+ string newFontFamily;
+
+ if (string.Equals(fontFamily, value)) return;
+
+ fontFamily = value;
+ if (fontFamily == Tizen.NUI.FontFamily.UseSystemSetting)
+ {
+ try
+ {
+ newFontFamily = SystemSettings.FontType;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("{0} Exception caught.", e);
+ newFontFamily = defaultFontFamily;
+ }
+ AddSystemSettingsFontTypeChanged();
+ }
+ else
+ {
+ newFontFamily = fontFamily;
+ RemoveSystemSettingsFontTypeChanged();
+ }
+
+ SetInternalFontFamily(newFontFamily);
+ }
+ }
+
+ private void SetInternalFontFamily(string fontFamily)
+ {
+ Object.InternalSetPropertyString(this.SwigCPtr, TextLabel.Property.FontFamily, (string)fontFamily);
+ RequestLayout();
+ }
+
/// <summary>
/// The FontStyle property.<br />
/// The requested font style to use.<br />
/// Deprecated.(API Level 6) Use Shadow instead.
/// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
/// </remarks>
- [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
+ [Obsolete("Do not use this ShadowOffset(Deprecated). Use Shadow instead.")]
public Vector2 ShadowOffset
{
get
/// Deprecated.(API Level 6) Use Shadow instead.
/// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
/// </remarks>
- [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
+ [Obsolete("Do not use this ShadowColor(Deprecated). Use Shadow instead.")]
public Vector4 ShadowColor
{
get
/// <remarks>
/// Deprecated.(API Level 6) Use Underline instead.
/// </remarks>
- [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
+ [Obsolete("Do not use this UnderlineEnabled(Deprecated). Use Underline instead.")]
public bool UnderlineEnabled
{
get
/// Deprecated.(API Level 6) Use Underline instead.
/// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
/// </remarks>
- [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
+ [Obsolete("Do not use this UnderlineColor(Deprecated). Use Underline instead.")]
public Vector4 UnderlineColor
{
get
/// <remarks>
/// Deprecated.(API Level 6) Use Underline instead.
/// </remarks>
- [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
+ [Obsolete("Do not use this UnderlineHeight(Deprecated). Use Underline instead.")]
public float UnderlineHeight
{
get
}
/// <summary>
+ /// The relative height of the line (a factor that will be multiplied by text height). <br />
+ /// If the value is less than 1, the lines could to be overlapped.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float RelativeLineHeight
+ {
+ get
+ {
+ return (float)GetValue(RelativeLineHeightProperty);
+ }
+ set
+ {
+ SetValue(RelativeLineHeightProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ /// <summary>
/// The Underline property.<br />
/// The default underline parameters.<br />
/// The underline map contains the following keys :<br />
}
/// <summary>
+ /// The AnchorColor property.<br />
+ /// The color of the anchor.<br />
+ /// This property is used as the default color of the markup anchor tag.<br />
+ /// If there is a color attribute in the markup anchor tag, the markup attribute takes precedence.
+ /// </summary>
+ /// <remarks>
+ /// The property cascade chaining set is possible. For example, this (textLabel.AnchorColor.X = 0.1f;) is possible.
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color AnchorColor
+ {
+ get
+ {
+ Color color = (Color)GetValue(AnchorColorProperty);
+ return new Color(OnAnchorColorChanged, color.R, color.G, color.B, color.A);
+ }
+ set
+ {
+ SetValue(AnchorColorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ /// <summary>
+ /// The AnchorClickedColor property.<br />
+ /// The color of the clicked anchor.<br />
+ /// This property is used as the default clicked color of the markup anchor tag.<br />
+ /// If there is a color attribute in the markup anchor tag, the markup attribute takes precedence.
+ /// </summary>
+ /// <remarks>
+ /// The property cascade chaining set is possible. For example, this (textLabel.AnchorClickedColor.X = 0.1f;) is possible.
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color AnchorClickedColor
+ {
+ get
+ {
+ Color color = (Color)GetValue(AnchorClickedColorProperty);
+ return new Color(OnAnchorClickedColorChanged, color.R, color.G, color.B, color.A);
+ }
+ set
+ {
+ SetValue(AnchorClickedColorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ /// <summary>
/// The FontSizeScale property for scaling the specified font size up or down. <br />
/// The default value is 1.0. <br />
/// The given font size scale value is used for multiplying the specified font size before querying fonts. <br />
{
get
{
+ return (float)GetValue(FontSizeScaleProperty);
+ }
+ set
+ {
+ SetValue(FontSizeScaleProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ private float InternalFontSizeScale
+ {
+ get
+ {
return fontSizeScale;
}
set
systemSettingsFontSize = SystemSettingsFontSize.Normal;
}
newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
- addFontSizeChangedCallback();
+ AddSystemSettingsFontSizeChanged();
}
else
{
newFontSizeScale = fontSizeScale;
- removeFontSizeChangedCallback();
+ RemoveSystemSettingsFontSizeChanged();
}
- SetValue(FontSizeScaleProperty, newFontSizeScale);
- NotifyPropertyChanged();
+ SetInternalFontSizeScale(newFontSizeScale);
}
}
+ private void SetInternalFontSizeScale(float fontSizeScale)
+ {
+ Object.InternalSetPropertyFloat(this.SwigCPtr, TextLabel.Property.FontSizeScale, (float)fontSizeScale);
+ RequestLayout();
+ }
+
/// <summary>
/// The EnableFontSizeScale property.<br />
/// Whether the font size scale is enabled. (The default value is true)
/// <returns></returns>
/// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
/// <since_tizen> 3 </since_tizen>
- /// Please do not use! this will be deprecated!
- /// Instead please use as keyword.
- [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
+ /// Do not use this, that will be deprecated. Use as keyword instead.
+ [Obsolete("Do not use this, that will be deprecated. Use as keyword instead. " +
"Like: " +
"BaseHandle handle = new TextLabel(\"Hello World!\"); " +
"TextLabel label = handle as TextLabel")]
return;
}
- if (systemlangTextFlag)
+ internalTextColor?.Dispose();
+ internalAnchorColor?.Dispose();
+ internalAnchorClickedColor?.Dispose();
+
+ if (hasSystemLanguageChanged)
{
- SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
+ systemLocaleLanguageChanged.Remove(SystemSettingsLocaleLanguageChanged);
}
- removeFontSizeChangedCallback();
+ RemoveSystemSettingsFontTypeChanged();
+ RemoveSystemSettingsFontSizeChanged();
if (type == DisposeTypes.Explicit)
{
internal override LayoutItem CreateDefaultLayout()
{
- return new TextLayout();
+ return new TextLabelLayout();
}
/// <summary>
base.OnBindingContextChanged();
}
- private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
+ private void SystemSettingsLocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
{
Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
}
private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
{
float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
- SetValue(FontSizeScaleProperty, newFontSizeScale);
+ SetInternalFontSizeScale(newFontSizeScale);
}
- private void addFontSizeChangedCallback()
+ private void AddSystemSettingsFontSizeChanged()
{
- if (hasFontSizeChangedCallback != true)
+ if (hasSystemFontSizeChanged != true)
{
try
{
- SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
- hasFontSizeChangedCallback = true;
+ SystemFontSizeChangedManager.Add(SystemSettingsFontSizeChanged);
+ hasSystemFontSizeChanged = true;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
- hasFontSizeChangedCallback = false;
+ hasSystemFontSizeChanged = false;
}
}
}
- private void removeFontSizeChangedCallback()
+ private void RemoveSystemSettingsFontSizeChanged()
{
- if (hasFontSizeChangedCallback == true)
+ if (hasSystemFontSizeChanged == true)
{
try
{
- SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
- hasFontSizeChangedCallback = false;
+ SystemFontSizeChangedManager.Remove(SystemSettingsFontSizeChanged);
+ hasSystemFontSizeChanged = false;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
- hasFontSizeChangedCallback = true;
+ hasSystemFontSizeChanged = true;
+ }
+ }
+ }
+
+ private void SystemSettingsFontTypeChanged(object sender, FontTypeChangedEventArgs e)
+ {
+ SetInternalFontFamily(e.Value);
+ }
+
+ private void AddSystemSettingsFontTypeChanged()
+ {
+ if (HasStyle() && !hasSystemFontTypeChanged)
+ {
+ try
+ {
+ systemFontTypeChanged.Add(SystemSettingsFontTypeChanged);
+ hasSystemFontTypeChanged = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("{0} Exception caught.", e);
+ hasSystemFontTypeChanged = false;
+ }
+ }
+ }
+
+ private void RemoveSystemSettingsFontTypeChanged()
+ {
+ if (hasSystemFontTypeChanged)
+ {
+ try
+ {
+ systemFontTypeChanged.Remove(SystemSettingsFontTypeChanged);
+ hasSystemFontTypeChanged = false;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("{0} Exception caught.", e);
+ hasSystemFontTypeChanged = true;
}
}
}
internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
+ internal static readonly int RelativeLineHeight = Interop.TextLabel.RelativeLineHeightGet();
internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
internal static readonly int Strikethrough = Interop.TextLabel.StrikethroughGet();
internal static readonly int CharacterSpacing = Interop.TextLabel.CharacterSpacingGet();
+ internal static readonly int AnchorColor = Interop.TextLabel.AnchorColorGet();
+ internal static readonly int AnchorClickedColor = Interop.TextLabel.AnchorClickedColorGet();
}
private void OnShadowColorChanged(float x, float y, float z, float w)
{
UnderlineColor = new Vector4(x, y, z, w);
}
+ private void OnAnchorColorChanged(float r, float g, float b, float a)
+ {
+ AnchorColor = new Color(r, g, b, a);
+ }
+ private void OnAnchorClickedColorChanged(float r, float g, float b, float a)
+ {
+ AnchorClickedColor = new Color(r, g, b, a);
+ }
}
}