a
    §ˆcf  ã                   @   sP   d Z ddl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.
é    N)Ú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                    sX   | j jr*tj|d| jtjd�| _|  ¡  ntƒ  	|¡ | j 
| j¡ | j t| ƒ¡ dS )z\Finishes initializing the editor by creating the underlying toolkit
        widget.
        éÿÿÿÿ)ÚstyleN)ÚfactoryÚreadonlyÚwxZTextCtrlÚ	str_valueZTE_READONLYÚcontrolZset_tooltipÚsuperÚinitZSetBackgroundColourÚok_colorZSetDropTargetr   )ÚselfÚparent©Ú	__class__© úZ/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/wx/drop_editor.pyr   %   s    ÿ
zSimpleEditor.initc                 C   s   |du rdS t |ƒS )zBReturns the text representation of a specified object trait value.NÚ )Ústr)r   Úvaluer   r   r   Ústring_value3   s    zSimpleEditor.string_valuec                 C   s   dS )zDHandles an error that occurs while setting the object's trait value.Nr   )r   Zexcpr   r   r   Úerror9   s    zSimpleEditor.errorc                 C   s˜   | j j}|}| j jr ttddƒ}|du s2t||ƒr’d| _zLt|dƒrP| ¡ | _	n|| _	t|dƒrn| 
| j¡ n| j | j¡ W d| _nd| _0 |S tjS )z2Handles 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_on?   s     

zSimpleEditor.wx_dropped_onc                 C   sN   | j jrttddƒ}z"| j | j¡ | j| j|¡ |W S    tj	 Y S 0 dS )z4Handles 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_overV   s    
ÿzSimpleEditor.wx_drag_over)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r)   r-   Ú__classcell__r   r   r   r   r      s   r   )r1   r   Zpyface.wx.drag_and_dropr   r   Ztext_editorr   ZEditorÚ	constantsr   Z
TextEditorZReadonlyEditorr   r   r   r   Ú<module>   s   G