3
7ßL]  ã               @   s<   d Z ddlmZ ddlmZ ddlmZ G dd„ deƒZdS )	z6 A wizard controller that can be chained with others. é    )ÚInstanceé   )ÚIWizardController)ÚWizardControllerc               @   sx   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dd„ Zdd„ Zdd„ Zdd„ ZdS )ÚChainedWizardControllerz6 A wizard controller that can be chained with others. c             C   sh   d}|| j krN|| j d k	r8| j j|ƒ}| j |d  }qd| jdk	rd| jjƒ }n| jdk	rd| jj|ƒ}|S )z Returns the next page. Nr   éÿÿÿÿ)Ú_pagesÚindexÚnext_controllerZget_first_pageÚget_next_page)ÚselfÚpageZ	next_pager	   © r   úK/tmp/pip-install-5sebvq2j/pyface/pyface/wizard/chained_wizard_controller.pyr   %   s    


z%ChainedWizardController.get_next_pagec             C   s^   || j kr&| j j|ƒ}| j |d  }n4| jdk	rV| jj|ƒrH| j d }qZ| j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   9   s    

z)ChainedWizardController.get_previous_pagec             C   s   || j d kS )z Is the page the first page? r   )r   )r   r   r   r   r   r   M   s    z%ChainedWizardController.is_first_pagec             C   sp   || j kr<|| j d k	rd}ql| jdkr.d}ql| jj|ƒ}n0| jdk	rT| jj|ƒ}nt| j ƒdkrhd}nd}|S )z Is the page the last page? r   FNTr   r   )r   r
   Úis_last_pageÚlen)r   r   Zis_lastr   r   r   r   R   s    


z$ChainedWizardController.is_last_pagec             C   s0   x| j D ]}|jƒ  qW | jdk	r,| jjƒ  dS )z Dispose the wizard's pages. N)r   Zdispose_pager
   Údispose_pages)r   r   r   r   r   r   p   s
    

z%ChainedWizardController.dispose_pagesc             C   s*   | j dd… }| jdk	r&|j| 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. N)r   )r   r   r   r   r   Ú
_set_pages‰   s    z"ChainedWizardController._set_pagesc             C   sH   xB| j D ]}|jsd| _P qW | jdk	r>| jjƒ  | jj| _nd| _dS )z1 Checks the completion status of the controller. FNT)r   Úcompleter
   Ú_update)r   r   r   r   r   r   ”   s    

zChainedWizardController._updatec             C   sN   |dk	r|j | jddd� |dk	r0|j | jdƒ | jdk	rB|| j_| jƒ  dS )z* Called when the current page is changed. Nr   T)Úremove)Úon_trait_changeÚ_on_page_completer
   Zcurrent_pager   )r   ÚoldÚnewr   r   r   Ú_current_page_changed­   s    
z-ChainedWizardController._current_page_changedc             C   s<   |dk	r|j | jddd� |dk	r0|j | jdƒ | jƒ  dS )z- Called when the next controller is changed. Nr   T)r   )r   Ú_on_controller_completer   )r   r   r   r   r   r   Ú_next_controller_changed¿   s    
z0ChainedWizardController._next_controller_changedc             C   s   | j ƒ  dS )z; Called when the next controller's complete state changes. N)r   )r   ÚobjÚ
trait_namer   r   r   r   r   r!   Ò   s    z/ChainedWizardController._on_controller_completec             C   s   | j ƒ  dS )z+ Called when the current page is complete. N)r   )r   r#   r$   r   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      s   
r   N)r(   Z
traits.apir   Zi_wizard_controllerr   Zwizard_controllerr   r   r   r   r   r   Ú<module>   s   