3
7ßL]è  ã               @   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 eeƒG d
d„ deeƒƒZdS )é    N)ÚQtGui)Ú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‡ f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   sF   t j|ƒ}t j|jƒ ƒ}|jt jjt jdƒƒ |j|ƒ |jdƒ |S )NZblueT)	r   ZQWidgetZQPaletteÚpaletteZsetColorr   ZQColorZ
setPaletteZsetAutoFillBackground)ÚselfÚparentZpanelr   © r   úD/tmp/pip-install-5sebvq2j/pyface/pyface/ui/qt4/application_window.pyÚ_create_contents?   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_barI   s    
z"ApplicationWindow._create_menu_barc             C   s4   | j d k	r0| j j|ƒ}| jj|ƒ |j| j jƒ d S )N)Ústatus_bar_managerZcreate_status_barr   ZsetStatusBarÚ
setVisibleÚvisible)r   r   Z
status_barr   r   r   Ú_create_status_barN   s    
z$ApplicationWindow._create_status_barc             C   st   | j ƒ }| jjƒ }xF|D ]>}|j|ƒ}| jj|ƒ |jƒ  t|jƒ ƒdkr|j|j	ƒ qW t
jdkrp| j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_barW   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.png)Úiconr   r   ZsetWindowIconZcreate_icon)r   r)   r   r   r   Ú_set_window_iconj   s
    


z"ApplicationWindow._set_window_iconc             C   s   dS )z Trait initialiser. é   éX  )r+   r,   r   )r   r   r   r   Ú_size_defaultv   s    zApplicationWindow._size_defaultc                s6   t t| ƒjƒ  | j| jƒ}| jj|ƒ | j| jƒ d S )N)Úsuperr   Ú_creater   r   ZsetCentralWidgetZ_create_trim_widgets)r   Úcontents)Ú	__class__r   r   r/      s    zApplicationWindow._createc                s2   t t| ƒj|ƒ}|jdƒ |jdƒ |jdƒ |S )Nr   FT)r.   r   Ú_create_controlr"   ZsetAnimatedZsetDockNestingEnabled)r   r   r   )r1   r   r   r2   ‡   s
    


z!ApplicationWindow._create_controlc             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   | 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	r&|d k	r|jƒ  | j| j ƒ d S )N)r   Zdestroy_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   sN   | j d k	rJx2| j jƒ D ]$}t|tjƒr| j j|ƒ |jƒ  qW | j| j ƒ d S )N)r   ÚchildrenÚ
isinstancer   ZQToolBarZremoveToolBarZdeleteLaterr(   )r   Úchildr   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
   Útitler   r   r   r(   r*   r-   r/   r2   r   r3   r6   r   r:   r;   Ú__classcell__r   r   )r1   r   r      s(   
		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.image_resourcer   Zwindowr   r   r   r   r   r   Ú<module>   s   