ó
±éRc           @  s  d  d l  m Z m Z d  d l Z d  d l m Z d  d l m Z d  d l Z d  d l m	 Z	 m
 Z
 m Z m Z m Z m Z m Z m Z m Z m Z m Z d  d l Z d e f d „  ƒ  YZ d e e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿ(   t   divisiont   print_functionN(   t   Figure(   t   FigureCanvasAgg(   t   FigureManagert   FigureManagerWxt   FigureCanvasWxt   FigureFrameWxt	   DEBUG_MSGt   NavigationToolbar2Wxt   error_msg_wxt   draw_if_interactivet   showt   Toolbart   backend_versiont   FigureFrameWxAggc           B  s   e  Z d  „  Z d „  Z RS(   c         C  s   t  |  d | ƒ S(   Niÿÿÿÿ(   t   FigureCanvasWxAgg(   t   selft   fig(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyt
   get_canvas   s    c         C  sd   t  j d d k r( t |  j t ƒ } n8 t  j d d k rZ t |  j ƒ } | j | ƒ n d  } | S(   Nt   toolbart   classict   toolbar2(   t
   matplotlibt   rcParamst   NavigationToolbarWxt   canvast   Truet   NavigationToolbar2WxAggt   set_status_bart   None(   R   t   statbarR   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyt   _get_toolbar   s    (   t   __name__t
   __module__R   R    (    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyR      s   	R   c           B  s8   e  Z d  Z d d „ Z d d „ Z e j Z d „  Z RS(   sd  
    The FigureCanvas contains the figure and does event handling.

    In the wxPython backend, it is derived from wxPanel, and (usually)
    lives inside a frame instantiated by a FigureManagerWx. The parent
    window probably implements a wxSizer to control the displayed
    control size - but we give a hint as to our preferred minimum
    size.
    c         C  sR   t  d d |  ƒ t j |  ƒ t |  j ƒ  d ƒ |  _ t |  _ |  j	 d | ƒ d S(   s.   
        Render the figure using agg.
        s   draw()i   t   drawDCN(
   R   R   t   drawt   _convert_agg_to_wx_bitmapt   get_rendererR   t   bitmapR   t   _isDrawnt   gui_repaint(   R   R#   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyR$   '   s
    	c         C  s7  | d k r2 t |  j ƒ  d ƒ |  _ |  j ƒ  d S| j \ } } } } | | } | | } t | ƒ } t |  j j ƒ  | ƒ }	 t |  j ƒ  d ƒ }
 t j	 ƒ  } | j
 |
 ƒ t j	 ƒ  } | j
 |  j ƒ | j ƒ  | j | |	 t | ƒ t | ƒ | | |	 ƒ | j ƒ  | j
 t j ƒ | j
 t j ƒ |  j ƒ  d S(   s’   
        Transfer the region of the agg buffer defined by bbox to the display.
        If bbox is None, the entire buffer is transferred.
        N(   R   R%   R&   R'   R)   t   boundst   intt	   GetHeightt   wxt   MemoryDCt   SelectObjectt   BeginDrawingt   Blitt
   EndDrawingt
   NullBitmap(   R   t   bboxt   lt   bt   wt   ht   rt   tt   xt   yt   srcBmpt   srcDCt   destDC(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyt   blit2   s(    



+
c         O  s0   t  j |  | | | Ž |  j r, |  j ƒ  n  d  S(   N(   R   t   print_figureR(   R$   (   R   t   filenamet   argst   kwargs(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyRA   S   s    	N(	   R!   R"   t   __doc__R   R$   R@   R   t	   filetypesRA   (    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyR      s
   		R   c           B  s   e  Z d  „  Z RS(   c         C  s   t  | d | ƒ S(   Niÿÿÿÿ(   R   (   R   t   frameR   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyR   _   s    (   R!   R"   R   (    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyR   ^   s   c         O  sH   t  d d d ƒ t j ƒ  | j d t ƒ } | | | Ž  } t |  | ƒ S(   s.   
    Create a new figure manager instance
    s   new_figure_manager()i   t   FigureClassN(   R   R   t
   backend_wxt   _create_wx_appt   popR   t   new_figure_manager_given_figure(   t   numRC   RD   RH   R   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyt   new_figure_managerc   s
    
c         C  s;   t  |  | ƒ } | j ƒ  } t j ƒ  r7 | j j ƒ  n  | S(   sD   
    Create a new figure manager instance for the given figure.
    (   R   t   get_figure_managerR   t   is_interactiveRG   t   Show(   RM   t   figureRG   t   figmgr(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyRL   q   s
    c         C  sa   | d k rG t j t |  j ƒ t |  j ƒ ƒ } | j |  j ƒ  ƒ | St j t	 |  | ƒ ƒ Sd S(   s¾   
    Convert the region of the agg buffer bounded by bbox to a wx.Image.  If
    bbox is None, the entire buffer is converted.

    Note: agg must be a backend_agg.RendererAgg instance.
    N(
   R   R-   t
   EmptyImageR+   t   widtht   heightt   SetDatat   tostring_rgbt   ImageFromBitmapt   _WX28_clipped_agg_as_bitmap(   t   aggR4   t   image(    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyt   _convert_agg_to_wx_image€   s
    $c         C  sH   | d k r7 t j t |  j ƒ t |  j ƒ |  j ƒ  ƒ St |  | ƒ Sd S(   s¿   
    Convert the region of the agg buffer bounded by bbox to a wx.Bitmap.  If
    bbox is None, the entire buffer is converted.

    Note: agg must be a backend_agg.RendererAgg instance.
    N(   R   R-   t   BitmapFromBufferRGBAR+   RU   RV   t   buffer_rgbaRZ   (   R[   R4   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyR%   ‘   s    c         C  s.  | j  \ } } } } | | } | | } t j t |  j ƒ t |  j ƒ |  j ƒ  ƒ } t j ƒ  }	 |	 j | ƒ t j	 t | ƒ t | ƒ ƒ }
 t j ƒ  } | j |
 ƒ | j
 ƒ  t | ƒ } t t |  j ƒ | ƒ } | j d d t | ƒ t | ƒ |	 | | ƒ | j ƒ  |	 j t j ƒ | j t j ƒ |
 S(   s‹   
    Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap.

    Note: agg must be a backend_agg.RendererAgg instance.
    i    (   R*   R-   R^   R+   RU   RV   R_   R.   R/   t   EmptyBitmapR0   R1   R2   R3   (   R[   R4   R5   R6   RU   RV   R9   R:   R=   R>   t   destBmpR?   R;   R<   (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyRZ   ¡   s$    


+
(   t
   __future__R    R   R   t   matplotlib.figureR   t   backend_aggR   RI   R   R   R   R   R   R	   R
   R   R   R   R   R-   R   R   R   RN   RL   R]   R%   RZ   (    (    (    s[   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.pyt   <module>   s   LB				