
    g
f                         d Z dZdZdZdZddlZ ej                  dd       dd	lmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd
lmZ ddlmZ  G d dej*                        Zy)z$Id$z
$Revision$z$Date$zQCopyright (c) 2005-2009 Sun Microsystems Inc., Copyright (c) 2010 Joanmarie DiggsLGPL    NAtspiz2.0)r   )AXObject)AXUtilitiesc                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)SpeechGeneratorc                 D    t         j                  j                  | |       y )N)speech_generatorr   __init__)selfscripts     [/usr/lib/python3/dist-packages/orca/scripts/toolkits/J2SE-access-bridge/speech_generator.pyr   zSpeechGenerator.__init__/   s    ((11$?    c                 X    d|d<   t        j                  j                  | |fi |}|d= |S )zThe Swing toolkit has labelled panels that do not implement the
        AccessibleText interface, but displayedText returns a meaningful
        string that needs to be used if displayedLabel returns None.
        FrequireText)r
   r   _generateAncestorsr   objargsresults       r   r   z"SpeechGenerator._generateAncestors2   s>    
 $]!11DD#r   c                     g }|j                  dt        j                  |            t        j                  j
                  k(  r|S |j                  t        j                  j                  | |fi |       |S )aw  Returns an array of strings (and possibly voice and audio
        specifications) that represent the text of the ancestors for
        the object.  This is typically used to present the context for
        an object (e.g., the names of the window, the panels, etc.,
        that the object is contained in).  If the 'priorObj' attribute
        of the args dictionary is set, only the differences in
        ancestry between the 'priorObj' and the current obj will be
        computed.  Otherwise, no ancestry will be computed.  The
        'priorObj' is typically set by Orca to be the previous object
        with focus.
        role)
getr   get_roler   RoleMENUextendr
   r   _generateNewAncestorsr   s       r   r   z%SpeechGenerator._generateNewAncestors=   sj     88FH--c23uzzF
 M&66//cC=AC 	Dr   c                 N   t        j                         j                  d      s4t        j                         j                  d      t        j                  k(  rg S g }t        j                  |      }|rt        j                  |      rmt        j                  |      rX|j                  t        j                  |             |j                   | j                  t        j                   fd|i|       |S |j                  t        j"                  j$                  | |fi |       |S )zReturns an array of strings (and possibly voice and audio
        specifications) that represents the number of children the
        object has.onlySpeakDisplayedTextspeechVerbosityLevelr   )settings_manager
getManager
getSettingsettingsVERBOSITY_LEVEL_BRIEFr   get_child_countr   is_labelis_expandedappendmessages	itemCountr   voicer
   SYSTEMr   _generateNumberOfChildren)r   r   r   r   
childCounts        r   r/   z)SpeechGenerator._generateNumberOfChildrenT   s    
 &&(334LM))+667MN001I--c2
+..s3&&s+MM(,,Z89MM*$**%5%<%<N#NNO
  MM*::33D#GAEG H r   c                 N   t        j                         j                  d      rg S d}t        j                  |      r(t        j
                  |      }t        |      dk(  r|d   }|!t        j                  j                  | |fi |S g }| j                  |      }d}dx}}	t        j                  |      D ]D  }
| j                  |
      }|r|d   dv st        j                  |
      s3|dz  }|	dz  }	||k(  sC|}F t        j                         j                  d      s|j                  dd	      rs|dk\  rn|j                  | j                   j"                  j%                  d
d      ||	dz         |j'                   | j(                  t        j*                  fd|i|       |S )zReturns an array of strings (and possibly voice and audio
        specifications) that represent the relative position of an
        object in a list.
        r    N   r   ) Empty	separatorenablePositionSpeaking	forceListFspeech
groupindex)mode
stringType)indextotalr   )r"   r#   r$   r   is_combo_boxfind_all_listslenr
   r   _generatePositionInList_generateNamer   iter_children
is_visibler   r*   _script
formatting	getStringr   r-   r.   )r   r   r   listObjallListsr   namepositionr=   r>   childnextNames               r   rB   z'SpeechGenerator._generatePositionInListj   s    &&(334LMI##C("11#6H8}!"1+?#33KKc#!# # !!#&++G4 
	!E))%0Hx{.HH!,,U3QJEQJE4 
	! '')445MNxxU+1}MM$,,11;;#+ < F,4!FG H MM*$**%5%<%<N#NNOr   c                 `   g }t        j                  |      rt        j                  t        j                  |            rl| j                  t        j                  j                  |      }|j                  t        j                  j                  | |fi |       | j                  ||       |j                  dd      dk(  r=t        j                  |      r(t        j                   |t         j"                        }||}|j                  t        j                  j                  | |fi |       |S )N
formatType	unfocusedbasicWhereAmI)r   is_check_boxis_menur   
get_parent_overrideRoler   r   CHECK_MENU_ITEMr   r
   r   generateSpeech_restoreRoler   is_textfind_ancestoris_spin_button)r   r   r   r   oldRolespinboxs         r   rX   zSpeechGenerator.generateSpeech   s    ##C([-@-@ATATUXAY-Z(()C)CTJGMM*::+9>$MGKM Ngt,88L+./AkFYFYZ]F^,,S+2L2LMG"&66EEdCXSWXYr   N)	__name__
__module____qualname__r   r   r   r/   rB   rX    r   r   r   r   -   s"    @	.,+Zr   r   )__id____version____date____copyright____license__girequire_versiongi.repositoryr   orca.messagesr+   orca.settingsr%   orca.settings_managerr"   orca.speech_generatorr
   orca.ax_objectr   orca.ax_utilitiesr   r   rb   r   r   <module>rq      sa   * 5 	   7E "      0 0 # )w&66 wr   