3
7ßL]î   ã               @   sª   d Z ddlZddlZddlmZ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 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 )z$ Enthought pyface package component
é    N)ÚauiÚPyfaceAuiManager)ÚMenuBarManagerÚStatusBarManager)ÚToolBarManager)ÚInstanceÚListÚon_trait_changeÚprovidesÚUnicode)ÚIApplicationWindow)ÚMApplicationWindow)ÚImageResourceé   )ÚWindowc                   sä   e Zd ZdZe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�}|jdƒ |jdƒ |S )	Nr   r   )Únameéô  é�  Zblueéÿÿÿÿ)r   r   )ÚwxZPanelZSetSizeÚSetBackgroundColour)ÚselfÚparentZpanel© r   úC/tmp/pip-install-5sebvq2j/pyface/pyface/ui/wx/application_window.pyÚ_create_contentsL   s    

z"ApplicationWindow._create_contentsc             C   s&   | j d k	r"| j j|ƒ}| jj|ƒ d S )N)Úmenu_bar_managerZcreate_menu_barÚcontrolZ
SetMenuBar)r   r   Zmenu_barr   r   r   Ú_create_menu_barS   s    
z"ApplicationWindow._create_menu_barc             C   s&   | j d k	r"| j j|ƒ}| jj|ƒ d S )N)Ústatus_bar_managerZcreate_status_barr   ÚSetStatusBar)r   r   Z
status_barr   r   r   Ú_create_status_barX   s    
z$ApplicationWindow._create_status_barc             C   sL   | j ƒ }t|ƒdkrHx(t|ƒD ]}|j|dd�}| j|ƒ qW | j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_bar_   s    
z"ApplicationWindow._create_tool_barc             C   s8   | j d krtdƒ}n| j }| jd k	r4| jj|jƒ ƒ d S )Nzapplication.ico)Úiconr   r   ZSetIconZcreate_icon)r   r-   r   r   r   Ú_set_window_iconi   s    


z"ApplicationWindow._set_window_iconc             C   s   dS )z Trait initialiser. é   éX  )r/   r0   r   )r   r   r   r   Ú_size_defaultx   s    zApplicationWindow._size_defaultc                sT   t t| ƒjƒ  tƒ | _| jj| jƒ | j| j_| j| jƒ}| j| jƒ | jj	ƒ  d S )N)
Úsuperr   Ú_creater   r'   ZSetManagedWindowr   r   Z_create_trim_widgetsr(   )r   Úcontents)Ú	__class__r   r   r3   �   s    

zApplicationWindow._createc             C   sF   t jt jB t jB }t j|d| j|| j| jd�}|jƒ }|j	|j
ƒ |S )Nr   )ÚstyleÚsizeÚposr   )r   ZDEFAULT_FRAME_STYLEZFRAME_NO_WINDOW_MENUZCLIP_CHILDRENZFrameÚtitler7   ÚpositionZGetDefaultAttributesr   ZcolBg)r   r   r6   r   Úattrr   r   r   Ú_create_control–   s    
z!ApplicationWindow._create_controlc                s"   | j r| jjƒ  tt| ƒjƒ  d S )N)r   r'   ZUnInitr2   r   Údestroy)r   )r5   r   r   r=   §   s    
zApplicationWindow.destroyc             C   s   | j |ƒ}| jj||ƒ dS )z# Add a toolbar to the AUI manager. N)Ú_get_tool_bar_pane_infor'   ÚAddPane)r   r+   Úinfor   r   r   r&   °   s    
z-ApplicationWindow._add_toolbar_to_aui_managerc             C   sL   t jƒ }|j|jjƒ |jdƒ |j|jjƒ |jdƒ |j	ƒ  |j
ƒ  |S )NF)r   ZAuiPaneInfoZCaptionr*   r   ZLeftDockableÚNameÚidZRightDockableZToolbarPaneZTop)r   r+   r@   r   r   r   r>   ¸   s    

z)ApplicationWindow._get_tool_bar_pane_infoc             C   s   | j dk	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jƒ}|r|jƒ  n>|jjdƒ | j j|jƒ | j|jƒ}|jƒ  | j j	|j|ƒ | j j
ƒ  dS )z Hide/Show a tool bar. FN)r'   ZGetPaner*   rB   ZShowÚwindowZ
DetachPaner>   ZHider?   r(   )r   r+   ZvisibleZpaner@   r   r   r   Ú_wx_show_tool_barÖ   s    

z#ApplicationWindow._wx_show_tool_barc             C   s   | j d k	r| j| j ƒ d S )N)r   r   )r   r   r   r   Ú_menu_bar_manager_changedí   s    
z+ApplicationWindow._menu_bar_manager_changedc             C   s:   | j d k	r6|d k	r*| j jd ƒ |j| j ƒ | j| j ƒ d S )N)r   r!   Zremove_status_barr"   )r   ÚoldÚnewr   r   r   Ú_status_bar_manager_changedñ   s
    
z-ApplicationWindow._status_bar_manager_changedz#tool_bar_manager, tool_bar_managersc             C   s   | j d k	r| j| j ƒ d S )N)r   r,   )r   r   r   r   Ú_update_tool_bar_managersø   s    
z+ApplicationWindow._update_tool_bar_managersc             C   s   | j ƒ  d S )N)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   r9   r   r   r"   r,   r.   r1   r3   r<   r=   r&   r>   r#   rC   rE   rF   rI   r	   rJ   rK   Ú__classcell__r   r   )r5   r   r   '   s2   
		r   )rO   Úsysr   Zpyface.wx.auir   r   Zpyface.action.apir   r   r   Z
traits.apir   r   r	   r
   r   Zpyface.i_application_windowr   r   Zpyface.image_resourcer   rD   r   r   r   r   r   r   Ú<module>   s   