[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / AccessibleObject.cs
blob3a0e24896d3326ab27d1d45124718533d2b918cd
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
22 // Authors:
23 // Peter Dennis Bartok pbartok@novell.com
27 // NOT COMPLETE
29 using Accessibility;
30 using System.Drawing;
31 using System.Globalization;
32 using System.Reflection;
33 using System.Runtime.InteropServices;
35 namespace System.Windows.Forms {
36 [ComVisible(true)]
37 public class AccessibleObject : StandardOleMarshalObject, IReflect, IAccessible {
38 #region Private Variables
39 internal string name;
40 internal string value;
41 internal Control owner;
42 internal AccessibleRole role;
43 internal AccessibleStates state;
44 internal string default_action;
45 internal string description;
46 internal string help;
47 internal string keyboard_shortcut;
48 #endregion // Private Variables
50 #region Public Constructors
51 public AccessibleObject() {
52 this.owner = null;
53 this.value = null;
54 this.name = null;
55 this.role = AccessibleRole.Default;
56 this.default_action = null;
57 this.description = null;
58 this.help = null;
59 this.keyboard_shortcut = null;
60 this.state = AccessibleStates.None;
62 #endregion // Public Constructors
64 #region Private Constructors
65 internal AccessibleObject(Control owner) : this () {
66 this.owner=owner;
68 #endregion // Private Constructors
70 #region Public Instance Properties
71 public virtual Rectangle Bounds {
72 get {
73 return owner.Bounds;
77 public virtual string DefaultAction {
78 get {
79 return default_action;
83 public virtual string Description {
84 get {
85 return description;
89 public virtual string Help {
90 get {
91 return help;
95 public virtual string KeyboardShortcut {
96 get {
97 return keyboard_shortcut;
101 public virtual string Name {
102 get {
103 return name;
106 set {
107 name=value;
111 public virtual AccessibleObject Parent {
112 get {
113 if ((owner!=null) && (owner.Parent!=null)) {
114 return owner.Parent.AccessibilityObject;
116 return null;
120 public virtual AccessibleRole Role {
121 get {
122 return role;
126 public virtual AccessibleStates State {
127 get {
128 if (owner!=null) {
129 if (owner.Focused) {
130 state |= AccessibleStates.Focused;
132 if (owner.CanFocus) {
133 state |= AccessibleStates.Focusable;
135 if (!owner.Visible) {
136 state |= AccessibleStates.Invisible;
139 return state;
143 public virtual string Value {
144 get {
145 return this.value;
148 set {
149 this.value=value;
152 #endregion // Public Instance Properties
154 #region Public Instance Methods
155 public virtual void DoDefaultAction() {
156 if (owner!=null) {
157 owner.DoDefaultAction();
161 public virtual AccessibleObject GetChild(int index) {
162 if (owner!=null) {
163 if (index<owner.Controls.Count) {
164 return owner.Controls[index].AccessibilityObject;
167 return null;
170 public virtual int GetChildCount() {
171 if (owner!=null) {
172 return owner.Controls.Count;
174 return -1;
177 public virtual AccessibleObject GetFocused() {
178 if (owner.has_focus) {
179 return owner.AccessibilityObject;
182 return FindFocusControl(owner);
185 public virtual int GetHelpTopic (out string fileName)
187 fileName = null;
188 return -1;
191 public virtual AccessibleObject GetSelected() {
192 if ((state & AccessibleStates.Selected) != 0) {
193 return this;
196 return FindSelectedControl(owner);
199 public virtual AccessibleObject HitTest(int x, int y) {
200 Control result;
202 result = FindHittestControl(owner, x, y);
204 if (result != null) {
205 return result.AccessibilityObject;
208 return null;
211 public virtual AccessibleObject Navigate(AccessibleNavigation navdir) {
212 int index;
214 // I'm not throwing exceptions if an object doesn't exist in the specified direction
215 // Might not be too helpful to a blind dude trying to navigate. Instead we return
216 // our own object
218 if (owner.Parent != null) {
219 index = owner.Parent.Controls.IndexOf(owner);
220 } else {
221 index = -1;
224 switch (navdir) {
225 // Spatial navigation; limited to siblings
226 case AccessibleNavigation.Up: {
227 if (owner.Parent != null) {
228 for (int i=0; i<owner.Parent.Controls.Count; i++) {
229 if ((owner != owner.Parent.Controls[i]) && (owner.Parent.Controls[i].Top<owner.Top)) {
230 return owner.Parent.Controls[i].AccessibilityObject;
235 return owner.AccessibilityObject;
238 case AccessibleNavigation.Down: {
239 if (owner.Parent != null) {
240 for (int i=0; i<owner.Parent.Controls.Count; i++) {
241 if ((owner != owner.Parent.Controls[i]) && (owner.Parent.Controls[i].Top>owner.Bottom)) {
242 return owner.Parent.Controls[i].AccessibilityObject;
247 return owner.AccessibilityObject;
250 case AccessibleNavigation.Left: {
251 if (owner.Parent != null) {
252 for (int i=0; i<owner.Parent.Controls.Count; i++) {
253 if ((owner != owner.Parent.Controls[i]) && (owner.Parent.Controls[i].Left<owner.Left)) {
254 return owner.Parent.Controls[i].AccessibilityObject;
259 return owner.AccessibilityObject;
262 case AccessibleNavigation.Right: {
263 if (owner.Parent != null) {
264 for (int i=0; i<owner.Parent.Controls.Count; i++) {
265 if ((owner != owner.Parent.Controls[i]) && (owner.Parent.Controls[i].Left>owner.Right)) {
266 return owner.Parent.Controls[i].AccessibilityObject;
271 return owner.AccessibilityObject;
274 // Logical navigation
275 case AccessibleNavigation.Next: {
276 if (owner.Parent != null) {
277 if ((index+1)<owner.Parent.Controls.Count) {
278 return owner.Parent.Controls[index+1].AccessibilityObject;
279 } else {
280 return owner.Parent.Controls[0].AccessibilityObject;
282 } else {
283 return owner.AccessibilityObject;
287 case AccessibleNavigation.Previous: {
288 if (owner.Parent != null) {
289 if (index>0) {
290 return owner.Parent.Controls[index-1].AccessibilityObject;
291 } else {
292 return owner.Parent.Controls[owner.Parent.Controls.Count-1].AccessibilityObject;
294 } else {
295 return owner.AccessibilityObject;
299 case AccessibleNavigation.FirstChild: {
300 if (owner.Controls.Count>0) {
301 return owner.Controls[0].AccessibilityObject;
302 } else {
303 return owner.AccessibilityObject;
307 case AccessibleNavigation.LastChild: {
308 if (owner.Controls.Count>0) {
309 return owner.Controls[owner.Controls.Count-1].AccessibilityObject;
310 } else {
311 return owner.AccessibilityObject;
316 return owner.AccessibilityObject;
319 public virtual void Select(AccessibleSelection flags) {
320 if ((flags & AccessibleSelection.TakeFocus) != 0){
321 owner.Focus();
323 return;
325 #endregion // Public Instance Methods
327 #region Protected Instance Methods
328 protected void UseStdAccessibleObjects(IntPtr handle) {
331 protected void UseStdAccessibleObjects(IntPtr handle, int objid) {
332 UseStdAccessibleObjects(handle, 0);
334 #endregion // Protected Instance Methods
337 #region Internal Methods
338 internal static AccessibleObject FindFocusControl(Control parent) {
339 Control child;
341 if (parent != null) {
342 for (int i=0; i < parent.Controls.Count; i++) {
343 child = parent.Controls[i];
344 if ((child.AccessibilityObject.state & AccessibleStates.Focused) != 0) {
345 return child.AccessibilityObject;
348 if (child.Controls.Count>0) {
349 AccessibleObject result;
351 result = FindFocusControl(child);
352 if (result != null) {
353 return result;
358 return null;
361 internal static AccessibleObject FindSelectedControl(Control parent) {
362 Control child;
364 if (parent != null) {
365 for (int i=0; i < parent.Controls.Count; i++) {
366 child = parent.Controls[i];
367 if ((child.AccessibilityObject.state & AccessibleStates.Selected) != 0) {
368 return child.AccessibilityObject;
370 if (child.Controls.Count>0) {
371 AccessibleObject result;
373 result = FindSelectedControl(child);
374 if (result != null) {
375 return result;
380 return null;
383 internal static Control FindHittestControl(Control parent, int x, int y) {
384 Control child;
385 Point child_point;
386 Point hittest_point;
388 hittest_point = new Point(x, y);
390 child_point = parent.PointToClient(hittest_point);
391 if (parent.ClientRectangle.Contains(child_point)) {
392 return parent;
395 for (int i=0; i < parent.Controls.Count; i++) {
396 child=parent.Controls[i];
397 child_point = child.PointToClient(hittest_point);
398 if (child.ClientRectangle.Contains(child_point)) {
399 return child;
401 if (child.Controls.Count>0) {
402 Control result;
404 result = FindHittestControl(child, x, y);
405 if (result != null) {
406 return result;
410 return null;
412 #endregion // Internal Methods
414 #region IReflection Methods and Properties
415 FieldInfo IReflect.GetField(String name, BindingFlags bindingAttr) {
416 throw new NotImplementedException();
419 FieldInfo[] IReflect.GetFields(BindingFlags bindingAttr) {
420 throw new NotImplementedException();
423 MemberInfo[] IReflect.GetMember(String name, BindingFlags bindingAttr) {
424 throw new NotImplementedException();
427 MemberInfo[] IReflect.GetMembers(BindingFlags bindingAttr) {
428 throw new NotImplementedException();
431 MethodInfo IReflect.GetMethod(String name, BindingFlags bindingAttr) {
432 throw new NotImplementedException();
435 MethodInfo IReflect.GetMethod(String name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers) {
436 throw new NotImplementedException();
439 MethodInfo[] IReflect.GetMethods(BindingFlags bindingAttr) {
440 throw new NotImplementedException();
443 PropertyInfo IReflect.GetProperty(String name, BindingFlags bindingAttr) {
444 throw new NotImplementedException();
447 PropertyInfo IReflect.GetProperty(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
448 throw new NotImplementedException();
451 PropertyInfo[] IReflect.GetProperties(BindingFlags bindingAttr) {
452 throw new NotImplementedException();
455 Object IReflect.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) {
456 throw new NotImplementedException();
459 Type IReflect.UnderlyingSystemType {
460 get {
461 throw new NotImplementedException();
464 #endregion // IReflection Methods and Properties
466 #region IAccessible Methods and Properties
467 void IAccessible.accDoDefaultAction(object childID) {
468 throw new NotImplementedException();
471 int IAccessible.accChildCount {
472 get {
473 throw new NotImplementedException();
477 object IAccessible.accFocus {
478 get {
479 throw new NotImplementedException();
483 object IAccessible.accHitTest(int xLeft, int yTop) {
484 throw new NotImplementedException();
487 void IAccessible.accLocation(out int pxLeft, out int pyTop, out int pcxWidth, out int pcyHeight, object childID) {
488 throw new NotImplementedException();
491 object IAccessible.accNavigate(int navDir, object childID) {
492 throw new NotImplementedException();
495 object IAccessible.accParent {
496 get {
497 throw new NotImplementedException();
501 void IAccessible.accSelect(int flagsSelect, object childID) {
502 throw new NotImplementedException();
505 object IAccessible.accSelection {
506 get {
507 throw new NotImplementedException();
511 object IAccessible.get_accChild(object childID) {
512 throw new NotImplementedException();
515 string IAccessible.get_accDefaultAction(object childID) {
516 throw new NotImplementedException();
519 string IAccessible.get_accDescription(object childID) {
520 throw new NotImplementedException();
523 string IAccessible.get_accHelp(object childID) {
524 throw new NotImplementedException();
527 int IAccessible.get_accHelpTopic(out string pszHelpFile,object childID) {
528 throw new NotImplementedException();
531 string IAccessible.get_accKeyboardShortcut(object childID) {
532 throw new NotImplementedException();
535 string IAccessible.get_accName(object childID) {
536 throw new NotImplementedException();
539 object IAccessible.get_accRole(object childID) {
540 throw new NotImplementedException();
543 object IAccessible.get_accState(object childID) {
544 throw new NotImplementedException();
547 string IAccessible.get_accValue(object childID) {
548 throw new NotImplementedException();
551 void IAccessible.set_accName(object childID, string newName) {
552 throw new NotImplementedException();
555 void IAccessible.set_accValue(object childID, string newValue) {
556 throw new NotImplementedException();
558 #endregion // IAccessible Methods and Properties