/*
* Copyright(c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
extern alias TizenSystemSettings;
using TizenSystemSettings.Tizen.System;
using System;
using System.Globalization;
using System.ComponentModel;
namespace Tizen.NUI.BaseComponents
{
///
/// A control which renders a short text string.
/// Text labels are lightweight, non-editable, and do not respond to the user input.
///
/// 3
public class TextLabel : View
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private string textLabelSid = null;
private bool systemlangTextFlag = false;
internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TextLabel_SWIGUpcast(cPtr), cMemoryOwn)
{
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
///
/// Dispose.
///
/// 3
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
if(type == DisposeTypes.Explicit)
{
//Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
NDalicPINVOKE.delete_TextLabel(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
base.Dispose(type);
}
internal new class Property
{
internal static readonly int RENDERING_BACKEND = NDalicPINVOKE.TextLabel_Property_RENDERING_BACKEND_get();
internal static readonly int TEXT = NDalicPINVOKE.TextLabel_Property_TEXT_get();
internal static readonly int FONT_FAMILY = NDalicPINVOKE.TextLabel_Property_FONT_FAMILY_get();
internal static readonly int FONT_STYLE = NDalicPINVOKE.TextLabel_Property_FONT_STYLE_get();
internal static readonly int POINT_SIZE = NDalicPINVOKE.TextLabel_Property_POINT_SIZE_get();
internal static readonly int MULTI_LINE = NDalicPINVOKE.TextLabel_Property_MULTI_LINE_get();
internal static readonly int HORIZONTAL_ALIGNMENT = NDalicPINVOKE.TextLabel_Property_HORIZONTAL_ALIGNMENT_get();
internal static readonly int VERTICAL_ALIGNMENT = NDalicPINVOKE.TextLabel_Property_VERTICAL_ALIGNMENT_get();
internal static readonly int TEXT_COLOR = NDalicPINVOKE.TextLabel_Property_TEXT_COLOR_get();
internal static readonly int SHADOW_OFFSET = NDalicPINVOKE.TextLabel_Property_SHADOW_OFFSET_get();
internal static readonly int SHADOW_COLOR = NDalicPINVOKE.TextLabel_Property_SHADOW_COLOR_get();
internal static readonly int UNDERLINE_ENABLED = NDalicPINVOKE.TextLabel_Property_UNDERLINE_ENABLED_get();
internal static readonly int UNDERLINE_COLOR = NDalicPINVOKE.TextLabel_Property_UNDERLINE_COLOR_get();
internal static readonly int UNDERLINE_HEIGHT = NDalicPINVOKE.TextLabel_Property_UNDERLINE_HEIGHT_get();
internal static readonly int ENABLE_MARKUP = NDalicPINVOKE.TextLabel_Property_ENABLE_MARKUP_get();
internal static readonly int ENABLE_AUTO_SCROLL = NDalicPINVOKE.TextLabel_Property_ENABLE_AUTO_SCROLL_get();
internal static readonly int AUTO_SCROLL_SPEED = NDalicPINVOKE.TextLabel_Property_AUTO_SCROLL_SPEED_get();
internal static readonly int AUTO_SCROLL_LOOP_COUNT = NDalicPINVOKE.TextLabel_Property_AUTO_SCROLL_LOOP_COUNT_get();
internal static readonly int AUTO_SCROLL_GAP = NDalicPINVOKE.TextLabel_Property_AUTO_SCROLL_GAP_get();
internal static readonly int LINE_SPACING = NDalicPINVOKE.TextLabel_Property_LINE_SPACING_get();
internal static readonly int UNDERLINE = NDalicPINVOKE.TextLabel_Property_UNDERLINE_get();
internal static readonly int SHADOW = NDalicPINVOKE.TextLabel_Property_SHADOW_get();
internal static readonly int EMBOSS = NDalicPINVOKE.TextLabel_Property_EMBOSS_get();
internal static readonly int OUTLINE = NDalicPINVOKE.TextLabel_Property_OUTLINE_get();
internal static readonly int PIXEL_SIZE = NDalicManualPINVOKE.TextLabel_Property_PIXEL_SIZE_get();
internal static readonly int ELLIPSIS = NDalicManualPINVOKE.TextLabel_Property_ELLIPSIS_get();
internal static readonly int AUTO_SCROLL_STOP_MODE = NDalicManualPINVOKE.TextLabel_Property_AUTO_SCROLL_STOP_MODE_get();
internal static readonly int AUTO_SCROLL_LOOP_DELAY = NDalicManualPINVOKE.TextLabel_Property_AUTO_SCROLL_LOOP_DELAY_get();
internal static readonly int LINE_COUNT = NDalicManualPINVOKE.TextLabel_Property_LINE_COUNT_get();
internal static readonly int LINE_WRAP_MODE = NDalicManualPINVOKE.TextLabel_Property_LINE_WRAP_MODE_get();
}
///
/// Creates the TextLabel control.
///
/// 3
public TextLabel() : this(NDalicPINVOKE.TextLabel_New__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Creates the TextLabel control.
///
/// The text to display
/// 3
public TextLabel(string text) : this(NDalicPINVOKE.TextLabel_New__SWIG_1(text), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Downcasts a handle to textLabel handle
///
///
///
/// 3
/// Please do not use! this will be deprecated!
/// Instead please use as keyword.
[Obsolete("Please DO NOT use! This will be deprecated, instead please USE as keyword.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public new static TextLabel DownCast(BaseHandle handle)
{
TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// The TranslatableText property.
/// The text can set the SID value.
///
///
/// ResourceManager about multilingual is null.
///
/// 4
public string TranslatableText
{
get
{
return textLabelSid;
}
set
{
if (NUIApplication.MultilingualResourceManager == null)
{
throw new ArgumentNullException("ResourceManager about multilingual is null");
}
string translatableText = null;
textLabelSid = value;
translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
if (translatableText != null)
{
Text = translatableText;
if (systemlangTextFlag == false)
{
SystemSettings.LocaleLanguageChanged += new WeakEventHandler(SystemSettings_LocaleLanguageChanged).Handler;
systemlangTextFlag = true;
}
}
else
{
Text = "";
}
}
}
private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
{
Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
}
///
/// The Text property.
/// The text to display in the UTF-8 format.
///
/// 3
public string Text
{
get
{
string temp;
GetProperty(TextLabel.Property.TEXT).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The FontFamily property.
/// The requested font family to use.
///
/// 3
public string FontFamily
{
get
{
string temp;
GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The FontStyle property.
/// The requested font style to use.
///
/// 3
public PropertyMap FontStyle
{
get
{
PropertyMap temp = new PropertyMap();
GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The PointSize property.
/// The size of font in points.
///
/// 3
public float PointSize
{
get
{
float temp = 0.0f;
GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The MultiLine property.
/// The single-line or multi-line layout option.
///
/// 3
public bool MultiLine
{
get
{
bool temp = false;
GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The HorizontalAlignment property.
/// The line horizontal alignment.
///
/// 3
public HorizontalAlignment HorizontalAlignment
{
get
{
string temp;
if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
{
NUILog.Error("HorizontalAlignment get error!");
}
switch (temp)
{
case "BEGIN":
return HorizontalAlignment.Begin;
case "CENTER":
return HorizontalAlignment.Center;
case "END":
return HorizontalAlignment.End;
default:
return HorizontalAlignment.Begin;
}
}
set
{
string valueToString = "";
switch (value)
{
case HorizontalAlignment.Begin:
{
valueToString = "BEGIN";
break;
}
case HorizontalAlignment.Center:
{
valueToString = "CENTER";
break;
}
case HorizontalAlignment.End:
{
valueToString = "END";
break;
}
default:
{
valueToString = "BEGIN";
break;
}
}
SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
}
}
///
/// The VerticalAlignment property.
/// The line vertical alignment.
///
/// 3
public VerticalAlignment VerticalAlignment
{
get
{
string temp;
if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
{
NUILog.Error("VerticalAlignment get error!");
}
switch (temp)
{
case "TOP":
return VerticalAlignment.Top;
case "CENTER":
return VerticalAlignment.Center;
case "BOTTOM":
return VerticalAlignment.Bottom;
default:
return VerticalAlignment.Bottom;
}
}
set
{
string valueToString = "";
switch (value)
{
case VerticalAlignment.Top:
{
valueToString = "TOP";
break;
}
case VerticalAlignment.Center:
{
valueToString = "CENTER";
break;
}
case VerticalAlignment.Bottom:
{
valueToString = "BOTTOM";
break;
}
default:
{
valueToString = "BOTTOM";
break;
}
}
SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
}
}
///
/// The TextColor property.
/// The color of the text.
/// Animation framework can be used to change the color of the text when not using mark up.
/// Cannot animate the color when text is auto scrolling.
///
/// 3
public Color TextColor
{
get
{
Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The ShadowOffset property.
/// The drop shadow offset 0 indicates no shadow.
///
/// 3
public Vector2 ShadowOffset
{
get
{
Vector2 temp = new Vector2(0.0f, 0.0f);
GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The ShadowColor property.
/// The color of a drop shadow.
///
/// 3
public Vector4 ShadowColor
{
get
{
Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The UnderlineEnabled property.
/// The underline enabled flag.
///
/// 3
public bool UnderlineEnabled
{
get
{
bool temp = false;
GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The UnderlineColor property.
/// Overrides the underline height from font metrics.
///
/// 3
public Vector4 UnderlineColor
{
get
{
Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The UnderlineHeight property.
/// Overrides the underline height from font metrics.
///
/// 3
public float UnderlineHeight
{
get
{
float temp = 0.0f;
GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The EnableMarkup property.
/// Whether the mark-up processing is enabled.
///
/// 3
public bool EnableMarkup
{
get
{
bool temp = false;
GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The EnableAutoScroll property.
/// Starts or stops auto scrolling.
///
/// 3
public bool EnableAutoScroll
{
get
{
bool temp = false;
GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The AutoScrollSpeed property.
/// Sets the speed of scrolling in pixels per second.
///
/// 3
public int AutoScrollSpeed
{
get
{
int temp = 0;
GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The AutoScrollLoopCount property.
/// Number of complete loops when scrolling enabled.
///
/// 3
public int AutoScrollLoopCount
{
get
{
int temp = 0;
GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The AutoScrollGap property.
/// Gap before scrolling wraps.
///
/// 3
public float AutoScrollGap
{
get
{
float temp = 0.0f;
GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The LineSpacing property.
/// The default extra space between lines in points.
///
/// 3
public float LineSpacing
{
get
{
float temp = 0.0f;
GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The Underline property.
/// The default underline parameters.
///
/// 3
public PropertyMap Underline
{
get
{
PropertyMap temp = new PropertyMap();
GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The Shadow property.
/// The default shadow parameters.
///
/// 3
public PropertyMap Shadow
{
get
{
PropertyMap temp = new PropertyMap();
GetProperty(TextLabel.Property.SHADOW).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The Emboss property.
/// The default emboss parameters.
///
/// 3
public string Emboss
{
get
{
string temp;
GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The Outline property.
/// The default outline parameters.
///
/// 3
public PropertyMap Outline
{
get
{
PropertyMap temp = new PropertyMap();
GetProperty(TextLabel.Property.OUTLINE).Get(temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The PixelSize property.
/// The size of font in pixels.
///
/// 3
public float PixelSize
{
get
{
float temp = 0.0f;
GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The Ellipsis property.
/// Enable or disable the ellipsis.
///
/// 3
public bool Ellipsis
{
get
{
bool temp = false;
GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The AutoScrollLoopDelay property.
/// Do something.
///
/// 3
public float AutoScrollLoopDelay
{
get
{
float temp = 0.0f;
GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
return temp;
}
set
{
SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
}
}
///
/// The AutoScrollStopMode property.
/// Do something.
///
/// 3
public AutoScrollStopMode AutoScrollStopMode
{
get
{
string temp;
if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
{
NUILog.Error("AutoScrollStopMode get error!");
}
switch (temp)
{
case "FINISH_LOOP":
return AutoScrollStopMode.FinishLoop;
case "IMMEDIATE":
return AutoScrollStopMode.Immediate;
default:
return AutoScrollStopMode.FinishLoop;
}
}
set
{
SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
}
}
///
/// The line count of the text.
///
/// 3
public int LineCount
{
get
{
int temp = 0;
GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);
return temp;
}
}
///
/// The LineWrapMode property.
/// line wrap mode when the text lines over layout width.
///
/// 4
public LineWrapMode LineWrapMode
{
get
{
int temp;
if(GetProperty(TextLabel.Property.LINE_WRAP_MODE).Get(out temp) == false)
{
NUILog.Error("LineWrapMode get error!");
}
return (LineWrapMode)temp;
}
set
{
SetProperty(TextLabel.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue((int)value));
}
}
}
}