3
7ßL]¨  ã               @   sð   d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
 ddlmZmZmZ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 dd	lmZ dd
lmZ ddlmZ ddlmZm Z  ej!e"ƒZ#G dd„ dej$ƒZ%G dd„ deƒZ&dS )z. A tree control with a model/ui architecture. é    N)ÚAnyÚBoolÚCallableÚEnumÚEventÚInstance)ÚListÚPropertyr   ÚStrÚTraitÚTuple)ÚFilter)ÚKeyPressedEvent)ÚSorter)Ú	TreeModel)ÚGUI)Ú	ImageList)ÚWidget)ÚPythonDropSourceÚPythonDropTargetc               @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú_Treez¤ The wx tree control that we delegate to.

    We use this derived class so that we can detect the destruction of the
    tree and remove model listeners etc.

    c             C   s   t jj| |||d� || _dS )z Creates a new tree. )ÚstyleN)ÚwxÚTreeCtrlÚ__init__Ú_tree)ÚselfÚtreeÚparentÚwxidr   © r    ú:/tmp/pip-install-5sebvq2j/pyface/pyface/ui/wx/tree/tree.pyr   7   s    z_Tree.__init__c             C   s   | j j| j jƒ dS )z Destructor. N)r   Ú_remove_model_listenersÚmodel)r   r    r    r!   Ú__del__B   s    z_Tree.__del__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r$   r    r    r    r!   r   +   s   r   c                   s~  e Zd ZdZejejB ejB Ze	e
ƒZedddƒZeef ƒZeeƒZe	ZeddƒZedƒZedƒZedƒZeeƒZeZeeƒZeZ eZ!eZ"eZ#eZ$eZ%e&dƒZ'e(d	e)d	ƒZ*ed
ƒZ+d{‡ fdd„	Z,dd„ Z-dd„ Z.dd„ Z/d|dd„Z0dd„ Z1dd„ Z2dd„ Z3dd„ Z4dd„ Z5d d!„ Z6d"d#„ Z7d$d%„ Z8d&d'„ Z9d(d)„ Z:d*d+„ Z;d,d-„ Z<d.d/„ Z=d0d1„ Z>d2d3„ Z?d4d5„ Z@d6d7„ ZAd8d9„ ZBd:d;„ ZCd<d=„ ZDd>d?„ ZEd@dA„ ZFdBdC„ ZGdDdE„ ZHdFdG„ ZIdHdI„ ZJd}dJdK„ZKd~dLdM„ZLdNdO„ ZMdPdQ„ ZNdRdS„ ZOdTdU„ ZPdVdW„ ZQdXdY„ ZRdZd[„ ZSd\d]„ ZTd^d_„ ZUd`da„ ZVdbdc„ ZWddde„ ZXdfdg„ ZYdhdi„ ZZdjdk„ Z[dldm„ Z\dndo„ Z]dpdq„ Z^drds„ Z_dtdu„ Z`dvdw„ Zadxdy„ Zb‡  ZcS )ÚTreez. A tree control with a model/ui architecture. Ú
appearanceÚonÚoffÚsingleÚextendedTzAnonymous treeNFé   c                sb  t t| ƒjf |Ž tjƒ }t| ||| jƒ d� | _}tj|| j	ƒ tj
|| jƒ tj|| jƒ tj|| jƒ tj||| jƒ tj||| jƒ tj||| jƒ tj||| jƒ tj||| jƒ tj||| jƒ tj||| jƒ tj||| jƒ tj ||| j!ƒ | jj"t#| ƒƒ t$|d |d ƒ| _%| j&�r4|j'| j%ƒ i | _(| j)dk	�rR| j*| j)ƒ | j+| j,ƒ dS )a   Creates a new tree.

        'parent' is the toolkit-specific control that is the tree's parent.

        'image_size' is a tuple in the form (int width, int height) that
        specifies the size of the images (if required) displayed in the tree.

        )r   r   é   N)-Úsuperr)   r   r   ZNewIdr   Ú
_get_styleÚcontrolZEVT_CHARÚ_on_charZEVT_LEFT_DOWNÚ_on_left_downZEVT_RIGHT_DOWNÚ_on_right_downZEVT_LEFT_DCLICKÚ_on_tree_item_activatedZEVT_TREE_ITEM_COLLAPSINGÚ_on_tree_item_collapsingZEVT_TREE_ITEM_COLLAPSEDÚ_on_tree_item_collapsedZEVT_TREE_ITEM_EXPANDINGÚ_on_tree_item_expandingZEVT_TREE_ITEM_EXPANDEDÚ_on_tree_item_expandedZEVT_TREE_BEGIN_LABEL_EDITÚ_on_tree_begin_label_editZEVT_TREE_END_LABEL_EDITÚ_on_tree_end_label_editZEVT_TREE_BEGIN_DRAGÚ_on_tree_begin_dragZEVT_TREE_SEL_CHANGEDÚ_on_tree_sel_changedZEVT_TREE_DELETE_ITEMÚ_on_tree_delete_itemZSetDropTargetr   r   Ú_image_listÚshow_imagesZAssignImageListÚ_node_to_id_mapÚrootÚ_add_root_nodeÚ_add_model_listenersr#   )r   r   Z
image_sizeZtraitsr   r   )Ú	__class__r    r!   r   §   s2    zTree.__init__c             C   s   | j jS )z$ Returns the root node of the tree. )r#   rD   )r   r    r    r!   Ú	_get_rootï   s    zTree._get_rootc             C   s   || j _dS )z! Sets the root node of the tree. N)r#   rD   )r   rD   r    r    r!   Ú	_set_rootô   s    zTree._set_rootc             C   s"   | j |ƒ}|dk	r| jj|ƒ dS )z Collapses the specified node. N)Ú	_get_wxidr3   ÚCollapse)r   Únoder   r    r    r!   Úcollapseý   s    
zTree.collapsec             C   s(   | j |ƒ}|dk	r$|| _| jj|ƒ dS )a   Edits the label of the specified node.

        If a callback is specified it will be called when the label edit
        completes WHETHER OR NOT the label was actually changed.

        The callback must take exactly 3 arguments:- (tree, node, label)

        N)rJ   Ú_label_edit_callbackr3   Z	EditLabel)r   rL   Úcallbackr   r    r    r!   Ú
edit_label  s
    

zTree.edit_labelc             C   s"   | j |ƒ}|dk	r| jj|ƒ dS )z Expands the specified node. N)rJ   r3   ÚExpand)r   rL   r   r    r    r!   Úexpand  s    
zTree.expandc             C   sD   | j r| j| j| jƒƒ n&x$| j| jƒD ]}| j| j|ƒƒ q(W dS )z! Expands every node in the tree. N)Ú	show_rootÚ_expand_itemrJ   rD   Ú_get_children)r   Úchildr    r    r!   Ú
expand_all   s
    zTree.expand_allc             C   s8   | j |ƒ}|dk	r0| jj|ƒ}| jj|ƒ\}}nd}|S )zŸ Returns the parent of a node.

        This will only work iff the node has been displayed in the tree.  If it
        hasn't then None is returned.

        N)rJ   r3   ZGetItemParentÚ	GetPyData)r   rL   r   ÚpidÚ	populatedr   r    r    r!   Ú
get_parent,  s    	
zTree.get_parentc             C   s@   | j |ƒ}|dk	r8|| jkr*| j r*d}q<| jj|ƒ}nd}|S )z8 Returns True if the node is expanded, otherwise False. NTF)rJ   rD   rS   r3   Ú
IsExpanded)r   rL   r   Úis_expandedr    r    r!   r]   C  s    
zTree.is_expandedc             C   s(   | j |ƒ}|dk	r | jj|ƒ}nd}|S )z8 Returns True if the node is selected, otherwise False. NF)rJ   r3   Z
IsSelected)r   rL   r   Úis_selectedr    r    r!   r^   T  s
    
zTree.is_selectedc             C   s¤   | j |ƒ}|dk	r | jj|ƒ | jj|d|fƒ | j|ƒ}| jj||ƒ || jkr|| j r|xD| j|ƒD ]}| j	||ƒ qfW n$| jj
|ƒr”| jj|ƒ | jj|ƒ dS )zŒ Refresh the tree starting from the specified node.

        Call this when the structure of the content has changed DRAMATICALLY.

        NF)rJ   r3   ÚDeleteChildrenÚ	SetPyDataÚ_has_childrenÚSetItemHasChildrenrD   rS   rU   Ú	_add_noder\   rK   rQ   )r   rL   rY   Úhas_childrenrV   r    r    r!   Úrefresh`  s    

zTree.refreshc             C   s"   | j |ƒ}|dk	r| jj|ƒ dS )z Selects the specified node. N)rJ   r3   Z
SelectItem)r   rL   r   r    r    r!   Úselectƒ  s    
zTree.selectc          
   C   sh   t jd|| ƒ d| _| jjƒ  x4|D ],}y| j|ƒ W q$   t jd|ƒ Y q$X q$W d| _| jƒ | _dS )z& Selects the specified list of nodes. z*Setting selection to [%s] within Tree [%s]TzUnable to select node [%s]FN)	ÚloggerÚdebugÚ_ignore_selection_eventsr3   ZUnselectAllrf   Ú	exceptionÚ_get_selectionÚ	selection)r   ÚlistrL   r    r    r!   Úset_selectionŒ  s    

zTree.set_selectionc             C   s0   t j}| j||ƒ}|dk	r,| jj||ƒr,|}|S )z. Called when a node is dragged over the tree. N)r   ZDragNoneÚ_get_drag_drop_noder#   Zcan_drop)r   ÚxÚyÚobjÚdefault_drag_resultÚresultrL   r    r    r!   Úon_drag_over¤  s    zTree.on_drag_overc             C   s&   | j ||ƒ}|dk	r"| jj||ƒ |S )z, Called when a node is dropped on the tree. N)ro   r#   Zdrop)r   rp   rq   rr   rs   rL   r    r    r!   Úon_drop³  s    zTree.on_dropc             C   s   | j j|ƒ}| jj|dƒS )zw Returns the wxid for the specified node.

        Returns None if the node has not yet appeared in the tree.

        N)r#   Úget_keyrC   Úget)r   rL   Úkeyr    r    r!   rJ   Á  s    	zTree._get_wxidc             C   s   | j j|ƒ}|| j|< dS )z' Sets the wxid for the specified node. N)r#   rw   rC   )r   rL   r   ry   r    r    r!   Ú	_set_wxidÎ  s    
zTree._set_wxidc             C   sD   | j j|ƒ}y| j|= W n& tk
r>   tjdt|ƒ ƒ Y nX dS )z* Removes the wxid for the specified node. zremoving node: %sN)r#   rw   rC   ÚKeyErrorrg   ÚwarnÚstr)r   rL   ry   r    r    r!   Ú_remove_wxidÙ  s    zTree._remove_wxidc             C   sd   | j }| jdkr tjdkr d| _| js0|tjB }| jsF|tjB tj	B }| j
dkr`|tjB tjB }|S )z; Returns the wx style flags for creating the tree control. r*   ÚposixFr-   )ÚSTYLEÚ
lines_modeÚosÚnameÚ
show_linesr   ZTR_NO_LINESrS   ZTR_HIDE_ROOTZTR_LINES_AT_ROOTÚselection_modeZTR_MULTIPLEZTR_EXTENDED)r   r   r    r    r!   r2   ê  s    

zTree._get_stylec             C   sX   |j | jdƒ |j | jdƒ |j | jdƒ |j | jdƒ |j | jdƒ |j | jdƒ dS )z# Adds listeners for model changes. rD   Únodes_changedÚnodes_insertedÚnodes_removedÚnodes_replacedÚstructure_changedN)Úon_trait_changeÚ_on_root_changedÚ_on_nodes_changedÚ_on_nodes_insertedÚ_on_nodes_removedÚ_on_nodes_replacedÚ_on_structure_changed)r   r#   r    r    r!   rF     s    zTree._add_model_listenersc             C   sp   |j | jddd� |j | jddd� |j | jddd� |j | jddd� |j | jddd� |j | jddd� d	S )
z& Removes listeners for model changes. rD   T)Úremover†   r‡   rˆ   r‰   rŠ   N)r‹   rŒ   r�   rŽ   r�   r�   r‘   )r   r#   r    r    r!   r"     s    zTree._remove_model_listenersc             C   s¬   | j |ƒ}| j|ƒ}| jj|||ƒ}| jj|ƒ | jsVx| j|ƒD ]}| j||ƒ qBW | j	|ƒ}| jj
||ƒ | jrŠ| jj|| j |fƒ | j||ƒ | jr¨| jj|ƒ dS )z Adds the root node. N)Ú_get_image_indexÚ	_get_textr3   ZAddRootr#   Úadd_listenerrS   rU   rc   ra   rb   r`   rz   rQ   )r   rL   Úimage_indexÚtextr   rV   rd   r    r    r!   rE   /  s    


zTree._add_root_nodec             C   sl   | j |ƒ}| j|ƒ}| jj||||ƒ}| jj|ƒ | j|ƒ}| jj||ƒ | jj|d|fƒ | j	||ƒ dS )z~ Adds 'node' as a child of the node identified by 'pid'.

        If 'pid' is None then we are adding the root node.

        FN)
r“   r”   r3   Z
AppendItemr#   r•   ra   rb   r`   rz   )r   rY   rL   r–   r—   r   rd   r    r    r!   rc   V  s    


zTree._add_nodec             C   sn   | j |ƒ}| j|ƒ}| jj|||||ƒ}| jj|ƒ | j|ƒ}| jj||ƒ | jj|d|fƒ | j	||ƒ dS )z� Inserts 'node' as a child of the node identified by 'pid'.

        If 'pid' is None then we are adding the root node.

        FN)
r“   r”   r3   ZInsertItemBeforer#   r•   ra   rb   r`   rz   )r   rY   rL   Úindexr–   r—   r   rd   r    r    r!   Ú_insert_nodev  s    


zTree._insert_nodec             C   s(   | j j|ƒ | j|ƒ | jj|dƒ dS )z Removes a node from the tree. N)r#   Úremove_listenerr~   r3   r`   )r   r   rL   r    r    r!   Ú_remove_node˜  s    
zTree._remove_nodec             C   sJ   | j |ƒ}| jj||tjƒ | jj||tjƒ | j|ƒ}| jj||ƒ dS )z3 Updates the image and text of the specified node. N)r“   r3   ZSetItemImager   ZTreeItemIcon_NormalZTreeItemIcon_Selectedr”   ZSetItemText)r   r   rL   r–   r—   r    r    r!   Ú_update_node¤  s    

zTree._update_nodec             C   s   | j j|ƒS )z& Returns True if a node has children. )r#   rd   )r   rL   r    r    r!   ra   ²  s    	zTree._has_childrenc             C   sf   | j j|ƒ}g }x6|D ].}x(| jD ]}|j| ||ƒs"P q"W |j|ƒ qW | jdk	rb| jj| ||ƒ |S )z Get the children of a node. N)r#   Zget_childrenÚfiltersrf   ÚappendÚsorterÚsort)r   rL   ÚchildrenZfiltered_childrenrV   Úfilterr    r    r!   rU   ½  s    

zTree._get_childrenc             C   sB   | j |ƒ}| j|ƒ}| jj|||ƒ}|dk	r:| jj|ƒ}nd}|S )z/ Returns the tree item image index for a node. Nr0   éÿÿÿÿ)r]   r^   r#   Z	get_imagerA   ZGetIndex)r   rL   ÚexpandedÚselectedÚimager–   r    r    r!   r“   Ò  s    

zTree._get_image_indexc       	      C   s0   | j ||fƒ\}}}}|dk	r(|\}}nd}|S )zŠ Returns the node that is being dragged/dropped on.

        Returns None if the cursor is not over the icon or label of a node.

        N)Ú	_hit_test)	r   rp   rq   Údatar   ÚflagsÚpointrZ   rL   r    r    r!   ro   â  s
    
zTree._get_drag_drop_nodec             C   s   | j j|ƒ}|dkrd}|S )z( Returns the tree item text for a node. NÚ )r#   Zget_text)r   rL   r—   r    r    r!   r”   ò  s    zTree._get_textc          	   C   s.   y|j ƒ }W n   |jƒ }Y nX | j||ƒS )z< Unpacks the event to see whether a tree item was involved. )ÚGetPositionZGetPointr§   )r   Úeventr   rª   r    r    r!   Ú_unpack_eventû  s
    zTree._unpack_eventc             C   sj   t j}|dks|jƒ  r(| jj|ƒ\}}|t j@ r8d}n&|t j@ sL|t j@ rZ| jj|ƒ}nd}||||fS )z> Determines whether a point is within a node's label or icon. N)r   ZTREE_HITTEST_ONITEMLABELÚIsOkr3   ÚHitTestZTREE_HITTEST_NOWHEREZTREE_HITTEST_ONITEMICONrX   )r   rª   r   r©   r¨   r    r    r!   r§     s    


zTree._hit_testc             C   sJ   g }x@| j jƒ D ]2}| j j|ƒ}|dk	r|\}}|j| jj|ƒƒ qW |S )z& Returns a list of the selected nodes N)r3   ZGetSelectionsrX   rž   r#   Zget_selection_value)r   rl   r   r¨   rZ   rL   r    r    r!   rk     s    zTree._get_selectionc             C   sJ   | j j|ƒ | j j|ƒ\}}x(|jƒ rD| j|ƒ | j j||ƒ\}}qW dS )z! Recursively expand a tree item. N)r3   rQ   ZGetFirstChildr¯   rT   ZGetNextChild)r   r   ÚcidÚcookier    r    r!   rT   *  s    

zTree._expand_itemc             C   s0   | j dk	r,| j jƒ  i | _|dk	r,| j|ƒ dS )z0 Called when the root of the model has changed. N)r3   ZDeleteAllItemsrC   rE   )r   rD   r    r    r!   rŒ   8  s    


zTree._on_root_changedc             C   sH   | j | j|jƒ|jƒ x,|jD ]"}| j|ƒ}|dk	r| j ||ƒ qW dS )z& Called when nodes have been changed. N)rœ   rJ   rL   r¡   )r   r­   rV   r±   r    r    r!   r�   G  s    
zTree._on_nodes_changedc       
      C   s  |j }|j}|j}| j|ƒ}|dk	�r| js6|| jk	rH| jj|ƒ\}}nd}|srxZ| j|ƒD ]}| j	||ƒ q\W n:|dkrˆ| jj
|dƒ}x"|D ]}| j|||ƒ |d7 }qŽW | js¼|| jk	rÎ| jj|d|fƒ | jj
|ƒdk}	| jj||	ƒ | j|ƒ�s| j|ƒ dS )z' Called when nodes have been inserted. NTr0   Fr   r£   )rL   r¡   r˜   rJ   rS   rD   r3   rX   rU   rc   ÚGetChildrenCountr™   r`   rb   r]   rR   )
r   r­   r   r¡   r˜   rY   rZ   rL   rV   rd   r    r    r!   rŽ   S  s.    



zTree._on_nodes_insertedc             C   sn   |j }|j}| j|ƒ}|dk	rjx,|jD ]"}| j|ƒ}|dk	r&| jj|ƒ q&W | jj|ƒdk}| jj||ƒ dS )z& Called when nodes have been removed. Nr   )rL   r¡   rJ   r3   ÚDeleter³   rb   )r   r­   r   r¡   rY   rV   r±   rd   r    r    r!   r�   „  s    

zTree._on_nodes_removedc             C   s¬   xœt |j|jƒD ]Š\}}| j|ƒ}|dk	r| jj|ƒ | jj|ƒ | j||ƒ | jj	|d|fƒ | j
|ƒ | j||ƒ | jj|ƒ | j|ƒ}| jj||ƒ qW | jƒ | _dS )z' Called when nodes have been replaced. NF)ÚzipZold_childrenr¡   rJ   r#   rš   r3   r_   rœ   r`   r~   rz   r•   ra   rb   rk   rl   )r   r­   Z	old_childÚ	new_childr±   rd   r    r    r!   r�   ˜  s    
	


zTree._on_nodes_replacedc             C   s   | j |jƒ dS )z> Called when the structure of a node has changed drastically. N)re   rL   )r   r­   r    r    r!   r‘   Â  s    zTree._on_structure_changedc             C   s2   t |jdk|jdk|jdk|jd�| _|jƒ  dS )z7 Called when a key is pressed when the tree has focus. r0   )Zalt_downZcontrol_downZ
shift_downZkey_codeN)r   Z	m_altDownZm_controlDownZm_shiftDownZ	m_keyCodeÚkey_pressedÚSkip)r   r­   r    r    r!   r4   Ë  s    zTree._on_charc             C   s>   | j |ƒ\}}}}|| _|dk	r2|\}}||f| _|jƒ  dS )z; Called when the left mouse button is clicked on the tree. N)r®   Z_point_left_clickedÚnode_left_clickedr¸   )r   r­   r¨   Úidr©   rª   rZ   rL   r    r    r!   r5   Ù  s    
zTree._on_left_downc             C   s@   | j |ƒ\}}}}|dk	r.|\}}||f| _n|| _|jƒ  dS )z< Called when the right mouse button is clicked on the tree. N)r®   Únode_right_clickedÚcontrol_right_clickedr¸   )r   r­   r¨   rº   r©   rª   rZ   rL   r    r    r!   r6   ï  s    zTree._on_right_downc             C   s2   |j ƒ }| jj|ƒ\}}| jj|ƒ\}}|| _dS )z> Called when a tree item is activated (i.e., double clicked). N)r¬   r3   r°   rX   Únode_activated)r   r­   rª   r   r©   rZ   rL   r    r    r!   r7     s
    
zTree._on_tree_item_activatedc             C   s0   |j ƒ }| jj|ƒ\}}| jj|ƒs,|jƒ  dS )z/ Called when a tree item is about to collapse. N)ÚGetItemr3   rX   r#   Zis_collapsibleÚVeto)r   r­   r   rZ   rL   r    r    r!   r8     s
    zTree._on_tree_item_collapsingc             C   s.   |j ƒ }| jj|ƒ\}}| j||ƒ || _dS )z- Called when a tree item has been collapsed. N)r¾   r3   rX   rœ   Únode_collapsed)r   r­   r   rZ   rL   r    r    r!   r9   ,  s
    zTree._on_tree_item_collapsedc             C   sh   |j ƒ }| jj|ƒ\}}| jj|ƒr\|sdx| j|ƒD ]}| j||ƒ q4W | jj|d|fƒ n|jƒ  dS )z- Called when a tree item is about to expand. TN)	r¾   r3   rX   r#   Zis_expandablerU   rc   r`   r¿   )r   r­   r   rZ   rL   rV   r    r    r!   r:   ?  s    zTree._on_tree_item_expandingc             C   s.   |j ƒ }| jj|ƒ\}}| j||ƒ || _dS )z, Called when a tree item has been expanded. N)r¾   r3   rX   rœ   Únode_expanded)r   r­   r   rZ   rL   r    r    r!   r;   Z  s
    zTree._on_tree_item_expandedc             C   s0   |j ƒ }| jj|ƒ\}}| jj|ƒs,|jƒ  dS )z; Called when the user has started editing an item's label. N)r¾   r3   rX   r#   Zis_editabler¿   )r   r­   r   rZ   rL   r    r    r!   r<   m  s
    zTree._on_tree_begin_label_editc                s‚   |j ƒ }ˆjj|ƒ\}‰|jƒ ‰ ˆ dk	r^tˆ ƒdkr^ˆjjˆˆ ƒr^‡ ‡‡fdd„}tj|ƒ n |j	ƒ  ˆj
dk	r~ˆj
ˆˆˆ ƒ dS )z< Called when the user has finished editing am item's label. Nr   c                  s*   ˆj jˆˆ ƒ ˆjdk	r&ˆjˆˆˆ ƒ dS )z$ Called to complete the label edit. N)r#   Zset_textrN   r    )ÚlabelrL   r   r    r!   Úend_label_editŽ  s    
z4Tree._on_tree_end_label_edit.<locals>.end_label_edit)r¾   r3   rX   ZGetLabelÚlenr#   Zcan_set_textr   Zinvoke_laterr¿   rN   )r   r­   r   rZ   rÃ   r    )rÂ   rL   r   r!   r=   }  s    
zTree._on_tree_end_label_editc       
      C   s¨   | j ||jƒ ƒ\}}}}|dkr@| j}| j|ƒ\}}| jj|ƒ}|dk	r¤|\}}| jj|ƒrœ| jj|ƒ}ddl	m
}	 |g|	_| jƒ | _t| j|| ƒ || _n|jƒ  dS )z: Called when a drag operation is starting on a tree item. r   N)Ú	clipboard)r   r   )r®   r¾   Zpoint_left_clickedr°   r3   rX   r#   Zis_draggableZget_drag_valueÚpyface.wx.drag_and_droprÅ   rL   rk   rl   r   Únode_begin_dragr¿   )
r   r­   r¨   r   r©   rª   rZ   rL   Z
drag_valuerÅ   r    r    r!   r>   ¬  s     
zTree._on_tree_begin_dragc             C   s   ddl m} d|_dS )z< Callback invoked when a drag/drop operation has completed. r   )rÅ   N)rÆ   rÅ   rL   )r   rÅ   r    r    r!   Ú
on_droppedÙ  s    zTree.on_droppedc             C   s   | j s| jƒ | _dS )z' Called when the selection is changed. N)ri   rk   rl   )r   r­   r    r    r!   r?   á  s    
zTree._on_tree_sel_changedc             C   s4   |j ƒ }| jj|ƒ}|dk	r0|\}}| j||ƒ dS )z0 Called when a tree item is being been deleted. N)r¾   r3   rX   r›   )r   r­   r   r¨   rZ   rL   r    r    r!   r@   í  s    	zTree._on_tree_delete_item©r/   r/   )rÉ   )N)N)N)dr%   r&   r'   r(   r   ZTR_EDIT_LABELSZTR_HAS_BUTTONSZCLIP_CHILDRENr€   r   r   r�   r   r�   r   r   r#   r	   r   rD   rl   r…   r   rB   r„   rS   r   rŸ   r   r¼   r   r·   r½   rÇ   rÀ   rÁ   r¹   r»   r
   Ú_namer   r   rN   ri   r   rH   rI   rM   rP   rR   rW   r[   r]   r^   re   rf   rn   ru   rv   rJ   rz   r~   r2   rF   r"   rE   rc   r™   r›   rœ   ra   rU   r“   ro   r”   r®   r§   rk   rT   rŒ   r�   rŽ   r�   r�   r‘   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   rÈ   r?   r@   Ú__classcell__r    r    )rG   r!   r)   K   sœ   

H		
	#	' "	

1*	/-r)   )'r(   Úloggingr‚   r   Z
traits.apir   r   r   r   r   r   r   r	   r
   r   r   Zpyface.filterr   Zpyface.key_pressed_eventr   Zpyface.sorterr   Zpyface.tree.tree_modelr   Zpyface.ui.wx.guir   Zpyface.ui.wx.image_listr   Zpyface.ui.wx.widgetr   rÆ   r   r   Ú	getLoggerr%   rg   r   r   r)   r    r    r    r!   Ú<module>   s      
 