Merge "[Slider] Add Property IndicatorVisibleMode" into tizen
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / AccessibleObject.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18
19 namespace ElmSharp.Accessible
20 {
21
22     public delegate string AccessibleInfoProvider (AccessibleObject obj);
23
24     public abstract class AccessibleObject : EvasObject, IAccessibleObject
25     {
26
27         AccessibleInfoProvider _nameProvider;
28         AccessibleInfoProvider _descriptionProvider;
29
30         Interop.Elementary.Elm_Atspi_Reading_Info_Cb _nameProviderInternal;
31         Interop.Elementary.Elm_Atspi_Reading_Info_Cb _descriptionProviderInternal;
32
33         ReadingInfoType IAccessibleObject.ReadingInfoType
34         {
35             get
36             {
37                 return (ReadingInfoType)Interop.Elementary.elm_atspi_accessible_reading_info_type_get(Handle);
38             }
39             set
40             {
41                 Interop.Elementary.elm_atspi_accessible_reading_info_type_set(Handle,
42                         (Interop.Elementary.Elm_Accessible_Reading_Info_Type)value);
43             }
44         }
45         AccessRole IAccessibleObject.Role
46         {
47             get
48             {
49                 return (AccessRole)Interop.Elementary.elm_atspi_accessible_role_get(Handle);
50             }
51             set
52             {
53                 Interop.Elementary.elm_atspi_accessible_role_set(Handle,
54                         (Interop.Elementary.Elm_Atspi_Role)value);
55             }
56         }
57         bool IAccessibleObject.CanHighlight
58         {
59             get
60             {
61                 return Interop.Elementary.elm_atspi_accessible_can_highlight_get(Handle);
62             }
63             set
64             {
65                 Interop.Elementary.elm_atspi_accessible_can_highlight_set(Handle, value);
66             }
67         }
68         string IAccessibleObject.TranslationDomain
69         {
70             get
71             {
72                 return Interop.Elementary.elm_atspi_accessible_translation_domain_get(Handle);
73             }
74             set
75             {
76                 Interop.Elementary.elm_atspi_accessible_translation_domain_set(Handle, value);
77             }
78         }
79         string IAccessibleObject.Name
80         {
81             get
82             {
83                 return Interop.Elementary.elm_atspi_accessible_name_get(Handle);
84             }
85             set
86             {
87                 Interop.Elementary.elm_atspi_accessible_name_set(Handle, value);
88             }
89         }
90         string IAccessibleObject.Description
91         {
92             get
93             {
94                 return Interop.Elementary.elm_atspi_accessible_description_get(Handle);
95             }
96             set
97             {
98                 Interop.Elementary.elm_atspi_accessible_description_set(Handle, value);
99             }
100         }
101
102         AccessibleInfoProvider IAccessibleObject.NameProvider
103         {
104             get
105             {
106                 return _nameProvider;
107             }
108
109             set
110             {
111                 if (_nameProviderInternal == null)
112                 {
113                     _nameProviderInternal = (data, obj) => _nameProvider(this);
114                 }
115                 if (value == null)
116                 {
117                     _nameProvider = null;
118                     Interop.Elementary.elm_atspi_accessible_name_cb_set(Handle, null, IntPtr.Zero);
119                 }
120                 else
121                 {
122                     _nameProvider = new AccessibleInfoProvider(value);
123                     Interop.Elementary.elm_atspi_accessible_name_cb_set(Handle, _nameProviderInternal, IntPtr.Zero);
124                 }
125             }
126         }
127         AccessibleInfoProvider IAccessibleObject.DescriptionProvider
128         {
129             get
130             {
131                 return _descriptionProvider;
132             }
133
134             set
135             {
136                 if (_descriptionProviderInternal == null)
137                 {
138                     _descriptionProviderInternal = (data, obj) => _descriptionProvider(this);
139                 }
140                 if (value == null)
141                 {
142                     _descriptionProvider = null;
143                     Interop.Elementary.elm_atspi_accessible_description_cb_set(Handle, null, IntPtr.Zero);
144                 }
145                 else
146                 {
147                     _descriptionProvider = new AccessibleInfoProvider(value);
148                     Interop.Elementary.elm_atspi_accessible_description_cb_set(Handle, _descriptionProviderInternal, IntPtr.Zero);
149                 }
150             }
151         }
152
153         public AccessibleObject(EvasObject parent) : base(parent)
154         {
155         }
156
157         public AccessibleObject() : base()
158         {
159         }
160
161         void IAccessibleObject.AppendRelation(IAccessibleRelation relation)
162         {
163             if (relation.Target == null) throw new ArgumentException("Target of Accessibility relation can not be null");
164             Interop.Elementary.elm_atspi_accessible_relationship_append(Handle, relation.Type, relation.Target.Handle);
165         }
166
167         void IAccessibleObject.RemoveRelation(IAccessibleRelation relation)
168         {
169             if (relation.Target == null) throw new ArgumentException("Target of Accessibility relation can not be null");
170             Interop.Elementary.elm_atspi_accessible_relationship_remove(Handle, relation.Type, relation.Target.Handle);
171         }
172
173         public void Highlight()
174         {
175             Interop.Elementary.elm_atspi_component_highlight_grab(Handle);
176         }
177
178         public void Unhighlight()
179         {
180             Interop.Elementary.elm_atspi_component_highlight_clear(Handle);
181         }
182     }
183 }