3
<Ad]d#  ã               @   sp   d Z ddlZddlmZ ddlmZmZ G dd„ deƒZG dd„ dej	ƒZ
G d	d
„ d
eƒZG dd„ dej	ƒZdS )z  Classes to provide a switcher. é    N)ÚScrolledPanel)Ú	HasTraitsÚIntc               @   s(   e Zd ZdZedƒZdd„ Zdd„ ZdS )	ÚSwitcherModelz! Base class for switcher models. é   c             C   s
   g | _ dS )z Creates a new switcher model. N)Úitems)Úself© r	   úq/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/pyface-6.1.2-py3.6.egg/pyface/wx/lazy_switcher.pyÚ__init__   s    zSwitcherModel.__init__c             C   s   t ‚dS )z( Creates a page for the switcher panel. N)ÚNotImplementedError)r   ÚparentÚindexr	   r	   r
   Úcreate_page+   s    zSwitcherModel.create_pageNéÿÿÿÿ)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úselectedr   r   r	   r	   r	   r
   r      s   r   c               @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚSwitcherControlz- The default switcher control (a combo box). Nc             K   s>   t jj| ||f|Ž || _|| _| j||ƒ |j| jdƒ dS )z! Creates a new switcher control. r   N)ÚwxÚPanelr   ÚmodelÚlabelÚ_create_widgetZon_trait_changeÚ_on_selected_changed)r   r   Úidr   r   Úkwr	   r	   r
   r   4   s    zSwitcherControl.__init__c             C   s   | j j|ƒ dS )z8 Called when the selected item in the model is changed. N)ÚcomboÚSetSelection)r   r   r	   r	   r
   r   L   s    z$SwitcherControl._on_selected_changedc             C   s   |j ƒ }|jƒ | j_dS )z1 Called when the combo box selection is changed. N)ZGetEventObjectÚGetSelectionr   r   )r   Úeventr   r	   r	   r
   Ú_on_comboboxW   s    zSwitcherControl._on_comboboxc             C   sN   t jt jƒ | _}| j|ƒ | jdƒ |j| j| ||ƒdt jƒ |j	| ƒ dS )z Creates the widget.Tr   N)
r   ÚBoxSizerÚVERTICALÚsizerÚSetSizerÚSetAutoLayoutÚAddÚ_comboÚEXPANDÚFit)r   r   r   r&   r	   r	   r
   r   e   s    


zSwitcherControl._create_widgetc       
      C   sÖ   t jt jƒ}|dk	r:t j|d|ƒ}|j|dt jt jB dƒ t j|dt jt j	B d� | _
}|j|dt jt jB t jB dƒ |j}t|ƒdkr¨x|jD ]\}}	|j||	ƒ q�W t j| |jƒ | jƒ |jdkrÒ|j|jƒ |S )	z Creates the switcher combo. Nr   r   é   )Ústyler   r   r   )r   r$   Ú
HORIZONTALZ
StaticTextr)   ZALIGN_CENTERÚALLZComboBoxZCB_DROPDOWNZCB_READONLYr   r+   r   ÚlenÚAppendZEVT_COMBOBOXÚGetIdr#   r   r    )
r   r   r   r   r&   Útextr   r   ÚnameÚdatar	   r	   r
   r*   u   s"    
zSwitcherControl._combo)N)	r   r   r   r   r   r   r#   r   r*   r	   r	   r	   r
   r   1   s   
r   c               @   s:   e Zd ZdZddd„Zdd„ Zdd	„ Zd
d„ Zdd„ ZdS )ÚSwitcherPanelz The default switcher panel. NTc             K   sB   t j| ||f|Ž | jƒ  || _|| _i | _d | _| j||ƒ d S )N)ÚwxScrolledPanelr   ZSetupScrollingr   ÚcacheÚ_page_cacheÚcurrentr   )r   r   r   r   r   r9   r   r	   r	   r
   r   š   s    zSwitcherPanel.__init__c             C   s   | j |ƒ dS )z( Shows the page at the specified index. N)Ú
_show_page)r   r   r	   r	   r
   Ú	show_page¸   s    
zSwitcherPanel.show_pagec             C   s   | j |ƒ dS )z8 Called when the selected item in the model is changed. N)r<   )r   r   r	   r	   r
   r   Ã   s    
z"SwitcherPanel._on_selected_changedc             C   s4   t jt jƒ | _}| j|ƒ | jdƒ |j| ƒ dS )z Creates the widget. TN)r   r$   r%   r&   r'   r(   r,   )r   r   r   r&   r	   r	   r
   r   Î   s
    



zSwitcherPanel._create_widgetc             C   s”   | j dk	r.| j jƒ }| j jdƒ | jj| j ƒ | jj|ƒ}| j sJ|dkrb| jj	| |ƒ}|| j|< | jj
|dtjdƒ |jdƒ || _ | jjƒ  dS )z( Shows the page at the specified index. NFé   r-   T)r;   ÚGetSizeZShowr&   ÚRemover:   Úgetr9   r   r   r)   r   r+   ÚLayout)r   r   Zcurrent_sizeÚpager	   r	   r
   r<   á   s    




zSwitcherPanel._show_page)NT)	r   r   r   r   r   r=   r   r   r<   r	   r	   r	   r
   r7   —   s   
r7   c               @   s"   e Zd ZdZddd„Zdd„ ZdS )ÚSwitcherz A switcher. Nc             K   s*   t jj| ||f|Ž || _| j||ƒ dS )z Create a new switcher. N)r   r   r   r   r   )r   r   r   r   r   r   r	   r	   r
   r     s    zSwitcher.__init__c             C   s|   t jt jƒ | _}| j|ƒ | jdƒ t| d||ƒ | _}|j|dt j	ƒ t
| d||ƒ | _}|j|dt j	ƒ |j| ƒ dS )z Creates the widget. Tr   r   Nr   r   )r   r$   r%   r&   r'   r(   r   Úcontrolr)   r+   r7   Úpanelr,   )r   r   r   r&   rE   rF   r	   r	   r
   r     s    


zSwitcher._create_widget)N)r   r   r   r   r   r   r	   r	   r	   r
   rD     s   
rD   )r   r   Zwx.lib.scrolledpanelr   r8   Z
traits.apir   r   r   r   r   r7   rD   r	   r	   r	   r
   Ú<module>   s   fn