Пример #1
0
    def bookmarkCurrentWhereAmI(self, inputEvent):
        """ Report "Where am I" information for this bookmark relative to the 
        current pointer location."""
        try:
            context = self._bookmarkToContext( \
                          self._bookmarks[inputEvent.hw_code])
        except KeyError:
            self._script.systemBeep()
            return   

        obj = context.getCurrentAccessible()    
        cur_obj = orca_state.locusOfFocus

        # Are they the same object?
        if self._script.utilities.isSameObject(cur_obj, obj):
            # Translators: this announces that the current object is the same
            # object pointed to by the bookmark.
            #
            self._script.presentMessage(_('bookmark is current object'))
            return
        # Are their parents the same?
        elif self._script.utilities.isSameObject(cur_obj.parent, obj.parent):
            # Translators: this announces that the current object's parent and 
            # the parent of the object pointed to by the bookmark are the same.
            #
            self._script.presentMessage(
                _('bookmark and current object have same parent'))
            return

        # Do they share a common ancestor?
        # bookmark's ancestors
        bookmark_ancestors = []
        p = obj.parent
        while p:
            bookmark_ancestors.append(p)
            p = p.parent
        # look at current object's ancestors to compare to bookmark's ancestors
        p = cur_obj.parent
        while p:
            if bookmark_ancestors.count(p) > 0:
                rolename = rolenames.getSpeechForRoleName(p)
                # Translators: this announces that the bookmark and the current
                # object share a common ancestor
                #
                self._script.presentMessage(_('shared ancestor %s') % rolename)
                return
            p = p.parent

        # Translators: This announces that a comparison between the bookmark
        # and the current object can not be determined.
        #
        self._script.presentMessage(_('comparison unknown'))
Пример #2
0
    def getSpeechContext(self, obj, stopAncestor=None):
        """Get the speech that describes the names and role of
        the container hierarchy of the object, stopping at and
        not including the stopAncestor.

        This method is identical to speechgeneratior.getSpeechContext
        with one exception. The following test in
        speechgenerator.getSpeechContext:

            if not text and parent.text:
                text = self._script.getDisplayedText(parent)

        has be replaced by

            if not text:
                text = self._script.getDisplayedText(parent)

        The Swing toolkit has components that do not implement the
        AccessibleText interface, but getDisplayedText returns
        a meaningful string that needs to be used if getDisplayedLabel
        returns None.

        Arguments:
        - obj: the object
        - stopAncestor: the anscestor to stop at and not include (None
          means include all ancestors)

        Returns a list of utterances to be spoken.
        """

        utterances = []

        if not obj:
            return utterances

        if obj is stopAncestor:
            return utterances

        parent = obj.parent
        if parent \
            and (obj.role == rolenames.ROLE_TABLE_CELL) \
            and (parent.role == rolenames.ROLE_TABLE_CELL):
            parent = parent.parent

        while parent and (parent.parent != parent):
            if parent == stopAncestor:
                break
            if not self._script.isLayoutOnly(parent):
                text = self._script.getDisplayedLabel(parent)
                if not text:  # changed from speechgenerator method
                    text = self._script.getDisplayedText(parent)
                if text and len(text.strip()):
                    # Push announcement of cell to the end
                    #
                    if not parent.role in [
                            rolenames.ROLE_TABLE_CELL, rolenames.ROLE_FILLER
                    ]:
                        utterances.append(\
                            rolenames.getSpeechForRoleName(parent))
                    utterances.append(text)
                    if parent.role == rolenames.ROLE_TABLE_CELL:
                        utterances.append(\
                            rolenames.getSpeechForRoleName(parent))
            parent = parent.parent

        utterances.reverse()

        return utterances
    def getSpeechContext(self, obj, stopAncestor=None):
        """Get the speech that describes the names and role of
        the container hierarchy of the object, stopping at and
        not including the stopAncestor.

        This method is identical to speechgeneratior.getSpeechContext
        with one exception. The following test in
        speechgenerator.getSpeechContext:

            if not text and parent.text:
                text = self._script.getDisplayedText(parent)

        has be replaced by

            if not text:
                text = self._script.getDisplayedText(parent)

        The Swing toolkit has components that do not implement the
        AccessibleText interface, but getDisplayedText returns
        a meaningful string that needs to be used if getDisplayedLabel
        returns None.

        Arguments:
        - obj: the object
        - stopAncestor: the anscestor to stop at and not include (None
          means include all ancestors)

        Returns a list of utterances to be spoken.
        """

        utterances = []

        if not obj:
            return utterances

        if obj is stopAncestor:
            return utterances

        parent = obj.parent
        if parent \
            and (obj.role == rolenames.ROLE_TABLE_CELL) \
            and (parent.role == rolenames.ROLE_TABLE_CELL):
            parent = parent.parent

        while parent and (parent.parent != parent):
            if parent == stopAncestor:
                break
            if not self._script.isLayoutOnly(parent):
                text = self._script.getDisplayedLabel(parent)
                if not text:  # changed from speechgenerator method
                    text = self._script.getDisplayedText(parent)
                if text and len(text.strip()):
                    # Push announcement of cell to the end
                    #
                    if not parent.role in [rolenames.ROLE_TABLE_CELL,
                                           rolenames.ROLE_FILLER]:
                        utterances.append(\
                            rolenames.getSpeechForRoleName(parent))
                    utterances.append(text)
                    if parent.role == rolenames.ROLE_TABLE_CELL:
                        utterances.append(\
                            rolenames.getSpeechForRoleName(parent))
            parent = parent.parent

        utterances.reverse()

        return utterances