ó
È4ec           @   s‚   d  d l  m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   i   (   t   Imaget   HDCc           B   s    e  Z d  Z d „  Z d „  Z RS(   s¤   
    Wraps an HDC integer. The resulting object can be passed to the
    :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
    methods.
    c         C   s   | |  _  d  S(   N(   t   dc(   t   selfR   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   __init__   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   __int__!   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR      s   	t   HWNDc           B   s    e  Z d  Z d „  Z d „  Z RS(   s¶   
    Wraps an HWND integer. The resulting object can be passed to the
    :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
    methods, instead of a DC.
    c         C   s   | |  _  d  S(   N(   t   wnd(   R   R
   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   ,   s    c         C   s   |  j  S(   N(   R
   (   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   /   s    (   R   R   R   R   R   (    (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR	   %   s   	t   Dibc           B   sV   e  Z d  Z d d „ Z d „  Z d d „ Z d „  Z d d „ Z d „  Z	 d „  Z
 RS(	   s&  
    A Windows bitmap with the given mode and size.  The mode can be one of "1",
    "L", "P", or "RGB".

    If the display requires a palette, this constructor creates a suitable
    palette and associates it with the image. For an "L" image, 128 greylevels
    are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together
    with 20 greylevels.

    To make sure that palettes work properly under Windows, you must call the
    **palette** method upon certain events from Windows.

    :param image: Either a PIL image, or a mode string. If a mode string is
                  used, a size must also be given.  The mode can be one of "1",
                  "L", "P", or "RGB".
    :param size: If the first argument is a mode string, this
                 defines the size of the image.
    c         C   s¡   t  | d ƒ r3 t  | d ƒ r3 | j } | j } n | } d  } | d k r] t j | ƒ } n  t j j | | ƒ |  _ | |  _ | |  _ | r |  j	 | ƒ n  d  S(   Nt   modet   sizet   1t   Lt   Pt   RGB(   R   R   R   R   (
   t   hasattrR   R   t   NoneR    t   getmodebaset   coret   displayt   imaget   paste(   R   R   R   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   G   s    			c         C   sg   t  | t ƒ rQ |  j j | ƒ } z |  j j | ƒ } Wd |  j j | | ƒ Xn |  j j | ƒ } | S(   s)  
        Copy the bitmap contents to a device context.

        :param handle: Device context (HDC), cast to a Python integer, or an
                       HDC or HWND instance.  In PythonWin, you can use the
                       :py:meth:`CDC.GetHandleAttrib` to get a suitable handle.
        N(   t
   isinstanceR	   R   t   getdct   exposet	   releasedc(   R   t   handleR   t   result(    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   V   s    c         C   s‰   | s d |  j  } n  t | t ƒ rm |  j j | ƒ } z |  j j | | | ƒ } Wd |  j j | | ƒ Xn |  j j | | | ƒ } | S(   sm  
        Same as expose, but allows you to specify where to draw the image, and
        what part of it to draw.

        The destination and source areas are given as 4-tuple rectangles. If
        the source is omitted, the entire image is copied. If the source and
        the destination have different sizes, the image is resized as
        necessary.
        i    N(   i    i    (   R   R   R	   R   R   t   drawR   (   R   R   t   dstt   srcR   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   h   s    
c         C   sg   t  | t ƒ rQ |  j j | ƒ } z |  j j | ƒ } Wd |  j j | | ƒ Xn |  j j | ƒ } | S(   se  
        Installs the palette associated with the image in the given device
        context.

        This method should be called upon **QUERYNEWPALETTE** and
        **PALETTECHANGED** events from Windows. If this method returns a
        non-zero value, one or more display palette entries were changed, and
        the image should be redrawn.

        :param handle: Device context (HDC), cast to a Python integer, or an
                       HDC or HWND instance.
        :return: A true value if one or more entries were changed (this
                 indicates that the image should be redrawn).
        N(   R   R	   R   R   t   query_paletteR   (   R   R   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR"   ~   s    c         C   sg   | j  ƒ  |  j | j k r1 | j |  j ƒ } n  | rP |  j j | j | ƒ n |  j j | j ƒ d S(   sõ  
        Paste a PIL image into the bitmap image.

        :param im: A PIL image.  The size must match the target region.
                   If the mode does not match, the image is converted to the
                   mode of the bitmap image.
        :param box: A 4-tuple defining the left, upper, right, and
                    lower pixel coordinate.  See :ref:`coordinate-system`. If
                    None is given instead of a tuple, all of the image is
                    assumed.
        N(   t   loadR   t   convertR   R   t   im(   R   R%   t   box(    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   —   s    
c         C   s   |  j  j | ƒ S(   sº   
        Load display memory contents from byte data.

        :param buffer: A buffer containing display data (usually
                       data returned from <b>tobytes</b>)
        (   R   t	   frombytes(   R   t   buffer(    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR'   «   s    c         C   s   |  j  j ƒ  S(   sy   
        Copy display memory contents to bytes object.

        :return: A bytes object containing display data.
        (   R   t   tobytes(   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR)   ´   s    N(   R   R   R   R   R   R   R   R"   R   R'   R)   (    (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   3   s   				t   Windowc           B   s_   e  Z d  Z d d
 d
 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(   s*   Create a Window with the given title size.t   PILc         C   s1   t  j j | |  j | p d | p$ d ƒ |  _ d  S(   Ni    (   R    R   t   createwindowt   _Window__dispatchert   hwnd(   R   t   titlet   widtht   height(    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   À   s    	c         G   s   t  |  d | ƒ | Œ  S(   Nt
   ui_handle_(   t   getattr(   R   t   actiont   args(    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   __dispatcherÅ   s    c         C   s   d  S(   N(    (   R   R   t   x0t   y0t   x1t   y1(    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_clearÈ   s    c         C   s   d  S(   N(    (   R   R7   R8   R9   R:   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_damageË   s    c         C   s   d  S(   N(    (   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_destroyÎ   s    c         C   s   d  S(   N(    (   R   R   R7   R8   R9   R:   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_repairÑ   s    c         C   s   d  S(   N(    (   R   R0   R1   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_resizeÔ   s    c         C   s   t  j j ƒ  d  S(   N(   R    R   t	   eventloop(   R   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   mainloop×   s    N(   R   R   R   R   R   R-   R;   R<   R=   R>   R?   RA   (    (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR*   ½   s   						t   ImageWindowc           B   s#   e  Z d  Z d d „ Z d „  Z RS(   s6   Create an image window which displays the given image.R+   c         C   sV   t  | t ƒ s t | ƒ } n  | |  _ | j \ } } t j |  | d | d | ƒd  S(   NR0   R1   (   R   R   R   R   R*   R   (   R   R   R/   R0   R1   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR   Þ   s
    	c         C   s#   |  j  j | | | | | f ƒ d  S(   N(   R   R   (   R   R   R7   R8   R9   R:   (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyR>   å   s    (   R   R   R   R   R>   (    (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyRB   Û   s   N(   t    R    t   objectR   R	   R   R*   RB   (    (    (    s6   /usr/local/lib/python2.7/dist-packages/PIL/ImageWin.pyt   <module>   s
   Š