2008-08-21 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / accessible.py
index 5853778..093ac03 100644 (file)
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import interfaces
-from base import BaseProxy
+from base import BaseProxy, Enum
 from factory import create_accessible, add_accessible_class
-from stateset import StateSet, _marshal_state_set
+from state import StateSet, _marshal_state_set
 from relation import _marshal_relation_set
+from role import Role
 
 __all__ = [
+          "LOCALE_TYPE",
+          "LOCALE_TYPE_COLLATE",
+          "LOCALE_TYPE_CTYPE",
+          "LOCALE_TYPE_MESSAGES",
+          "LOCALE_TYPE_MONETARY",
+          "LOCALE_TYPE_NUMERIC",
+          "LOCALE_TYPE_TIME",
+          "BoundingBox",
           "Accessible",
          ]
 
 #------------------------------------------------------------------------------
 
+class LOCALE_TYPE(Enum):
+    _enum_lookup = {
+        0:'LOCALE_TYPE_MESSAGES',
+        1:'LOCALE_TYPE_COLLATE',
+        2:'LOCALE_TYPE_CTYPE',
+        3:'LOCALE_TYPE_MONETARY',
+        4:'LOCALE_TYPE_NUMERIC',
+        5:'LOCALE_TYPE_TIME',
+    }
+
+LOCALE_TYPE_COLLATE = LOCALE_TYPE(1)
+LOCALE_TYPE_CTYPE = LOCALE_TYPE(2)
+LOCALE_TYPE_MESSAGES = LOCALE_TYPE(0)
+LOCALE_TYPE_MONETARY = LOCALE_TYPE(3)
+LOCALE_TYPE_NUMERIC = LOCALE_TYPE(4)
+LOCALE_TYPE_TIME = LOCALE_TYPE(5)
+
+#------------------------------------------------------------------------------
+
+class BoundingBox(list):
+    def __new__(cls, x, y, width, height):
+        return list.__new__(cls, (x, y, width, height))
+    def __init__(self, x, y, width, height):
+        list.__init__(self, (x, y, width, height))
+    
+    def _get_x(self):
+        return self[0]
+    def _set_x(self, val):
+        self[0] = val
+    x = property(fget=_get_x, fset=_set_x)
+    def _get_y(self):
+        return self[1]
+    def _set_y(self, val):
+        self[1] = val
+    y = property(fget=_get_y, fset=_set_y)
+    def _get_width(self):
+        return self[2]
+    def _set_width(self, val):
+        self[2] = val
+    width = property(fget=_get_width, fset=_set_width)
+    def _get_height(self):
+        return self[3]
+    def _set_height(self, val):
+        self[3] = val
+    height = property(fget=_get_height, fset=_set_height)
+
+#------------------------------------------------------------------------------
+
 class Accessible(BaseProxy):
     """
     The base interface which is implemented by all accessible objects.
@@ -31,6 +88,12 @@ class Accessible(BaseProxy):
     'children' and position in the accessible-object hierarchy,
     whether or not they actually have children.
     """
+
+    def __len__(self):
+           return self.getChildCount()
+
+    def __getitem__(self, index):
+           return self.getChildAtIndex(index)
     
     def getApplication(self):
         """
@@ -43,7 +106,7 @@ class Accessible(BaseProxy):
                                 self._app_name,
                                 application_root,
                                 interfaces.ATSPI_APPLICATION,
-                                dbus_object=self._dbus_object)
+                                connection=self._cache._connection)
     
     def getAttributes(self):
         """
@@ -91,7 +154,7 @@ class Accessible(BaseProxy):
                                 self._app_name,
                                 path,
                                 interfaces.ATSPI_ACCESSIBLE,
-                                dbus_object=self._dbus_object)
+                                connection=self._cache._connection)
     
     def getIndexInParent(self):
         """
@@ -131,7 +194,7 @@ class Accessible(BaseProxy):
         @return : a Role indicating the type of UI role played by this
         object.
         """
-        return self.cached_data.role
+        return Role(self.cached_data.role)
     
     def getRoleName(self):
         """
@@ -199,7 +262,7 @@ class Accessible(BaseProxy):
                                         self._app_name,
                                         self.cached_data.parent,
                                         interfaces.ATSPI_ACCESSIBLE,
-                                        dbus_object=self._dbus_object)
+                                        connection=self._cache._connection)
 
     _parentDoc = \
         """