
    
3jW                         S r SSKJr  SSKJr  SSKJrJr  SSKJ	r
  S rS r\R                  " SS	S
9SS j5       r\R                  " SSS
9SS j5       rSS jrg)z|
========================
Widget testing utilities
========================

See also :mod:`matplotlib.tests.test_widgets`.
    )mock)_api)
MouseEventKeyEventNc                      [         R                  " SS5      u  pUR                  SS/SS/5        UR                  S5        U R                  R                  5         U$ )z"Create a plot and return its Axes.   r      g      ?)pltsubplotsplot
set_aspectcanvasdraw)figaxs     T/home/wildlama/miniconda3/lib/python3.13/site-packages/matplotlib/testing/widgets.pyget_axr      sI    ll1a GCGGQHq#hMM#JJOOI    c                      g N )argskwargss     r   noopr      s    r   z3.11zMouseEvent or KeyEvent)alternativec                 2   [         R                  " 5       nXl        U R                  R	                  X#4X#4/5      S   u  Ul        Ul        X#sUl        Ul        Xl	        U R                  SS9R                  Ul        XFl        XVl        SUl        SUl        U$ )a  
Create a mock event that can stand in for `.Event` and its subclasses.

This event is intended to be used in tests where it can be passed into
event handling functions.

Parameters
----------
ax : `~matplotlib.axes.Axes`
    The Axes the event will be in.
xdata : float
    x coord of mouse in data coords.
ydata : float
    y coord of mouse in data coords.
button : None or `MouseButton` or {'up', 'down'}
    The mouse button pressed in this event (see also `.MouseEvent`).
key : None or str
    The key pressed when the mouse event triggered (see also `.KeyEvent`).
step : int
    Number of scroll steps (positive for 'up', negative for 'down').

Returns
-------
event
    A `.Event`\-like Mock instance.
r   T)rootNCustom)r   Mockbutton	transData	transformxyxdataydatainaxes
get_figurer   keystepguiEventname)r   r    r%   r&   r)   r*   events          r   
mock_eventr.      s    8 IIKEL||--~05~/? @@ACEGUW$EKL==d=+22ELIJENEJLr   zcallbacks.process(event)c                 Z    [        U R                  X#XEU5      n[        X5      nU" U5        g)a  
Trigger an event on the given tool.

Parameters
----------
tool : matplotlib.widgets.AxesWidget
etype : str
    The event to trigger.
xdata : float
    x coord of mouse in data coords.
ydata : float
    y coord of mouse in data coords.
button : None or `MouseButton` or {'up', 'down'}
    The mouse button pressed in this event (see also `.MouseEvent`).
key : None or str
    The key pressed when the mouse event triggered (see also `.KeyEvent`).
step : int
    Number of scroll steps (positive for 'up', negative for 'down').
N)r.   r   getattr)	tooletyper    r%   r&   r)   r*   r-   funcs	            r   do_eventr4   G   s)    * twwu4@E4DKr   c                    U R                   nUb&  [        R                  " SXAU5      R                  5         [        R                  " SXAS5      R                  5         [        R                  " SXBS5      R                  5         [        R                  " SXBS5      R                  5         Ub'  [        R                  " SXBU5      R                  5         gg)aM  
Helper to simulate a mouse drag operation.

Parameters
----------
tool : `~matplotlib.widgets.Widget`
start : [float, float]
    Starting point in data coordinates.
end : [float, float]
    End point in data coordinates.
key : None or str
     An optional key that is pressed during the whole operation
     (see also `.KeyEvent`).
Nkey_press_eventbutton_press_eventr   motion_notify_eventbutton_release_eventkey_release_event)r   r   _from_ax_coords_processr   )r1   startendr)   r   s        r   click_and_dragr?   a   s     
B
  !2BsCLLN3RBKKM4bqAJJL5rBKKM
  !4bsCLLN r   )r   r   r   Nr   r   )__doc__unittestr   
matplotlibr   matplotlib.backend_basesr   r   matplotlib.pyplotpyplotr
   r   r   
deprecatedr.   r4   r?   r   r   r   <module>rG      sj      9 	 %=>& ?&R %?@ A2Or   