Ticket #228: 228-2.patch

File 228-2.patch, 78.7 KB (added by orcauser, 11 months ago)
  • source/NVDAObjects/IAccessible/__init__.py

    # Bazaar merge directive format 2 (Bazaar 0.90)
    # revision_id: mhameed@src.gnome.org-20110617124746-cufp3o7kxf13vd8x
    # target_branch: http://bzr.nvaccess.org/nvda/main/
    # testament_sha1: d29a9fb6a717ed03c0d9e3a57324676dd7020200
    # timestamp: 2011-06-18 08:38:17 +0100
    # base_revision_id: mick@kulgan.net-20110618071115-cezi1vx8u8na23rs
    # 
    # Begin patch
    === modified file 'source/NVDAObjects/IAccessible/__init__.py'
     
    11#NVDAObjects/IAccessible.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    11731173                if self in api.getFocusAncestors(): 
    11741174                        return 
    11751175                speech.cancelSpeech() 
    1176                 speech.speakObject(self, reason=speech.REASON_FOCUS) 
     1176                speech.speakObject(self, reason=controlTypes.REASON_FOCUS) 
    11771177                for child in self.recursiveDescendants: 
    11781178                        if controlTypes.STATE_FOCUSABLE in child.states: 
    1179                                 speech.speakObject(child, reason=speech.REASON_FOCUS) 
     1179                                speech.speakObject(child, reason=controlTypes.REASON_FOCUS) 
    11801180 
    11811181        def event_caret(self): 
    11821182                super(IAccessible, self).event_caret() 
     
    12271227                        h=hash(child) 
    12281228                        if h not in hashList: 
    12291229                                hashList.append(h) 
    1230                                 speech.speakObject(child,reason=speech.REASON_FOCUS) 
     1230                                speech.speakObject(child,reason=controlTypes.REASON_FOCUS) 
    12311231                                child.speakDescendantObjects(hashList=hashList) 
    12321232                        child=child.next 
    12331233 
     
    13761376        def event_show(self): 
    13771377                # TODO: Abstract this somehow. 
    13781378                if (config.conf["presentation"]["reportTooltips"] and (self.IAccessibleRole==oleacc.ROLE_SYSTEM_TOOLTIP)) or (config.conf["presentation"]["reportHelpBalloons"] and (self.IAccessibleRole==oleacc.ROLE_SYSTEM_HELPBALLOON)): 
    1379                         speech.speakObject(self,reason=speech.REASON_FOCUS) 
     1379                        speech.speakObject(self,reason=controlTypes.REASON_FOCUS) 
    13801380                        # TODO: Don't use getBrailleTextForProperties directly. 
    13811381                        braille.handler.message(braille.getBrailleTextForProperties(name=self.name, role=self.role)) 
    13821382 
     
    13881388        def speakDescendantObjects(self,hashList=None): 
    13891389                child=self.activeChild 
    13901390                if child: 
    1391                         speech.speakObject(child,reason=speech.REASON_FOCUS) 
     1391                        speech.speakObject(child,reason=controlTypes.REASON_FOCUS) 
    13921392 
    13931393class ComboBox(IAccessible): 
    13941394 
    13951395        def speakDescendantObjects(self,hashList=None): 
    13961396                child=self.activeChild 
    13971397                if child: 
    1398                         speech.speakObject(child,reason=speech.REASON_FOCUS) 
     1398                        speech.speakObject(child,reason=controlTypes.REASON_FOCUS) 
    13991399 
    14001400class Outline(IAccessible): 
    14011401 
    14021402        def speakDescendantObjects(self,hashList=None): 
    14031403                child=self.activeChild 
    14041404                if child: 
    1405                         speech.speakObject(child,reason=speech.REASON_FOCUS) 
     1405                        speech.speakObject(child,reason=controlTypes.REASON_FOCUS) 
    14061406 
    14071407class SysLinkClient(IAccessible): 
    14081408 
  • source/NVDAObjects/UIA/__init__.py

    === modified file 'source/NVDAObjects/UIA/__init__.py'
     
     1#NVDAObjects/UIA.py 
     2#A part of NonVisual Desktop Access (NVDA) 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
     4#This file is covered by the GNU General Public License. 
     5#See the file COPYING for more details. 
     6 
    17from ctypes.wintypes import POINT 
    28from comtypes import COMError 
    39import weakref 
     
    500506        def event_valueChange(self): 
    501507                focusParent=api.getFocusObject().parent 
    502508                if self==focusParent: 
    503                         speech.speakObjectProperties(self,value=True,reason=speech.REASON_CHANGE) 
     509                        speech.speakObjectProperties(self,value=True,reason=controlTypes.REASON_CHANGE) 
    504510                else: 
    505511                        super(SensitiveSlider,self).event_valueChange() 
    506512 
  • source/NVDAObjects/__init__.py

    === modified file 'source/NVDAObjects/__init__.py'
     
    11#NVDAObjects/baseType.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    726726        def reportFocus(self): 
    727727                """Announces this object in a way suitable such that it gained focus. 
    728728                """ 
    729                 speech.speakObject(self,reason=speech.REASON_FOCUS) 
     729                speech.speakObject(self,reason=controlTypes.REASON_FOCUS) 
    730730 
    731731        def event_typedCharacter(self,ch): 
    732732                speech.speakTypedCharacters(ch) 
     
    768768 
    769769        def event_stateChange(self): 
    770770                if self is api.getFocusObject(): 
    771                         speech.speakObjectProperties(self,states=True, reason=speech.REASON_CHANGE) 
     771                        speech.speakObjectProperties(self,states=True, reason=controlTypes.REASON_CHANGE) 
    772772                braille.handler.handleUpdate(self) 
    773773 
    774774        def event_focusEntered(self): 
     
    776776                        speech.cancelSpeech() 
    777777                        return 
    778778                if self.isPresentableFocusAncestor: 
    779                         speech.speakObject(self,reason=speech.REASON_FOCUSENTERED) 
     779                        speech.speakObject(self,reason=controlTypes.REASON_FOCUSENTERED) 
    780780 
    781781        def event_gainFocus(self): 
    782782                """ 
     
    799799 
    800800        def event_valueChange(self): 
    801801                if self is api.getFocusObject(): 
    802                         speech.speakObjectProperties(self, value=True, reason=speech.REASON_CHANGE) 
     802                        speech.speakObjectProperties(self, value=True, reason=controlTypes.REASON_CHANGE) 
    803803                braille.handler.handleUpdate(self) 
    804804 
    805805        def event_nameChange(self): 
    806806                if self is api.getFocusObject(): 
    807                         speech.speakObjectProperties(self, name=True, reason=speech.REASON_CHANGE) 
     807                        speech.speakObjectProperties(self, name=True, reason=controlTypes.REASON_CHANGE) 
    808808                braille.handler.handleUpdate(self) 
    809809 
    810810        def event_descriptionChange(self): 
    811811                if self is api.getFocusObject(): 
    812                         speech.speakObjectProperties(self, description=True, reason=speech.REASON_CHANGE) 
     812                        speech.speakObjectProperties(self, description=True, reason=controlTypes.REASON_CHANGE) 
    813813                braille.handler.handleUpdate(self) 
    814814 
    815815        def event_caret(self): 
  • source/NVDAObjects/window/winword.py

    === modified file 'source/NVDAObjects/window/winword.py'
     
    11#appModules/winword.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    386386                info=self.makeTextInfo(textInfos.POSITION_CARET) 
    387387                if info._rangeObj.tables.count>0: 
    388388                        info.expand(textInfos.UNIT_LINE) 
    389                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     389                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    390390 
    391391        def script_nextRow(self,gesture): 
    392392                info=self.makeTextInfo("caret") 
     
    396396                if info._moveInTable(0,1): 
    397397                        info.updateCaret() 
    398398                        info.expand(textInfos.UNIT_CELL) 
    399                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     399                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    400400                else: 
    401401                        speech.speakMessage(_("edge of table")) 
    402402 
     
    408408                if info._moveInTable(0,-1): 
    409409                        info.updateCaret() 
    410410                        info.expand(textInfos.UNIT_CELL) 
    411                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     411                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    412412                else: 
    413413                        speech.speakMessage(_("edge of table")) 
    414414 
     
    420420                if info._moveInTable(1,0): 
    421421                        info.updateCaret() 
    422422                        info.expand(textInfos.UNIT_CELL) 
    423                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     423                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    424424                else: 
    425425                        speech.speakMessage(_("edge of table")) 
    426426 
     
    432432                if info._moveInTable(-1,0): 
    433433                        info.updateCaret() 
    434434                        info.expand(textInfos.UNIT_CELL) 
    435                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     435                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    436436                else: 
    437437                        speech.speakMessage(_("edge of table")) 
    438438 
  • source/api.py

    === modified file 'source/api.py'
     
    11#api.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    7878                        safetyCount+=1 
    7979                else: 
    8080                        try: 
    81                                 log.error("Never ending focus ancestry: last object: %s, %s, window class %s, application name %s"%(tempObj.name,controlTypes.speechRoleLabels[tempObj.role],tempObj.windowClassName,tempObj.appModule.appName)) 
     81                                log.error("Never ending focus ancestry: last object: %s, %s, window class %s, application name %s"%(tempObj.name,controlTypes.labels[tempObj.role],tempObj.windowClassName,tempObj.appModule.appName)) 
    8282                        except: 
    8383                                pass 
    8484                        tempObj=getDesktopObject() 
  • source/appModules/firefox.py

    === modified file 'source/appModules/firefox.py'
     
    11#appModules/firefox.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    1818                        if statusBar: 
    1919                                statusText = api.getStatusBarText(statusBar) 
    2020                                speech.cancelSpeech() 
    21                                 speech.speakMessage(controlTypes.speechStateLabels[controlTypes.STATE_BUSY]) 
     21                                speech.speakMessage(controlTypes.stateLabels[controlTypes.STATE_BUSY]) 
    2222                                speech.speakMessage(statusText) 
    2323                                return 
    2424                nextHandler() 
  • source/appModules/miranda32.py

    === modified file 'source/appModules/miranda32.py'
     
    11#appModules/miranda32.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    161161                gesture.send() 
    162162                if not isScriptWaiting(): 
    163163                        api.processPendingEvents() 
    164                         speech.speakObject(self,reason=speech.REASON_FOCUS) 
     164                        speech.speakObject(self,reason=controlTypes.REASON_FOCUS) 
    165165                        braille.handler.handleGainFocus(self) 
    166166 
    167167        __changeItemGestures = ( 
  • source/appModules/msimn.py

    === modified file 'source/appModules/msimn.py'
     
    11#appModules/msimn.py - Outlook Express appModule 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2010 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    8787                nameList=[] 
    8888                imageState=winUser.sendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12 
    8989                if imageState==5: 
    90                         nameList.append(controlTypes.speechStateLabels[controlTypes.STATE_COLLAPSED]) 
     90                        nameList.append(controlTypes.stateLabels[controlTypes.STATE_COLLAPSED]) 
    9191                elif imageState==6: 
    92                         nameList.append(controlTypes.speechStateLabels[controlTypes.STATE_EXPANDED]) 
     92                        nameList.append(controlTypes.stateLabels[controlTypes.STATE_EXPANDED]) 
    9393                if self.isUnread: 
    9494                        nameList.append(_("unread")) 
    9595                name=super(MessageListItem,self).name 
  • source/appModules/thunderbird.py

    === modified file 'source/appModules/thunderbird.py'
     
    11#appModules/thunderbird.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    2222                                except: 
    2323                                        # Fall back to reading the entire status bar. 
    2424                                        statusText = api.getStatusBarText(statusBar) 
    25                                 speech.speakMessage(controlTypes.speechStateLabels[controlTypes.STATE_BUSY]) 
     25                                speech.speakMessage(controlTypes.stateLabels[controlTypes.STATE_BUSY]) 
    2626                                speech.speakMessage(statusText) 
    2727                                return 
    2828                nextHandler() 
  • source/appModules/totalcmd.py

    === modified file 'source/appModules/totalcmd.py'
     
    11#appModules/totalcmd.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    4141                if self.name: 
    4242                        speakList=[] 
    4343                        if controlTypes.STATE_SELECTED in self.states: 
    44                                 speakList.append(controlTypes.speechStateLabels[controlTypes.STATE_SELECTED]) 
     44                                speakList.append(controlTypes.stateLabels[controlTypes.STATE_SELECTED]) 
    4545                        speakList.append(self.name.split("\\")[-1]) 
    4646                        speech.speakMessage(" ".join(speakList)) 
    4747                else: 
  • source/appModules/winamp.py

    === modified file 'source/appModules/winamp.py'
     
    11#appModules/winamp.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2010 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    115115                gesture.send() 
    116116                if not isScriptWaiting(): 
    117117                        api.processPendingEvents() 
    118                         speech.speakObject(self,reason=speech.REASON_FOCUS) 
     118                        speech.speakObject(self,reason=controlTypes.REASON_FOCUS) 
    119119 
    120120        def event_nameChange(self): 
    121121                return super(winampMainWindow,self).event_nameChange() 
  • source/braille.py

    === modified file 'source/braille.py'
     
    7373        ("zh-tw.ctb", _("Chinese (Taiwan, Mandarin)")), 
    7474) 
    7575 
    76 roleLabels = { 
     76labels = { 
    7777        controlTypes.ROLE_EDITABLETEXT: _("edt"), 
    7878        controlTypes.ROLE_LIST: _("lst"), 
    7979        controlTypes.ROLE_MENUBAR: _("mnubar"), 
     
    209209                textList.append(name) 
    210210        role = propertyValues.get("role") 
    211211        if role is not None: 
    212                 if name and role in speech.silentRolesOnFocus: 
     212                if name and role in controlTypes.ignoreRolesOnFocus: 
    213213                        roleText = None 
    214214                else: 
    215                         roleText = roleLabels.get(role, controlTypes.speechRoleLabels[role]) 
     215                        roleText = labels.get(role, controlTypes.labels[role]) 
    216216        else: 
    217217                role = propertyValues.get("_role") 
    218218                roleText = None 
    219219        value = propertyValues.get("value") 
    220         if value and role not in speech.silentValuesForRoles: 
     220        if value and role not in controlTypes.ignoreValuesForRoles: 
    221221                textList.append(value) 
    222222        states = propertyValues.get("states") 
    223223        if states: 
    224                 positiveStates = speech.processPositiveStates(role, states, speech.REASON_FOCUS, states) 
    225                 textList.extend(positiveStateLabels.get(state, controlTypes.speechStateLabels[state]) for state in positiveStates) 
    226                 negativeStates = speech.processNegativeStates(role, states, speech.REASON_FOCUS, None) 
    227                 textList.extend(negativeStateLabels.get(state, _("not %s") % controlTypes.speechStateLabels[state]) for state in negativeStates) 
     224                positiveStates = controlTypes.processPositiveStates(role, states, controlTypes.REASON_FOCUS, states) 
     225                textList.extend(positiveStateLabels.get(state, controlTypes.stateLabels[state]) for state in positiveStates) 
     226                negativeStates = controlTypes.processNegativeStates(role, states, controlTypes.REASON_FOCUS, None) 
     227                textList.extend(negativeStateLabels.get(state, _("not %s") % controlTypes.stateLabels[state]) for state in negativeStates) 
    228228        if roleText: 
    229229                textList.append(roleText) 
    230230        description = propertyValues.get("description") 
  • source/compoundDocuments.py

    === modified file 'source/compoundDocuments.py'
     
    22#A part of NonVisual Desktop Access (NVDA) 
    33#This file is covered by the GNU General Public License. 
    44#See the file COPYING for more details. 
    5 #Copyright (C) 2010 James Teh <jamie@jantrid.net> 
     5#Copyright (C) 2010-2011 James Teh <jamie@jantrid.net> 
    66 
    77import winUser 
    88import textInfos 
     
    388388                return eventHandler.lastQueuedFocusObject 
    389389 
    390390        def event_treeInterceptor_gainFocus(self): 
    391                 speech.speakObject(self.rootNVDAObject, reason=speech.REASON_FOCUS) 
     391                speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS) 
    392392                try: 
    393393                        info = self.makeTextInfo(textInfos.POSITION_SELECTION) 
    394394                except RuntimeError: 
  • source/controlTypes.py

    === modified file 'source/controlTypes.py'
     
     1#controlTypes.py 
     2#A part of NonVisual Desktop Access (NVDA) 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
     4#This file is covered by the GNU General Public License. 
     5#See the file COPYING for more details. 
    16 
    27ROLE_UNKNOWN=0 
    38ROLE_WINDOW=1 
     
    178183STATE_SORTED_DESCENDING=0x200000000 
    179184STATES_SORTED=frozenset([STATE_SORTED,STATE_SORTED_ASCENDING,STATE_SORTED_DESCENDING]) 
    180185 
    181 speechRoleLabels={ 
     186labels={ 
    182187        ROLE_UNKNOWN:_("unknown"), 
    183188        ROLE_WINDOW:_("window"), 
    184189        ROLE_TITLEBAR:_("title bar"), 
     
    323328        ROLE_CALENDAR:_("calendar"), 
    324329} 
    325330 
    326 speechStateLabels={ 
     331stateLabels={ 
    327332        STATE_UNAVAILABLE:_("unavailable"), 
    328333        STATE_FOCUSED:_("focused"), 
    329334        STATE_SELECTED:_("selected"), 
     
    359364        STATE_SORTED_ASCENDING:_("sorted ascending"), 
    360365        STATE_SORTED_DESCENDING:_("sorted descending"), 
    361366} 
     367 
     368ignoreRolesOnFocus=set([ 
     369        ROLE_PANE, 
     370        ROLE_ROOTPANE, 
     371        ROLE_FRAME, 
     372        ROLE_UNKNOWN, 
     373        ROLE_APPLICATION, 
     374        ROLE_TABLECELL, 
     375        ROLE_LISTITEM, 
     376        ROLE_MENUITEM, 
     377        ROLE_CHECKMENUITEM, 
     378        ROLE_TREEVIEWITEM, 
     379]) 
     380 
     381ignoreValuesForRoles=set([ 
     382        ROLE_CHECKBOX, 
     383        ROLE_RADIOBUTTON, 
     384        ROLE_LINK, 
     385        ROLE_MENUITEM, 
     386        ROLE_APPLICATION, 
     387]) 
     388 
     389# Reason constants, to determine why information is required, enables us to provide different information depending  
     390# on an object is being focused, the user specifically requested information via a query etc. 
     391REASON_FOCUS=1 
     392REASON_MOUSE=2 
     393REASON_QUERY=3 
     394REASON_CHANGE=4 
     395REASON_MESSAGE=5 
     396REASON_SAYALL=6 
     397REASON_CARET=7 
     398REASON_DEBUG=8 
     399REASON_ONLYCACHE=9 
     400REASON_FOCUSENTERED=10 
     401 
     402def processPositiveStates(role, states, reason, positiveStates): 
     403        positiveStates = positiveStates.copy() 
     404        # The user never cares about certain states. 
     405        if role==ROLE_EDITABLETEXT: 
     406                positiveStates.discard(STATE_EDITABLE) 
     407        if role!=ROLE_LINK: 
     408                positiveStates.discard(STATE_VISITED) 
     409        positiveStates.discard(STATE_SELECTABLE) 
     410        positiveStates.discard(STATE_FOCUSABLE) 
     411        positiveStates.discard(STATE_CHECKABLE) 
     412        if STATE_DRAGGING in positiveStates: 
     413                # It's obvious that the control is draggable if it's being dragged. 
     414                positiveStates.discard(STATE_DRAGGABLE) 
     415        if role == ROLE_COMBOBOX: 
     416                # Combo boxes inherently have a popup, so don't report it. 
     417                positiveStates.discard(STATE_HASPOPUP) 
     418        if reason == REASON_QUERY: 
     419                return positiveStates 
     420        positiveStates.discard(STATE_DEFUNCT) 
     421        positiveStates.discard(STATE_MODAL) 
     422        positiveStates.discard(STATE_FOCUSED) 
     423        positiveStates.discard(STATE_OFFSCREEN) 
     424        positiveStates.discard(STATE_INVISIBLE) 
     425        if reason != REASON_CHANGE: 
     426                positiveStates.discard(STATE_LINKED) 
     427                if role in (ROLE_LISTITEM, ROLE_TREEVIEWITEM, ROLE_MENUITEM, ROLE_TABLEROW) and STATE_SELECTABLE in states: 
     428                        positiveStates.discard(STATE_SELECTED) 
     429        if role != ROLE_EDITABLETEXT: 
     430                positiveStates.discard(STATE_READONLY) 
     431        if role == ROLE_CHECKBOX: 
     432                positiveStates.discard(STATE_PRESSED) 
     433        if role == ROLE_MENUITEM: 
     434                # The user doesn't usually care if a menu item is expanded or collapsed. 
     435                positiveStates.discard(STATE_COLLAPSED) 
     436                positiveStates.discard(STATE_EXPANDED) 
     437        return positiveStates 
     438 
     439def processNegativeStates(role, states, reason, negativeStates): 
     440        presentNegatives = set() 
     441        # Add the negative selected state if the control is selectable, 
     442        # but only if it is either focused or this is something other than a change event. 
     443        # The condition stops "not selected" from being presented in some broken controls 
     444        # when the state change for the previous focus is issued before the focus change. 
     445        if role in (ROLE_LISTITEM, ROLE_TREEVIEWITEM, ROLE_TABLEROW) and STATE_SELECTABLE in states and (reason != REASON_CHANGE or STATE_FOCUSED in states): 
     446                presentNegatives.add(STATE_SELECTED) 
     447        # Restrict "not checked" in a similar way to "not selected". 
     448        if (role in (ROLE_CHECKBOX, ROLE_RADIOBUTTON, ROLE_CHECKMENUITEM) or STATE_CHECKABLE in states)  and (STATE_HALFCHECKED not in states) and (reason != REASON_CHANGE or STATE_FOCUSED in states): 
     449                presentNegatives.add(STATE_CHECKED) 
     450        if reason == REASON_CHANGE: 
     451                # We want to present this state only if it is changing to negative. 
     452                presentNegatives.add(STATE_DROPTARGET) 
     453                # We were given states which have changed to negative. 
     454                # Return only those supplied negative states which should be presented; 
     455                # i.e. the states in both sets. 
     456                presentNegatives &= negativeStates 
     457                if STATES_SORTED & negativeStates and not STATES_SORTED & states: 
     458                        # If the object has just stopped being sorted, just report not sorted. 
     459                        # The user doesn't care how it was sorted before. 
     460                        presentNegatives.add(STATE_SORTED) 
     461                return presentNegatives 
     462        else: 
     463                # This is not a state change; only positive states were supplied. 
     464                # Return all negative states which should be presented, excluding the positive states. 
     465                return presentNegatives - states 
     466 
  • source/cursorManager.py

    === modified file 'source/cursorManager.py'
     
    11#cursorManager.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
     
    1717import speech 
    1818import config 
    1919import braille 
     20import controlTypes 
    2021 
    2122class CursorManager(baseObject.ScriptableObject): 
    2223        """ 
     
    7273                        info.move(unit,direction) 
    7374                self.selection=info 
    7475                info.expand(unit) 
    75                 speech.speakTextInfo(info,unit=unit,reason=speech.REASON_CARET) 
     76                speech.speakTextInfo(info,unit=unit,reason=controlTypes.REASON_CARET) 
    7677                if not oldInfo.isCollapsed: 
    7778                        speech.speakSelectionChange(oldInfo,self.selection) 
    7879 
     
    9394                        self.selection=info 
    9495                        speech.cancelSpeech() 
    9596                        info.move(textInfos.UNIT_LINE,1,endPoint="end") 
    96                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     97                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    9798                else: 
    9899                        wx.CallAfter(gui.messageBox,_('text "%s" not found')%text,_("Find Error"),wx.OK|wx.ICON_ERROR) 
    99100                CursorManager._lastFindText=text 
  • source/editableText.py

    === modified file 'source/editableText.py'
     
    22#A part of NonVisual Desktop Access (NVDA) 
    33#This file is covered by the GNU General Public License. 
    44#See the file COPYING for more details. 
    5 #Copyright (C) 2006-2010 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net> 
     5#Copyright (C) 2006-2011 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net> 
    66 
    77"""Common support for editable text. 
    88""" 
     
    1313import braille 
    1414import speech 
    1515import config 
     16import controlTypes 
    1617import eventHandler 
    1718from scriptHandler import isScriptWaiting 
    1819import textInfos 
     
    6566                        api.setReviewPosition(info.copy()) 
    6667                if speakUnit: 
    6768                        info.expand(speakUnit) 
    68                         speech.speakTextInfo(info, unit=speakUnit, reason=speech.REASON_CARET) 
     69                        speech.speakTextInfo(info, unit=speakUnit, reason=controlTypes.REASON_CARET) 
    6970 
    7071        def _caretMovementScriptHelper(self, gesture, unit): 
    7172                try: 
  • source/globalCommands.py

    === modified file 'source/globalCommands.py'
     
    22#A part of NonVisual Desktop Access (NVDA) 
    33#This file is covered by the GNU General Public License. 
    44#See the file COPYING for more details. 
    5 #Copyright (C) 2006-2010 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net>, Peter Vágner <peter.v@datagate.sk>, Aleksey Sadovoy <lex@onm.su>, Rui Batista<ruiandrebatista@gmail.com> 
     5#Copyright (C) 2006-2011 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net>, Peter Vágner <peter.v@datagate.sk>, Aleksey Sadovoy <lex@onm.su>, Rui Batista<ruiandrebatista@gmail.com> 
    66 
    77import time 
    88import tones 
     
    6565                        info=obj.makeTextInfo(textInfos.POSITION_FIRST) 
    6666                info.expand(textInfos.UNIT_LINE) 
    6767                if scriptHandler.getLastScriptRepeatCount()==0: 
    68                         speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET) 
     68                        speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET) 
    6969                else: 
    7070                        speech.speakSpelling(info.text) 
    7171        script_reportCurrentLine.__doc__=_("Reports the current line under the application cursor. Pressing this key twice will spell the current line") 
     
    287287                                        if api.copyToClip(text): 
    288288                                                speech.speakMessage(_("%s copied to clipboard")%text) 
    289289                else: 
    290                         speech.speakObject(curObject,reason=speech.REASON_QUERY) 
     290                        speech.speakObject(curObject,reason=controlTypes.REASON_QUERY) 
    291291        script_navigatorObject_current.__doc__=_("Reports the current navigator object. Pressing twice spells this information,and pressing three times Copies name and value of this  object to the clipboard") 
    292292 
    293293        def script_navigatorObject_currentDimensions(self,gesture): 
     
    317317                        pos=obj.makeTextInfo(textInfos.POSITION_FIRST) 
    318318                api.setReviewPosition(pos) 
    319319                speech.speakMessage(_("move to focus")) 
    320                 speech.speakObject(obj,reason=speech.REASON_QUERY) 
     320                speech.speakObject(obj,reason=controlTypes.REASON_QUERY) 
    321321        script_navigatorObject_toFocus.__doc__=_("Sets the navigator object to the current focus, and the review cursor to the position of the caret inside it, if possible.") 
    322322 
    323323        def script_navigatorObject_moveFocus(self,gesture): 
     
    336336                                return 
    337337                        info=review.copy() 
    338338                        info.expand(textInfos.UNIT_LINE) 
    339                         speech.speakTextInfo(info,reason=speech.REASON_CARET) 
     339                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET) 
    340340        script_navigatorObject_moveFocus.__doc__=_("Pressed once Sets the keyboard focus to the navigator object, pressed twice sets the system caret to the position of the review cursor") 
    341341 
    342342        def script_navigatorObject_parent(self,gesture): 
     
    348348                curObject=curObject.simpleParent if simpleReviewMode else curObject.parent 
    349349                if curObject is not None: 
    350350                        api.setNavigatorObject(curObject) 
    351                         speech.speakObject(curObject,reason=speech.REASON_QUERY) 
     351                        speech.speakObject(curObject,reason=controlTypes.REASON_QUERY) 
    352352                else: 
    353353                        speech.speakMessage(_("No parents")) 
    354354        script_navigatorObject_parent.__doc__=_("Moves the navigator object to the object containing it") 
     
    362362                curObject=curObject.simpleNext if simpleReviewMode else curObject.next 
    363363                if curObject is not None: 
    364364                        api.setNavigatorObject(curObject) 
    365                         speech.speakObject(curObject,reason=speech.REASON_QUERY) 
     365                        speech.speakObject(curObject,reason=controlTypes.REASON_QUERY) 
    366366                else: 
    367367                        speech.speakMessage(_("No next")) 
    368368        script_navigatorObject_next.__doc__=_("Moves the navigator object to the next object") 
     
    376376                curObject=curObject.simplePrevious if simpleReviewMode else curObject.previous 
    377377                if curObject is not None: 
    378378                        api.setNavigatorObject(curObject) 
    379                         speech.speakObject(curObject,reason=speech.REASON_QUERY) 
     379                        speech.speakObject(curObject,reason=controlTypes.REASON_QUERY) 
    380380                else: 
    381381                        speech.speakMessage(_("No previous")) 
    382382        script_navigatorObject_previous.__doc__=_("Moves the navigator object to the previous object") 
     
    390390                curObject=curObject.simpleFirstChild if simpleReviewMode else curObject.firstChild 
    391391                if curObject is not None: 
    392392                        api.setNavigatorObject(curObject) 
    393                         speech.speakObject(curObject,reason=speech.REASON_QUERY) 
     393                        speech.speakObject(curObject,reason=controlTypes.REASON_QUERY) 
    394394                else: 
    395395                        speech.speakMessage(_("No children")) 
    396396        script_navigatorObject_firstChild.__doc__=_("Moves the navigator object to the first object it contains") 
     
    418418                api.setReviewPosition(info.copy()) 
    419419                info.expand(textInfos.UNIT_LINE) 
    420420                speech.speakMessage(_("top")) 
    421                 speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET) 
     421                speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET) 
    422422        script_review_top.__doc__=_("Moves the review cursor to the top line of the current navigator object and speaks it") 
    423423 
    424424        def script_review_previousLine(self,gesture): 
     
    430430                info.expand(textInfos.UNIT_LINE) 
    431431                if res==0: 
    432432                        speech.speakMessage(_("top")) 
    433                 speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET) 
     433                speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET) 
    434434        script_review_previousLine.__doc__=_("Moves the review cursor to the previous line of the current navigator object and speaks it") 
    435435 
    436436        def script_review_currentLine(self,gesture): 
     
    438438                info.expand(textInfos.UNIT_LINE) 
    439439                scriptCount=scriptHandler.getLastScriptRepeatCount() 
    440440                if scriptCount==0: 
    441                         speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET) 
     441                        speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET) 
    442442                else: 
    443443                        speech.speakSpelling(info.text,useCharacterDescriptions=bool(scriptCount>1)) 
    444444        script_review_currentLine.__doc__=_("Reports the line of the current navigator object where the review cursor is situated. If this key is pressed twice, the current line will be spelled. Pressing three times will spell the line using character descriptions.") 
     
    452452                info.expand(textInfos.UNIT_LINE) 
    453453                if res==0: 
    454454                        speech.speakMessage(_("bottom")) 
    455                 speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET) 
     455                speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET) 
    456456        script_review_nextLine.__doc__=_("Moves the review cursor to the next line of the current navigator object and speaks it") 
    457457 
    458458        def script_review_bottom(self,gesture): 
     
    460460                api.setReviewPosition(info.copy()) 
    461461                info.expand(textInfos.UNIT_LINE) 
    462462                speech.speakMessage(_("bottom")) 
    463                 speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET) 
     463                speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET) 
    464464        script_review_bottom.__doc__=_("Moves the review cursor to the bottom line of the current navigator object and speaks it") 
    465465 
    466466        def script_review_previousWord(self,gesture): 
     
    472472                info.expand(textInfos.UNIT_WORD) 
    473473                if res==0: 
    474474                        speech.speakMessage(_("top")) 
    475                 speech.speakTextInfo(info,reason=speech.REASON_CARET,unit=textInfos.UNIT_WORD) 
     475                speech.speakTextInfo(info,reason=controlTypes.REASON_CARET,unit=textInfos.UNIT_WORD) 
    476476        script_review_previousWord.__doc__=_("Moves the review cursor to the previous word of the current navigator object and speaks it") 
    477477 
    478478        def script_review_currentWord(self,gesture): 
     
    480480                info.expand(textInfos.UNIT_WORD) 
    481481                scriptCount=scriptHandler.getLastScriptRepeatCount() 
    482482                if scriptCount==0: 
    483                         speech.speakTextInfo(info,reason=speech.REASON_CARET,unit=textInfos.UNIT_WORD) 
     483                        speech.speakTextInfo(info,reason=controlTypes.REASON_CARET,unit=textInfos.UNIT_WORD) 
    484484                else: 
    485485                        speech.speakSpelling(info.text,useCharacterDescriptions=bool(scriptCount>1)) 
    486486        script_review_currentWord.__doc__=_("Speaks the word of the current navigator object where the review cursor is situated. If this key is pressed twice, the word will be spelled") 
     
    494494                info.expand(textInfos.UNIT_WORD) 
    495495                if res==0: 
    496496                        speech.speakMessage(_("bottom")) 
    497                 speech.speakTextInfo(info,reason=speech.REASON_CARET,unit=textInfos.UNIT_WORD) 
     497                speech.speakTextInfo(info,reason=controlTypes.REASON_CARET,unit=textInfos.UNIT_WORD) 
    498498        script_review_nextWord.__doc__=_("Moves the review cursor to the next word of the current navigator object and speaks it") 
    499499 
    500500        def script_review_startOfLine(self,gesture): 
     
    504504                api.setReviewPosition(info.copy()) 
    505505                info.expand(textInfos.UNIT_CHARACTER) 
    506506                speech.speakMessage(_("left")) 
    507                 speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     507                speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    508508        script_review_startOfLine.__doc__=_("Moves the review cursor to the first character of the line where it is situated in the current navigator object and speaks it") 
    509509 
    510510        def script_review_previousCharacter(self,gesture): 
     
    518518                        speech.speakMessage(_("left")) 
    519519                        reviewInfo=api.getReviewPosition().copy() 
    520520                        reviewInfo.expand(textInfos.UNIT_CHARACTER) 
    521                         speech.speakTextInfo(reviewInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     521                        speech.speakTextInfo(reviewInfo,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    522522                else: 
    523523                        api.setReviewPosition(charInfo.copy()) 
    524524                        charInfo.expand(textInfos.UNIT_CHARACTER) 
    525                         speech.speakTextInfo(charInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     525                        speech.speakTextInfo(charInfo,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    526526        script_review_previousCharacter.__doc__=_("Moves the review cursor to the previous character of the current navigator object and speaks it") 
    527527 
    528528        def script_review_currentCharacter(self,gesture): 
     
    530530                info.expand(textInfos.UNIT_CHARACTER) 
    531531                scriptCount=scriptHandler.getLastScriptRepeatCount() 
    532532                if scriptCount==0: 
    533                         speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     533                        speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    534534                elif scriptCount==1: 
    535535                        speech.speakSpelling(info.text,useCharacterDescriptions=True) 
    536536                else: 
     
    539539                                speech.speakMessage("%d," % c) 
    540540                                speech.speakSpelling(hex(c)) 
    541541                        except: 
    542                                 speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     542                                speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    543543        script_review_currentCharacter.__doc__=_("Reports the character of the current navigator object where the review cursor is situated. If this key is pressed twice, ascii and hexadecimal values are spoken for the character") 
    544544 
    545545        def script_review_nextCharacter(self,gesture): 
     
    553553                        speech.speakMessage(_("right")) 
    554554                        reviewInfo=api.getReviewPosition().copy() 
    555555                        reviewInfo.expand(textInfos.UNIT_CHARACTER) 
    556                         speech.speakTextInfo(reviewInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     556                        speech.speakTextInfo(reviewInfo,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    557557                else: 
    558558                        api.setReviewPosition(charInfo.copy()) 
    559559                        charInfo.expand(textInfos.UNIT_CHARACTER) 
    560                         speech.speakTextInfo(charInfo,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     560                        speech.speakTextInfo(charInfo,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    561561        script_review_nextCharacter.__doc__=_("Moves the review cursor to the next character of the current navigator object and speaks it") 
    562562 
    563563        def script_review_endOfLine(self,gesture): 
     
    568568                api.setReviewPosition(info.copy()) 
    569569                info.expand(textInfos.UNIT_CHARACTER) 
    570570                speech.speakMessage(_("right")) 
    571                 speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET) 
     571                speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) 
    572572        script_review_endOfLine.__doc__=_("Moves the review cursor to the last character of the line where it is situated in the current navigator object and speaks it") 
    573573 
    574574        def script_speechMode(self,gesture): 
     
    666666                focusObject=api.getFocusObject() 
    667667                if isinstance(focusObject,NVDAObject): 
    668668                        if scriptHandler.getLastScriptRepeatCount()==0: 
    669                                 speech.speakObject(focusObject, reason=speech.REASON_QUERY) 
     669                                speech.speakObject(focusObject, reason=controlTypes.REASON_QUERY) 
    670670                        else: 
    671671                                speech.speakSpelling(focusObject.name) 
    672672                else: 
     
    717717        def script_speakForeground(self,gesture): 
    718718                obj=api.getForegroundObject() 
    719719                if obj: 
    720                         speech.speakObject(obj,reason=speech.REASON_QUERY) 
     720                        speech.speakObject(obj,reason=controlTypes.REASON_QUERY) 
    721721                        obj.speakDescendantObjects() 
    722722        script_speakForeground.__doc__ = _("speaks the current foreground object") 
    723723 
  • source/inputCore.py

    === modified file 'source/inputCore.py'
     
    22#A part of NonVisual Desktop Access (NVDA) 
    33#This file is covered by the GNU General Public License. 
    44#See the file COPYING for more details. 
    5 #Copyright (C) 2010 James Teh <jamie@jantrid.net> 
     5#Copyright (C) 2010-2011 James Teh <jamie@jantrid.net> 
    66 
    77import sys 
    88import os 
     
    1515import speech 
    1616import characterProcessing 
    1717import config 
     18import controlTypes 
    1819import watchdog 
    1920from logHandler import log 
    2021import globalVars 
     
    337338                import braille 
    338339                braille.handler.message("\t\t".join(textList)) 
    339340                # Punctuation must be spoken for the gesture name (the first chunk) so that punctuation keys are spoken. 
    340                 speech.speakText(textList[0], reason=speech.REASON_MESSAGE, symbolLevel=characterProcessing.SYMLVL_ALL) 
     341                speech.speakText(textList[0], reason=controlTypes.REASON_MESSAGE, symbolLevel=characterProcessing.SYMLVL_ALL) 
    341342                for text in textList[1:]: 
    342343                        speech.speakMessage(text) 
    343344 
  • source/sayAllHandler.py

    === modified file 'source/sayAllHandler.py'
     
    11#sayAllHandler.py 
    22#A part of NonVisual Desktop Access (NVDA) 
    3 #Copyright (C) 2006-2007 NVDA Contributors <http://www.nvda-project.org/> 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
    44#This file is covered by the GNU General Public License. 
    55#See the file COPYING for more details. 
    66 
    77import queueHandler 
    88import config 
     9import controlTypes 
    910import speech 
    1011import textInfos 
    1112import globalVars 
     
    5859                        yield 
    5960                        continue 
    6061                if keepReading: 
    61                         speech.speakObject(obj,index=indexCount,reason=speech.REASON_SAYALL) 
     62                        speech.speakObject(obj,index=indexCount,reason=controlTypes.REASON_SAYALL) 
    6263                        up=[] 
    6364                        down=[] 
    6465                        obj=obj.getNextInFlow(up=up,down=down) 
     
    117118                                        speech.speakWithoutPauses(None) 
    118119                                        keepReading=False 
    119120                                        continue 
    120                                 speech.speakTextInfo(reader,unit=textInfos.UNIT_READINGCHUNK,reason=speech.REASON_SAYALL,index=index) 
     121                                speech.speakTextInfo(reader,unit=textInfos.UNIT_READINGCHUNK,reason=controlTypes.REASON_SAYALL,index=index) 
    121122                                sendCount+=1 
    122123                                cursorIndexMap[index]=bookmark 
    123124                                reader.collapse(end=True) 
  • source/speech.py

    === modified file 'source/speech.py' (properties changed: +x to -x)
     
    3434isPaused=False 
    3535curWordChars=[] 
    3636 
    37 REASON_FOCUS=1 
    38 REASON_MOUSE=2 
    39 REASON_QUERY=3 
    40 REASON_CHANGE=4 
    41 REASON_MESSAGE=5 
    42 REASON_SAYALL=6 
    43 REASON_CARET=7 
    44 REASON_DEBUG=8 
    45 REASON_ONLYCACHE=9 
    46 REASON_FOCUSENTERED=10 
    4737 
    4838#: The string used to separate distinct chunks of text when multiple chunks should be spoken without pauses. 
    4939CHUNK_SEPARATOR = "  " 
     
    122112@param index: the index to mark this current text with, its best to use the character position of the text if you know it  
    123113@type index: int 
    124114""" 
    125         speakText(text,index=index,reason=REASON_MESSAGE) 
     115        speakText(text,index=index,reason=controlTypes.REASON_MESSAGE) 
    126116 
    127117_speakSpellingGenID = None 
    128118 
     
    188178                if uppercase and  synthConfig["beepForCapitals"]: 
    189179                        tones.beep(2000,50) 
    190180 
    191 def speakObjectProperties(obj,reason=REASON_QUERY,index=None,**allowedProperties): 
     181def speakObjectProperties(obj,reason=controlTypes.REASON_QUERY,index=None,**allowedProperties): 
    192182        if speechMode==speechMode_off: 
    193183                return 
    194184        #Fetch the values for all wanted properties 
     
    216206        cachedPropertyValues.update(newPropertyValues) 
    217207        obj._speakObjectPropertiesCache=cachedPropertyValues 
    218208        #If we should only cache we can stop here 
    219         if reason==REASON_ONLYCACHE: 
     209        if reason==controlTypes.REASON_ONLYCACHE: 
    220210                return 
    221211        #If only speaking change, then filter out all values that havn't changed 
    222         if reason==REASON_CHANGE: 
     212        if reason==controlTypes.REASON_CHANGE: 
    223213                for name in set(newPropertyValues)&set(oldCachedPropertyValues): 
    224214                        if newPropertyValues[name]==oldCachedPropertyValues[name]: 
    225215                                del newPropertyValues[name] 
     
    237227        if text: 
    238228                speakText(text,index=index) 
    239229 
    240 def speakObject(obj,reason=REASON_QUERY,index=None): 
     230def speakObject(obj,reason=controlTypes.REASON_QUERY,index=None): 
    241231        from NVDAObjects import NVDAObjectTextInfo 
    242         isEditable=(reason!=REASON_FOCUSENTERED and obj.TextInfo!=NVDAObjectTextInfo and (obj.role in (controlTypes.ROLE_EDITABLETEXT,controlTypes.ROLE_TERMINAL) or controlTypes.STATE_EDITABLE in obj.states)) 
     232        isEditable=(reason!=controlTypes.REASON_FOCUSENTERED and obj.TextInfo!=NVDAObjectTextInfo and (obj.role in (controlTypes.ROLE_EDITABLETEXT, controlTypes.ROLE_TERMINAL) or controlTypes.STATE_EDITABLE in obj.states)) 
    243233        allowProperties={'name':True,'role':True,'states':True,'value':True,'description':True,'keyboardShortcut':True,'positionInfo_level':True,'positionInfo_indexInGroup':True,'positionInfo_similarItemsInGroup':True,"rowNumber":True,"columnNumber":True,"columnCount":True,"rowCount":True} 
    244234 
    245         if reason==REASON_FOCUSENTERED: 
     235        if reason==controlTypes.REASON_FOCUSENTERED: 
    246236                allowProperties["value"]=False 
    247237                allowProperties["keyboardShortcut"]=False 
    248238                allowProperties["positionInfo_level"]=False 
    249239                # Aside from excluding some properties, focus entered should be spoken like focus. 
    250                 reason=REASON_FOCUS 
     240                reason=controlTypes.REASON_FOCUS 
    251241 
    252242        if not config.conf["presentation"]["reportObjectDescriptions"]: 
    253243                allowProperties["description"]=False 
     
    257247                allowProperties["positionInfo_level"]=False 
    258248                allowProperties["positionInfo_indexInGroup"]=False 
    259249                allowProperties["positionInfo_similarItemsInGroup"]=False 
    260         if reason!=REASON_QUERY: 
     250        if reason!=controlTypes.REASON_QUERY: 
    261251                allowProperties["rowCount"]=False 
    262252                allowProperties["columnCount"]=False 
    263253                if (not config.conf["documentFormatting"]["reportTables"] 
     
    269259                allowProperties['value']=False 
    270260 
    271261        speakObjectProperties(obj,reason=reason,index=index,**allowProperties) 
    272         if reason!=REASON_ONLYCACHE and isEditable: 
     262        if reason!=controlTypes.REASON_ONLYCACHE and isEditable: 
    273263                try: 
    274264                        info=obj.makeTextInfo(textInfos.POSITION_SELECTION) 
    275265                        if not info.isCollapsed: 
     
    281271                        newInfo=obj.makeTextInfo(textInfos.POSITION_ALL) 
    282272                        speakTextInfo(newInfo,unit=textInfos.UNIT_PARAGRAPH,reason=reason) 
    283273 
    284 def speakText(text,index=None,reason=REASON_MESSAGE,symbolLevel=None): 
     274def speakText(text,index=None,reason=controlTypes.REASON_MESSAGE,symbolLevel=None): 
    285275        """Speaks some text. 
    286276        @param text: The text to speak. 
    287277        @type text: str 
    288278        @param index: The index to mark this text with, which can be used later to determine whether this piece of text has been spoken. 
    289279        @type index: int 
    290         @param reason: The reason for this speech; one of the REASON_* constants. 
     280        @param reason: The reason for this speech; one of the controlTypes.REASON_* constants. 
    291281        @param symbolLevel: The symbol verbosity level; C{None} (default) to use the user's configuration. 
    292282        """ 
    293283        speechSequence=[] 
     
    425415        if config.conf["keyboard"]["speakTypedCharacters"] and ord(ch)>=32: 
    426416                speakSpelling(realChar) 
    427417 
    428 silentRolesOnFocus=set([ 
    429         controlTypes.ROLE_PANE, 
    430         controlTypes.ROLE_ROOTPANE, 
    431         controlTypes.ROLE_FRAME, 
    432         controlTypes.ROLE_UNKNOWN, 
    433         controlTypes.ROLE_APPLICATION, 
    434         controlTypes.ROLE_TABLECELL, 
    435         controlTypes.ROLE_LISTITEM, 
    436         controlTypes.ROLE_MENUITEM, 
    437         controlTypes.ROLE_CHECKMENUITEM, 
    438         controlTypes.ROLE_TREEVIEWITEM, 
    439 ]) 
    440  
    441 silentValuesForRoles=set([ 
    442         controlTypes.ROLE_CHECKBOX, 
    443         controlTypes.ROLE_RADIOBUTTON, 
    444         controlTypes.ROLE_LINK, 
    445         controlTypes.ROLE_MENUITEM, 
    446         controlTypes.ROLE_APPLICATION, 
    447 ]) 
    448  
    449 def processPositiveStates(role, states, reason, positiveStates): 
    450         positiveStates = positiveStates.copy() 
    451         # The user never cares about certain states. 
    452         if role==controlTypes.ROLE_EDITABLETEXT: 
    453                 positiveStates.discard(controlTypes.STATE_EDITABLE) 
    454         if role!=controlTypes.ROLE_LINK: 
    455                 positiveStates.discard(controlTypes.STATE_VISITED) 
    456         positiveStates.discard(controlTypes.STATE_SELECTABLE) 
    457         positiveStates.discard(controlTypes.STATE_FOCUSABLE) 
    458         positiveStates.discard(controlTypes.STATE_CHECKABLE) 
    459         if controlTypes.STATE_DRAGGING in positiveStates: 
    460                 # It's obvious that the control is draggable if it's being dragged. 
    461                 positiveStates.discard(controlTypes.STATE_DRAGGABLE) 
    462         if role == controlTypes.ROLE_COMBOBOX: 
    463                 # Combo boxes inherently have a popup, so don't report it. 
    464                 positiveStates.discard(controlTypes.STATE_HASPOPUP) 
    465         if reason == REASON_QUERY: 
    466                 return positiveStates 
    467         positiveStates.discard(controlTypes.STATE_DEFUNCT) 
    468         positiveStates.discard(controlTypes.STATE_MODAL) 
    469         positiveStates.discard(controlTypes.STATE_FOCUSED) 
    470         positiveStates.discard(controlTypes.STATE_OFFSCREEN) 
    471         positiveStates.discard(controlTypes.STATE_INVISIBLE) 
    472         if reason != REASON_CHANGE: 
    473                 positiveStates.discard(controlTypes.STATE_LINKED) 
    474                 if role in (controlTypes.ROLE_LISTITEM, controlTypes.ROLE_TREEVIEWITEM, controlTypes.ROLE_MENUITEM, controlTypes.ROLE_TABLEROW) and controlTypes.STATE_SELECTABLE in states: 
    475                         positiveStates.discard(controlTypes.STATE_SELECTED) 
    476         if role != controlTypes.ROLE_EDITABLETEXT: 
    477                 positiveStates.discard(controlTypes.STATE_READONLY) 
    478         if role == controlTypes.ROLE_CHECKBOX: 
    479                 positiveStates.discard(controlTypes.STATE_PRESSED) 
    480         if role == controlTypes.ROLE_MENUITEM: 
    481                 # The user doesn't usually care if a menu item is expanded or collapsed. 
    482                 positiveStates.discard(controlTypes.STATE_COLLAPSED) 
    483                 positiveStates.discard(controlTypes.STATE_EXPANDED) 
    484         return positiveStates 
    485  
    486 def processNegativeStates(role, states, reason, negativeStates): 
    487         speakNegatives = set() 
    488         # Add the negative selected state if the control is selectable, 
    489         # but only if it is either focused or this is something other than a change event. 
    490         # The condition stops "not selected" from being spoken in some broken controls 
    491         # when the state change for the previous focus is issued before the focus change. 
    492         if role in (controlTypes.ROLE_LISTITEM, controlTypes.ROLE_TREEVIEWITEM, controlTypes.ROLE_TABLEROW) and controlTypes.STATE_SELECTABLE in states and (reason != REASON_CHANGE or controlTypes.STATE_FOCUSED in states): 
    493                 speakNegatives.add(controlTypes.STATE_SELECTED) 
    494         # Restrict "not checked" in a similar way to "not selected". 
    495         if (role in (controlTypes.ROLE_CHECKBOX, controlTypes.ROLE_RADIOBUTTON, controlTypes.ROLE_CHECKMENUITEM) or controlTypes.STATE_CHECKABLE in states)  and (controlTypes.STATE_HALFCHECKED not in states) and (reason != REASON_CHANGE or controlTypes.STATE_FOCUSED in states): 
    496                 speakNegatives.add(controlTypes.STATE_CHECKED) 
    497         if reason == REASON_CHANGE: 
    498                 # We want to speak this state only if it is changing to negative. 
    499                 speakNegatives.add(controlTypes.STATE_DROPTARGET) 
    500                 # We were given states which have changed to negative. 
    501                 # Return only those supplied negative states which should be spoken; 
    502                 # i.e. the states in both sets. 
    503                 speakNegatives &= negativeStates 
    504                 if controlTypes.STATES_SORTED & negativeStates and not controlTypes.STATES_SORTED & states: 
    505                         # If the object has just stopped being sorted, just report not sorted. 
    506                         # The user doesn't care how it was sorted before. 
    507                         speakNegatives.add(controlTypes.STATE_SORTED) 
    508                 return speakNegatives 
    509         else: 
    510                 # This is not a state change; only positive states were supplied. 
    511                 # Return all negative states which should be spoken, excluding the positive states. 
    512                 return speakNegatives - states 
    513  
    514 def speakTextInfo(info,useCache=True,formatConfig=None,unit=None,extraDetail=False,reason=REASON_QUERY,index=None): 
     418def speakTextInfo(info,useCache=True,formatConfig=None,unit=None,extraDetail=False,reason=controlTypes.REASON_QUERY,index=None): 
    515419        if unit in (textInfos.UNIT_CHARACTER,textInfos.UNIT_WORD): 
    516420                extraDetail=True 
    517421        if not formatConfig: 
     
    651555                                textList.append(text) 
    652556 
    653557        # If there is nothing  that should cause the TextInfo to be considered non-blank, blank should be reported, unless we are doing a say all. 
    654         if reason != REASON_SAYALL and len(textList)==textListBlankLen: 
     558        if reason != controlTypes.REASON_SAYALL and len(textList)==textListBlankLen: 
    655559                textList.append(_("blank")) 
    656560 
    657561        #Cache a copy of the new controlFieldStack for future use 
     
    667571        if text: 
    668572                speechSequence.append(text) 
    669573        if speechSequence: 
    670                 if reason==REASON_SAYALL: 
     574                if reason==controlTypes.REASON_SAYALL: 
    671575                        speakWithoutPauses(speechSequence) 
    672576                else: 
    673577                        speak(speechSequence) 
    674578 
    675 def getSpeechTextForProperties(reason=REASON_QUERY,**propertyValues): 
     579def getSpeechTextForProperties(reason=controlTypes.REASON_QUERY,**propertyValues): 
    676580        global oldTreeLevel, oldTableID, oldRowNumber, oldColumnNumber 
    677581        textList=[] 
    678582        name=propertyValues.get('name') 
     
    687591        else: 
    688592                speakRole=False 
    689593                role=controlTypes.ROLE_UNKNOWN 
    690         value=propertyValues.get('value') if role not in silentValuesForRoles else None 
     594        value=propertyValues.get('value') if role not in controlTypes.ignoreValuesForRoles else None 
    691595        rowNumber=propertyValues.get('rowNumber') 
    692596        columnNumber=propertyValues.get('columnNumber') 
    693597        includeTableCellCoords=propertyValues.get('includeTableCellCoords',True) 
    694         if speakRole and (reason not in (REASON_SAYALL,REASON_CARET,REASON_FOCUS) or not (name or value or rowNumber or columnNumber) or role not in silentRolesOnFocus): 
    695                 textList.append(controlTypes.speechRoleLabels[role]) 
     598        if speakRole and (reason not in (controlTypes.REASON_SAYALL, controlTypes.REASON_CARET, controlTypes.REASON_FOCUS) or not (name or value or rowNumber or columnNumber) or role not in controlTypes.ignoreRolesOnFocus): 
     599                textList.append(controlTypes.labels[role]) 
    696600        if value: 
    697601                textList.append(value) 
    698602        states=propertyValues.get('states') 
    699603        realStates=propertyValues.get('_states',states) 
    700604        if states is not None: 
    701                 positiveStates=processPositiveStates(role,realStates,reason,states) 
    702                 textList.extend([controlTypes.speechStateLabels[x] for x in positiveStates]) 
     605                positiveStates=controlTypes.processPositiveStates(role,realStates,reason,states) 
     606                textList.extend([controlTypes.stateLabels[x] for x in positiveStates]) 
    703607        if 'negativeStates' in propertyValues: 
    704608                negativeStates=propertyValues['negativeStates'] 
    705609        else: 
    706610                negativeStates=None 
    707         if negativeStates is not None or (reason != REASON_CHANGE and states is not None): 
    708                 negativeStates=processNegativeStates(role, realStates, reason, negativeStates) 
     611        if negativeStates is not None or (reason != controlTypes.REASON_CHANGE and states is not None): 
     612                negativeStates=controlTypes.processNegativeStates(role, realStates, reason, negativeStates) 
    709613                if controlTypes.STATE_DROPTARGET in negativeStates: 
    710614                        # "not drop target" doesn't make any sense, so use a custom message. 
    711615                        textList.append(_("done dragging")) 
    712616                        negativeStates.discard(controlTypes.STATE_DROPTARGET) 
    713                 textList.extend([_("not %s")%controlTypes.speechStateLabels[x] for x in negativeStates]) 
     617                textList.extend([_("not %s")%controlTypes.stateLabels[x] for x in negativeStates]) 
    714618        if 'description' in propertyValues: 
    715619                textList.append(propertyValues['description']) 
    716620        if 'keyboardShortcut' in propertyValues: 
     
    722626        if 'positionInfo_level' in propertyValues: 
    723627                level=propertyValues.get('positionInfo_level',None) 
    724628                role=propertyValues.get('role',None) 
    725                 if level is not None and role in (controlTypes.ROLE_TREEVIEWITEM,controlTypes.ROLE_LISTITEM) and level!=oldTreeLevel: 
     629                if level is not None and role in (controlTypes.ROLE_TREEVIEWITEM, controlTypes.ROLE_LISTITEM) and level!=oldTreeLevel: 
    726630                        textList.insert(0,_("level %s")%level) 
    727631                        oldTreeLevel=level 
    728632                elif level: 
     
    766670                formatConfig=config.conf["documentFormatting"] 
    767671 
    768672        childCount=int(attrs.get('_childcount',"0")) 
    769         if reason==REASON_FOCUS or attrs.get('alwaysReportName',False): 
     673        if reason==controlTypes.REASON_FOCUS or attrs.get('alwaysReportName',False): 
    770674                name=attrs.get('name',"") 
    771675        else: 
    772676                name="" 
    773         role=attrs.get('role',controlTypes.ROLE_UNKNOWN) 
     677        role=attrs.get('role', controlTypes.ROLE_UNKNOWN) 
    774678        states=attrs.get('states',set()) 
    775679        keyboardShortcut=attrs.get('keyboardShortcut', "") 
    776         if reason==REASON_FOCUS or attrs.get('alwaysReportDescription',False): 
     680        if reason==controlTypes.REASON_FOCUS or attrs.get('alwaysReportDescription',False): 
    777681                description=attrs.get('description',"") 
    778682        else: 
    779683                description="" 
    780684        level=attrs.get('level',None) 
    781685 
    782686        #Remove the clickable state from controls that are clearly clickable according to their role 
    783         if role in (controlTypes.ROLE_LINK,controlTypes.ROLE_BUTTON,controlTypes.ROLE_CHECKBOX,controlTypes.ROLE_RADIOBUTTON): 
     687        if role in (controlTypes.ROLE_LINK, controlTypes.ROLE_BUTTON, controlTypes.ROLE_CHECKBOX, controlTypes.ROLE_RADIOBUTTON): 
    784688                states=states.copy() 
    785689                states.discard(controlTypes.STATE_CLICKABLE) 
    786690 
     
    806710                tableID=None 
    807711 
    808712        # Honour verbosity configuration. 
    809         if reason in (REASON_CARET,REASON_SAYALL,REASON_FOCUS) and ( 
     713        if reason in (controlTypes.REASON_CARET, controlTypes.REASON_SAYALL, controlTypes.REASON_FOCUS) and ( 
    810714                (role==controlTypes.ROLE_LINK and not formatConfig["reportLinks"]) or  
    811715                (role==controlTypes.ROLE_HEADING and not formatConfig["reportHeadings"]) or 
    812716                (role==controlTypes.ROLE_BLOCKQUOTE and not formatConfig["reportBlockQuotes"]) or 
    813                 (role in (controlTypes.ROLE_TABLE,controlTypes.ROLE_TABLECELL,controlTypes.ROLE_TABLEROWHEADER,controlTypes.ROLE_TABLECOLUMNHEADER) and not formatConfig["reportTables"]) or 
    814                 (role in (controlTypes.ROLE_LIST,controlTypes.ROLE_LISTITEM) and controlTypes.STATE_READONLY in states and not formatConfig["reportLists"]) 
     717                (role in (controlTypes.ROLE_TABLE, controlTypes.ROLE_TABLECELL, controlTypes.ROLE_TABLEROWHEADER, controlTypes.ROLE_TABLECOLUMNHEADER) and not formatConfig["reportTables"]) or 
     718                (role in (controlTypes.ROLE_LIST, controlTypes.ROLE_LISTITEM) and controlTypes.STATE_READONLY in states and not formatConfig["reportLists"]) 
    815719        ): 
    816720                return "" 
    817721 
     
    830734        # speakExitForOther: When moving by word or character, speak when the user exits the control. 
    831735        speakEntry=speakWithinForLine=speakExitForLine=speakExitForOther=False 
    832736        if ( 
    833                 role in (controlTypes.ROLE_LINK,controlTypes.ROLE_HEADING,controlTypes.ROLE_BUTTON,controlTypes.ROLE_RADIOBUTTON,controlTypes.ROLE_CHECKBOX,controlTypes.ROLE_GRAPHIC,controlTypes.ROLE_MENUITEM,controlTypes.ROLE_TAB,controlTypes.ROLE_COMBOBOX,controlTypes.ROLE_SLIDER,controlTypes.ROLE_SPINBUTTON,controlTypes.ROLE_COMBOBOX,controlTypes.ROLE_PROGRESSBAR) 
     737                role in (controlTypes.ROLE_LINK, controlTypes.ROLE_HEADING, controlTypes.ROLE_BUTTON, controlTypes.ROLE_RADIOBUTTON, controlTypes.ROLE_CHECKBOX, controlTypes.ROLE_GRAPHIC, controlTypes.ROLE_MENUITEM, controlTypes.ROLE_TAB, controlTypes.ROLE_COMBOBOX, controlTypes.ROLE_SLIDER, controlTypes.ROLE_SPINBUTTON, controlTypes.ROLE_COMBOBOX, controlTypes.ROLE_PROGRESSBAR) 
    834738                or (role==controlTypes.ROLE_EDITABLETEXT and controlTypes.STATE_MULTILINE not in states and (controlTypes.STATE_READONLY not in states or controlTypes.STATE_FOCUSABLE in states)) 
    835739                or (role==controlTypes.ROLE_LIST and controlTypes.STATE_READONLY not in states) 
    836740        ): 
     
    838742                speakEntry=True 
    839743                speakWithinForLine=True 
    840744                speakExitForOther=True 
    841         elif role in (controlTypes.ROLE_SEPARATOR,controlTypes.ROLE_EMBEDDEDOBJECT): 
     745        elif role in (controlTypes.ROLE_SEPARATOR, controlTypes.ROLE_EMBEDDEDOBJECT): 
    842746                # This node is only ever a marker; i.e. single character. 
    843747                speakEntry=True 
    844748        elif ( 
    845                 role in (controlTypes.ROLE_BLOCKQUOTE,controlTypes.ROLE_FRAME,controlTypes.ROLE_INTERNALFRAME,controlTypes.ROLE_TOOLBAR,controlTypes.ROLE_MENUBAR,controlTypes.ROLE_POPUPMENU) 
     749                role in (controlTypes.ROLE_BLOCKQUOTE, controlTypes.ROLE_FRAME, controlTypes.ROLE_INTERNALFRAME, controlTypes.ROLE_TOOLBAR, controlTypes.ROLE_MENUBAR, controlTypes.ROLE_POPUPMENU) 
    846750                or (role==controlTypes.ROLE_EDITABLETEXT and (controlTypes.STATE_READONLY not in states or controlTypes.STATE_FOCUSABLE in states) and controlTypes.STATE_MULTILINE in states) 
    847751                or (role==controlTypes.ROLE_LIST and controlTypes.STATE_READONLY in states) 
    848752                or (role==controlTypes.ROLE_DOCUMENT and controlTypes.STATE_EDITABLE in states) 
     
    855759 
    856760        # Determine the order of speech. 
    857761        # speakContentFirst: Speak the content before the control field info. 
    858         speakContentFirst=reason==REASON_FOCUS and role not in (controlTypes.ROLE_EDITABLETEXT,controlTypes.ROLE_COMBOBOX) and controlTypes.STATE_EDITABLE not in states 
     762        speakContentFirst=reason==controlTypes.REASON_FOCUS and role not in (controlTypes.ROLE_EDITABLETEXT, controlTypes.ROLE_COMBOBOX) and controlTypes.STATE_EDITABLE not in states 
    859763        # speakStatesFirst: Speak the states before the role. 
    860764        speakStatesFirst=role==controlTypes.ROLE_LINK 
    861765 
     
    871775        elif fieldType=="start_addedToControlFieldStack" and role==controlTypes.ROLE_TABLE and tableID: 
    872776                # Table. 
    873777                return " ".join((roleText, getSpeechTextForProperties(_tableID=tableID, rowCount=attrs.get("table-rowcount"), columnCount=attrs.get("table-columncount")))) 
    874         elif fieldType=="start_addedToControlFieldStack" and role in (controlTypes.ROLE_TABLECELL,controlTypes.ROLE_TABLECOLUMNHEADER,controlTypes.ROLE_TABLEROWHEADER) and tableID: 
     778        elif fieldType=="start_addedToControlFieldStack" and role in (controlTypes.ROLE_TABLECELL, controlTypes.ROLE_TABLECOLUMNHEADER, controlTypes.ROLE_TABLEROWHEADER) and tableID: 
    875779                # Table cell. 
    876780                reportTableHeaders = formatConfig["reportTableHeaders"] 
    877781                reportTableCellCoords = formatConfig["reportTableCellCoords"] 
  • source/virtualBuffers/__init__.py

    === modified file 'source/virtualBuffers/__init__.py'
     
     1#VirtualBuffer.py 
     2#A part of NonVisual Desktop Access (NVDA) 
     3#Copyright (C) 2006-2011 NVDA Contributors <http://www.nvda-project.org/> 
     4#This file is covered by the GNU General Public License. 
     5#See the file COPYING for more details. 
     6 
    17import time 
    28import threading 
    39import ctypes 
     
    488494 
    489495        def _reportElement(self, element): 
    490496                speech.cancelSpeech() 
    491                 speech.speakTextInfo(element,reason=speech.REASON_FOCUS) 
     497                speech.speakTextInfo(element,reason=controlTypes.REASON_FOCUS) 
    492498 
    493499class VirtualBuffer(cursorManager.CursorManager, treeInterceptorHandler.TreeInterceptor): 
    494500 
     
    647653                                        self.selection = self.makeTextInfo(initialPos) 
    648654                                speech.cancelSpeech() 
    649655                                reportPassThrough(self) 
    650                                 speech.speakObjectProperties(self.rootNVDAObject,name=True,states=True,reason=speech.REASON_FOCUS) 
     656                                speech.speakObjectProperties(self.rootNVDAObject,name=True,states=True,reason=controlTypes.REASON_FOCUS) 
    651657                                info=self.makeTextInfo(textInfos.POSITION_CARET) 
    652658                                sayAllHandler.readText(info,sayAllHandler.CURSOR_CARET) 
    653659                        self._hadFirstGainFocus = True 
     
    656662                        # This buffer has had focus before. 
    657663                        if not self.passThrough: 
    658664                                # Speak it like we would speak focus on any other document object. 
    659                                 speech.speakObject(self.rootNVDAObject, reason=speech.REASON_FOCUS) 
     665                                speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS) 
    660666                                info = self.selection 
    661667                                if not info.isCollapsed: 
    662668                                        speech.speakSelectionMessage(_("selected %s"), info.text) 
    663669                                else: 
    664670                                        info.expand(textInfos.UNIT_LINE) 
    665                                         speech.speakTextInfo(info, reason=speech.REASON_CARET) 
     671                                        speech.speakTextInfo(info, reason=controlTypes.REASON_CARET) 
    666672 
    667673                reportPassThrough(self) 
    668674                braille.handler.handleGainFocus(self) 
     
    692698                        reportPassThrough(self) 
    693699                elif obj.role == controlTypes.ROLE_EMBEDDEDOBJECT: 
    694700                        obj.setFocus() 
    695                         speech.speakObject(obj, reason=speech.REASON_FOCUS) 
     701                        speech.speakObject(obj, reason=controlTypes.REASON_FOCUS) 
    696702                else: 
    697703                        self._activateNVDAObject(obj) 
    698704 
    699         def _set_selection(self, info, reason=speech.REASON_CARET): 
     705        def _set_selection(self, info, reason=controlTypes.REASON_CARET): 
    700706                super(VirtualBuffer, self)._set_selection(info) 
    701707                if isScriptWaiting() or not info.isCollapsed: 
    702708                        return 
    703709                if config.conf['reviewCursor']['followCaret'] and api.getNavigatorObject() is self.rootNVDAObject: 
    704710                        api.setReviewPosition(info) 
    705                 if reason == speech.REASON_FOCUS: 
     711                if reason == controlTypes.REASON_FOCUS: 
    706712                        focusObj = api.getFocusObject() 
    707713                        if focusObj==self.rootNVDAObject: 
    708714                                return 
     
    800806                        if info.compareEndPoints(fieldInfo, "endToEnd") > 0: 
    801807                                # We've expanded past the end of the field, so limit to the end of the field. 
    802808                                info.setEndPoint(fieldInfo, "endToEnd") 
    803                 speech.speakTextInfo(info, reason=speech.REASON_FOCUS) 
     809                speech.speakTextInfo(info, reason=controlTypes.REASON_FOCUS) 
    804810                info.collapse() 
    805811                self._set_selection(info, reason=self.REASON_QUICKNAV) 
    806812 
     
    837843                """Determine whether pass through mode should be enabled or disabled for a given object. 
    838844                @param obj: The object in question. 
    839845                @type obj: L{NVDAObjects.NVDAObject} 
    840                 @param reason: The reason for this query; one of the speech reasons, L{REASON_QUICKNAV}, or C{None} for manual pass through mode activation by the user. 
     846                @param reason: The reason for this query; one of the reasons in controlTypes, L{REASON_QUICKNAV}, or C{None} for manual pass through mode activation by the user. 
    841847                @return: C{True} if pass through mode should be enabled, C{False} if it should be disabled. 
    842848                """ 
    843849                if reason and ( 
    844850                        self.disableAutoPassThrough 
    845                         or (reason == speech.REASON_FOCUS and not config.conf["virtualBuffers"]["autoPassThroughOnFocusChange"]) 
    846                         or (reason == speech.REASON_CARET and not config.conf["virtualBuffers"]["autoPassThroughOnCaretMove"]) 
     851                        or (reason == controlTypes.REASON_FOCUS and not config.conf["virtualBuffers"]["autoPassThroughOnFocusChange"]) 
     852                        or (reason == controlTypes.REASON_CARET and not config.conf["virtualBuffers"]["autoPassThroughOnCaretMove"]) 
    847853                ): 
    848854                        # This check relates to auto pass through and auto pass through is disabled, so don't change the pass through state. 
    849855                        return self.passThrough 
     
    855861                role = obj.role 
    856862                if controlTypes.STATE_READONLY in states and role != controlTypes.ROLE_EDITABLETEXT: 
    857863                        return False 
    858                 if reason == speech.REASON_CARET: 
     864                if reason == controlTypes.REASON_CARET: 
    859865                        return role == controlTypes.ROLE_EDITABLETEXT or (role == controlTypes.ROLE_DOCUMENT and controlTypes.STATE_EDITABLE in states) 
    860                 if reason == speech.REASON_FOCUS and role in (controlTypes.ROLE_LISTITEM, controlTypes.ROLE_RADIOBUTTON): 
     866                if reason == controlTypes.REASON_FOCUS and role in (controlTypes.ROLE_LISTITEM, controlTypes.ROLE_RADIOBUTTON): 
    861867                        return True 
    862868                if role in (controlTypes.ROLE_COMBOBOX, controlTypes.ROLE_EDITABLETEXT, controlTypes.ROLE_LIST, controlTypes.ROLE_SLIDER, controlTypes.ROLE_TABCONTROL, controlTypes.ROLE_TAB, controlTypes.ROLE_MENUBAR, controlTypes.ROLE_POPUPMENU, controlTypes.ROLE_MENUITEM, controlTypes.ROLE_TREEVIEW, controlTypes.ROLE_TREEVIEWITEM, controlTypes.ROLE_SPINBUTTON) or controlTypes.STATE_EDITABLE in states: 
    863869                        return True 
     
    942948                        # This node is already focused, so we need to move to and speak this node here. 
    943949                        newCaret = newInfo.copy() 
    944950                        newCaret.collapse() 
    945                         self._set_selection(newCaret,reason=speech.REASON_FOCUS) 
     951                        self._set_selection(newCaret,reason=controlTypes.REASON_FOCUS) 
    946952                        if self.passThrough: 
    947953                                obj.event_gainFocus() 
    948954                        else: 
    949                                 speech.speakTextInfo(newInfo,reason=speech.REASON_FOCUS) 
     955                                speech.speakTextInfo(newInfo,reason=controlTypes.REASON_FOCUS) 
    950956                else: 
    951957                        # This node doesn't have the focus, so just set focus to it. The gainFocus event will handle the rest. 
    952958                        obj.setFocus() 
     
    10081014                except: 
    10091015                        # This object is not in the virtual buffer, even though it resides beneath the document. 
    10101016                        # Automatic pass through should be enabled in certain circumstances where this occurs. 
    1011                         if not self.passThrough and self.shouldPassThrough(obj,reason=speech.REASON_FOCUS): 
     1017                        if not self.passThrough and self.shouldPassThrough(obj,reason=controlTypes.REASON_FOCUS): 
    10121018                                self.passThrough=True 
    10131019                                reportPassThrough(self) 
    10141020                                self._replayFocusEnteredEvents() 
     
    10251031                                # If pass-through is disabled, cancel speech, as a focus change should cause page reading to stop. 
    10261032                                # This must be done before auto-pass-through occurs, as we want to stop page reading even if pass-through will be automatically enabled by this focus change. 
    10271033                                speech.cancelSpeech() 
    1028                         self.passThrough=self.shouldPassThrough(obj,reason=speech.REASON_FOCUS) 
     1034                        self.passThrough=self.shouldPassThrough(obj,reason=controlTypes.REASON_FOCUS) 
    10291035                        if not self.passThrough: 
    10301036                                # We read the info from the buffer instead of the control itself. 
    1031                                 speech.speakTextInfo(focusInfo,reason=speech.REASON_FOCUS) 
     1037                                speech.speakTextInfo(focusInfo,reason=controlTypes.REASON_FOCUS) 
    10321038                                # However, we still want to update the speech property cache so that property changes will be spoken properly. 
    1033                                 speech.speakObject(obj,speech.REASON_ONLYCACHE) 
     1039                                speech.speakObject(obj,controlTypes.REASON_ONLYCACHE) 
    10341040                        else: 
    10351041                                if not oldPassThrough: 
    10361042                                        self._replayFocusEnteredEvents() 
    10371043                                nextHandler() 
    10381044                        focusInfo.collapse() 
    1039                         self._set_selection(focusInfo,reason=speech.REASON_FOCUS) 
     1045                        self._set_selection(focusInfo,reason=controlTypes.REASON_FOCUS) 
    10401046                else: 
    10411047                        # The virtual buffer caret was already at the focused node. 
    10421048                        if not self.passThrough: 
    10431049                                # This focus change was caused by a virtual caret movement, so don't speak the focused node to avoid double speaking. 
    10441050                                # However, we still want to update the speech property cache so that property changes will be spoken properly. 
    1045                                 speech.speakObject(obj,speech.REASON_ONLYCACHE) 
     1051                                speech.speakObject(obj,controlTypes.REASON_ONLYCACHE) 
    10461052                        else: 
    10471053                                return nextHandler() 
    10481054 
     
    10761082                if not scrollInfo.isOverlapping(caretInfo): 
    10771083                        if scrollInfo.isCollapsed: 
    10781084                                scrollInfo.expand(textInfos.UNIT_LINE) 
    1079                         speech.speakTextInfo(scrollInfo,reason=speech.REASON_CARET) 
     1085                        speech.speakTextInfo(scrollInfo,reason=controlTypes.REASON_CARET) 
    10801086                        scrollInfo.collapse() 
    10811087                        self.selection = scrollInfo 
    10821088                        return True 
     
    11921198                        # Retrieve the cell on which we started. 
    11931199                        info = next(self._iterTableCells(tableID, row=origRow, column=origCol)) 
    11941200 
    1195                 speech.speakTextInfo(info,formatConfig=formatConfig,reason=speech.REASON_CARET) 
     1201                speech.speakTextInfo(info,formatConfig=formatConfig,reason=controlTypes.REASON_CARET) 
    11961202                info.collapse() 
    11971203                self.selection = info 
    11981204