a Z^kc@spdZddlZddlZddlZGdddeZGdddZddZd d Ze d krldd l m Z e d ddddS)z Zoom a window to maximum height.Nc@s eZdZdS)WmInfoGatheringErrorN)__name__ __module__ __qualname__rr*/usr/lib64/python3.9/idlelib/zoomheight.pyrsrc@s2eZdZiZddZd ddZddZdd ZdS) ZoomHeightcCs||_|jj|_dSN)editwintop)selfr rrr__init__szZoomHeight.__init__NcCsD|}|dur|jn$|r$dnd}|jjdd|dddS)NZRestoreZZoomZoptionsz* Heightz Height)ZmenuZindexZlabelZbreak) zoom_heightr Zbellr Zupdate_menu_label)r ZeventzoomedZ menu_statusrrrzoom_height_events   zZoomHeight.zoom_height_eventcCs||j}t|\}}}}|dkr&dSz|\}}WntyJYdS0||krjt|||||fdS|ddSdS)NnormalTZF)r get_window_geometrywm_stateget_max_height_and_y_coordrset_window_geometry wm_geometry)r r ZwidthZheightZxZy maxheightmaxyrrrr !s   zZoomHeight.zoom_heightc Cs|j}||f}||jvr|}z|dWntjyRtdYn0|t |\}}}}t j dkrzd}| }|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.Zwin32rri)r Zwinfo_screenwidthZwinfo_screenheight_max_height_and_y_coordsrtkinterZTclErrorrZupdatersysZplatformZ winfo_rootyr) r r Zscreen_dimensionsZ orig_stateZmaxwidthrZmaxxrZmaxrootyZ orig_geomZ max_y_geomZmax_y_geom_rootyrrrr<s:        z%ZoomHeight.get_max_height_and_y_coordr)rrrrr rr rrrrrr s  rcCs&|}td|}ttt|S)Nz(\d+)x(\d+)\+(-?\d+)\+(-?\d+))rreZmatchZtupleZmapZintZgroups)r ZgeomZmrrrrns rcCs|dj|dS)Nz{:d}x{:d}+{:d}+{:d})rZformat)r ZgeometryrrrrtsrZ__main__)mainz!idlelib.idle_test.test_zoomheightiF)Z verbosityZexit) Z__doc__rrrZ ExceptionrrrrrZunittestrrrrrZsb