a
    ¦ˆc"  ã                   @   sZ   d dl mZmZmZ d dlmZmZmZ d dlm	Z	 G dd„ de	eƒZ
G dd„ deƒZdS )	é    )Ú	HasTraitsÚIntÚTuple)ÚILayoutItemÚSizeÚ
SizePolicy)ÚIWidgetc                   @   s   e Zd ZdZdS )ÚILayoutWidgetz¬ Interface for widgets that can participate in layout.

    Most widgets implement ILayoutWidget, but widgets like top-level windows,
    menus, toolbars, etc. do not.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úY/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/i_layout_widget.pyr	      s   r	   c                       s´   e Zd ZdZeZeZeeeƒZ	ee
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„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS ) ÚMLayoutWidgetz« A mixin for Widgets that can participate in layouts.

    Most widgets implement ILayoutWidget, but widgets like top-level windows,
    menus, toolbars, etc. do not.
    c                    s>   t ƒ  ¡  |  | j¡ |  | j¡ |  | j¡ |  | j	¡ dS )z! Initialize the toolkit control. N)
ÚsuperÚ_initialize_controlÚ_set_control_minimum_sizeÚminimum_sizeÚ_set_control_maximum_sizeÚmaximum_sizeÚ_set_control_stretchÚstretchÚ_set_control_size_policyÚsize_policy©Úself©Ú	__class__r   r   r   -   s
    
z!MLayoutWidget._initialize_controlc                    sV   t ƒ  ¡  | j| jddd� | j| jddd� | j| jddd� | j| jddd� dS )z* Add trait observers and toolkit binding. r   Úui)Údispatchr   r   r   N)r   Ú_add_event_listenersÚobserveÚ_minimum_size_updatedÚ_maximum_size_updatedÚ_stretch_updatedÚ_size_policy_updatedr   r   r   r   r!   5   s*    
ýýýýz"MLayoutWidget._add_event_listenersc                    s^   | 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 trait observers and toolkit binding. r   r   T)r    Úremover   r   r   N)r"   r#   r$   r%   r&   r   Ú_remove_event_listenersr   r   r   r   r(   M   s2    üüüüz%MLayoutWidget._remove_event_listenersc                 C   s   | j dur|  |j¡ dS )z" Trait observer for minimum size. N)Úcontrolr   Únew©r   Úeventr   r   r   r#   i   s    
z#MLayoutWidget._minimum_size_updatedc                 C   s   | j dur|  |j¡ dS )z" Trait observer for maximum size. N)r)   r   r*   r+   r   r   r   r$   n   s    
z#MLayoutWidget._maximum_size_updatedc                 C   s   | j dur|  |j¡ dS )z Trait observer for stretch. N)r)   r   r*   r+   r   r   r   r%   s   s    
zMLayoutWidget._stretch_updatedc                 C   s   | j dur|  |j¡ dS )z! Trait observer for size policy. N)r)   r   r*   r+   r   r   r   r&   x   s    
z"MLayoutWidget._size_policy_updatedc                 C   s
   t ƒ ‚dS )zr Set the minimum size of the control.

        Toolkit implementations will need to override this method.
        N©ÚNotImplementedError©r   Úsizer   r   r   r   }   s    z'MLayoutWidget._set_control_minimum_sizec                 C   s
   t ƒ ‚dS )z  Get the minimum size of the control.

        Toolkit implementations will need to override this method.
        This method is only used for testing.
        Nr-   r   r   r   r   Ú_get_control_minimum_size„   s    z'MLayoutWidget._get_control_minimum_sizec                 C   s
   t ƒ ‚dS )zr Set the maximum size of the control.

        Toolkit implementations will need to override this method.
        Nr-   r/   r   r   r   r   Œ   s    z'MLayoutWidget._set_control_maximum_sizec                 C   s
   t ƒ ‚dS )z  Get the maximum size of the control.

        Toolkit implementations will need to override this method.
        This method is only used for testing.
        Nr-   r   r   r   r   Ú_get_control_maximum_size“   s    z'MLayoutWidget._get_control_maximum_sizec                 C   s
   t ƒ ‚dS )zt Set the stretch factor of the control.

        Toolkit implementations will need to override this method.
        Nr-   )r   r   r   r   r   r   ›   s    z"MLayoutWidget._set_control_stretchc                 C   s
   t ƒ ‚dS )z¢ Get the stretch factor of the control.

        Toolkit implementations will need to override this method.
        This method is only used for testing.
        Nr-   r   r   r   r   Ú_get_control_stretch¢   s    z"MLayoutWidget._get_control_stretchc                 C   s
   t ƒ ‚dS )zq Set the size policy of the control.

        Toolkit implementations will need to override this method.
        Nr-   )r   r   r   r   r   r   ª   s    z&MLayoutWidget._set_control_size_policyc                 C   s
   t ƒ ‚dS )zŸ Get the size policy of the control.

        Toolkit implementations will need to override this method.
        This method is only used for testing.
        Nr-   r   r   r   r   Ú_get_control_size_policy±   s    z&MLayoutWidget._get_control_size_policy)r
   r   r   r   r   r   r   r   r   r   r   r   r   r!   r(   r#   r$   r%   r&   r   r1   r   r2   r   r3   r   r4   Ú__classcell__r   r   r   r   r      s(   

r   N)Z
traits.apir   r   r   Zpyface.i_layout_itemr   r   r   Zpyface.i_widgetr   r	   r   r   r   r   r   Ú<module>   s   	