/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * 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. */ using System; namespace ElmSharp.Accessible { /// /// The delegate to define how to provide informations for or . /// /// The sender obj. /// Return information for Name or Description. public delegate string AccessibleInfoProvider (AccessibleObject obj); /// /// It's a base abstract class for . /// It provides available definitions for the screen reader, such as , , , etc. /// There's many the relationship between two accessible objects, like , , , , etc. /// public abstract class AccessibleObject : EvasObject, IAccessibleObject { AccessibleInfoProvider _nameProvider; AccessibleInfoProvider _descriptionProvider; Interop.Elementary.Elm_Atspi_Reading_Info_Cb _nameProviderInternal; Interop.Elementary.Elm_Atspi_Reading_Info_Cb _descriptionProviderInternal; /// /// Gets or sets the reading information types of an accessible object. /// ReadingInfoType IAccessibleObject.ReadingInfoType { get { return (ReadingInfoType)Interop.Elementary.elm_atspi_accessible_reading_info_type_get(RealHandle); } set { Interop.Elementary.elm_atspi_accessible_reading_info_type_set(RealHandle, (Interop.Elementary.Elm_Accessible_Reading_Info_Type)value); } } /// /// Gets or sets the role of the object in accessibility domain. /// AccessRole IAccessibleObject.Role { get { return (AccessRole)Interop.Elementary.elm_atspi_accessible_role_get(RealHandle); } set { Interop.Elementary.elm_atspi_accessible_role_set(RealHandle, (Interop.Elementary.Elm_Atspi_Role)value); } } /// /// Gets or sets highlightable of given widget. /// bool IAccessibleObject.CanHighlight { get { return Interop.Elementary.elm_atspi_accessible_can_highlight_get(RealHandle); } set { Interop.Elementary.elm_atspi_accessible_can_highlight_set(RealHandle, value); } } /// /// Gets or sets the translation domain of "name" and "description" properties. /// Translation domain should be set if application wants to support i18n for accessibily "name" and "description" properties. /// When translation domain is set values of "name" and "description" properties will be translated with dgettext function using current translation domain as "domainname" parameter. /// It is application developer responsibility to ensure that translation files are loaded and binded to translation domain when accessibility is enabled. /// string IAccessibleObject.TranslationDomain { get { return Interop.Elementary.elm_atspi_accessible_translation_domain_get(RealHandle); } set { Interop.Elementary.elm_atspi_accessible_translation_domain_set(RealHandle, value); } } /// /// Gets or sets an accessible name of the object. /// string IAccessibleObject.Name { get { return Interop.Elementary.elm_atspi_accessible_name_get(RealHandle); } set { Interop.Elementary.elm_atspi_accessible_name_set(RealHandle, value); } } /// /// Gets or sets contextual information about object. /// string IAccessibleObject.Description { get { return Interop.Elementary.elm_atspi_accessible_description_get(RealHandle); } set { Interop.Elementary.elm_atspi_accessible_description_set(RealHandle, value); } } /// /// Gets or sets the delegate for . /// AccessibleInfoProvider IAccessibleObject.NameProvider { get { return _nameProvider; } set { if (_nameProviderInternal == null) { _nameProviderInternal = (data, obj) => _nameProvider(this); } if (value == null) { _nameProvider = null; Interop.Elementary.elm_atspi_accessible_name_cb_set(RealHandle, null, IntPtr.Zero); } else { _nameProvider = new AccessibleInfoProvider(value); Interop.Elementary.elm_atspi_accessible_name_cb_set(RealHandle, _nameProviderInternal, IntPtr.Zero); } } } /// /// Gets or sets the delegate for . /// AccessibleInfoProvider IAccessibleObject.DescriptionProvider { get { return _descriptionProvider; } set { if (_descriptionProviderInternal == null) { _descriptionProviderInternal = (data, obj) => _descriptionProvider(this); } if (value == null) { _descriptionProvider = null; Interop.Elementary.elm_atspi_accessible_description_cb_set(RealHandle, null, IntPtr.Zero); } else { _descriptionProvider = new AccessibleInfoProvider(value); Interop.Elementary.elm_atspi_accessible_description_cb_set(RealHandle, _descriptionProviderInternal, IntPtr.Zero); } } } /// /// Creates and initializes a new instance of the AccessibleObject class with parent EvasObject class parameter. /// /// Parent EvasObject class public AccessibleObject(EvasObject parent) : base(parent) { } /// /// Creates and initializes a new instance of the AccessibleObject class. /// public AccessibleObject() : base() { } /// /// Defines the relationship between two accessible objects. /// Relationships can be queried by Assistive Technology clients to provide customized feedback, improving overall user experience. /// AppendRelation API is asymmetric, which means that appending, for example, relation from object A to B, do not append relation from object B to object A. /// /// The relationship between source object and target object of a given type. void IAccessibleObject.AppendRelation(IAccessibleRelation relation) { if (relation.Target == null) throw new ArgumentException("Target of Accessibility relation can not be null"); Interop.Elementary.elm_atspi_accessible_relationship_append(RealHandle, relation.Type, relation.Target.Handle); } /// /// Removes the relationship between two accessible objects. /// /// The relationship between source object and target object of a given type. void IAccessibleObject.RemoveRelation(IAccessibleRelation relation) { if (relation.Target == null) throw new ArgumentException("Target of Accessibility relation can not be null"); Interop.Elementary.elm_atspi_accessible_relationship_remove(RealHandle, relation.Type, relation.Target.Handle); } /// /// Highlights accessible widget. /// public void Highlight() { Interop.Elementary.elm_atspi_component_highlight_grab(RealHandle); } /// /// Clears highlight of accessible widget. /// public void Unhighlight() { Interop.Elementary.elm_atspi_component_highlight_clear(RealHandle); } } }