a
    §ˆcÎ  ã                   @   sž   d dl 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	m
Z
mZmZ d dlmZmZ d dlmZ dd	lmZ dd
lmZ eeƒG dd„ deeƒƒZdS )é    N)ÚQtGui)ÚMenuBarManagerÚStatusBarManager)ÚToolBarManager)ÚInstanceÚListÚobserveÚprovidesÚStr)ÚIApplicationWindowÚMApplicationWindow)ÚImageé   )Ú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‡ fdd„Zdd„ Zedƒdd„ ƒZedƒdd„ ƒZedƒdd„ ƒZedƒdd „ ƒZ‡  ZS )!ÚApplicationWindowz‡ The toolkit specific implementation of an ApplicationWindow.  See the
    IApplicationWindow interface for the API documentation.
    ZPyfacec                 C   sH   t  |¡}t  | ¡ ¡}| t jjjt  d¡¡ | |¡ | 	d¡ |S )NZblueT)
r   ZQWidgetZQPaletteÚpaletteZsetColorZ	ColorRoler   ZQColorZ
setPaletteZsetAutoFillBackground)ÚselfÚparentZpanelr   © r   úc/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/ui/qt4/application_window.pyÚ_create_contentsD   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_barN   s    
z"ApplicationWindow._create_menu_barc                 C   s4   | j d ur0| j  |¡}| j |¡ | | j j¡ d S r   )Ústatus_bar_managerZcreate_status_barr   ZsetStatusBarÚ
setVisibleÚvisible)r   r   Z
status_barr   r   r   Ú_create_status_barS   s    
z$ApplicationWindow._create_status_barc                 C   sp   |   ¡ }| j ¡ }|D ]>}| |¡}| j |¡ | ¡  t| ¡ ƒdkr| |j	¡ qt
jdkrl| j |¡ d S )Nr   Údarwin)Ú_get_tool_bar_managersr   Z	isVisibleZcreate_tool_barZ
addToolBarÚshowÚlenZ
objectNameÚsetObjectNameÚnameÚsysÚplatformr   )r   r   Útool_bar_managersr   Útool_bar_managerZtool_barr   r   r   Ú_create_tool_bar\   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.png)Úiconr   r   ZsetWindowIconZcreate_icon)r   r+   r   r   r   Ú_set_window_icono   s
    


z"ApplicationWindow._set_window_iconc                 C   s   dS )z Trait initialiser. )i   iX  r   )r   r   r   r   Ú_size_default{   s    zApplicationWindow._size_defaultc                    s2   t ƒ  ¡  |  | j¡}| j |¡ |  | j¡ d S r   )ÚsuperÚ_creater   r   ZsetCentralWidgetZ_create_trim_widgets)r   Úcontents©Ú	__class__r   r   r/   „   s    
zApplicationWindow._createc                    s.   t ƒ  |¡}| d¡ | d¡ | d¡ |S )Nr   FT)r.   Ú_create_controlr$   ZsetAnimatedZsetDockNestingEnabled)r   r   r   r1   r   r   r3   Œ   s
    


z!ApplicationWindow._create_controlc                 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_managersr   c                 C   s   | j d ur|  | j ¡ d S r   )r   r   ©r   Úeventr   r   r   Ú_menu_bar_manager_updated«   s    
z+ApplicationWindow._menu_bar_manager_updatedr   c                 C   s.   | j d ur*|jd ur|j ¡  |  | j ¡ d S r   )r   ÚoldÚdestroyr   r4   r   r   r   Ú_status_bar_manager_updated°   s    


z-ApplicationWindow._status_bar_manager_updatedz)tool_bar_manager, tool_bar_managers.itemsc                 C   sJ   | j d urF| j  ¡ D ]$}t|tjƒr| j  |¡ | ¡  q|  | j ¡ d S r   )r   ÚchildrenÚ
isinstancer   ZQToolBarZremoveToolBarZdeleteLaterr*   )r   r5   Úchildr   r   r   Ú_update_tool_bar_managers·   s    

z+ApplicationWindow._update_tool_bar_managersr+   c                 C   s   |   ¡  d S r   )r,   r4   r   r   r   Ú_icon_updatedÃ   s    zApplicationWindow._icon_updated) Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r+   r   r   r   r   r   r   r)   r   r(   r
   Útitler   r   r   r*   r,   r-   r/   r3   r!   r   r6   r9   r=   r>   Ú__classcell__r   r   r1   r   r   $   s0   
		


r   )r&   Z	pyface.qtr   Zpyface.action.apir   r   r   Z
traits.apir   r   r   r	   r
   Zpyface.i_application_windowr   r   Zpyface.ui_traitsr   Zimage_resourcer   Zwindowr   r   r   r   r   r   Ú<module>   s   