a
    ¦ˆcr  ã                   @   sH   d Z ddlmZmZmZmZmZmZ G dd„ deƒZG dd„ deƒZ	dS )z, The base interface for all pyface widgets. é    )ÚAnyÚBoolÚ	HasTraitsÚ	InterfaceÚInstanceÚStrc                   @   s‚   e Zd ZdZeƒ Zeƒ ZedƒZedƒZ	e
ƒ Ze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„ Zdd„ ZdS )ÚIWidgetzl The base interface for all pyface widgets.

    Pyface widgets delegate to a toolkit specific control.
    Tú&pyface.action.menu_manager.MenuManagerc                 C   s   dS )z¦ Show or hide the widget.

        Parameters
        ----------
        visible : bool
            Visible should be ``True`` if the widget should be shown.
        N© )ÚselfÚvisibler
   r
   úR/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/i_widget.pyÚshow-   s    zIWidget.showc                 C   s   dS )z™ Enable or disable the widget.

        Parameters
        ----------
        enabled : bool
            The enabled state to set the widget to.
        Nr
   )r   Úenabledr
   r
   r   Úenable6   s    zIWidget.enablec                 C   s   dS )z0 Set the keyboard focus to this widget.
        Nr
   ©r   r
   r
   r   Úfocus?   s    zIWidget.focusc                 C   s   dS )z® Does the widget currently have keyboard focus?

        Returns
        -------
        focus_state : bool
            Whether or not the widget has keyboard focus.
        Nr
   r   r
   r
   r   Ú	has_focusC   s    zIWidget.has_focusc                 C   s   dS ©z— Creates the toolkit specific control.

        This method should create the control and assign it to the
        :py:attr:``control`` trait.
        Nr
   r   r
   r
   r   ÚcreateL   s    zIWidget.createc                 C   s   dS )z# Destroy the control if it exists. Nr
   r   r
   r
   r   ÚdestroyS   s    zIWidget.destroyc                 C   s   dS ©aU   Create toolkit specific control that represents the widget.

        Parameters
        ----------
        parent : toolkit control
            The toolkit control to be used as the parent for the widget's
            control.

        Returns
        -------
        control : toolkit control
            A control for the widget.
        Nr
   ©r   Úparentr
   r
   r   Ú_create_controlZ   s    zIWidget._create_controlc                 C   s   dS )ú- Set up toolkit-specific bindings for events Nr
   r   r
   r
   r   Ú_add_event_listenersi   s    zIWidget._add_event_listenersc                 C   s   dS )ú- Remove toolkit-specific bindings for events Nr
   r   r
   r
   r   Ú_remove_event_listenersl   s    zIWidget._remove_event_listenersN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úcontrolr   r   r   r   r   Útooltipr   Úcontext_menur   r   r   r   r   r   r   r   r   r
   r
   r
   r   r      s    			r   c                   @   sˆ   e Zd ZdZeƒ Ze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„ Zdd„ Zddd„Zdd„ Zdd„ Zdd„ ZdS ) ÚMWidgetzr The mixin class that contains common code for toolkit specific
    implementations of the IWidget interface.
    r	   c                 C   s   |   ¡  dS )zj Creates the toolkit specific control.

        The default implementation simply calls _create()
        N)Ú_creater   r
   r
   r   r   {   s    zMWidget.createc                 C   s   | j dur|  ¡  d| _ dS )z¾ Call clean-up code and destroy toolkit objects.

        Subclasses should override to perform any additional clean-up, ensuring
        that they call super() after that clean-up.
        N)r#   r   r   r
   r
   r   r   ‚   s    
zMWidget.destroyc                 C   s"   |   | j¡| _|  ¡  |  ¡  dS r   )r   r   r#   Ú_initialize_controlr   r   r
   r
   r   r'   �   s    zMWidget._createc                 C   s
   t ƒ ‚dS r   ©ÚNotImplementedErrorr   r
   r
   r   r   š   s    zMWidget._create_controlc                 C   s   |   | j¡ dS )zC Perform any post-creation initialization for the control.
        N)Ú_set_control_tooltipr$   r   r
   r
   r   r(   ª   s    zMWidget._initialize_controlc                 C   sD   | j | jddd� | j | jddd� | jdur@| jdur@|  ¡  dS )r   r$   Úui)Údispatchr%   N)ÚobserveÚ_tooltip_updatedÚ_context_menu_updatedr#   r%   Ú_observe_control_context_menur   r
   r
   r   r   ¯   s    ÿzMWidget._add_event_listenersc                 C   sL   | j dur | jdur | jdd� | j| jdddd� | j| jdddd� dS )r   NT©Úremover%   r,   )r-   r3   r$   )r#   r%   r1   r.   r0   r/   r   r
   r
   r   r   ¸   s    ü
ÿzMWidget._remove_event_listenersc                 C   s
   t ƒ ‚dS )z7 Toolkit specific method to get the control's tooltip. Nr)   r   r
   r
   r   Ú_get_control_tooltipÈ   s    zMWidget._get_control_tooltipc                 C   s
   t ƒ ‚dS )z7 Toolkit specific method to set the control's tooltip. Nr)   )r   r$   r
   r
   r   r+   Ì   s    zMWidget._set_control_tooltipFc                 C   s
   t ƒ ‚dS )a   Toolkit specific method to change the context menu observer.

        This should use _handle_control_context_menu as the event handler.

        Parameters
        ----------
        remove : bool
            Whether the context menu handler should be removed or added.
        Nr)   )r   r3   r
   r
   r   r1   Ð   s    
z%MWidget._observe_control_context_menuc                 C   s
   t ƒ ‚dS )a    Handle a context menu event.

        Implementations should override this with a method suitable to be used
        as a toolkit event handler that invokes a context menu.

        The function signature will likely vary from toolkit to toolkit.
        Nr)   ©r   Úeventr
   r
   r   Ú_handle_control_context_menuÜ   s    z$MWidget._handle_control_context_menuc                 C   s   |j }| jd ur|  |¡ d S )N)Únewr#   r+   )r   r6   r$   r
   r
   r   r/   è   s    
zMWidget._tooltip_updatedc                 C   s6   | j d ur2|jd u r | jdd� |jd u r2|  ¡  d S )NTr2   )r#   r8   r1   Úoldr5   r
   r
   r   r0   í   s
    


zMWidget._context_menu_updatedN)F)r   r    r!   r"   r   r$   r   r%   r   r   r'   r   r(   r   r   r4   r+   r1   r7   r/   r0   r
   r
   r
   r   r&   p   s    
	
r&   N)
r"   Z
traits.apir   r   r   r   r   r   r   r&   r
   r
   r
   r   Ú<module>   s    _