a
    §ˆcá  ã                   @   s¦   d Z ddlZddlmZmZmZmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ ddlmZmZ d	d
lmZ d	dlmZ eeƒG dd„ deeƒƒZdS )z$ Enthought pyface package component
é    N)ÚInstanceÚListÚStrÚobserveÚprovides)ÚMenuBarManagerÚStatusBarManager)ÚToolBarManager)ÚIApplicationWindowÚMApplicationWindow)ÚImage)ÚauiÚPyfaceAuiManageré   )ÚImageResource)ÚWindowc                       sâ   e Zd ZdZeƒ ZeeƒZee	ƒZ
eeƒZeeƒZedƒZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z‡ fdd„Zdd„ Z‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Z e!d#ƒd$d%„ ƒZ"d&d'„ Z#‡  Z$S )(ÚApplicationWindowz‡ The toolkit specific implementation of an ApplicationWindow.  See the
    IApplicationWindow interface for the API documentation.
    ZPyfacec                 C   s   t j|ddd�}| d¡ |S )Néÿÿÿÿr   )ÚnameZblue)ÚwxZPanelÚSetBackgroundColour)ÚselfÚparentZpanel© r   úb/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/ui/wx/application_window.pyÚ_create_contentsB   s    
z"ApplicationWindow._create_contentsc                 C   s&   | j d ur"| j  |¡}| j |¡ d S ©N)Úmenu_bar_managerZcreate_menu_barÚcontrolZ
SetMenuBar)r   r   Zmenu_barr   r   r   Ú_create_menu_barG   s    
z"ApplicationWindow._create_menu_barc                 C   s&   | j d ur"| j  |¡}| j |¡ d S r   )Ústatus_bar_managerZcreate_status_barr   ÚSetStatusBar)r   r   Z
status_barr   r   r   Ú_create_status_barL   s    
z$ApplicationWindow._create_status_barc                 C   sH   |   ¡ }t|ƒdkrDt|ƒD ]}|j|dd�}|  |¡ q| j ¡  d S )Nr   T)r   )Ú_get_tool_bar_managersÚlenÚreversedZcreate_tool_barÚ_add_toolbar_to_aui_managerÚ_aui_managerÚUpdate)r   r   Útool_bar_managersÚtool_bar_managerÚtool_barr   r   r   Ú_create_tool_barQ   s    z"ApplicationWindow._create_tool_barc                 C   s8   | j d u rtdƒ}n| j }| jd ur4| j | ¡ ¡ d S )Nzapplication.ico)Úiconr   r   ZSetIconZcreate_icon)r   r-   r   r   r   Ú_set_window_iconY   s
    


z"ApplicationWindow._set_window_iconc                 C   s   dS )z Trait initialiser. )i   iX  r   ©r   r   r   r   Ú_size_defaultf   s    zApplicationWindow._size_defaultc                    sf   t ƒ  ¡  tƒ | _| j | j¡ | j| j_|  | j¡}| j |t 	¡  
¡ ¡ |  | j¡ | j ¡  d S r   )ÚsuperÚ_creater   r'   ZSetManagedWindowr   r   ÚAddPaner   ÚAuiPaneInfoZ
CenterPaneZ_create_trim_widgetsr(   )r   Úcontents©Ú	__class__r   r   r2   n   s    

zApplicationWindow._createc                 C   sF   t jt jB t jB }t j|d| j|| j| jd�}| ¡ }| 	|j
¡ |S )Nr   )ÚstyleÚsizeÚpos)r   ZDEFAULT_FRAME_STYLEZFRAME_NO_WINDOW_MENUZCLIP_CHILDRENZFrameÚtitler9   ÚpositionZGetDefaultAttributesr   ZcolBg)r   r   r8   r   Úattrr   r   r   Ú_create_control‚   s    ÿú
z!ApplicationWindow._create_controlc                    s   | j r| j ¡  tƒ  ¡  d S r   )r   r'   ZUnInitr1   Údestroyr/   r6   r   r   r?   —   s    
zApplicationWindow.destroyc                 C   s   |   |¡}| j ||¡ dS )z# Add a toolbar to the AUI manager. N)Ú_get_tool_bar_pane_infor'   r3   ©r   r+   Úinfor   r   r   r&       s    
z-ApplicationWindow._add_toolbar_to_aui_managerc                 C   sL   t  ¡ }| |jj¡ | d¡ | |jj¡ | d¡ | 	¡  | 
¡  |S )NF)r   r4   ZCaptionr*   r   ZLeftDockableÚNameÚidZRightDockableZToolbarPaneZToprA   r   r   r   r@   ¦   s    

z)ApplicationWindow._get_tool_bar_pane_infoc                 C   s   | j dur| j g}n| j}|S )z8 Return all tool bar managers specified for the window. N)r*   r)   )r   r)   r   r   r   r#   ±   s    

z(ApplicationWindow._get_tool_bar_managersc                 C   s   dS )z Enable/Disablea tool bar. Nr   )r   r+   Zenabledr   r   r   Ú_wx_enable_tool_bar½   s    z%ApplicationWindow._wx_enable_tool_barc                 C   sj   | j  |jj¡}|r| ¡  n>|j d¡ | j  |j¡ |  |j¡}| ¡  | j  	|j|¡ | j  
¡  dS )z Hide/Show a tool bar. FN)r'   ZGetPaner*   rD   ZShowÚwindowZ
DetachPaner@   ZHider3   r(   )r   r+   ZvisibleZpanerB   r   r   r   Ú_wx_show_tool_barÂ   s    

z#ApplicationWindow._wx_show_tool_barc                 C   s   | j d ur|  | j ¡ d S r   )r   r   r/   r   r   r   Ú_menu_bar_manager_changedÙ   s    
z+ApplicationWindow._menu_bar_manager_changedc                 C   s:   | j d ur6|d ur*| j  d ¡ | | j ¡ |  | j ¡ d S r   )r   r!   r?   r"   )r   ÚoldÚnewr   r   r   Ú_status_bar_manager_changedÝ   s
    
z-ApplicationWindow._status_bar_manager_changedz)tool_bar_manager, tool_bar_managers.itemsc                 C   s   | j d ur|  | j ¡ d S r   )r   r,   )r   Úeventr   r   r   Ú_update_tool_bar_managersä   s    
z+ApplicationWindow._update_tool_bar_managersc                 C   s   |   ¡  d S r   )r.   r/   r   r   r   Ú_icon_changedé   s    zApplicationWindow._icon_changed)%Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r-   r   r   r   r   r    r	   r*   r   r)   r   r;   r   r   r"   r,   r.   r0   r2   r>   r?   r&   r@   r#   rE   rG   rH   rK   r   rM   rN   Ú__classcell__r   r   r6   r   r      s4   	
r   )rR   r   Z
traits.apir   r   r   r   r   Zpyface.action.apir   r   r	   Zpyface.i_application_windowr
   r   Zpyface.ui_traitsr   Zpyface.wx.auir   r   Zimage_resourcer   rF   r   r   r   r   r   r   Ú<module>   s   