3
7ßL]z  ã               @   s�   d Z ddlZejr ddlmZ nddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ G dd„ deƒZdS )z, A tree control with extensible node types. é    N)Ú
getargspec)Úgetfullargspec)ÚActionEvent)ÚInstanceÚListÚPropertyé   )ÚNodeManager)ÚNodeType)ÚNodeTreeModel)ÚTreec               @   sš   e Zd ZdZeef ƒZeeeƒƒZ	e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d„ ZdS )ÚNodeTreez, A tree control with extensible node types. c             C   s   | j jS )z$ Returns the root node of the tree. )ÚmodelÚnode_manager)Úself© r   ú9/tmp/pip-install-5sebvq2j/pyface/pyface/tree/node_tree.pyÚ_get_node_manager;   s    zNodeTree._get_node_managerc             C   s   || j _dS )z! Sets the root node of the tree. N)r   r   )r   r   r   r   r   Ú_set_node_manager@   s    zNodeTree._set_node_managerc             C   s
   | j jjS )z% Returns the node types in the tree. )r   r   Ú
node_types)r   r   r   r   Ú_get_node_typesH   s    zNodeTree._get_node_typesc             C   s   || j j_dS )z" Sets the node types in the tree. N)r   r   r   )r   r   r   r   r   Ú_set_node_typesM   s    
zNodeTree._set_node_typesc             C   s$   | j j|ƒ}|dk	r | j||ƒ dS )z? Called when a node has been activated (i.e., double-clicked). N)r   Zget_default_actionÚ_perform_default_action)r   ÚobjZdefault_actionr   r   r   Ú_node_activated_changedZ   s    z NodeTree._node_activated_changedc             C   s6   | j |ƒ || _| jj|ƒ}|dk	r2| j|||ƒ dS )z< Called when the right mouse button is clicked on the tree. N)ÚselectÚ_contextr   Zget_context_menuÚ_popup_menu)r   r   ÚpointÚmenu_managerr   r   r   Ú_node_right_clicked_changedc   s    
z$NodeTree._node_right_clicked_changedc             C   s   dS )z! Adds a menu item to a menu bar. Nr   )r   Z	menu_itemr   r   r   Úadd_to_menux   s    zNodeTree.add_to_menuc             C   s   dS )z% Adds a tool bar item to a tool bar. Nr   )r   Ztoolvar_itemr   r   r   Úadd_to_toolbar}   s    zNodeTree.add_to_toolbarc             C   s   dS )z6 Returns True iff an action can be added to the menu. Tr   )r   Úactionr   r   r   Úcan_add_to_menu‚   s    zNodeTree.can_add_to_menuc             C   sD   | |_ | j|_t|jƒ\}}}}t|ƒdkr6|jƒ  n
|j|ƒ dS )z Perform an action. r   N)Úwidgetr   Úcontextr   ÚperformÚlen)r   r#   ÚeventÚargsÚvarargsÚvarkwÚdefaultsr   r   r   r'   ‡   s    

zNodeTree.performc             C   s   t | |d�S )z5 Return a new action event for the specified object. )r%   r&   )r   )r   r   r   r   r   Ú_create_action_eventŸ   s    zNodeTree._create_action_eventc             C   s   |j | j|ƒƒ dS )z5 Perform the default action on the specified object. N)r'   r.   )r   r#   r   r   r   r   r   ¤   s    z NodeTree._perform_default_actionc             C   s,   |j | j| ƒ}|jƒ s(|j|Ž  |jƒ  dS )z/ Popup the menu described by the menu manager. N)Zcreate_menuÚcontrolZis_emptyÚshowÚdestroy)r   r   r   r   Úmenur   r   r   r   «   s
    
zNodeTree._popup_menuN)Ú__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   r   r   r   r   r   r   $   s"   
		r   )r6   ÚsixÚPY2Úinspectr   r   Zpyface.action.apir   Z
traits.apir   r   r   r   r	   Z	node_typer
   Znode_tree_modelr   Útreer   r   r   r   r   r   Ú<module>   s   