/* * 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 information for or . /// /// The sender obj. /// Return information for name or description. /// preview public delegate string AccessibleInfoProvider (AccessibleObject obj); /// /// It's a base abstract class for . /// It provides the available definitions for the screen reader, such as , , , etc. /// There are many relationships between two accessible objects, like , , , , etc. /// /// preview 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 an 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 the highlightable of a 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 the "name" and "description" properties. /// The translation domain should be set if the application wants to support i18n for accessing the "name" and "description" properties. /// When the translation domain is set, values of the "name" and "description" properties will be translated with dgettext function using the current translation domain as "domainname" parameter. /// It is the application developers responsibility to ensure that translation files are loaded and binded to the 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 the contextual information about an 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 the parent EvasObject class parameter. /// /// Parent EvasObject class. /// preview protected AccessibleObject(EvasObject parent) : base(parent) { } /// /// Creates and initializes a new instance of the AccessibleObject class. /// /// preview protected AccessibleObject() { } /// /// Defines the relationship between two accessible objects. /// Relationships can be queried by the Assistive Technology clients to provide customized feedback, and improving overall user experience. /// AppendRelation API is asymmetric, which means that appending, for example, relation from object A to B, does not append the relation from object B to object A. /// /// The relationship between the 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 the 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 the accessible widget. /// /// preview public void Highlight() { Interop.Elementary.elm_atspi_component_highlight_grab(RealHandle); } /// /// Clears the highlight of the accessible widget. /// /// preview public void Unhighlight() { Interop.Elementary.elm_atspi_component_highlight_clear(RealHandle); } } }