Package virtualBuffers :: Module adobeFlash
[hide private]
[frames] | no frames]

Source Code for Module virtualBuffers.adobeFlash

 1  from . import VirtualBuffer, VirtualBufferTextInfo 
 2  import controlTypes 
 3  import NVDAObjects.IAccessible 
 4  import winUser 
 5  import IAccessibleHandler 
 6  import oleacc 
 7  from logHandler import log 
 8  import textInfos 
 9   
10 -class AdobeFlash_TextInfo(VirtualBufferTextInfo):
11
12 - def _normalizeControlField(self,attrs):
13 accRole=attrs['IAccessible::role'] 14 if accRole.isdigit(): 15 accRole=int(accRole) 16 else: 17 accRole = accRole.lower() 18 role=IAccessibleHandler.IAccessibleRolesToNVDARoles.get(accRole,controlTypes.ROLE_UNKNOWN) 19 20 states=set(IAccessibleHandler.IAccessibleStatesToNVDAStates[x] for x in [1<<y for y in xrange(32)] if int(attrs.get('IAccessible::state_%s'%x,0)) and x in IAccessibleHandler.IAccessibleStatesToNVDAStates) 21 22 attrs['role']=role 23 attrs['states']=states 24 return super(AdobeFlash_TextInfo, self)._normalizeControlField(attrs)
25
26 -class AdobeFlash(VirtualBuffer):
27 TextInfo = AdobeFlash_TextInfo 28
29 - def __init__(self,rootNVDAObject):
30 super(AdobeFlash,self).__init__(rootNVDAObject,backendName="adobeFlash")
31
32 - def __contains__(self,obj):
33 return winUser.isDescendantWindow(self.rootNVDAObject.windowHandle, obj.windowHandle)
34
35 - def _get_isAlive(self):
36 if self.isLoading: 37 return True 38 root=self.rootNVDAObject 39 if not root: 40 return False 41 if not winUser.isWindow(root.windowHandle) or root.role == controlTypes.ROLE_UNKNOWN: 42 return False 43 return True
44
45 - def getNVDAObjectFromIdentifier(self, docHandle, ID):
47
48 - def getIdentifierFromNVDAObject(self,obj):
49 return obj.windowHandle, obj.event_childID
50
51 - def _searchableAttribsForNodeType(self,nodeType):
52 if nodeType=="formField": 53 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_PUSHBUTTON,oleacc.ROLE_SYSTEM_RADIOBUTTON,oleacc.ROLE_SYSTEM_CHECKBUTTON,oleacc.ROLE_SYSTEM_COMBOBOX,oleacc.ROLE_SYSTEM_LIST,oleacc.ROLE_SYSTEM_TEXT]} 54 elif nodeType=="list": 55 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_LIST]} 56 elif nodeType=="listItem": 57 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_LISTITEM]} 58 elif nodeType=="button": 59 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_PUSHBUTTON]} 60 elif nodeType=="edit": 61 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_TEXT]} 62 elif nodeType=="radioButton": 63 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_RADIOBUTTON]} 64 elif nodeType=="comboBox": 65 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_COMBOBOX]} 66 elif nodeType=="checkBox": 67 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_CHECKBUTTON]} 68 elif nodeType=="graphic": 69 attrs={"IAccessible::role":[oleacc.ROLE_SYSTEM_GRAPHIC]} 70 elif nodeType=="focusable": 71 attrs={"IAccessible::state_%s"%oleacc.STATE_SYSTEM_FOCUSABLE:[1]} 72 else: 73 return None 74 return attrs
75
76 - def _activateNVDAObject(self, obj):
77 try: 78 obj.doAction() 79 return 80 except: 81 pass 82 83 log.debugWarning("could not programmatically activate field, trying mouse") 84 l=obj.location 85 if not l: 86 log.debugWarning("no location for field") 87 return 88 x=(l[0]+l[2]/2) 89 y=l[1]+(l[3]/2) 90 oldX,oldY=winUser.getCursorPos() 91 winUser.setCursorPos(x,y) 92 winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None) 93 winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None) 94 winUser.setCursorPos(oldX,oldY)
95