GetElement() static private method

static private GetElement ( Accessible accessible ) : Element
accessible Atspi.Accessible
return Element
Example #1
0
        public IElement [] GetColumnHeaders()
        {
            // TODO: would be nice if at-spi made this easier
            Accessible accessible = table.GetColumnHeader(0);

            // If that returned null, then maybe we have no
            // headers, so not going to query every single row
            if (accessible == null)
            {
                return(new Element [0]);
            }
            int count = ColumnCount;

            Element [] elements = new Element [count];
            elements [0] = Element.GetElement(accessible);
            for (int i = 1; i < count; i++)
            {
                accessible = table.GetColumnHeader(i);
                if (accessible != null)
                {
                    elements [i] = Element.GetElement(accessible);
                }
            }
            return(elements);
        }
Example #2
0
        private void OnChildRemoved(Accessible sender, Accessible child)
        {
            Element childElement = Element.GetElement(child, false);

            if (childElement == null)
            {
                return;
            }
            Element parentElement;

            parentElement = childElement.Parent as Element;
            if (parentElement != null)
            {
                if (parentElement.extraChildren.IndexOf(childElement) != -1)
                {
                    parentElement.extraChildren.Remove(childElement);
                }
                RaiseStructureChangedEvent(parentElement, StructureChangeType.ChildrenInvalidated);
                RaiseStructureChangedEvent(parentElement, StructureChangeType.ChildRemoved);
            }
            if (sender == Desktop.Instance || sender.Role == Role.Application)
            {
                OnRootElementsChanged();
            }
        }
Example #3
0
        // This is only here to implement AutomationElementFromPoint;
        // it doesn't really work.
        public IElement GetElementFromHandle(IntPtr handle)
        {
            var win = Gdk.Window.ForeignNew((uint)handle);

            if (win == null)
            {
                return(null);
            }
            int x, y, width, height, depth;

            win.GetGeometry(out x, out y, out width, out height, out depth);
            win.GetOrigin(out x, out y);
            foreach (IElement element in GetRootElements())
            {
                Component component = ((Element)element).Accessible.QueryComponent();
                if (component != null)
                {
                    BoundingBox extents = component.GetExtents(CoordType.Screen);
                    if (SizeFits(extents, x, y, width, height))
                    {
                        Accessible ret = component.GetAccessibleAtPoint(x, y, CoordType.Screen);
                        if (ret == null)
                        {
                            return(element);
                        }
                        return(Element.GetElement(ret));
                    }
                }
            }
            return(null);
        }
Example #4
0
        private void OnChildAdded(Accessible sender, Accessible child)
        {
            if (sender.Role == Role.DesktopFrame)
            {
                foreach (Accessible frame in child.Children)
                {
                    OnChildAdded(child, frame);
                }
                return;
            }

            IElement childElement = Element.GetElement(child, true);

            if (childElement == null)
            {
                return;
            }
            if (childElement.Parent != null)
            {
                RaiseStructureChangedEvent(childElement.Parent, StructureChangeType.ChildrenInvalidated);
            }
            if (child.Role != Role.Application)
            {
                RaiseStructureChangedEvent(childElement, StructureChangeType.ChildAdded);
            }
            if (child.Role == Role.Frame)
            {
                RaiseAutomationEvent(child, WindowPattern.WindowOpenedEvent);
            }
            if (sender.Role == Role.Application)
            {
                OnRootElementsChanged();
            }
        }
Example #5
0
        internal static void RaiseFocusChangedEvent(Accessible accessible)
        {
            IElement element = Element.GetElement(accessible);
            IElement parent  = Element.GetElement(accessible.Parent);

            RaiseFocusChangedEvent(parent, element);
        }
Example #6
0
 public IElement GetFocusedElement()
 {
     if (focusedAccessible == null)
     {
         focusedAccessible = FindFocusedAccessible(Desktop.Instance);
     }
     return(Element.GetElement(focusedAccessible));
 }
Example #7
0
        internal TreeItemElement GetTreeItemElement(int row)
        {
            EnsureRowsSize(row);
            if (rows [row] != null)
            {
                return(rows [row] as TreeItemElement);
            }
            Accessible      cell = table.GetAccessibleAt(row, 0);
            TreeItemElement e    = Element.GetElement(cell, this, row) as TreeItemElement;

            rows [row] = e;
            return(e);
        }
Example #8
0
 private void SetParentCell()
 {
     Relation [] relations = accessible.RelationSet;
     foreach (Relation relation in relations)
     {
         if (relation.Type == RelationType.NodeChildOf)
         {
             parentCell = Element.GetElement(relation.Targets [0]) as TreeItemElement;
             break;
         }
     }
     ancestors = new List <TreeItemElement> ();
     for (TreeItemElement ancestor = parentCell; ancestor != null; ancestor = ancestor.parentCell)
     {
         ancestors.Add(ancestor);
     }
 }
Example #9
0
        public IElement [] GetSelection()
        {
            int nSelectedChildren = AtspiSelection.NSelectedChildren;

            if (nSelectedChildren < 0)
            {
                nSelectedChildren = 0;
            }
            IElement [] currentSelection = new IElement [nSelectedChildren];
            Selection   selection        = AtspiSelection;

            for (int i = 0; i < nSelectedChildren; i++)
            {
                currentSelection [i] = Element.GetElement(selection.GetSelectedChild(i));
            }
            return(currentSelection);
        }
Example #10
0
        public IElement [] GetRootElements()
        {
            List <Accessible> elements = new List <Accessible> ();

            foreach (Accessible element in Desktop.Instance.Children)
            {
                foreach (Accessible child in element.Children)
                {
                    if (Element.GetElement(child).Parent == null)
                    {
                        elements.Add(child);
                    }
                }
            }
            IElement [] ret = new IElement [elements.Count];
            int         i   = 0;

            foreach (Accessible accessible in elements)
            {
                ret [i++] = Element.GetElement(accessible);
            }
            Log.Debug("AtspiUiaSource: GetRootElements count will be: " + ret.Length);
            return(ret);
        }
Example #11
0
 public TreeItemElement(Accessible accessible) : base(accessible)
 {
     tableElement = Element.GetElement(accessible.Parent) as TableElement;
     this.row     = tableElement.table.GetRowAtIndex(accessible.IndexInParent);;
     SetParentCell();
 }
Example #12
0
 public IElement GetItem(int row, int column)
 {
     return(Element.GetElement(table.GetAccessibleAt(row, column)));
 }
Example #13
0
 public IElement GetEnclosingElement()
 {
     return(Element.GetElement(accessible));
 }
Example #14
0
        internal static void RaisePropertyChangedEvent(Accessible accessible, AutomationProperty property, object oldValue, object newValue)
        {
            IElement element = Element.GetElement(accessible);

            RaisePropertyChangedEvent(element, property, oldValue, newValue);
        }
Example #15
0
        internal static void RaiseAutomationEvent(Accessible accessible, AutomationEvent eventId)
        {
            IElement element = Element.GetElement(accessible);

            RaiseAutomationEvent(element, eventId);
        }