3
7ßL]±  ã               @   sX   d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
mZ G dd	„ d	eƒZdS )
z A Layered panel. é    )Úabsolute_importN)ÚScrolledPanel)ÚAnyÚStrÚInté   )ÚWidgetc                   sn   e Zd ZdZejZeZe	Z
edƒZedƒZ‡ fdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚLayeredPanelzÚ A Layered panel.

    A layered panel contains one or more named layers, with only one layer
    visible at any one time (think of a 'tab' control minus the tabs!).  Each
    layer is a toolkit-specific control.

    r   c                s(   t t| ƒjf |Ž | j|ƒ| _i | _dS )z Creates a new LayeredPanel. N)Úsuperr	   Ú__init__Ú_create_controlÚcontrolÚ_layers)ÚselfÚparentZtraits)Ú	__class__© ú>/tmp/pip-install-5sebvq2j/pyface/pyface/ui/wx/layered_panel.pyr   9   s    zLayeredPanel.__init__c             C   sè   | j jƒ }|j|dtjƒ |j|dƒ || j|< | jdksD| jdkrä|jƒ dkrT|S |jƒ j	ƒ }d}|j
ƒ | jkr€|j
ƒ | _d}|jƒ | jkrœ|jƒ | _d}|rä| j j| j| jƒ | j jƒ jƒ  | j jƒ }|jƒ j|ƒ |jƒ jƒ  |S )z— Adds a layer with the specified name.

        All layers are hidden when they are added.  Use 'show_layer' to make a
        layer visible.

        r   FNTéÿÿÿÿr   )r   ÚGetSizerÚAddÚwxZEXPANDÚShowr   Ú	min_widthÚ
min_heightZCalcMinZGetWidthZ	GetHeightZSetSizeHintsÚLayoutZ	GetParent)r   ÚnameÚlayerÚsizerZmin_sizeZneeds_layoutr   r   r   r   Ú	add_layerM   s,    	




zLayeredPanel.add_layerc             C   s,   | j dk	r| j| j ƒ | j|| j| ƒ}|S )z* Shows the layer with the specified name. N)Úcurrent_layerÚ_hide_layerÚ_show_layerr   )r   r   r   r   r   r   Ú
show_layer~   s    
zLayeredPanel.show_layerc             C   s
   || j kS )z9 Does the panel contain a layer with the specified name? )r   )r   r   r   r   r   Ú	has_layerŠ   s    zLayeredPanel.has_layerc             C   s<   t |d| jd�}tjtjƒ}|j|ƒ |jdƒ |jƒ  |S )zA Create the toolkit-specific control that represents the widget. r   )ÚstyleTr   )r   ÚSTYLEr   ZBoxSizerZVERTICALZSetSizerZSetAutoLayoutZSetupScrolling)r   r   Zpanelr   r   r   r   r   “   s    

zLayeredPanel._create_controlc             C   s"   | j jƒ }|j|dƒ |jƒ  dS )z Hides the specified layer. FN)r   r   r   r   )r   r   r   r   r   r   r!   ž   s    
zLayeredPanel._hide_layerc             C   s.   | j jƒ }|j|dƒ |jƒ  || _|| _|S )z Shows the specified layer. T)r   r   r   r   r    Úcurrent_layer_name)r   r   r   r   r   r   r   r"   §   s    
zLayeredPanel._show_layer)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZCLIP_CHILDRENr&   r   r    r   r'   r   r   r   r   r   r#   r$   r   r!   r"   Ú__classcell__r   r   )r   r   r	      s   1		r	   )r+   Ú
__future__r   r   Zwx.lib.scrolledpanelr   Z
traits.apir   r   r   Zwidgetr   r	   r   r   r   r   Ú<module>   s   