a
    §ˆcH  ã                   @   sŽ   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	m
Z
 d dlmZ eeddƒZG d	d
„ d
eƒZee	ƒG dd„ de
eƒƒZdd„ ZdS )é    )ÚEnum)Úprovides)ÚQtGui©ÚDEFAULT_SIZE)ÚILayoutWidgetÚMLayoutWidget)ÚWidgetÚQWIDGETSIZE_MAXi  € c                   @   s.   e Zd ZdZejjjZejjj	Z
ejjjZdS )ÚSizePolicieszz Qt values for size policies

    Note that Qt has additional values that are not mapped to Pyface size
    policies.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚQSizePolicyÚPolicyZFixedÚfixedZ	PreferredÚ	preferredZ	ExpandingÚexpand© r   r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/ui/qt4/layout_widget.pyr      s   

r   c                       s`   e Zd Z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‡ fdd„Z‡  ZS )ÚLayoutWidgetz5 A widget which can participate as part of a layout. c                 C   s"   t dd„ |D ƒƒ}| jj|Ž  d S )Nc                 s   s   | ]}|t kr|nd V  qdS )r   Nr   ©Ú.0Úxr   r   r   Ú	<genexpr>)   s   ÿz9LayoutWidget._set_control_minimum_size.<locals>.<genexpr>)ÚtupleÚcontrolZsetMinimumSize©ÚselfÚsizer   r   r   Ú_set_control_minimum_size(   s    þz&LayoutWidget._set_control_minimum_sizec                 C   s   | j  ¡ }| ¡ | ¡ fS ©N)r   ZminimumSizeÚwidthÚheightr   r   r   r   Ú_get_control_minimum_size/   s    
z&LayoutWidget._get_control_minimum_sizec                 C   s"   t dd„ |D ƒƒ}| jj|Ž  d S )Nc                 s   s   | ]}|t kr|ntV  qd S r"   )r   r
   r   r   r   r   r   4   s   ÿz9LayoutWidget._set_control_maximum_size.<locals>.<genexpr>)r   r   ZsetMaximumSizer   r   r   r   Ú_set_control_maximum_size3   s    þz&LayoutWidget._set_control_maximum_sizec                 C   s   | j  ¡ }| ¡ | ¡ fS r"   )r   ZmaximumSizer#   r$   r   r   r   r   Ú_get_control_maximum_size:   s    
z&LayoutWidget._get_control_maximum_sizec                 C   s:   t | j ¡ ƒ}| |d ¡ | |d ¡ | j |¡ dS )z0 Set the stretch factor of the control.
        r   é   N)Ú_clone_size_policyr   Ú
sizePolicyÚsetHorizontalStretchÚsetVerticalStretchÚsetSizePolicy)r   ZstretchÚnew_size_policyr   r   r   Ú_set_control_stretch>   s    z!LayoutWidget._set_control_stretchc                 C   s   | j  ¡ }| ¡ | ¡ fS )z_ Get the stretch factor of the control.

        This method is only used for testing.
        )r   r*   ÚhorizontalStretchÚverticalStretch)r   Úsize_policyr   r   r   Ú_get_control_stretchF   s    
þz!LayoutWidget._get_control_stretchc                 C   s^   t | j ¡ ƒ}|d dkr.| t|d  j¡ |d dkrN| t|d  j¡ | j |¡ d S ©Nr   Údefaultr(   )r)   r   r*   ÚsetHorizontalPolicyr   ÚvalueÚsetVerticalPolicyr-   )r   r2   r.   r   r   r   Ú_set_control_size_policyQ   s    ÿÿz%LayoutWidget._set_control_size_policyc                 C   sV   | j  ¡ }| jd dkr(t| ¡ ƒj}nd}| jd dkrJt| ¡ ƒj}nd}||fS r4   )r   r*   r2   r   ÚhorizontalPolicyÚnameÚverticalPolicy)r   r2   Zhorizontal_policyZvertical_policyr   r   r   Ú_get_control_size_policy]   s    
ÿÿz%LayoutWidget._get_control_size_policyc                    s"   | j d ur| j  ¡  tƒ  ¡  d S r"   )r   ÚhideÚsuperÚdestroy)r   ©Ú	__class__r   r   r@   k   s    

zLayoutWidget.destroy)r   r   r   r   r!   r%   r&   r'   r/   r3   r9   r=   r@   Ú__classcell__r   r   rA   r   r   $   s   r   c                 C   s`   t  ¡ }| |  ¡ ¡ | |  ¡ ¡ | |  ¡ ¡ | |  	¡ ¡ | 
|  ¡ ¡ | |  ¡ ¡ |S )z‡ Clone the state of an existing QSizePolicy object

    This is required because there is no standard Qt copy or clone
    method.
    )r   r   r6   r:   r8   r<   r+   r0   r,   r1   ZsetHeightForWidthZhasHeightForWidthZsetWidthForHeightZhasWidthForHeight)r2   r.   r   r   r   r)   q   s(    ÿÿÿÿÿÿr)   N)Úenumr   Z
traits.apir   Z	pyface.qtr   Zpyface.i_layout_itemr   Zpyface.i_layout_widgetr   r   Zpyface.ui.qt4.widgetr	   Úgetattrr
   r   r   r)   r   r   r   r   Ú<module>   s   L