a
    §ˆcù  ã                   @   s@   d Z ddlmZmZ ddlmZ ddlmZ G dd„ deƒZdS )	ú6 A wizard controller that can be chained with others. é    )ÚInstanceÚobserveé   )ÚIWizardController)ÚWizardControllerc                   @   sˆ   e Zd ZdZeeƒ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edƒdd„ ƒZedƒdd„ ƒZdd„ Zdd„ ZdS )ÚChainedWizardControllerr   c                 C   sh   d}|| j v rN|| j d ur8| j  |¡}| j |d  }qd| jdurd| j ¡ }n| jdurd| j |¡}|S )z Returns the next page. Néÿÿÿÿr   )Ú_pagesÚindexÚnext_controllerZget_first_pageÚget_next_page)ÚselfÚpageZ	next_pager   © r   új/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/wizard/chained_wizard_controller.pyr   !   s    


z%ChainedWizardController.get_next_pagec                 C   s^   || j v r&| j  |¡}| j |d  }n4| jdurV| j |¡rH| j d }qZ| j |¡}nd}|S )z Returns the previous page. r   Nr	   )r
   r   r   Úis_first_pageÚget_previous_page)r   r   r   Zprevious_pager   r   r   r   5   s    

ÿz)ChainedWizardController.get_previous_pagec                 C   s   || j d u S )z Is the page the first page? r   ©r
   ©r   r   r   r   r   r   K   s    z%ChainedWizardController.is_first_pagec                 C   sp   || j v r<|| j d urd}ql| jdu r.d}ql| j |¡}n0| jdurT| j |¡}nt| j ƒdkrhd}nd}|S )z Is the page the last page? r	   FNTr   )r
   r   Úis_last_pageÚlen)r   r   Zis_lastr   r   r   r   P   s    


z$ChainedWizardController.is_last_pagec                 C   s,   | j D ]}| ¡  q| jdur(| j ¡  dS )z Dispose the wizard's pages. N)r
   Zdispose_pager   Údispose_pagesr   r   r   r   r   n   s
    



z%ChainedWizardController.dispose_pagesc                 C   s*   | j dd… }| jdur&| | jj¡ |S )z" Returns the pages in the wizard. N)r
   r   ÚextendÚpages©r   r   r   r   r   Ú
_get_pages}   s    
z"ChainedWizardController._get_pagesc                 C   s
   || _ dS )z Sets the pages in the wizard. Nr   r   r   r   r   Ú
_set_pages‡   s    z"ChainedWizardController._set_pagesc                 C   sF   | j D ]}|jsd| _ qBq| jdur<| j ¡  | jj| _nd| _dS )z1 Checks the completion status of the controller. FNT)r
   Úcompleter   Ú_updater   r   r   r   r   ’   s    


zChainedWizardController._updateÚcurrent_pagec                 C   s\   |j |j }}|dur(|j| jddd� |dur>| | jd¡ | jdurP|| j_|  ¡  dS )z* Called when the current page is changed. Nr   T©Úremove)ÚoldÚnewr   Ú_on_page_completer   r    r   ©r   Úeventr#   r$   r   r   r   Ú+_reset_observers_on_current_page_and_update«   s    ÿ
zCChainedWizardController._reset_observers_on_current_page_and_updater   c                 C   sJ   |j |j }}|dur(|j| jddd� |dur>| | jd¡ |  ¡  dS )z- Called when the next controller is changed. Nr   Tr!   )r#   r$   r   Ú_on_controller_completer   r&   r   r   r   Ú._reset_observers_on_next_controller_and_update¼   s    ÿzFChainedWizardController._reset_observers_on_next_controller_and_updatec                 C   s   |   ¡  dS )z; Called when the next controller's complete state changes. N©r   ©r   r'   r   r   r   r)   Î   s    z/ChainedWizardController._on_controller_completec                 C   s   |   ¡  dS )z+ Called when the current page is complete. Nr+   r,   r   r   r   r%   Ó   s    z)ChainedWizardController._on_page_completeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r   r(   r*   r)   r%   r   r   r   r   r      s    


r   N)	r0   Z
traits.apir   r   Zi_wizard_controllerr   Zwizard_controllerr   r   r   r   r   r   Ú<module>   s   