3
<Ad]
  ã               @   s’   d Z yddlmZ W n  ek
r4   ddlmZ Y nX ddlmZ ddlmZm	Z	 ddl
mZmZmZ ddlZG dd„ deƒZG d	d
„ d
eƒZdS )z& The interface for an image resource. é    )ÚSequence)Úresource_manager)Úresource_moduleÚresource_path)Ú	InterfaceÚListÚUnicodeNc               @   sP   e Zd ZdZeZeZeZddd„Z	ddd„Z
ddd„Zdd	d
„Zedd„ ƒZdS )ÚIImageResourcez© The interface for an image resource.

    An image resource describes the location of an image and provides a way
    to create a toolkit-specific image on demand.
    Nc             C   s   dS )z Creates a new image resource. N© )ÚselfÚnameÚsearch_pathr
   r
   úq/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/pyface-6.1.2-py3.6.egg/pyface/i_image_resource.pyÚ__init__/   s    zIImageResource.__init__c             C   s   dS )a�   Creates a toolkit specific image for this resource.

        Parameters
        ----------
        size : (int, int) or None
            The desired size as a width, height tuple, or None if wanting
            default image size.

        Returns
        -------
        image : toolkit image
            The toolkit image corresponding to the resource and the specified
            size.
        Nr
   )r   Úsizer
   r
   r   Úcreate_image6   s    zIImageResource.create_imagec             C   s   dS )aœ   Creates a toolkit specific bitmap for this resource.

        Parameters
        ----------
        size : (int, int) or None
            The desired size as a width, height tuple, or None if wanting
            default image size.

        Returns
        -------
        image : toolkit image
            The toolkit image corresponding to the resource and the specified
            size as a bitmap.
        Nr
   )r   r   r
   r
   r   Úcreate_bitmapI   s    zIImageResource.create_bitmapc             C   s   dS )a™   Creates a toolkit-specific icon for this resource.

        Parameters
        ----------
        size : (int, int) or None
            The desired size as a width, height tuple, or None if wanting
            default image size.

        Returns
        -------
        image : toolkit image
            The toolkit image corresponding to the resource and the specified
            size as an icon.
        Nr
   )r   r   r
   r
   r   Úcreate_iconY   s    zIImageResource.create_iconc             C   s   dS )a   Get the size of a toolkit image

        Parameters
        ----------
        image : toolkit image
            A toolkit image to compute the size of.

        Returns
        -------
        size : tuple
            The (width, height) tuple giving the size of the image.
        Nr
   )ÚclsÚimager
   r
   r   Ú
image_sizei   s    zIImageResource.image_size)N)N)N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Zabsolute_pathr   r   r   r   r   r   r   Úclassmethodr   r
   r
   r
   r   r	      s   



r	   c               @   sF   e Zd ZdZdZddd„Zddd„Zddd„Zd	d
„ Ze	dd„ ƒZ
dS )ÚMImageResourcez¥ The mixin class that contains common code for toolkit specific
    implementations of the IImageResource interface.

    Implements: __init__(), create_image()
    Nc             C   sT   || _ t|tjƒr|g}n(t|tƒr*|}n|d k	r:|g}ntƒ g}|tƒ g | _d S )N)r   Ú
isinstanceÚsixÚstring_typesr   r   r   r   )r   r   r   Ú_pathr
   r
   r   r   Š   s    
zMImageResource.__init__c             C   s(   | j |ƒ}|dk	r|jƒ }n| jƒ }|S )a�   Creates a toolkit specific image for this resource.

        Parameters
        ----------
        size : (int, int) or None
            The desired size as a width, height tuple, or None if wanting
            default image size.

        Returns
        -------
        image : toolkit image
            The toolkit image corresponding to the resource and the specified
            size.
        N)Ú_get_refÚloadÚ_get_image_not_found_image)r   r   Úrefr   r
   r
   r   r   ›   s
    

zMImageResource.create_imagec             C   s$   | j dkrtj| j| j|ƒ| _ | j S )ai   Return the resource manager reference to the image.

        Parameters
        ----------
        size : (int, int) or None
            The desired size as a width, height tuple, or None if wanting
            default image size.

        Returns
        -------
        ref : ImageReference instance
            The reference to the requested image.
        N)Z_refr   Zlocate_imager   r   )r   r   r
   r
   r   r!   ·   s    
zMImageResource._get_refc             C   s&   | j ƒ }| |k	r|jƒ }ntdƒ‚|S )z˜ Returns the 'image not found' image.

        Returns
        -------
        image : toolkit image
            The 'not found' toolkit image.
        z,cannot locate the file for 'image_not_found')Ú_get_image_not_foundr   Ú
ValueError)r   Z	not_foundr   r
   r
   r   r#   Ì   s
    	
z)MImageResource._get_image_not_found_imagec             C   s&   | j dkr ddlm} |dƒ| _ | j S )zÀ Returns the 'image not found' image resource.

        Returns
        -------
        not_found : ImageResource instance
            An image resource for the the 'not found' image.
        Nr   )ÚImageResourceZimage_not_found)Ú_image_not_foundZpyface.image_resourcer'   )r   r'   r
   r
   r   r%   ß   s    


z#MImageResource._get_image_not_found)N)N)N)r   r   r   r   r(   r   r   r!   r#   r   r%   r
   r
   r
   r   r   z   s   


r   )r   Úcollections.abcr   ÚImportErrorÚcollectionsZpyface.resource_managerr   Zpyface.resource.resource_pathr   r   Z
traits.apir   r   r   r   r	   Úobjectr   r
   r
   r
   r   Ú<module>   s   b