B � fk�@spdZddlZddlZddlZGdd�de�ZGdd�d�Zdd�Zd d �Ze d krldd l m Z e d ddd�dS)z Zoom a window to maximum height.�Nc@s eZdZdS)�WmInfoGatheringErrorN)�__name__� __module__� __qualname__�rr�7/opt/alt/python37/lib64/python3.7/idlelib/zoomheight.pyrsrc@s2eZdZiZdd�Zd dd�Zdd�Zdd �ZdS) � ZoomHeightcCs||_|jj|_dS)N)�editwin�top)�selfr rrr�__init__szZoomHeight.__init__NcCsD|��}|dkr|j��n$|r$dnd}|jjdd|�d�d�dS)NZRestoreZZoomZoptionsz* Heightz Height)Zmenu�indexZlabel�break)� zoom_heightr Zbellr Zupdate_menu_label)r Zevent�zoomedZ menu_statusrrr�zoom_height_events   zZoomHeight.zoom_height_eventcCs||j}t|�\}}}}|��dkr&dSy|��\}}Wntk rJdSX||krjt|||||f�dS|�d�dSdS)N�normalT�F)r �get_window_geometry�wm_state�get_max_height_and_y_coordr�set_window_geometry� wm_geometry)r r �widthZheight�x�y� maxheight�maxyrrrr!s  zZoomHeight.zoom_heightc Cs|j}|��|��f}||jkr�|��}y|�d�Wntjk rTtd��YnX|��t |�\}}}}t j dkr|d}|� �}|�d�|��t |�} | dd�|f} t || �|��|� �} ||| 7}||f|j|<t || �|�|�|j|S)Nrz_Failed getting geometry of maximized windows, because the "zoomed" window state is unavailable.Zwin32rr�)r Zwinfo_screenwidthZwinfo_screenheight�_max_height_and_y_coordsr�tkinterZTclErrorr�updater�sys�platformZ winfo_rootyr) r r Zscreen_dimensionsZ orig_stateZmaxwidthrZmaxxrZmaxrootyZ orig_geomZ max_y_geomZmax_y_geom_rootyrrrr<s6         z%ZoomHeight.get_max_height_and_y_coord)N)rrrrr rrrrrrrr s  rcCs&|��}t�d|�}ttt|����S)Nz(\d+)x(\d+)\+(-?\d+)\+(-?\d+))r�re�match�tuple�map�int�groups)r Zgeom�mrrrrns rcCs|�dj|��dS)Nz{:d}x{:d}+{:d}+{:d})r�format)r Zgeometryrrrrtsr�__main__)�mainz!idlelib.idle_test.test_zoomheight�F)� verbosity�exit) �__doc__r$r"r � ExceptionrrrrrZunittestr-rrrr�sb