using System;
using ElmSharp;
using ESize = ElmSharp.Size;
using ELayout = ElmSharp.Layout;
namespace Xamarin.Forms.Platform.Tizen.Native
{
///
/// The Text Helper contains functions that assist in working with text-able objects.
///
internal static class TextHelper
{
///
/// Gets the size of raw text block.
///
/// The with text part.
/// Returns the size of raw text block.
public static ESize GetRawTextBlockSize(EvasObject textable)
{
return GetElmTextPart(textable).TextBlockNativeSize;
}
///
/// Gets the size of formatted text block.
///
/// The with text part.
/// Returns the size of formatted text block.
public static ESize GetFormattedTextBlockSize(EvasObject textable)
{
return GetElmTextPart(textable).TextBlockFormattedSize;
}
///
/// Gets the ELM text part of evas object.
///
/// The with text part.
/// Throws exception when parameter isn't text-able object or doesn't have ELM text part.
/// Requested instance.
static EdjeTextPartObject GetElmTextPart(EvasObject textable)
{
ELayout widget = textable as ELayout;
if (widget == null)
{
throw new ArgumentException("textable should be ElmSharp.Layout", "textable");
}
EdjeTextPartObject textPart = widget.EdjeObject["elm.text"];
if (textPart == null)
{
throw new ArgumentException("There is no elm.text part", "textable");
}
return textPart;
}
}
}