B
    ]”t\¯  ã               @   s€   d dl Z ddlmZ ddlmZmZmZmZ G dd„ deƒZ	G dd„ deeƒZ
d	d
„ Zdd„ Zdd„ ZejG dd„ deƒƒZdS )é    Né   )ÚFigureCanvasAgg)Ú
_BackendWxÚ_FigureCanvasWxBaseÚFigureFrameWxÚNavigationToolbar2Wxc               @   s   e Zd Zdd„ ZdS )ÚFigureFrameWxAggc             C   s   t | d|ƒS )Néÿÿÿÿ)ÚFigureCanvasWxAgg)ÚselfZfig© r   ú@lib/python3.7/site-packages/matplotlib/backends/backend_wxagg.pyÚ
get_canvas
   s    zFigureFrameWxAgg.get_canvasN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   	   s   r   c               @   s*   e Zd ZdZddd„Zddd„ZejZdS )	r
   ad  
    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.
    Nc             C   s2   t  | ¡ t|  ¡ dƒ| _d| _| j|dd dS )z.
        Render the figure using agg.
        NTZWXAgg)ÚdrawDCÚorigin)r   ÚdrawÚ_convert_agg_to_wx_bitmapÚget_rendererÚbitmapZ_isDrawnÚgui_repaint)r   r   r   r   r   r      s    
zFigureCanvasWxAgg.drawc          	   C   sÒ   |dkr$t |  ¡ dƒ| _|  ¡  dS |j\}}}}|| }|| }t|ƒ}t| j ¡ | ƒ}	t |  ¡ dƒ}
t ¡ }| 	|
¡ t ¡ }| 	| j¡ | 
||	t|ƒt|ƒ|||	¡ | 	tj¡ | 	tj¡ |  ¡  dS )z’
        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   ÚboundsÚintZ	GetHeightÚwxÚMemoryDCÚSelectObjectÚBlitÚ
NullBitmap)r   ÚbboxÚlÚbÚwÚhÚrÚtÚxÚyÚsrcBmpÚsrcDCÚdestDCr   r   r   Úblit#   s$    
zFigureCanvasWxAgg.blit)N)N)r   r   r   Ú__doc__r   r,   r   Z	filetypesr   r   r   r   r
      s   	


r
   c             C   sF   |dkr2t  t| jƒt| jƒ¡}| |  ¡ ¡ |S t  t| |ƒ¡S dS )z¾
    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   ZImager   ÚwidthÚheightZSetDataZtostring_rgbZImageFromBitmapÚ_WX28_clipped_agg_as_bitmap)Úaggr    Zimager   r   r   Ú_convert_agg_to_wx_imageE   s
    r2   c             C   s6   |dkr(t j t| jƒt| jƒ|  ¡ ¡S t| |ƒS dS )z¿
    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   ÚBitmapÚFromBufferRGBAr   r.   r/   Úbuffer_rgbar0   )r1   r    r   r   r   r   V   s    
r   c          	   C   sÊ   |j \}}}}|| }|| }tj t| jƒt| jƒ|  ¡ ¡}t ¡ }	|	 	|¡ t t|ƒt|ƒ¡}
t ¡ }| 	|
¡ t|ƒ}tt| jƒ| ƒ}| 
ddt|ƒt|ƒ|	||¡ |	 	tj¡ | 	tj¡ |
S )z‹
    Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap.

    Note: agg must be a backend_agg.RendererAgg instance.
    r   )r   r   r3   r4   r   r.   r/   r5   r   r   r   r   )r1   r    r!   r"   r.   r/   r%   r&   r)   r*   ZdestBmpr+   r'   r(   r   r   r   r0   f   s     


r0   c               @   s   e Zd ZeZeZdS )Ú_BackendWxAggN)r   r   r   r
   ZFigureCanvasr   Z_frame_classr   r   r   r   r6   ƒ   s   r6   )r   Zbackend_aggr   Z
backend_wxr   r   r   r   ZNavigationToolbar2WxAggr   r
   r2   r   r0   Zexportr6   r   r   r   r   Ú<module>   s   7