
    \
j	                       d Z ddlZddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlmZ  eed          oej        Z G d d	e          Z G d
 de          Z G d de          Z G d de          Z G d de          Z G d d          Z G d de          Z G d de          Z G d d          Z G d de          Z G d de          Zd Zd Z G d  d!e           Z! G d" d# ee!e
                    Z"e"#                    d$           e"#                    d%           e"#                    d&           e"#                    d'           e"#                    d(           e"#                    d)           e"#                    d*           e"#                    d+           e"#                    d,           e"#                    d-           e"#                    d.           e"#                    d/           e"#                    d0           e"#                    d1           e"#                    d2           e"#                    d3           e"#                    d4           e"#                    d5           e"#                    d6           e"#                    d7           e"#                    d8           e"#                    d9           e"#                    d:           e"#                    d;            G d< d=          Z$ere"Z%d>e%_&        ["n<ej'        d?         rdd@l(m)Z% n(ej*        dAk    rddBl+m,Z% nej*        dCv rddDl-m.Z% nddEl/m0Z% es#ej1        e&         e_2         ej3                     dS dS )Fa  Windowing and user-interface events.

This module allows applications to create and display windows with an
OpenGL context.  Windows can be created with a variety of border styles
or set fullscreen.

You can register event handlers for keyboard, mouse and window events.
For games and kiosks you can also restrict the input to your windows,
for example disabling users from switching away from the application
with certain key combinations or capturing and hiding the mouse.

Getting started
---------------

Call the Window constructor to create a new window::

    from pyglet.window import Window
    win = Window(width=640, height=480)

Attach your own event handlers::

    @win.event
    def on_key_press(symbol, modifiers):
        # ... handle this event ...

Place drawing code for the window within the `Window.on_draw` event handler::

    @win.event
    def on_draw():
        # ... drawing code ...

Call `pyglet.app.run` to enter the main event loop (by default, this
returns when all open windows are closed)::

    from pyglet import app
    app.run()

Creating a game window
----------------------

Use :py:meth:`~pyglet.window.Window.set_exclusive_mouse` to hide the mouse
cursor and receive relative mouse movement events.  Specify ``fullscreen=True``
as a keyword argument to the :py:class:`~pyglet.window.Window` constructor to
render to the entire screen rather than opening a window::

    win = Window(fullscreen=True)
    win.set_exclusive_mouse()

Working with multiple screens
-----------------------------

By default, fullscreen windows are opened on the primary display (typically
set by the user in their operating system settings).  You can retrieve a list
of attached screens and select one manually if you prefer.  This is useful for
opening a fullscreen window on each screen::

    display = pyglet.canvas.get_display()
    screens = display.get_screens()
    windows = []
    for screen in screens:
        windows.append(window.Window(fullscreen=True, screen=screen))

Specifying a screen has no effect if the window is not fullscreen.

Specifying the OpenGL context properties
----------------------------------------

Each window has its own context which is created when the window is created.
You can specify the properties of the context before it is created
by creating a "template" configuration::

    from pyglet import gl
    # Create template config
    config = gl.Config()
    config.stencil_size = 8
    config.aux_buffers = 4
    # Create a window using this config
    win = window.Window(config=config)

To determine if a given configuration is supported, query the screen (see
above, "Working with multiple screens")::

    configs = screen.get_matching_configs(config)
    if not configs:
        # ... config is not supported
    else:
        win = window.Window(config=configs[0])

    N)gl)EventDispatcher)key)with_metaclassis_pyglet_doc_runc                       e Zd ZdZdS )WindowExceptionz1The root exception for all window-related errors.N__name__
__module____qualname____doc__     P/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/window/__init__.pyr	   r	      s        ;;Dr   r	   c                       e Zd ZdZdS )NoSuchDisplayExceptionz?An exception indicating the requested display is not available.Nr
   r   r   r   r   r      s        IIDr   r   c                       e Zd ZdZdS )NoSuchConfigExceptionzIAn exception indicating the requested configuration is not
    available.Nr
   r   r   r   r   r      s         Dr   r   c                       e Zd ZdZdS )NoSuchScreenModeExceptionzMAn exception indicating the requested screen resolution could not be
    met.Nr
   r   r   r   r   r      s         Dr   r   c                       e Zd ZdZdS )MouseCursorExceptionz7The root exception for all mouse cursor-related errors.Nr
   r   r   r   r   r      s        AADr   r   c                        e Zd ZdZdZdZd ZdS )MouseCursorzAn abstract mouse cursor.TFc                     dS )a  Abstract render method.

        The cursor should be drawn with the "hot" spot at the given
        coordinates.  The projection is set to the pyglet default (i.e.,
        orthographic in window-space), however no other aspects of the
        state can be assumed.

        :Parameters:
            `x` : int
                X coordinate of the mouse pointer's hot spot.
            `y` : int
                Y coordinate of the mouse pointer's hot spot.

        Nr   selfxys      r   drawzMouseCursor.draw   	     	r   N)r   r   r   r   gl_drawablehw_drawabler!   r   r   r   r   r      s5        ## KK    r   r   c                       e Zd ZdZdZdZdS )DefaultMouseCursorz5The default mouse cursor set by the operating system.FTN)r   r   r   r   r#   r$   r   r   r   r&   r&      s        ??KKKKr   r&   c                        e Zd ZdZddZd ZdS )ImageMouseCursora  A user-defined mouse cursor created from an image.

    Use this class to create your own mouse cursors and assign them
    to windows. Cursors can be drawn by OpenGL, or optionally passed
    to the OS to render natively. There are no restrictions on cursors
    drawn by OpenGL, but natively rendered cursors may have some
    platform limitations (such as color depth, or size). In general,
    reasonably sized cursors will render correctly
    r   Fc                 r    |                                 | _        || _        || _        | | _        || _        dS )aw  Create a mouse cursor from an image.

        :Parameters:
            `image` : `pyglet.image.AbstractImage`
                Image to use for the mouse cursor.  It must have a
                valid ``texture`` attribute.
            `hot_x` : int
                X coordinate of the "hot" spot in the image relative to the
                image's anchor. May be clamped to the maximum image width
                if ``acceleration=True``.
            `hot_y` : int
                Y coordinate of the "hot" spot in the image, relative to the
                image's anchor. May be clamped to the maximum image height
                if ``acceleration=True``.
            `acceleration` : int
                If True, draw the cursor natively instead of usign OpenGL.
                The image may be downsampled or color reduced to fit the
                platform limitations.
        N)get_texturetexturehot_xhot_yr#   r$   )r   imager,   r-   accelerations        r   __init__zImageMouseCursor.__init__   s>    ( ((**

++'r   c                    t          j        t           j        t           j        z             t          j        dddd           t          j        t           j                   t          j        t           j        t           j	                   | j
                            || j        z
  || j        z
  d           t          j                     d S )N   r   )r   glPushAttribGL_ENABLE_BITGL_CURRENT_BIT	glColor4fglEnableGL_BLENDglBlendFuncGL_SRC_ALPHAGL_ONE_MINUS_SRC_ALPHAr+   blitr,   r-   glPopAttribr   s      r   r!   zImageMouseCursor.draw   s    
(2+<<===
Q1a   
BK   
r(ABBB!dj.!dj.!<<<
r   N)r   r   F)r   r   r   r   r0   r!   r   r   r   r(   r(      sA         ( ( ( (6    r   r(   c                       e Zd ZdZd ZdS )
ProjectionzAbstract OpenGL projection.c                      t          d          )a  Set the OpenGL projection

        Using the passed in Window and viewport sizes,
        set a desired orthographic or perspective projection.

        :Parameters:
            `window_width` : int
                The Window width
            `window_height` : int
                The Window height
            `viewport_width` : int
                The Window internal viewport width.
            `viewport_height` : int
                The Window internal viewport height.
        abstractNotImplementedErrorr   window_widthwindow_heightviewport_widthviewport_heights        r   setzProjection.set   s      "*---r   Nr   r   r   r   rI   r   r   r   r?   r?      s)        %%. . . . .r   r?   c                       e Zd ZdZd ZdS )Projection2DzA 2D orthographic projectionc           	      t   t          j        ddt          d|          t          d|                     t          j        t           j                   t          j                     t          j        dt          d|          dt          d|          dd           t          j        t           j                   d S )Nr   r2   )r   
glViewportmaxglMatrixModeGL_PROJECTIONglLoadIdentityglOrthoGL_MODELVIEWrD   s        r   rI   zProjection2D.set  s    
aC>22C?4K4KLLL
()))


1c!\**As1m/D/Db!LLL
(((((r   NrJ   r   r   r   rL   rL     s)        &&) ) ) ) )r   rL   c                        e Zd ZdZddZd ZdS )	Projection3DzA 3D perspective projection<   皙?   c                 0    || _         || _        || _        dS )a.  Create a 3D projection

        :Parameters:
            `fov` : float
                The field of vision. Defaults to 60.
            `znear` : float
                The near clipping plane. Defaults to 0.1.
            `zfar` : float
                The far clipping plane. Defaults to 255.
        N)fovznearzfar)r   r\   r]   r^   s       r   r0   zProjection3D.__init__  s     
			r   c           	         t          j        ddt          d|          t          d|                     t          j        t           j                   t          j                     t          |          t          |          z  }t          j        | j	        dz  t          j
        z            | j        z  }||z  }t          j        | || || j        | j                   t          j        t           j                   d S )Nr   r2   g     v@)r   rO   rP   rQ   rR   rS   floatmathtanr\   pir]   	glFrustumr^   rU   )r   rE   rF   rG   rH   aspect_ratiof_widthf_heights           r   rI   zProjection3D.set,  s    
aC>22C?4K4KLLL
()))
 \**U=-A-AA(48e+dg577$*D\)
hY7(GTZSSS
(((((r   N)rX   rY   rZ   )r   r   r   r   r0   rI   r   r   r   rW   rW     s=        %%   ) ) ) ) )r   rW   c                       fd}|S )a  Decorator for platform event handlers.

    Apply giving the platform-specific data needed by the window to associate
    the method with an event.  See platform-specific subclasses of this
    decorator for examples.

    The following attributes are set on the function, which is returned
    otherwise unchanged:

    _platform_event
        True
    _platform_event_data
        List of data applied to the function (permitting multiple decorators
        on the same method).
    c                 x    d| _         t          | d          sg | _        | j                                       | S )NT_platform_event_data)_platform_eventhasattrrj   append)fdatas    r   _event_wrapperz-_PlatformEventHandler.<locals>._event_wrapperK  sB     q011 	(%'A"	%%d+++r   r   )ro   rp   s   ` r   _PlatformEventHandlerrq   :  s$    "     r   c                     d| _         | S )NT)_view)rn   s    r   _ViewEventHandlerrt   U  s    AGHr   c                   "     e Zd ZdZ fdZ xZS )_WindowMetaclasszNSets the _platform_event_names class variable on the window
    subclass.
    c                 r   t                      | _        |D ]1}t          |d          r| j                            |j                   2|                                D ]/\  }}t          |d          r| j                            |           0t          t          |                               |||           d S )N_platform_event_namesrk   )	rI   rx   rl   updateitemsaddsuperrv   r0   )clsnamebasesdictbasefunc	__class__s         r   r0   z_WindowMetaclass.__init___  s    $'EE! 	M 	MDt455 M)001KLLL**,, 	4 	4JD$t.// 4)--d333$$--dE4@@@@@r   )r   r   r   r   r0   __classcell__)r   s   @r   rv   rv   Z  sK         A A A A A A A A Ar   rv   c                   L   e Zd ZdZ e            ZdZdZdZdZ	dZ
dZdZdZd	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%eZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ- e.            Z/dZ0dZ1 e2            Z3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<dZ=ddddedddddddddfdZ>d  Z?d! Z@d" ZAd# ZBd$ ZCd% ZD	 	 dmd&ZEd' ZFd( ZGd) ZHd* ZId+ ZJd, ZKeLd-             ZMeLd.             ZNeLd/             ZOeLd0             ZPeLd1             ZQeLd2             ZReLd3             ZSeLd4             ZTeLd5             ZUeLd6             ZVeLd7             ZWeWjX        d8             ZWeLd9             ZYeYjX        d:             ZYeLd;             ZZeZjX        d<             ZZd= Z[d> Z\d? Z]d@ Z^dA Z_dB Z`dC ZaeaZbdD ZcdE ZddF ZedndGZfdH ZgdI ZhdJ ZidndKZjdodLZkdodMZldndNZmdndOZndP ZodQ ZpdR ZqdS ZrdT ZsetrJdU ZIdV ZudW ZvdX ZwdY ZxdZ Zyd[ Zzd\ Z{d] Z|d^ Z}d_ ZHd` Z~da Zdb Zdc ZGdd Zde Zdf Zdg Zdh Zdi Zdj Zdk Zdl ZdS dS )p
BaseWindowaA  Platform-independent application window.

    A window is a "heavyweight" object occupying operating system resources.
    The "client" or "content" area of a window is filled entirely with
    an OpenGL viewport.  Applications have no access to operating system
    widgets or controls; all rendering must be done via OpenGL.

    Windows may appear as floating regions or can be set to fill an entire
    screen (fullscreen).  When floating, windows may appear borderless or
    decorated with a platform-specific frame (including, for example, the
    title bar, minimize and close buttons, resize handles, and so on).

    While it is possible to set the location of a window, it is recommended
    that applications allow the platform to place it according to local
    conventions.  This will ensure it is not obscured by other windows,
    and appears on an appropriate screen for the user.

    To render into a window, you must first call `switch_to`, to make
    it the current OpenGL context.  If you use only one window in the
    application, there is no need to do this.
    Ndialogtool
borderlesstransparentoverlay	crosshairhandhelpnosizesize_upsize_up_right
size_rightsize_down_right	size_downsize_down_left	size_leftsize_up_leftsize_up_downsize_left_righttextwait
wait_arrowFTr   i  i  c                 T   t          j        |            g | _        |
st          j                                        }
|s|
                                }|sht          j        dd          t          j        dd          dfD ])}	 |	                    |          } n# t          $ r Y &w xY w|st          d          |dv rd|_        |                                s|	                    |          }|s|                    t          j                  }|| _        | j        j        | _        t%          | j        d	          r| j        j        | _        n|| _        | j        j        | _        |rB||| j        | j        f| _        |                     |||          \  }}| j        s	||f| _        n|| j        }|| j        }|| _        || _        || _        || _        || _        t          j         d
         t          j         d
         | _!        n|| _!        |	| _"        |tF          j$        d         }|| _%        ddlm&} |j'        (                    |            | )                                 |*                                }|+                    dd          sUd|,                                 d|-                                 d|.                                 }t_          j0        |           | 1                                 |r+| 2                    d           | 3                                 dS dS )a  Create a window.

        All parameters are optional, and reasonable defaults are assumed
        where they are not specified.

        The `display`, `screen`, `config` and `context` parameters form
        a hierarchy of control: there is no need to specify more than
        one of these.  For example, if you specify `screen` the `display`
        will be inferred, and a default `config` and `context` will be
        created.

        `config` is a special case; it can be a template created by the
        user specifying the attributes desired, or it can be a complete
        `config` as returned from `Screen.get_matching_configs` or similar.

        The context will be active as soon as the window is created, as if
        `switch_to` was just called.

        :Parameters:
            `width` : int
                Width of the window, in pixels.  Defaults to 640, or the
                screen width if `fullscreen` is True.
            `height` : int
                Height of the window, in pixels.  Defaults to 480, or the
                screen height if `fullscreen` is True.
            `caption` : str or unicode
                Initial caption (title) of the window.  Defaults to
                ``sys.argv[0]``.
            `resizable` : bool
                If True, the window will be resizable.  Defaults to False.
            `style` : int
                One of the ``WINDOW_STYLE_*`` constants specifying the
                border style of the window.
            `fullscreen` : bool
                If True, the window will cover the entire screen rather
                than floating.  Defaults to False.
            `visible` : bool
                Determines if the window is visible immediately after
                creation.  Defaults to True.  Set this to False if you
                would like to change attributes of the window before
                having it appear to the user.
            `vsync` : bool
                If True, buffer flips are synchronised to the primary screen's
                vertical retrace, eliminating flicker.
            `display` : `Display`
                The display device to use.  Useful only under X11.
            `screen` : `Screen`
                The screen to use, if in fullscreen.
            `config` : `pyglet.gl.Config`
                Either a template from which to create a complete config,
                or a complete config.
            `context` : `pyglet.gl.Context`
                The context to attach to this window.  The context must
                not already be attached to another window.
            `mode` : `ScreenMode`
                The screen will be switched to this mode if `fullscreen` is
                True.  If None, an appropriate mode is selected to accomodate
                `width` and `height.`

        T   )double_buffer
depth_size   Nz No standard config is available.)r   r      screenvsyncr   app   zb
Your graphics drivers do not support OpenGL 2.0.
You may experience rendering issues or crashes.

)4r   r0   _event_queuepygletcanvasget_displayget_default_screenr   Configget_best_configr   alphais_completecreate_contextcurrent_context_contextconfig_configrl   r   _screendisplay_display_default_width_default_height_windowed_size_set_fullscreen_mode_width_height
_resizable_fullscreen_styleoptions_vsync_file_dropssysargv_captionr   windowsr{   _createget_infohave_version
get_vendorget_rendererget_versionwarningswarn	switch_toset_visibleactivate)r   widthheightcaption	resizablestyle
fullscreenvisibler   
file_dropsr   r   r   contextmodetemplate_configr   gl_infomessages                      r   r0   zBaseWindow.__init__   sw   V 	 &&& 	2m//11G 	2//11F 
	P$&IDR$P$P$P$&IDR$P$P$P$($*  #33ODDFE,   D P+,NOOO ...FL!!## 	4++F33F 	@++B,>??G  }+ 4<** 	"<.DLL!DL, 
	.}&*&94;O&O# 55dE6JJME6& 4&+Vm#}+~-#%>'". .1DKKDK%?hqkG ""$$##Aq)) 	#d!,,..d d292F2F2H2Hd dLSL_L_LaLad dG M'""" 	T"""MMOOOOO	 	s   B
B('B(c                 @    	 |                                   d S #  Y d S xY wN)closer   s    r   __del__zBaseWindow.__del__  s(    	JJLLLLL	DDs    c                 :    d| j         j        | j        | j        fz  S )Nz%s(width=%d, height=%d))r   r   r   r   r   s    r   __repr__zBaseWindow.__repr__  s    (DN,CTZQUQ\+]]]r   c                      t          d          )NrA   rB   r   s    r   r   zBaseWindow._create  s    !*---r   c                      t          d          )aR  Recreate the window with current attributes.

        :Parameters:
            `changes` : list of str
                List of attribute names that were changed since the last
                `_create` or `_recreate`.  For example, ``['fullscreen']``
                is given if the window is to be toggled to or from fullscreen.
        rA   rB   )r   changess     r   	_recreatezBaseWindow._recreate       "*---r   c                      t          d          )a  Swap the OpenGL front and back buffers.

        Call this method on a double-buffered window to update the
        visible display with the back buffer.  The contents of the back buffer
        is undefined after this operation.

        Windows are double-buffered by default.  This method is called
        automatically by `EventLoop` after the :py:meth:`~pyglet.window.Window.on_draw` event.
        rA   rB   r   s    r   flipzBaseWindow.flip       "*---r   c                      t          d          )aT  Make this window the current OpenGL rendering context.

        Only one OpenGL context can be active at a time.  This method sets
        the current window's context to be current.  You should use this
        method in preference to `pyglet.gl.Context.set_current`, as it may
        perform additional initialisation functions.
        rA   rB   r   s    r   r   zBaseWindow.switch_to       "*---r   c                 d   || j         k    r'|	|| j        u r||| j        k    r||| j        k    rdS | j         s2|                                 | _        |                                 | _        |r||j        | j        u sJ || _        || _         | j         r%| 	                    |||          \  | _        | _        n?| j
                                         | j        \  | _        | _        ||| _        ||| _        |                     dg           | j         s| j        r | j        | j          dS dS dS )a  Toggle to or from fullscreen.

        After toggling fullscreen, the GL context should have retained its
        state and objects, however the buffers will need to be cleared and
        redrawn.

        If `width` and `height` are specified and `fullscreen` is True, the
        screen may be switched to a different resolution that most closely
        matches the given size.  If the resolution doesn't match exactly,
        a higher resolution is selected and the window will be centered
        within a black border covering the rest of the screen.

        :Parameters:
            `fullscreen` : bool
                True if the window should be made fullscreen, False if it
                should be windowed.
            `screen` : Screen
                If not None and fullscreen is True, the window is moved to the
                given screen.  The screen must belong to the same display as
                the window.
            `mode` : `ScreenMode`
                The screen will be switched to the given mode.  The mode must
                have been obtained by enumerating `Screen.get_modes`.  If
                None, an appropriate mode will be selected from the given
                `width` and `height`.
            `width` : int
                Optional width of the window.  If unspecified, defaults to the
                previous window size when windowed, or the screen size if
                fullscreen.

                .. versionadded:: 1.2
            `height` : int
                Optional height of the window.  If unspecified, defaults to
                the previous window size when windowed, or the screen size if
                fullscreen.

                .. versionadded:: 1.2
        Nr   )r   r   r   r   get_sizer   get_location_windowed_locationr   r   r   restore_moder   set_location)r   r   r   r   r   r   s         r   set_fullscreenzBaseWindow.set_fullscreen  sm   P $***^v55]et{22^v55F 	:"&--//D&*&7&7&9&9D# 	"&,>T\1111!DL% 		&(,(A(A$v(V(V%DKK$$&&&(,(;%DK #!%~&&& 	8D$; 	8Dt67777	8 	8 	8 	8r   c                    |7| j                             |           || j         j        }|| j         j        }n||n|d}|d}| j                             ||          }|| j                             |           nF| j                                         rt          d||fz            n| j         j        }| j         j        }||fS )Nr   zNo mode matching %dx%d)r   set_moder   r   get_closest_mode	get_modesr   )r   r   r   r   s       r   r   zBaseWindow._set_fullscreen_mode  s    K  &&&})~+&"4}~;//v>>D$$T****&&(( \/0HESY?0Z[[[\ K%E['Ff}r   c                 R     | j         j        ||g|                                 R   dS )a  A default resize event handler.

        This default handler updates the GL viewport to cover the entire
        window and sets the ``GL_PROJECTION`` matrix to be orthogonal in
        window space.  The bottom-left corner is (0, 0) and the top-right
        corner is the width and height of the window in pixels.

        Override this event handler with your own to create another
        projection, for example in perspective.
        N)_projectionrI   get_framebuffer_sizer   r   r   s      r   	on_resizezBaseWindow.on_resize3  s6     	UFIT-F-F-H-HIIIIIIr   c                 d    d| _         ddlm} |j        j        r|                                  dS dS )zDefault on_close handler.Tr   r   N)has_exitr   r   
event_loop
is_runningr   r   r   s     r   on_closezBaseWindow.on_close@  sC    >$ 	JJLLLLL	 	r   c                     |t           j        k    rA|t           j        t           j        z  t           j        z   z  s|                     d           dS dS dS )zDefault on_key_press handler.r	  N)r   ESCAPEMOD_NUMLOCKMOD_CAPSLOCKMOD_SCROLLLOCKdispatch_eventr   symbol	modifierss      r   on_key_presszBaseWindow.on_key_pressG  sf    SZs7:7G8H7:7I8J 6K *K 
+++++  r   c                     ddl m} | j        sdS |j                            |            | j                                         d| _        d| _        |j        r|j                            d|            g | _	        dS )a8  Close the window.

        After closing the window, the GL context will be invalid.  The
        window instance cannot be reused once closed (see also `set_visible`).

        The `pyglet.app.EventLoop.on_window_close` event is dispatched on
        `pyglet.app.event_loop` when this method is called.
        r   r   Non_window_close)
r   r   r   r   removedestroyr   r  r  r   r  s     r   r   zBaseWindow.closeN  s     	} 	F4   > 	CN))*;TBBBr   c                    | j         j        rD| j        r>| j        r8t	          j        t          j                   t	          j                     t	          j                     t	          j	        d| j
        d| j        dd           t	          j        t          j                   t	          j                     t	          j                     | j                             | j        | j                   t	          j        t          j                   t	          j                     t	          j        t          j                   t	          j                     dS dS dS dS )a  Draw the custom mouse cursor.

        If the current mouse cursor has ``drawable`` set, this method
        is called before the buffers are flipped to render it.

        This method always leaves the ``GL_MODELVIEW`` matrix as current,
        regardless of what it was set to previously.  No other GL state
        is affected.

        There is little need to override this method; instead, subclass
        :py:class:`MouseCursor` and provide your own
        :py:meth:`~MouseCursor.draw` method.
        r   rN   r2   N)_mouse_cursorr#   _mouse_visible_mouse_in_windowr   rQ   rR   glPushMatrixrS   rT   r   r   rU   r!   _mouse_x_mouse_yglPopMatrixr   s    r   draw_mouse_cursorzBaseWindow.draw_mouse_cursorb  s%     ) 	d.A 	dF[ 	OB,---OJq$*ab!<<<OBO,,,O##DM4=AAAOB,---NOBO,,,N!	 	 	 	 	 	r   c                     | j         S )zDThe window caption (title).  Read-only.

        :type: str
        )r   r   s    r   r   zBaseWindow.caption       }r   c                     | j         S )zJTrue if the window is resizable.  Read-only.

        :type: bool
        )r   r   s    r   
resizeablezBaseWindow.resizeable  s     r   c                     | j         S )zjThe window style; one of the ``WINDOW_STYLE_*`` constants.
        Read-only.

        :type: int
        )r   r   s    r   r   zBaseWindow.style       {r   c                     | j         S )zUTrue if the window is currently fullscreen.  Read-only.

        :type: bool
        )r   r   s    r   r   zBaseWindow.fullscreen  s     r   c                     | j         S )zRTrue if the window is currently visible.  Read-only.

        :type: bool
        )_visibler   s    r   r   zBaseWindow.visible  r"  r   c                     | j         S )zyTrue if buffer flips are synchronised to the screen's vertical
        retrace.  Read-only.

        :type: bool
        )r   r   s    r   r   zBaseWindow.vsync  r&  r   c                     | j         S )z\The display this window belongs to.  Read-only.

        :type: :py:class:`Display`
        )r   r   s    r   r   zBaseWindow.display  r"  r   c                     | j         S )z`The screen this window is fullscreen in.  Read-only.

        :type: :py:class:`Screen`
        )r   r   s    r   r   zBaseWindow.screen       |r   c                     | j         S )ztA GL config describing the context of this window.  Read-only.

        :type: :py:class:`pyglet.gl.Config`
        )r   r   s    r   r   zBaseWindow.config  r-  r   c                     | j         S )znThe OpenGL context attached to this window.  Read-only.

        :type: :py:class:`pyglet.gl.Context`
        )r   r   s    r   r   zBaseWindow.context  r"  r   c                 6    |                                  d         S )zMThe width of the window, in pixels.  Read-write.

        :type: int
        r   r   r   s    r   r   zBaseWindow.width       }}q!!r   c                 <    |                      || j                   d S r   )set_sizer   )r   	new_widths     r   r   zBaseWindow.width  s    i-----r   c                 6    |                                  d         S )zNThe height of the window, in pixels.  Read-write.

        :type: int
        r2   r1  r   s    r   r   zBaseWindow.height  r2  r   c                 <    |                      | j        |           d S r   )r4  r   )r   
new_heights     r   r   zBaseWindow.height  s    dj*-----r   c                     | j         S )a  The OpenGL window projection. Read-write.

        The default window projection is orthographic (2D), but can
        be changed to a 3D or custom projection. Custom projections
        should subclass :py:class:`pyglet.window.Projection`. There
        are two default projection classes are also provided, which
        are :py:class:`pyglet.window.Projection3D` and
        :py:class:`pyglet.window.Projection3D`.

        :type: :py:class:`pyglet.window.Projection`
        )r   r   s    r   
projectionzBaseWindow.projection  s     r   c                     t          |t                    sJ  |j        | j        | j        g|                                 R   || _        d S r   )
isinstancer?   rI   r   r   r  r   )r   r:  s     r   r:  zBaseWindow.projection  sR    *j11111
t{DLO43L3L3N3NOOOO%r   c                      t          d          )a  Set the window's caption.

        The caption appears in the titlebar of the window, if it has one,
        and in the taskbar on Windows and many X11 window managers.

        :Parameters:
            `caption` : str or unicode
                The caption to set.

        rA   rB   )r   r   s     r   set_captionzBaseWindow.set_caption  s     "*---r   c                      t          d          )av  Set the minimum size of the window.

        Once set, the user will not be able to resize the window smaller
        than the given dimensions.  There is no way to remove the
        minimum size constraint on a window (but you could set it to 0,0).

        The behaviour is undefined if the minimum size is set larger than
        the current size of the window.

        The window size does not include the border or title bar.

        :Parameters:
            `width` : int
                Minimum width of the window, in pixels.
            `height` : int
                Minimum height of the window, in pixels.

        rA   rB   r  s      r   set_minimum_sizezBaseWindow.set_minimum_size  s    & "*---r   c                      t          d          )a  Set the maximum size of the window.

        Once set, the user will not be able to resize the window larger
        than the given dimensions.  There is no way to remove the
        maximum size constraint on a window (but you could set it to a large
        value).

        The behaviour is undefined if the maximum size is set smaller than
        the current size of the window.

        The window size does not include the border or title bar.

        :Parameters:
            `width` : int
                Maximum width of the window, in pixels.
            `height` : int
                Maximum height of the window, in pixels.

        rA   rB   r  s      r   set_maximum_sizezBaseWindow.set_maximum_size'  s    ( "*---r   c                      t          d          )a  Resize the window.

        The behaviour is undefined if the window is not resizable, or if
        it is currently fullscreen.

        The window size does not include the border or title bar.

        :Parameters:
            `width` : int
                New width of the window, in pixels.
            `height` : int
                New height of the window, in pixels.

        rA   rB   r  s      r   r4  zBaseWindow.set_size=       "*---r   c                 F    |                                  d         | j        z  S )aI  Return the framebuffer/window size ratio.

        Some platforms and/or window systems support subpixel scaling,
        making the framebuffer size larger than the window size.
        Retina screens on OS X and Gnome on Linux are some examples.

        On a Retina systems the returned ratio would usually be 2.0 as a
        window of size 500 x 500 would have a frambuffer of 1000 x 1000.
        Fractional values between 1.0 and 2.0, as well as values above
        2.0 may also be encountered.

        :rtype: float
        :return: The framebuffer/window size ratio
        r   )r  r   r   s    r   get_pixel_ratiozBaseWindow.get_pixel_ratioN  s"     ((**1-
::r   c                      t          d          )zReturn the current size of the window.

        The window size does not include the border or title bar.

        :rtype: (int, int)
        :return: The width and height of the window, in pixels.
        rA   rB   r   s    r   r   zBaseWindow.get_size_  r   r   c                 *    |                                  S )a?  Return the size in actual pixels of the Window framebuffer.

        When using HiDPI screens, the size of the Window's framebuffer
        can be higher than that of the Window size requested. If you
        are performing operations that require knowing the actual number
        of pixels in the window, this method should be used instead of
        :py:func:`Window.get_size()`. For example, setting the Window
        projection or setting the glViewport size.

        :rtype: (int, int)
        :return: The width and height of the Window viewport, in pixels.
        r1  r   s    r   r  zBaseWindow.get_framebuffer_sizei  s     }}r   c                      t          d          )ae  Set the position of the window.

        :Parameters:
            `x` : int
                Distance of the left edge of the window from the left edge
                of the virtual desktop, in pixels.
            `y` : int
                Distance of the top edge of the window from the top edge of
                the virtual desktop, in pixels.

        rA   rB   r   s      r   r   zBaseWindow.set_location{  s     "*---r   c                      t          d          )zReturn the current position of the window.

        :rtype: (int, int)
        :return: The distances of the left and top edges from their respective
            edges on the virtual desktop, in pixels.
        rA   rB   r   s    r   r   zBaseWindow.get_location       "*---r   c                      t          d          )ab  Attempt to restore keyboard focus to the window.

        Depending on the window manager or operating system, this may not
        be successful.  For example, on Windows XP an application is not
        allowed to "steal" focus from another application.  Instead, the
        window's taskbar icon will flash, indicating it requires attention.
        rA   rB   r   s    r   r   zBaseWindow.activate  r   r   c                      t          d          )zShow or hide the window.

        :Parameters:
            `visible` : bool
                If True, the window will be shown; otherwise it will be
                hidden.

        rA   rB   r   r   s     r   r   zBaseWindow.set_visible  r   r   c                      t          d          )zMinimize the window.
        rA   rB   r   s    r   minimizezBaseWindow.minimize  s     "*---r   c                      t          d          )zMaximize the window.

        The behaviour of this method is somewhat dependent on the user's
        display setup.  On a multi-monitor system, the window may maximize
        to either a single screen or the entire virtual desktop.
        rA   rB   r   s    r   maximizezBaseWindow.maximize  rK  r   c                      t          d          )ag  Enable or disable vertical sync control.

        When enabled, this option ensures flips from the back to the front
        buffer are performed only during the vertical retrace period of the
        primary display.  This can prevent "tearing" or flickering when
        the buffer is updated in the middle of a video scan.

        Note that LCD monitors have an analogous time in which they are not
        reading from the video buffer; while it does not correspond to
        a vertical retrace it has the same effect.

        Also note that with multi-monitor systems the secondary monitor
        cannot be synchronised to, so tearing and flicker cannot be avoided
        when the window is positioned outside of the primary display.

        :Parameters:
            `vsync` : bool
                If True, vsync is enabled, otherwise it is disabled.

        rA   rB   )r   r   s     r   	set_vsynczBaseWindow.set_vsync  s    * "*---r   c                 <    || _         |                                  dS )aT  Show or hide the mouse cursor.

        The mouse cursor will only be hidden while it is positioned within
        this window.  Mouse events will still be processed as usual.

        :Parameters:
            `visible` : bool
                If True, the mouse cursor will be visible, otherwise it
                will be hidden.

        N)r  set_mouse_platform_visiblerN  s     r   set_mouse_visiblezBaseWindow.set_mouse_visible  s$     &'')))))r   c                     t                      )a  Set the platform-drawn mouse cursor visibility.  This is called
        automatically after changing the mouse cursor or exclusive mode.

        Applications should not normally need to call this method, see
        `set_mouse_visible` instead.

        :Parameters:
            `platform_visible` : bool or None
                If None, sets platform visibility to the required visibility
                for the current exclusive mode and cursor type.  Otherwise,
                a bool value will override and force a visibility.

        rB   )r   platform_visibles     r   rV  z%BaseWindow.set_mouse_platform_visible  s     "###r   c                 \    |t                      }|| _        |                                  dS )a  Change the appearance of the mouse cursor.

        The appearance of the mouse cursor is only changed while it is
        within this window.

        :Parameters:
            `cursor` : `MouseCursor`
                The cursor to set, or None to restore the default cursor.

        N)r&   r  rV  )r   cursors     r   set_mouse_cursorzBaseWindow.set_mouse_cursor  s4     >'))F#'')))))r   c                      t          d          )aJ  Hide the mouse cursor and direct all mouse events to this
        window.

        When enabled, this feature prevents the mouse leaving the window.  It
        is useful for certain styles of games that require complete control of
        the mouse.  The position of the mouse as reported in subsequent events
        is meaningless when exclusive mouse is enabled; you should only use
        the relative motion parameters ``dx`` and ``dy``.

        :Parameters:
            `exclusive` : bool
                If True, exclusive mouse is enabled, otherwise it is disabled.

        rA   rB   r   	exclusives     r   set_exclusive_mousezBaseWindow.set_exclusive_mouse  rD  r   c                      t          d          )a  Prevent the user from switching away from this window using
        keyboard accelerators.

        When enabled, this feature disables certain operating-system specific
        key combinations such as Alt+Tab (Command+Tab on OS X).  This can be
        useful in certain kiosk applications, it should be avoided in general
        applications or games.

        :Parameters:
            `exclusive` : bool
                If True, exclusive keyboard is enabled, otherwise it is
                disabled.

        rA   rB   r^  s     r   set_exclusive_keyboardz!BaseWindow.set_exclusive_keyboard  rD  r   c                     t                      )a  Obtain a system mouse cursor.

        Use `set_mouse_cursor` to make the cursor returned by this method
        active.  The names accepted by this method are the ``CURSOR_*``
        constants defined on this class.

        :Parameters:
            `name` : str
                Name describing the mouse cursor to return.  For example,
                ``CURSOR_WAIT``, ``CURSOR_HELP``, etc.

        :rtype: `MouseCursor`
        :return: A mouse cursor which can be used with `set_mouse_cursor`.
        rB   )r   r~   s     r   get_system_mouse_cursorz"BaseWindow.get_system_mouse_cursor  s     "###r   c                     dS )a  Set the window icon.

        If multiple images are provided, one with an appropriate size
        will be selected (if the correct size is not provided, the image
        will be scaled).

        Useful sizes to provide are 16x16, 32x32, 64x64 (Mac only) and
        128x128 (Mac only).

        :Parameters:
            `images` : sequence of `pyglet.image.AbstractImage`
                List of images to use for the window icon.

        Nr   )r   imagess     r   set_iconzBaseWindow.set_icon.  r"   r   c                 \    t          j        t           j        t           j        z             dS )zClear the window.

        This is a convenience method for clearing the color and depth
        buffer.  The window must be the active context (see `switch_to`).
        N)r   glClearGL_COLOR_BUFFER_BITGL_DEPTH_BUFFER_BITr   s    r   clearzBaseWindow.clear?  s%     	
2)B,BBCCCCCr   c                     | j         r| j        r!t          j        | g|R  dk    r	d| _        d S d S | j                            |           d S )NFT)_enable_event_queue_allow_dispatch_eventr   r  _legacy_invalidr   rm   )r   argss     r   r  zBaseWindow.dispatch_eventG  sk    ' 	+4+E 	+-d:T:::eCC'+$$$ DC $$T*****r   c                      t          d          )aX  Poll the operating system event queue for new events and call
        attached event handlers.

        This method is provided for legacy applications targeting pyglet 1.0,
        and advanced applications that must integrate their event loop
        into another framework.

        Typical applications should use `pyglet.app.run`.
        rA   rB   r   s    r   dispatch_eventszBaseWindow.dispatch_eventsN  r   r   c                     dS )a/  A key on the keyboard was pressed (and held down).

            In pyglet 1.0 the default handler sets `has_exit` to ``True`` if
            the ``ESC`` key is pressed.

            In pyglet 1.1 the default handler dispatches the :py:meth:`~pyglet.window.Window.on_close`
            event if the ``ESC`` key is pressed.

            :Parameters:
                `symbol` : int
                    The key symbol pressed.
                `modifiers` : int
                    Bitwise combination of the key modifiers active.

            :event:
            Nr   r  s      r   r  zBaseWindow.on_key_press]        r   c                     dS )a  A key on the keyboard was released.

            :Parameters:
                `symbol` : int
                    The key symbol pressed.
                `modifiers` : int
                    Bitwise combination of the key modifiers active.

            :event:
            Nr   r  s      r   on_key_releasezBaseWindow.on_key_releaseo  ru  r   c                     dS )a  The user input some text.

            Typically this is called after :py:meth:`~pyglet.window.Window.on_key_press` and before
            :py:meth:`~pyglet.window.Window.on_key_release`, but may also be called multiple times if the key
            is held down (key repeating); or called without key presses if
            another input method was used (e.g., a pen input).

            You should always use this method for interpreting text, as the
            key symbols often have complex mappings to their unicode
            representation which this event takes care of.

            :Parameters:
                `text` : unicode
                    The text entered by the user.

            :event:
            Nr   )r   r   s     r   on_textzBaseWindow.on_text{  ru  r   c                     dS )a  The user moved the text input cursor.

            Typically this is called after :py:meth:`~pyglet.window.Window.on_key_press` and before
            :py:meth:`~pyglet.window.Window.on_key_release`, but may also be called multiple times if the key
            is help down (key repeating).

            You should always use this method for moving the text input cursor
            (caret), as different platforms have different default keyboard
            mappings, and key repeats are handled correctly.

            The values that `motion` can take are defined in
            :py:mod:`pyglet.window.key`:

            * MOTION_UP
            * MOTION_RIGHT
            * MOTION_DOWN
            * MOTION_LEFT
            * MOTION_NEXT_WORD
            * MOTION_PREVIOUS_WORD
            * MOTION_BEGINNING_OF_LINE
            * MOTION_END_OF_LINE
            * MOTION_NEXT_PAGE
            * MOTION_PREVIOUS_PAGE
            * MOTION_BEGINNING_OF_FILE
            * MOTION_END_OF_FILE
            * MOTION_BACKSPACE
            * MOTION_DELETE

            :Parameters:
                `motion` : int
                    The direction of motion; see remarks.

            :event:
            Nr   r   motions     r   on_text_motionzBaseWindow.on_text_motion  ru  r   c                     dS )a  The user moved the text input cursor while extending the
            selection.

            Typically this is called after :py:meth:`~pyglet.window.Window.on_key_press` and before
            :py:meth:`~pyglet.window.Window.on_key_release`, but may also be called multiple times if the key
            is help down (key repeating).

            You should always use this method for responding to text selection
            events rather than the raw :py:meth:`~pyglet.window.Window.on_key_press`, as different platforms
            have different default keyboard mappings, and key repeats are
            handled correctly.

            The values that `motion` can take are defined in :py:mod:`pyglet.window.key`:

            * MOTION_UP
            * MOTION_RIGHT
            * MOTION_DOWN
            * MOTION_LEFT
            * MOTION_NEXT_WORD
            * MOTION_PREVIOUS_WORD
            * MOTION_BEGINNING_OF_LINE
            * MOTION_END_OF_LINE
            * MOTION_NEXT_PAGE
            * MOTION_PREVIOUS_PAGE
            * MOTION_BEGINNING_OF_FILE
            * MOTION_END_OF_FILE

            :Parameters:
                `motion` : int
                    The direction of selection motion; see remarks.

            :event:
            Nr   r{  s     r   on_text_motion_selectz BaseWindow.on_text_motion_select  ru  r   c                     dS )a  The mouse was moved with no buttons held down.

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.
                `dx` : int
                    Relative X position from the previous mouse position.
                `dy` : int
                    Relative Y position from the previous mouse position.

            :event:
            Nr   )r   r   r    dxdys        r   on_mouse_motionzBaseWindow.on_mouse_motion  ru  r   c                     dS )a  The mouse was moved with one or more mouse buttons pressed.

            This event will continue to be fired even if the mouse leaves
            the window, so long as the drag buttons are continuously held down.

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.
                `dx` : int
                    Relative X position from the previous mouse position.
                `dy` : int
                    Relative Y position from the previous mouse position.
                `buttons` : int
                    Bitwise combination of the mouse buttons currently pressed.
                `modifiers` : int
                    Bitwise combination of any keyboard modifiers currently
                    active.

            :event:
            Nr   )r   r   r    r  r  buttonsr  s          r   on_mouse_dragzBaseWindow.on_mouse_drag  ru  r   c                     dS )a  A mouse button was pressed (and held down).

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.
                `button` : int
                    The mouse button that was pressed.
                `modifiers` : int
                    Bitwise combination of any keyboard modifiers currently
                    active.

            :event:
            Nr   r   r   r    buttonr  s        r   on_mouse_presszBaseWindow.on_mouse_press  ru  r   c                     dS )a  A mouse button was released.

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.
                `button` : int
                    The mouse button that was released.
                `modifiers` : int
                    Bitwise combination of any keyboard modifiers currently
                    active.

            :event:
            Nr   r  s        r   on_mouse_releasezBaseWindow.on_mouse_release  ru  r   c                     dS )a  The mouse wheel was scrolled.

            Note that most mice have only a vertical scroll wheel, so
            `scroll_x` is usually 0.  An exception to this is the Apple Mighty
            Mouse, which has a mouse ball in place of the wheel which allows
            both `scroll_x` and `scroll_y` movement.

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.
                `scroll_x` : float
                    Amount of movement on the horizontal axis.
                `scroll_y` : float
                    Amount of movement on the vertical axis.

            :event:
            Nr   )r   r   r    scroll_xscroll_ys        r   on_mouse_scrollzBaseWindow.on_mouse_scroll  ru  r   c                     dS )a  The user attempted to close the window.

            This event can be triggered by clicking on the "X" control box in
            the window title bar, or by some other platform-dependent manner.

            The default handler sets `has_exit` to ``True``.  In pyglet 1.1, if
            `pyglet.app.event_loop` is being used, `close` is also called,
            closing the window immediately.

            :event:
            Nr   r   s    r   r	  zBaseWindow.on_close4  ru  r   c                     dS )a  The mouse was moved into the window.

            This event will not be triggered if the mouse is currently being
            dragged.

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.

            :event:
            Nr   r   s      r   on_mouse_enterzBaseWindow.on_mouse_enterA  ru  r   c                     dS )a  The mouse was moved outside of the window.

            This event will not be triggered if the mouse is currently being
            dragged.  Note that the coordinates of the mouse pointer will be
            outside of the window rectangle.

            :Parameters:
                `x` : int
                    Distance in pixels from the left edge of the window.
                `y` : int
                    Distance in pixels from the bottom edge of the window.

            :event:
            Nr   r   s      r   on_mouse_leavezBaseWindow.on_mouse_leaveP  ru  r   c                     dS )a/  A portion of the window needs to be redrawn.

            This event is triggered when the window first appears, and any time
            the contents of the window is invalidated due to another window
            obscuring it.

            There is no way to determine which portion of the window needs
            redrawing.  Note that the use of this method is becoming
            increasingly uncommon, as newer window managers composite windows
            automatically and keep a backing store of the window contents.

            :event:
            Nr   r   s    r   	on_exposezBaseWindow.on_expose`  ru  r   c                     dS )a  The window was resized.

            The window will have the GL context when this event is dispatched;
            there is no need to call `switch_to` in this handler.

            :Parameters:
                `width` : int
                    The new width of the window, in pixels.
                `height` : int
                    The new height of the window, in pixels.

            :event:
            Nr   r  s      r   r  zBaseWindow.on_resizeo  ru  r   c                     dS )a  The window was moved.

            :Parameters:
                `x` : int
                    Distance from the left edge of the screen to the left edge
                    of the window.
                `y` : int
                    Distance from the top edge of the screen to the top edge of
                    the window.  Note that this is one of few methods in pyglet
                    which use a Y-down coordinate system.

            :event:
            Nr   r   s      r   on_movezBaseWindow.on_move~  ru  r   c                     dS )a  The window was activated.

            This event can be triggered by clicking on the title bar, bringing
            it to the foreground; or by some platform-specific method.

            When a window is "active" it has the keyboard focus.

            :event:
            Nr   r   s    r   on_activatezBaseWindow.on_activate  ru  r   c                     dS )zThe window was deactivated.

            This event can be triggered by clicking on another application
            window.  When a window is deactivated it no longer has the
            keyboard focus.

            :event:
            Nr   r   s    r   on_deactivatezBaseWindow.on_deactivate  ru  r   c                     dS )zThe window was shown.

            This event is triggered when a window is restored after being
            minimised, or after being displayed for the first time.

            :event:
            Nr   r   s    r   on_showzBaseWindow.on_show  ru  r   c                     dS )zThe window was hidden.

            This event is triggered when a window is minimised or (on Mac OS X)
            hidden by the user.

            :event:
            Nr   r   s    r   on_hidezBaseWindow.on_hide  ru  r   c                     dS )a  The window's GL context was lost.

            When the context is lost no more GL methods can be called until it
            is recreated.  This is a rare event, triggered perhaps by the user
            switching to an incompatible video mode.  When it occurs, an
            application will need to reload all objects (display lists, texture
            objects, shaders) as well as restore the GL state.

            :event:
            Nr   r   s    r   on_context_lostzBaseWindow.on_context_lost  ru  r   c                     dS )a#  The state of the window's GL context was lost.

            pyglet may sometimes need to recreate the window's GL context if
            the window is moved to another video device, or between fullscreen
            or windowed mode.  In this case it will try to share the objects
            (display lists, texture objects, shaders) between the old and new
            contexts.  If this is possible, only the current state of the GL
            context is lost, and the application should simply restore state.

            :event:
            Nr   r   s    r   on_context_state_lostz BaseWindow.on_context_state_lost  ru  r   c                     dS )zFile(s) were dropped into the window, will return the position of the cursor and
            a list of paths to the files that were dropped.

            .. versionadded:: 1.5.1

            :event:
            Nr   )r   r   r    pathss       r   on_file_dropzBaseWindow.on_file_drop  ru  r   c                     dS )a  The window contents must be redrawn.

            The `EventLoop` will dispatch this event when the window
            should be redrawn.  This will happen during idle time after
            any window events and after any scheduled functions were called.

            The window will already have the GL context, so there is no
            need to call `switch_to`.  The window's `flip` method will
            be called after this event, so your event handler should not.

            You should make no assumptions about the window contents when
            this event is triggered; a resize or expose event may have
            invalidated the framebuffer since the last time it was drawn.

            .. versionadded:: 1.1

            :event:
            Nr   r   s    r   on_drawzBaseWindow.on_draw  ru  r   )TNNNN)Tr   )r   r   r   r   rI   rx   WINDOW_STYLE_DEFAULTWINDOW_STYLE_DIALOGWINDOW_STYLE_TOOLWINDOW_STYLE_BORDERLESSWINDOW_STYLE_TRANSPARENTWINDOW_STYLE_OVERLAYCURSOR_DEFAULTCURSOR_CROSSHAIRCURSOR_HANDCURSOR_HELP	CURSOR_NOCURSOR_SIZECURSOR_SIZE_UPCURSOR_SIZE_UP_RIGHTCURSOR_SIZE_RIGHTCURSOR_SIZE_DOWN_RIGHTCURSOR_SIZE_DOWNCURSOR_SIZE_DOWN_LEFTCURSOR_SIZE_LEFTCURSOR_SIZE_UP_LEFTCURSOR_SIZE_UP_DOWNCURSOR_SIZE_LEFT_RIGHTCURSOR_TEXTCURSOR_WAITCURSOR_WAIT_ARROWr  invalidrp  r   r   r   r   r   r   r)  r   r   r   r   r   rL   r   r   r   r&   r  r  r  r  _mouse_exclusiver  r   rn  ro  r   r   r0   r   r   r   r   r   r   r   r   r  r	  r  r   r   propertyr   r$  r   r   r   r   r   r   r   r   r   setterr   r:  r>  r@  rB  r4  rF  r   r  get_viewport_sizer   r   r   r   rP  rR  rT  rW  rV  r\  r`  rb  rd  rg  rl  r  rs  _is_pyglet_doc_runrw  ry  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r   j  so        0  CEE  "*,$ N"KKIK N + % / # - # )(.KK$ H G
 O FGHJ!FKHFKGGH,..K N '&((MHHNL! NO  +!!a a a aF  ^ ^ ^. . .	. 	. 	.
. 
. 
.. . . AE*.G8 G8 G8 G8R  .J J J  , , ,  (     F   X   X   X     X    X   X   X   X   X   X " " X" \. . \. " " X" ]. . ].     X  & & &
. . .. . .*. . .,. . ."; ; ;". . .    -. . .. . .. . .	. 	. 	. 	.. . .
. . .. . ..* * * *$ $ $ $ * * * * . . . .". . . ."$ $ $"  "D D D+ + +
. 
. 
.  L	 	 	$
	 
	 
		 	 	&"	 "	 "	H!	 !	 !	F	 	 	 	 	 	0	 	 	"	 	 	"	 	 	*	 	 		 	 		 	 	 	 	 		 	 		 	 			 		 			 	 		 	 		 	 	
	 
	 
		 	 		 	 		 	 	 	 	uL Lr   r   r  rw  ry  r}  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r  r  r  r  r  c                   4    e Zd ZdZdZd Zd Zd Zd Zd Z	dS )	
FPSDisplaya  Display of a window's framerate.

    This is a convenience class to aid in profiling and debugging.  Typical
    usage is to create an `FPSDisplay` for each window, and draw the display
    at the end of the windows' :py:meth:`~pyglet.window.Window.on_draw` event handler::

        window = pyglet.window.Window()
        fps_display = FPSDisplay(window)

        @window.event
        def on_draw():
            # ... perform ordinary window drawing operations ...

            fps_display.draw()

    The style and position of the display can be modified via the :py:func:`~pyglet.text.Label`
    attribute.  Different text can be substituted by overriding the
    `set_fps` method.  The display can be set to update more or less often
    by setting the `update_period` attribute. Note: setting the `update_period`
    to a value smaller than your Window refresh rate will cause inaccurate readings.

    :Ivariables:
        `label` : Label
            The text label displaying the framerate.

    g      ?c                     ddl m } ddlm}  |dddddd	          | _        || _        |j        | _        | j        |_        d
| _          |            | _        d| _	        d S )Nr   time)Label 
   r   T)   r  r  r  )r   r    	font_sizeboldcolorg        )
r  pyglet.textr  labelwindowr   _window_flip
_hook_flip	last_timecount)r   r  r  r  s       r   r0   zFPSDisplay.__init__&  s    %%%%%%U2r%'d!57 7 7
 "Ko	


r   c                 $   ddl m }  |            }| xj        dz  c_        | xj         || j        z
  z  c_         || _        | j         | j        k    r@|                     | j        | j         z             | xj         | j        z  c_         d| _        dS dS )zRecords a new data point at the current time.  This method
        is called automatically when the window buffer is flipped.
        r   r  r2   N)r  r  r  update_periodset_fps)r   r  ts      r   ry   zFPSDisplay.update5  s     	DFF

a

		Q''		9***LLdi/000II++IIDJJJ +*r   c                 $    d|z  | j         _        dS )zSet the label text for the given FPS estimation.

        Called by `update` every `update_period` seconds.

        :Parameters:
            `fps` : float
                Estimated framerate of the window.

        z%.2fN)r  r   )r   fpss     r   r  zFPSDisplay.set_fpsD  s     !3,
r   c                 *   t          j        t           j                   t          j                     t          j                     t          j        t           j                   t          j                     t          j                     t          j        d| j        j        d| j        j	        dd           | j
                                         t          j                     t          j        t           j                   t          j                     dS )zDraw the label.

        The OpenGL state is assumed to be at default values, except
        that the MODELVIEW and PROJECTION matrices are ignored.  At
        the return of this method the matrix mode will be MODELVIEW.
        r   rN   r2   N)r   rQ   rU   r  rS   rR   rT   r  r   r   r  r!   r  r   s    r   r!   zFPSDisplay.drawP  s     	(((


()))



1dk'DK,>AFFF


(((
r   c                 V    |                                   |                                  d S r   )ry   r  r   s    r   r  zFPSDisplay._hook_flipg  s'    r   N)
r   r   r   r   r  r0   ry   r  r!   r  r   r   r   r  r    sp         < M    
' 
' 
'  .    r   r  Windowheadless)HeadlessWindowdarwin)CocoaWindow)win32cygwin)Win32Window)
XlibWindow)4r   r   ra   r   r   pyglet.window.keypyglet.window.mousepyglet.window.eventr   pyglet.eventr   pyglet.windowr   pyglet.utilr   rl   r   r  	Exceptionr	   r   r   r   r   r   r&   r(   r?   rL   rW   rq   rt   typerv   r   register_event_typer  r  r   r   pyglet.window.headlessr  compat_platformpyglet.window.cocoar  pyglet.window.win32r  pyglet.window.xlibr  modulesr  _create_shadow_windowr   r   r   <module>r     s  HX Xt 


                      ( ( ( ( ( (       & & & & & & WS"566P3;P 	 	 	 	 	i 	 	 	
	 	 	 	 	_ 	 	 	
	 	 	 	 	O 	 	 		 	 	 	 	 	 	 		 	 	 	 	? 	 	 	
       4       + + + + +{ + + +\. . . . . . . .,) ) ) ) ): ) ) )) ) ) ) ): ) ) )@  6  
A A A A At A A A ~ ~ ~ ~ ~ 0/BB ~ ~ ~B,   ~ . . . 
  / 0 0 0 
  y ) ) ) 
  / 0 0 0 
  6 7 7 7 
  0 1 1 1 
   / / / 
  / 0 0 0 
  1 2 2 2 
  0 1 1 1 
  / 0 0 0 
  / 0 0 0 
  z * * * 
  { + + + 
  { + + + 
  y ) ) ) 
  } - - - 
   / / / 
  y ) ) ) 
  y ) ) ) 
  0 1 1 1 
  6 7 7 7 
  ~ . . . 
  y ) ) )d d d d d d d dN  <FFO
 ~j! <CCCCCCC		8	+	+=======		#6	6	6=======;;;;;;  K)FMB r   