a
    ¦ˆco  ã                   @   sL   d Z ddlmZmZmZmZ ddlmZ G dd„ deƒZG dd„ deƒZ	dS )	ú The text field interface. é    )ÚBoolÚEnumÚ	HasTraitsÚStr)ÚIFieldc                   @   s6   e Zd ZdZeƒ ZeddƒZeƒ ZeddƒZ	e
ƒ ZdS )Ú
ITextFieldr   ÚautoÚediting_finishedÚnormalÚpasswordN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úvaluer   Úupdate_textÚplaceholderÚechor   Ú	read_only© r   r   ú]/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/fields/i_text_field.pyr      s   

r   c                       sÀ   e Zd ZdZeƒ ZeddƒZeƒ ZeddƒZ	e
ƒ Z‡ fdd„Z‡ fdd	„Z‡ fd
d„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd%dd„Zdd„ Zdd „ Zd!d"„ Zd#d$„ Z‡  ZS )&Ú
MTextFieldz The text field mix-in. r	   r
   r   r   c                    s>   |   | j¡ |  | j¡ |  | j¡ |  | j¡ tƒ  	¡  d S ©N)
Ú_set_control_echor   Z_set_control_valuer   Ú_set_control_placeholderr   Ú_set_control_read_onlyr   ÚsuperÚ_initialize_control©Úself©Ú	__class__r   r   r   <   s
    zMTextField._initialize_controlc                    s|   t ƒ  ¡  | j| jddd� | j| jddd� | j| jddd� | j| jddd� | jdurx| jdkrp|  	¡  n|  
¡  dS )	z- Set up toolkit-specific bindings for events r   Úui)Údispatchr   r   r   Nr
   )r   Ú_add_event_listenersÚobserveÚ_update_text_updatedÚ_placeholder_updatedÚ_echo_updatedÚ_read_only_updatedÚcontrolr   Ú!_observe_control_editing_finishedÚ_observe_control_valuer   r!   r   r   r%   D   s    



zMTextField._add_event_listenersc                    sŒ   | j dur.| jdkr"| jdd� n| jdd� | j| jdddd� | j| jdddd� | j| jd	ddd� | j| jd
ddd� t	ƒ  
¡  dS )z- Remove toolkit-specific bindings for events Nr
   T©Úremover   r#   )r$   r/   r   r   r   )r+   r   r,   r-   r&   r'   r(   r)   r*   r   Ú_remove_event_listenersr   r!   r   r   r0   Q   s.    

üü
ÿ
ÿz"MTextField._remove_event_listenersc                 C   s    | j d ur|  ¡ }|  |¡ d S r   )r+   Z_get_control_valueZ_update_value)r    r   r   r   r   Ú_editing_finishedl   s    
zMTextField._editing_finishedc                 C   s
   t ƒ ‚dS ©z; Toolkit specific method to set the control's placeholder. N©ÚNotImplementedErrorr   r   r   r   Ú_get_control_placeholders   s    z#MTextField._get_control_placeholderc                 C   s
   t ƒ ‚dS r2   r3   )r    r   r   r   r   r   w   s    z#MTextField._set_control_placeholderc                 C   s
   t ƒ ‚dS )z4 Toolkit specific method to get the control's echo. Nr3   r   r   r   r   Ú_get_control_echo{   s    zMTextField._get_control_echoc                 C   s
   t ƒ ‚dS )z4 Toolkit specific method to set the control's echo. Nr3   )r    r   r   r   r   r      s    zMTextField._set_control_echoc                 C   s
   t ƒ ‚dS )z? Toolkit specific method to get the control's read_only state. Nr3   r   r   r   r   Ú_get_control_read_onlyƒ   s    z!MTextField._get_control_read_onlyc                 C   s
   t ƒ ‚dS )z? Toolkit specific method to set the control's read_only state. Nr3   )r    r   r   r   r   r   ‡   s    z!MTextField._set_control_read_onlyFc                 C   s
   t ƒ ‚dS )z4 Change observation of whether editing is finished. Nr3   )r    r/   r   r   r   r,   ‹   s    z,MTextField._observe_control_editing_finishedc                 C   s   | j d ur|  | j¡ d S r   )r+   r   r   ©r    Úeventr   r   r   r(   ‘   s    
zMTextField._placeholder_updatedc                 C   s   | j d ur|  | j¡ d S r   )r+   r   r   r8   r   r   r   r)   •   s    
zMTextField._echo_updatedc                 C   s   | j d ur|  | j¡ d S r   )r+   r   r   r8   r   r   r   r*   ™   s    
zMTextField._read_only_updatedc                 C   sB   | j dur>|jdkr*| jdd� |  ¡  n| jdd� |  ¡  dS )z4 Change how we listen to for updates to text value. Nr
   Tr.   )r+   Únewr-   r,   r8   r   r   r   r'   �   s    


zMTextField._update_text_updated)F)r   r   r   r   r   r   r   r   r   r   r   r   r   r%   r0   r1   r5   r   r6   r   r7   r   r,   r(   r)   r*   r'   Ú__classcell__r   r   r!   r   r   &   s*   


r   N)
r   Z
traits.apir   r   r   r   Zpyface.fields.i_fieldr   r   r   r   r   r   r   Ú<module>   s   