a
    §ˆc>  ã                   @   sn   d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	 dZ
eeƒG dd„ dee	ƒƒZd	d
„ Zdd„ ZdS )é    N)Úprovides)ÚDEFAULT_SIZE)ÚILayoutWidgetÚMLayoutWidget)ÚWidgetéÿÿÿÿc                   @   sP   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dS )ÚLayoutWidgetz� A widget which can participate as part of a layout.

    This is an abstract class, as Widget._create_control needs to be
    implemented at a minimum.
    c                 C   s   t |ƒ}| j |¡ dS )z& Set the minimum size of the control. N)Ú_size_to_wx_sizeÚcontrolZ
SetMinSize©ÚselfÚsizeÚwx_size© r   ú]/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/ui/wx/layout_widget.pyÚ_set_control_minimum_size    s    z&LayoutWidget._set_control_minimum_sizec                 C   s   | j  ¡ }t|ƒS )z& Get the minimum size of the control. )r
   Z
GetMinSizeÚ_wx_size_to_size©r   r   r   r   r   Ú_get_control_minimum_size%   s    
z&LayoutWidget._get_control_minimum_sizec                 C   s   t |ƒ}| j |¡ dS )z& Set the maximum size of the control. N)r	   r
   Z
SetMaxSizer   r   r   r   Ú_set_control_maximum_size*   s    z&LayoutWidget._set_control_maximum_sizec                 C   s   | j  ¡ }t|ƒS )z& Get the maximum size of the control. )r
   Z
GetMaxSizer   r   r   r   r   Ú_get_control_maximum_size/   s    
z&LayoutWidget._get_control_maximum_sizec                 C   s   dS )zÀ Set the stretch factor of the control.

        In Wx the stretch factor is set at layout time and can't be changed
        without removing and adding the widget back into a layout.
        Nr   ©r   Úsize_policyr   r   r   Ú_set_control_stretch4   s    z!LayoutWidget._set_control_stretchc                 C   s   | j S )a   Get the stretch factor of the control.

        In Wx the stretch factor is set at layout time and can't be obtained
        from the widget itself.  As a result, this method simply returns the
        current trait value.  This method is only used for testing.
        )Zstretch©r   r   r   r   Ú_get_control_stretch<   s    z!LayoutWidget._get_control_stretchc                 C   s   dS )z¹ Set the size policy of the control

        In Wx the size policy is set at layout time and can't be changed
        without removing and adding the widget back into a layout.
        Nr   r   r   r   r   Ú_set_control_size_policyE   s    z%LayoutWidget._set_control_size_policyc                 C   s   | j S )a   Get the size policy of the control

        In Wx the size policy is set at layout time and can't be obtained from
        the widget itself.  As a result, this method simply returns the
        current trait value.  This method is only used for testing.
        )r   r   r   r   r   Ú_get_control_size_policyM   s    z%LayoutWidget._get_control_size_policyN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r   r      s   	r   c                 C   s   t jdd„ | D ƒŽ S )a   Convert a size tuple to a wx.Size instance.

    Parameters
    ----------
    size : tuple of (width, height)
        The width and height as a tuple of ints.

    Returns
    -------
    wx_size : wx.Size instance
        A corresponding wx Size instance.
    c                 s   s   | ]}|t kr|ntV  qd S )N)r   ÚWX_DEFAULT_SIZE)Ú.0Úxr   r   r   Ú	<genexpr>d   s   ÿz#_size_to_wx_size.<locals>.<genexpr>)ÚwxÚSize)r   r   r   r   r	   W   s    
þr	   c                 C   s   |   ¡ |  ¡ fS )a   Convert a wx.Size instance to a size tuple.

    Parameters
    ----------
    wx_size : wx.Size instance
        A wx Size instance.

    Returns
    -------
    size : tuple of (width, height)
        The corresponding width and height as a tuple of ints.
    )ZGetWidthZ	GetHeight)r   r   r   r   r   j   s    r   )r&   Z
traits.apir   Zpyface.i_layout_itemr   Zpyface.i_layout_widgetr   r   Zpyface.ui.wx.widgetr   r"   r   r	   r   r   r   r   r   Ú<module>   s   >