
    g
f                         d Z dZdZdZdZdZddlZddlmZ d	d
l	m
Z
 d	dlmZ dZdZdZ G d dej                         Z G d dej$                        Z G d dej(                        Zy)zCProvides a graphical braille display, mainly for development tasks.z$Id$z
$Revision$z$Date$zNCopyright (c) 2005-2008 Sun Microsystems Inc.Copyright (c) 2011 The Orca Team.LGPL    N)Gtk   )script_manager)BrailleEvent@      Àc                   <     e Zd ZdZdZdZdZd fd	Zd Zd Z	 xZ
S )	BrlDotzA single braille dot.z<tt><small>%s</small></tt>u   ○u   ●c                 z   t         |           |dv r)| j                  dddd       | j                  dddd       n(| j                  dddd       | j                  dddd       t	        j
                         | _        | j                  | j                         |r| j                          y| j                          y)zCreate a new BrlDot.

        Arguments:
        - dotNumber: an integer reflecting the location of the dot within
          an 8-dot braille cell, using traditional braille dot values.
        )r            g      ?      ?g        r   r   N)
super__init__setset_paddingr   LabellabeladdraiseDotlowerDot)self	dotNumberisRaised	__class__s      -/usr/lib/python3/dist-packages/orca/brlmon.pyr   zBrlDot.__init__2   s     	$HHS#sC(Q1a(HHS#sC(Q1a(YY[
MMOMMO    c                     | j                  dddd       | j                  j                  | j                  | j                  z         y Nr   r   )r   r   
set_markupMARKUP_NORMALSYMBOL_RAISEDr   s    r   r   zBrlDot.raiseDotI   s7    c1a 

d0043E3EEFr    c                     | j                  dddd       | j                  j                  | j                  | j                  z         y r"   )r   r   r#   r$   SYMBOL_LOWEREDr&   s    r   r   zBrlDot.lowerDotM   s7    c1a 

d0043F3FFGr    )F)__name__
__module____qualname____doc__r$   r(   r%   r   r   r   __classcell__r   s   @r   r   r   +   s&    1MNM.GHr    r   c                   2    e Zd ZdZdZdZd Zd Zd Zd	dZ	y)
BrlCellz?A single graphical braille cell with cursor routing capability.z<tt><big>%s</big></tt>z<b><u>%s</u></b>c                 "   t         j                  j                  |        | j                  dd       || _        t        j
                         | _        t        d      | _        t        d      | _	        t        j                         }|j                  | j                  dddd       |j                  | j                  dddd       |j                  | j                  dddd       | j                  |       | j                  d	| j                         y
)z|Create a new BrlCell.

        Arguments:
        - position: The location of the cell with respect to the monitor.
           -   r      r   r   r   r   clickedN)r   Buttonr   set_size_request	_positionr   _displayedCharr   _dot7_dot8Gridattachr   connect_onCellClicked)r   positiongrids      r   r   zBrlCell.__init__W   s     	

D!b"%!!iikAY
AY
xxzD''Aq!4DJJ1a+DJJ1a+Y 3 34r    c                     t        j                         j                         }|yi }t        j                  |d<   | j
                  |d<   t        |      }|j                  |       y)zCallback for the 'clicked' signal on the push button. Synthesizes
        a fake brlapi command to route the cursor to the current cell, similar
        to what occurs when a user presses the cursor routing key on his/her
        hardware braille display.Ncommandargument)r   
getManagergetActiveScriptbrlapiKEY_CMD_ROUTEr8   r   processRoutingKey)r   widgetscriptfakeKeyPressevents        r   r?   zBrlCell._onCellClickedm   s^      **,<<>>"("6"6Y#'>>Z \*  'r    c                     | j                   j                  d       | j                  j                          | j                  j                          y)zClears the braille cell. N)r9   r#   r:   r   r;   r&   s    r   clearzBrlCell.clear}   s8     	&&r*



r    Nc                 J   |dk(  rd}n|dk(  rd}n|dk(  rd}| j                   }|r|| j                  z  }| j                  j                  ||z         |t        t
        fv r| j                  j                          |t        t
        fv r| j                  j                          yy)zDisplays the specified character in the cell.

        Arguments:
        - char: The character to display in the cell.
        - isCursorCell: If True, the cursor/caret is at this cell and this
          should be indicated visually.
        &z&amp;<z&lt;	z$tN)
r$   MARKUP_CURSOR_CELLr9   r#   DOT_7DOTS_78r:   r   DOT_8r;   )r   charmaskisCursorCellmarkups        r   displayzBrlCell.display   s     3;DS[DT\D##d555F&&v}5E7##JJ!E7##JJ! $r    )NF)
r)   r*   r+   r,   r$   rU   r   r?   rP   r]    r    r   r0   r0   Q   s$    I1M+5,( "r    r0   c                   2     e Zd ZdZd fd	Zd ZddZ xZS )BrlMona1  Displays a GUI braille monitor that mirrors what would be displayed
    by Orca on a connected, configured, and enabled braille display. Cursor
    routing functionality is emulated by each cell being a push button.
    Panning and other functionality found on hardware braille displays will
    be added.c                    t         |           | j                  d       t        j                         }| j                  |       g | _        t        |      D ]=  }t        |      }|j                  ||ddd       | j                  j                  |       ? | j                  d       | j                  dd       | j                  d       | j                  d       y)zdCreate a new BrlMon.

        Arguments:
        - numCells: how many braille cells to make
        zBraille Monitorr   r   Fzaccept-focusTN)r   r   	set_titler   r<   r   cellsranger0   r=   appendset_resizableset_propertyset_skip_taskbar_hintset_skip_pager_hint)r   numCellsrA   icellr   s        r   r   zBrlMon.__init__   s     	()xxz
x 	$A1:DKKaAq)JJd#	$
 	5!.%0""4(  &r    c                 F    | j                   D ]  }|j                           y)z#Clears the braille monitor display.N)rc   rP   )r   rl   s     r   rP   zBrlMon.clear   s      JJ 	DJJL	r    c                 $   | j                          t        t        |      t        | j                              }t	        |      D ]3  }||dz
  k(  }	 ||   }| j                  |   j                  ||   ||       5 y# t
        t        f$ r d}Y 9w xY w)zDisplay the given text and highlight the given
        cursor cell.  A cursorCell of 0 means no cell has
        the cursor.

        Arguments:
        - cursorCell: 1-based index of cell with cursor
        - string: len must be <= num cells.
        r   N)rP   minlenrc   rd   
IndexError	TypeErrorr]   )r   
cursorCellstringrZ   lengthrk   r[   cellMasks           r   	writeTextzBrlMon.writeText   s     	

S[#djj/2v 	EA
Q.L 7 JJqM!!&)X|D	E 	*   s   A;;BB)    )N)r)   r*   r+   r,   r   rP   rw   r-   r.   s   @r   r`   r`      s    '0Er    r`   )r,   __id____version____date____copyright____license__rG   gi.repositoryr   rO   r   input_eventr   rV   rX   rW   	Alignmentr   r6   r0   Windowr`   r^   r    r   <module>r      s{   , J4    % 

$HS]] $HLK"cjj K"Z7ESZZ 7Er    