B
    Mô`ô
  ã            
   @   sÌ   d dl ZddlmZ yddlmZ W n, ek
rP Z zedƒe‚W ddZ[X Y nX ddlmZmZ ddlm	Z	 dd	lm
Z
mZ d d
lmZ G dd„ dejejƒZG dd„ dejƒZejG dd„ deƒƒZdS )é    Né   )Úcbooké   )Úbackend_cairozbackend Gtk3Agg requires cairo)Úbackend_aggÚbackend_gtk3)Úcairo)ÚGtkÚ_BackendGTK3)Ú
transformsc                   s>   e Zd Zdd„ Zdd„ Zddd„Z‡ fdd	„Zd
d„ Z‡  ZS )ÚFigureCanvasGTK3Aggc             C   s   t j | |¡ g | _d S )N)r   ÚFigureCanvasGTK3Ú__init__Ú_bbox_queue)ÚselfÚfigure© r   úG/tmp/pip-unpacked-wheel-0c1wfn4v/matplotlib/backends/backend_gtk3agg.pyr      s    zFigureCanvasGTK3Agg.__init__c             C   s  |   ¡ }|j|j }}t| jƒsZt |  ¡ ||j|j	|j|j¡ t
 ddg||gg¡g}n| j}t |¡}x’|D ]Š}t|jƒ}|t|jƒ }	t|jƒt|jƒ }
t|jƒt|jƒ }t t |  |¡¡¡}tj | ¡ jtj|
|¡}| |||	¡ | ¡  qpW t| jƒ�rg | _dS )z5GtkDrawable draw event, like expose_event in GTK 2.X.r   F) Úget_allocationÚwidthÚheightÚlenr   r	   Zrender_backgroundZget_style_contextÚxÚyr   ZBboxr   Z_to_contextÚintÚx0Úy1Úx1Úy0r   Z._unmultiplied_rgba8888_to_premultiplied_argb32ÚnpZasarrayZcopy_from_bboxr   ZImageSurfaceZcreate_for_dataZravelÚdataZFORMAT_ARGB32Zset_source_surfaceZpaint)r   ZwidgetÚctxÚ
allocationÚwÚhZ
bbox_queueÚbboxr   r   r   r   ÚbufÚimager   r   r   Úon_draw_event   s0    



z!FigureCanvasGTK3Agg.on_draw_eventNc             C   sz   |d kr| j j}|  ¡ }t|jƒ}|jt|jƒ }t|jƒt|jƒ }t|jƒt|jƒ }| j	 
|¡ |  ||||¡ d S )N)r   r%   r   r   r   r   r   r   r   r   ÚappendZqueue_draw_area)r   r%   r"   r   r   r   r   r   r   r   Úblit6   s    
zFigureCanvasGTK3Agg.blitc                s   t j | ¡ tƒ  ¡  d S )N)r   ÚFigureCanvasAggÚdrawÚsuper)r   )Ú	__class__r   r   r,   E   s    zFigureCanvasGTK3Agg.drawc             O   s   |   tj¡}|j|f|ž|ŽS )N)Zswitch_backendsr   r+   Ú	print_png)r   ÚfilenameÚargsÚkwargsZaggr   r   r   r/   I   s    zFigureCanvasGTK3Agg.print_png)N)	Ú__name__Ú
__module__Ú__qualname__r   r(   r*   r,   r/   Ú__classcell__r   r   )r.   r   r      s
   "
r   c               @   s   e Zd ZdS )ÚFigureManagerGTK3AggN)r3   r4   r5   r   r   r   r   r7   O   s   r7   c               @   s   e Zd ZeZeZdS )Ú_BackendGTK3CairoN)r3   r4   r5   r   ZFigureCanvasr7   ZFigureManagerr   r   r   r   r8   S   s   r8   )Znumpyr   Ú r   r   ÚImportErrorÚer   r   r   r	   r
   Z
matplotlibr   r   r+   r   ZFigureManagerGTK3r7   Úexportr8   r   r   r   r   Ú<module>   s   @