3
8ßL]0  ã               @   sh   d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z ddlmZ G d	d
„ d
eƒZ
e
 ZZdS )z“ Defines a drop target editor for the wxPython user interface toolkit. A
    drop target editor handles drag and drop operations as a drop target.
é    )Úabsolute_importN)ÚToolkitEditorFactory)ÚPythonDropTargetÚ	clipboardé   )ÚSimpleEditor)Ú	DropColorc                   sD   e Zd ZdZeZ‡ fdd„Zdd„ Zdd„ Zdd	„ Z	d
d„ Z
‡  ZS )r   z‘ Simple style of drop editor, which displays a read-only text field that
    contains the string representation of the object trait's value.
    c                s\   | j jr*tj|d| jtjd�| _| jƒ  ntt	| ƒj
|ƒ | jj| jƒ | jjt| ƒƒ dS )za Finishes initializing the editor by creating the underlying toolkit
            widget.
        r   )ÚstyleNéÿÿÿÿ)ÚfactoryÚreadonlyÚwxZTextCtrlÚ	str_valueZTE_READONLYÚcontrolZset_tooltipÚsuperr   ÚinitZSetBackgroundColourÚok_colorZSetDropTargetr   )ÚselfÚparent)Ú	__class__© ú=/tmp/pip-install-5sebvq2j/traitsui/traitsui/wx/drop_editor.pyr   >   s    
zSimpleEditor.initc             C   s   |dkrdS t |ƒS )zL Returns the text representation of a specified object trait value.
        NÚ )Ústr)r   Úvaluer   r   r   Ústring_valueO   s    zSimpleEditor.string_valuec             C   s   dS )zN Handles an error that occurs while setting the object's trait value.
        Nr   )r   Zexcpr   r   r   ÚerrorZ   s    zSimpleEditor.errorc             C   s’   | j j}|}| j jr ttddƒ}|dks2t||ƒrŒd| _zFt|dƒrP|jƒ | _	n|| _	t|dƒrn|j
| jƒ n| jj| jƒ W dd| _X |S tjS )z< Handles a Python object being dropped on the tree.
        ÚnodeNTÚdrop_editor_valueÚdrop_editor_updateF)r   ÚklassÚbindingÚgetattrr   Ú
isinstanceZ
_no_updateÚhasattrr   r   r   r   ZSetValuer   r   ÚDragNone)r   ÚxÚyÚdataÚdrag_resultr    r   r   r   r   Úwx_dropped_one   s     

zSimpleEditor.wx_dropped_onc          
   C   sF   | j jrttddƒ}y | jj| jƒj| j| j|ƒ |S    tj	S dS )z> Handles a Python object being dragged over the tree.
        r   N)
r   r!   r"   r   ÚobjectZ
base_traitÚnameÚvalidater   r%   )r   r&   r'   r(   r)   r   r   r   Úwx_drag_over�   s    
zSimpleEditor.wx_drag_over)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r*   r.   Ú__classcell__r   r   )r   r   r   1   s   r   )r2   Ú
__future__r   r   Ztraitsui.editors.drop_editorr   Zpyface.wx.drag_and_dropr   r   Ztext_editorr   ZEditorÚ	constantsr   Z
TextEditorZReadonlyEditorr   r   r   r   Ú<module>   s   ]