2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 namespace ElmSharp.Accessible
22 /// The delegate to define how to provide informations for <see cref="IAccessibleObject.Name"/> or <see cref="IAccessibleObject.Description"/>.
24 /// <param name="obj">The sender obj.</param>
25 /// <returns>Return information for Name or Description.</returns>
26 public delegate string AccessibleInfoProvider (AccessibleObject obj);
29 /// It's a base abstract class for <see cref="Widget"/>.
30 /// It provides available definitions for the screen reader, such as <see cref="IAccessibleObject.Name"/>, <see cref="IAccessibleObject.Description"/>, <see cref="IAccessibleObject.ReadingInfoType"/>, etc.
31 /// There's many the relationship between two accessible objects, like <see cref="ChildOf"/>, <see cref="ParentOf"/>, <see cref="FlowsTo"/>, <see cref="FlowsFrom"/>, etc.
33 public abstract class AccessibleObject : EvasObject, IAccessibleObject
36 AccessibleInfoProvider _nameProvider;
37 AccessibleInfoProvider _descriptionProvider;
39 Interop.Elementary.Elm_Atspi_Reading_Info_Cb _nameProviderInternal;
40 Interop.Elementary.Elm_Atspi_Reading_Info_Cb _descriptionProviderInternal;
43 /// Gets or sets the reading information types of an accessible object.
45 ReadingInfoType IAccessibleObject.ReadingInfoType
49 return (ReadingInfoType)Interop.Elementary.elm_atspi_accessible_reading_info_type_get(Handle);
53 Interop.Elementary.elm_atspi_accessible_reading_info_type_set(Handle,
54 (Interop.Elementary.Elm_Accessible_Reading_Info_Type)value);
59 /// Gets or sets the role of the object in accessibility domain.
61 AccessRole IAccessibleObject.Role
65 return (AccessRole)Interop.Elementary.elm_atspi_accessible_role_get(Handle);
69 Interop.Elementary.elm_atspi_accessible_role_set(Handle,
70 (Interop.Elementary.Elm_Atspi_Role)value);
75 /// Gets or sets highlightable of given widget.
77 bool IAccessibleObject.CanHighlight
81 return Interop.Elementary.elm_atspi_accessible_can_highlight_get(Handle);
85 Interop.Elementary.elm_atspi_accessible_can_highlight_set(Handle, value);
90 /// Gets or sets the translation domain of "name" and "description" properties.
91 /// Translation domain should be set if application wants to support i18n for accessibily "name" and "description" properties.
92 /// When translation domain is set values of "name" and "description" properties will be translated with dgettext function using current translation domain as "domainname" parameter.
93 /// It is application developer responsibility to ensure that translation files are loaded and binded to translation domain when accessibility is enabled.
95 string IAccessibleObject.TranslationDomain
99 return Interop.Elementary.elm_atspi_accessible_translation_domain_get(Handle);
103 Interop.Elementary.elm_atspi_accessible_translation_domain_set(Handle, value);
108 /// Gets or sets an accessible name of the object.
110 string IAccessibleObject.Name
114 return Interop.Elementary.elm_atspi_accessible_name_get(Handle);
118 Interop.Elementary.elm_atspi_accessible_name_set(Handle, value);
123 /// Gets or sets contextual information about object.
125 string IAccessibleObject.Description
129 return Interop.Elementary.elm_atspi_accessible_description_get(Handle);
133 Interop.Elementary.elm_atspi_accessible_description_set(Handle, value);
138 /// Gets or sets the delegate for <see cref="IAccessibleObject.Name"/>.
140 AccessibleInfoProvider IAccessibleObject.NameProvider
144 return _nameProvider;
149 if (_nameProviderInternal == null)
151 _nameProviderInternal = (data, obj) => _nameProvider(this);
155 _nameProvider = null;
156 Interop.Elementary.elm_atspi_accessible_name_cb_set(Handle, null, IntPtr.Zero);
160 _nameProvider = new AccessibleInfoProvider(value);
161 Interop.Elementary.elm_atspi_accessible_name_cb_set(Handle, _nameProviderInternal, IntPtr.Zero);
167 /// Gets or sets the delegate for <see cref = "IAccessibleObject.Description" />.
169 AccessibleInfoProvider IAccessibleObject.DescriptionProvider
173 return _descriptionProvider;
178 if (_descriptionProviderInternal == null)
180 _descriptionProviderInternal = (data, obj) => _descriptionProvider(this);
184 _descriptionProvider = null;
185 Interop.Elementary.elm_atspi_accessible_description_cb_set(Handle, null, IntPtr.Zero);
189 _descriptionProvider = new AccessibleInfoProvider(value);
190 Interop.Elementary.elm_atspi_accessible_description_cb_set(Handle, _descriptionProviderInternal, IntPtr.Zero);
196 /// Creates and initializes a new instance of the AccessibleObject class with parent EvasObject class parameter.
198 /// <param name="parent">Parent EvasObject class </param>
199 public AccessibleObject(EvasObject parent) : base(parent)
204 /// Creates and initializes a new instance of the AccessibleObject class.
206 public AccessibleObject() : base()
211 /// Defines the relationship between two accessible objects.
212 /// Relationships can be queried by Assistive Technology clients to provide customized feedback, improving overall user experience.
213 /// AppendRelation API is asymmetric, which means that appending, for example, relation <see cref="FlowsTo"/> from object A to B, do not append relation <see cref="FlowsFrom"/> from object B to object A.
215 /// <param name="relation">The relationship between source object and target object of a given type.</param>
216 void IAccessibleObject.AppendRelation(IAccessibleRelation relation)
218 if (relation.Target == null) throw new ArgumentException("Target of Accessibility relation can not be null");
219 Interop.Elementary.elm_atspi_accessible_relationship_append(Handle, relation.Type, relation.Target.Handle);
223 /// Removes the relationship between two accessible objects.
225 /// <param name="relation">The relationship between source object and target object of a given type.</param>
226 void IAccessibleObject.RemoveRelation(IAccessibleRelation relation)
228 if (relation.Target == null) throw new ArgumentException("Target of Accessibility relation can not be null");
229 Interop.Elementary.elm_atspi_accessible_relationship_remove(Handle, relation.Type, relation.Target.Handle);
233 /// Highlights accessible widget.
235 public void Highlight()
237 Interop.Elementary.elm_atspi_component_highlight_grab(Handle);
241 /// Clears highlight of accessible widget.
243 public void Unhighlight()
245 Interop.Elementary.elm_atspi_component_highlight_clear(Handle);