3
8ßL]&  ã               @   s˜   d Z ddlmZ ddlmZ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ZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZdS )zo Defines the various instance descriptors used by the instance editor and
    instance editor factory classes.
é    )Úabsolute_import)ÚHasPrivateTraitsÚStrÚAnyÚDictÚTupleÚCallableÚBoolé   )ÚAView)Úuser_name_forNc               @   sN   e Zd ZeZeZedƒZddd„Z	dd„ Z
dd„ Zd	d
„ Zdd„ Zdd„ ZdS )ÚInstanceChoiceItemFNc             C   s   | j S )z' Returns the name of the item.
        )Úname)ÚselfÚobject© r   ú>/tmp/pip-install-5sebvq2j/traitsui/traitsui/instance_choice.pyÚget_name;   s    zInstanceChoiceItem.get_namec             C   s   | j S )z6 Returns the view associated with the object.
        )Úview)r   r   r   r   Úget_viewD   s    zInstanceChoiceItem.get_viewc             C   s   t ‚dS )z6 Returns the object associated with the item.
        N)ÚNotImplementedError)r   r   r   r   Ú
get_objectM   s    zInstanceChoiceItem.get_objectc             C   s   t ‚dS )zK Indicates whether a specified object is compatible with the item.
        N)r   )r   r   r   r   r   Úis_compatibleV   s    z InstanceChoiceItem.is_compatiblec             C   s   dS )zA Indicates whether the item can be selected by the user.
        Tr   )r   r   r   r   Úis_selectable_   s    z InstanceChoiceItem.is_selectablec             C   s   dS )z< Indicates whether the item supports drag and drop.
        Fr   )r   r   r   r   Úis_droppableh   s    zInstanceChoiceItem.is_droppable)N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r	   Ú
is_factoryr   r   r   r   r   r   r   r   r   r   r   (   s   
					r   c               @   s2   e Zd ZeZedƒZd	dd„Zdd„ Zdd„ Z	dS )
ÚInstanceChoicer   Nc             C   s>   | j dkr| j S t| j| jdƒ}t|tjƒr0|S t| jjj	ƒS )z' Returns the name of the item.
        Ú N)
r   Úgetattrr   Ú
name_traitÚ
isinstanceÚsixÚstring_typesr   Ú	__class__r   )r   r   r   r   r   r   r   ‚   s    
zInstanceChoice.get_namec             C   s   | j S )z6 Returns the object associated with the item.
        )r   )r   r   r   r   r   ’   s    zInstanceChoice.get_objectc             C   s
   || j kS )zK Indicates whether a specified object is compatible with the item.
        )r   )r   r   r   r   r   r   ›   s    zInstanceChoice.is_compatible)N)
r   r   r   r   r   r   r"   r   r   r   r   r   r   r   r   r   s
   
	r   c               @   s\   e Zd ZedƒZedƒZeZeZ	e
eeƒZdZddd„Zdd„ Zdd	„ Zd
d„ Zdd„ ZdS )ÚInstanceFactoryChoiceFTNc             C   sX   | j dkr| j S t|ddƒ}t|tjƒr,|S tt| jƒtƒrD| j}n
| jƒ j	}t
|jƒS )z' Returns the name of the item.
        r    r   N)r   r!   r#   r$   r%   Ú
issubclassÚtypeÚklassr   r&   r   r   )r   r   r   r*   r   r   r   r   Ã   s    

zInstanceFactoryChoice.get_namec             C   s   | j | j| jŽS )z6 Returns the object associated with the item.
        )r*   ÚargsÚkw_args)r   r   r   r   r   Ø   s    z InstanceFactoryChoice.get_objectc             C   s   | j S )z< Indicates whether the item supports drag and drop.
        )Ú	droppable)r   r   r   r   r   á   s    z"InstanceFactoryChoice.is_droppablec             C   s,   t t| jƒtƒrt|| jƒS t|| jƒ jƒS )zK Indicates whether a specified object is compatible with the item.
        )r(   r)   r*   r#   r   r&   )r   r   r   r   r   r   ê   s    z#InstanceFactoryChoice.is_compatiblec             C   s   | j S )zA Indicates whether the item can be selected by the user.
        )Ú
selectable)r   r   r   r   r   õ   s    z#InstanceFactoryChoice.is_selectable)N)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'   c               @   s   e Zd ZdZdZdZdS )ÚInstanceDropChoiceTFN)r   r   r   r-   r.   r   r   r   r   r   r/   ÿ   s   r/   )Ú__doc__Ú
__future__r   Z
traits.apir   r   r   r   r   r   r	   Z	ui_traitsr   Úhelperr   r$   r   r   r'   r/   r   r   r   r   Ú<module>   s   $J3Z