a
    ¦ˆc„Ã  ã                   @   sö  d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZmZ ddlmZ ddlmZ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-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8 ej9dkZ:i a;eddd�Z<eddd�Z=edddd�Z>eddd�Z?eddd�Z@ed d!d�ZAed"d#d�ZBed$d%d�ZCG d&d'„ d'eƒZDeDƒ ZEG d(d)„ d)eƒZFG d*d+„ d+eƒZGG d,d-„ d-eHƒZIG d.d/„ d/eƒZJdS )0a~   Pyface 'DockWindow' support.

    This package provides a Pyface 'dockable' window component that allows
    child windows to be reorganized within the DockWindow using drag and drop.
    The component also allows multiple sub-windows to occupy the same
    sub-region of the DockWindow, in which case each sub-window appears as a
    separate notebook-like tab within the region.
é    )Ú
attrgetterN)	ÚHasPrivateTraitsÚInstanceÚTupleÚPropertyÚAnyÚStrÚListÚBoolÚobserve)Útraits_home)ÚViewÚHGroupÚVGroupÚItemÚHandlerÚerror)Úuser_name_for)ÚMenuÚActionÚ	Separator)ÚDockableViewElement)Údock_window_themeÚDockWindowTheme)ÚSystemMetrics)ÚPythonDropTargetÚ	clipboard)r   é   )Ú	DockSizerÚDockControlÚ
DockRegionÚ	DockStyleÚDockSplitterÚno_dock_infoÚclear_windowÚfeatures)Ú	IDockable)ÚIDockUIProviderÚdarwinÚMaximizeÚ
on_min_max©ÚnameÚactionZUndockÚ	on_undockzLock LayoutÚon_lock_layoutÚtoggle)r,   r-   ÚstylezSwitch LayoutÚon_switch_layoutzSave Layout...Úon_save_layoutzEdit Properties...Úon_editzShow AllÚon_enable_all_featureszHide AllÚon_disable_all_featuresc                   @   s.   e Zd Zdd„ Zdd„ Zddd„Zdd	„ Zd
S )ÚDockWindowHandlerc                 C   s   dS )z^ Returns whether or not a specified object can be inserted into the
            view.
        T© ©ÚselfÚobjectr8   r8   úZ/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/dock/dock_window.pyÚcan_dropt   s    zDockWindowHandler.can_dropc              	   C   s  z
|j }W n(   z
|j}W n   d}Y n0 Y n0 |dkrHt|jjƒ}d}d}t|tƒr¸|}|j}|j}|j	}| 
¡ }|rˆ|jdd� | |¡}	|rô|j|	|jjd� | |¡ |S n<t|tƒrÒ|}| |¡}	n"| |¡}
t|
d�}|
jj}|
j}	t|	|||jj|dd�}| |¡ |S )z@ Returns the DockControl object for a specified object.
        Ú NT)Úforce)Úcontrolr1   )Úui)r@   r,   Úexportr1   ÚimageZ	closeable)r,   Úlabelr   Ú	__class__Ú__name__Ú
isinstancer   rC   rB   ÚdockableZdockable_should_closeÚcloseZdockable_get_controlÚ	trait_setÚownerr1   Zdockable_init_dockcontrolr&   Zget_dockable_uir   Úviewr@   )r:   Úparentr;   r,   rC   rB   Údock_controlrH   rI   r@   rA   Údcr8   r8   r<   Údock_control_for~   sV    



ÿ



ú	
z"DockWindowHandler.dock_control_forTc                 C   s   ddl m} |||d� dS )z4 Creates a new view of a specified control.
        r   )ÚDockWindowShell©Ú	use_mouseN)Zdock_window_shellrQ   )r:   r@   rS   rQ   r8   r8   r<   Úopen_view_for»   s    zDockWindowHandler.open_view_forc                 C   s   |j r|j ¡  ¡  dS )z0 Handles the DockWindow becoming empty.
        N)Ú
auto_closer@   Z	GetParentZDestroy)r:   Údock_windowr8   r8   r<   Údock_window_emptyÆ   s    z#DockWindowHandler.dock_window_emptyN)T)rF   Ú
__module__Ú__qualname__r=   rP   rT   rW   r8   r8   r8   r<   r7   n   s   
=
r7   c                   @   s>   e Zd Zeƒ ZeeƒZeeddd�ddddgd�Z	d	d
„ Z
dS )Ú
LayoutNamer,   zLayout name)rD   zSave LayoutÚmodalÚOKÚCancel©ÚtitleÚkindZbuttonsc                 C   sR   |rN|j j ¡ }|dkr.t|jjddd� dS || jv rNtd| d|jjd�S d	S )
Nr>   zNo name specifiedzSave Layout Error©r_   Fz%s is already defined. Replace?zSave Layout Warning©Úmessager_   rM   T)r;   r,   ÚstripÚwarningrA   r@   Únamesr   )r:   ÚinfoZis_okr,   r8   r8   r<   rI   ð   s     ý
ýzLayoutName.closeN)rF   rX   rY   r   r,   r	   rf   r   r   rL   rI   r8   r8   r8   r<   rZ   Õ   s   
ürZ   c                       s.  e Zd ZeejƒZeeƒZ	e
ƒ ZedƒZeedd�ZeZeZeƒ Zdejejejf‡ fdd„	Zdd„ Zedƒd	d
„ ƒZdd„ Zdwdd„Zdd„ Zdd„ Z dd„ Z!dd„ Z"dd„ Z#dd„ Z$dd„ Z%dd„ Z&d d!„ Z'd"d#„ Z(d$d%„ Z)d&d'„ Z*d(d)„ Z+d*d+„ Z,d,d-„ Z-d.d/„ Z.d0d1„ Z/dxd2d3„Z0d4d5„ Z1d6d7„ Z2d8d9„ Z3d:d;„ Z4d<d=„ Z5d>d?„ Z6d@dA„ Z7dBdC„ Z8dDdE„ Z9dydFdG„Z:dHdI„ Z;dJdK„ Z<dLdM„ Z=dNdO„ Z>dPdQ„ Z?dRdS„ Z@dTdU„ ZAdVdW„ ZBdzdYdZ„ZCd[d\„ ZDd]d^„ ZEd_d`„ ZFdadb„ ZGdcdd„ ZHdedf„ ZIdgdh„ ZJdidj„ ZKdkdl„ ZLdmdn„ ZMdodp„ ZNdqdr„ ZOdsdt„ ZPdudv„ ZQ‡  ZRS ){Ú
DockWindowF)Ú
allow_noneéÿÿÿÿc           	         s.  t ƒ jf i |¤Ž t |||||¡ | _}| |_| tj| j¡ | tj	| j
¡ | tj| j¡ | tj| j¡ | tj| j¡ | tj| j¡ | tj| j¡ | tj| j¡ | tj| j¡ | t| ƒ¡ | jjrä| jjjj}n:t ƒ j!}t "t#|d d ƒt#|d d ƒt#|d d ƒ¡}| j $|¡ d S )Nr   éÿ   r   é   )%ÚsuperÚ__init__ÚwxÚWindowr@   rK   ZBindÚ	EVT_PAINTÚ_paintÚEVT_SIZEÚ_sizeÚEVT_LEFT_DOWNÚ
_left_downÚEVT_LEFT_UPÚ_left_upÚEVT_LEFT_DCLICKÚ_left_dclickÚEVT_RIGHT_DOWNÚ_right_downÚEVT_RIGHT_UPÚright_upÚ
EVT_MOTIONÚ_mouse_moveÚEVT_LEAVE_WINDOWÚ_mouse_leaveZSetDropTargetr   ÚthemeÚuse_theme_colorÚtabÚimage_sliceÚbg_colorr   Zdialog_background_colorZColourÚintÚSetBackgroundColour)	r:   rM   ZwidÚposÚsizer1   Ztraitsr@   Úcolor©rE   r8   r<   rn   +  s(    	*ÿzDockWindow.__init__c                 C   s   t ƒ S ©N)r   ©r:   r8   r8   r<   Ú_theme_defaultV  s    zDockWindow._theme_defaultrƒ   c                 C   s@   |j }| jd ur<|jr"|jjj}ntj}| j |¡ |  	¡  d S rŽ   )
Únewr@   r„   r…   r†   r‡   ro   Z
NullColourr‰   Úupdate_layout)r:   Úeventrƒ   rŒ   r8   r8   r<   Ú#_update_background_color_and_layout[  s    
z.DockWindow._update_background_color_and_layoutc                 C   s   | j  | ¡ dS )z> Notifies the DockWindow that its contents are empty.
        N)ÚhandlerrW   r�   r8   r8   r<   rW   k  s    zDockWindow.dock_window_emptyNc                 C   sD   |du r| j  tj¡ dS |tvr0t |¡t|< | j  t| ¡ dS )z6 Sets the cursor to a specified cursor shape.
        N)r@   Z	SetCursorro   Z
NullCursorÚ
cursor_mapÚCursor)r:   Úcursorr8   r8   r<   Ú
set_cursort  s    zDockWindow.set_cursorc                 C   s   | j durd| _ | j ¡  dS )z2 Releases ownership of the mouse capture.
        N)Ú_ownerr@   ÚReleaseMouser�   r8   r8   r<   Úrelease_mouse†  s    
zDockWindow.release_mousec                 C   s   | j r| j  ¡  | j  ¡  dS )z+ Updates the layout of the window.
        N)r@   ZLayoutZRefreshr�   r8   r8   r<   r’   ‘  s    
zDockWindow.update_layoutc                 C   s(   | j }|dur$| | j|¡ |  ¡  dS )z6 Minimizes/maximizes a specified DockControl.
        N)ÚsizerZMinMaxr@   r’   )r:   rN   r�   r8   r8   r<   Úmin_maxœ  s    zDockWindow.min_maxc                 C   sL   | j }|du r:ddlm} || jd� | _ }| | jd¡ ||_| ¡  dS )z> Pops up the feature bar for a specified DockControl.
        Nr   )Ú
FeatureBar©rM   Z	completed)Ú_feature_barZfeature_barrŸ   r@   r   Ú_feature_bar_closedrN   Úshow)r:   rN   ÚfbrŸ   r8   r8   r<   Úfeature_bar_popup¨  s    zDockWindow.feature_bar_popupc                 C   s   | j }|j ¡  | ¡  d S rŽ   )r¡   rN   Zfeature_bar_closedÚhide)r:   r“   r¤   r8   r8   r<   r¢   ¹  s    
zDockWindow._feature_bar_closedc                 C   s   |   ¡  dS )a   Closes the dock window.  In this case, all event handlers are
        unregistered.  Other cleanup operations go here, but at the moment Linux
        (and other non-Windows platforms?) are less forgiving when things like
        event handlers arent unregistered.
        N)Ú_unregister_event_handlersr�   r8   r8   r<   rI   Â  s    zDockWindow.closec                 C   s~   | j }|durz| tj¡ | tj¡ | tj¡ | tj¡ | tj¡ | tj¡ | tj	¡ | tj
¡ | tj¡ dS )a   Unregister all event handlers setup in the constructor.  This is
        typically done prior to an app shutting down and is needed since Linux
        (and other non-Windows platforms?) trigger mouse, repaint, etc. events
        for controls which have already been deleted.
        N)r@   ZUnbindro   rq   rs   ru   rw   ry   r{   r}   r   r�   )r:   r@   r8   r8   r<   r§   Î  s    z%DockWindow._unregister_event_handlersc                 C   s<   t r|  ¡ rdS | j}t|tƒr.| | j¡ n
t| jƒ dS )z( Handles repainting the window.
        N)Úis_macÚ_is_child_paintr�   rG   r   ZDrawr@   r$   )r:   r“   r�   r8   r8   r<   rr   ä  s    
zDockWindow._paintc                 C   s>   | j jr:| j jj}| j jD ]}| ¡ s|j |¡r dS qdS )zV Returns whether or not the current update region is entirely within a child.
        TF)r@   ZChildrenZUpdateRegionZBoxZHasTransparentBackgroundZRectZContains)r:   Zupdate_rectÚchildr8   r8   r<   r©   ÷  s    
ÿzDockWindow._is_child_paintc                 C   sN   | j }|durBz&| j ¡  ¡ \}}| dd||¡ W n   Y n0 | ¡  dS )z+ Handles the window being resized.
        Nr   )r�   r@   ZGetSizeZGetZSetDimensionZSkip)r:   r“   r�   ZdxZdyr8   r8   r<   rt     s    zDockWindow._sizec                 C   sH   | j }|durD| | ¡ | ¡ ¡}|durD|| _| j ¡  | |¡ dS )z6 Handles the left mouse button being pressed.
        N)r�   ÚObjectAtÚGetXÚGetYrš   r@   ÚCaptureMouseÚ
mouse_down©r:   r“   r�   r;   r8   r8   r<   rv     s    
zDockWindow._left_downc                 C   sœ   | j }| jdur*| ¡  | j |¡ d| _| ¡ r˜| ¡ r~| ¡ rh| j ¡ }|dur|| 	¡  t
j ¡  q˜| j |¡ |  ¡  n| ¡ r˜| j ¡  |  ¡  dS )z7 Handles the left mouse button being released.
        N)r@   rš   r›   Zmouse_upÚ	ShiftDownÚControlDownÚAltDownr�   ÚGetContentsÚdumpÚsysÚstdoutÚflushÚResetStructurer’   Ú
ToggleLock)r:   r“   ÚwindowÚcontentsr8   r8   r<   rx   )  s"    



zDockWindow._left_upc                 C   sŠ   | j }|dur†| | ¡ | ¡ d¡}t|tƒrb|j}|du sL| ||¡du r†|jdkr†|  	|¡ n$t|t
ƒr†|| _| j ¡  | |¡ dS )z= Handles the left mouse button being double clicked.
        NTFÚfixed)r�   r«   r¬   r­   rG   r   rH   Zdockable_dclickr1   rž   r    rš   r@   r®   r¯   )r:   r“   r�   r;   rH   r8   r8   r<   rz   F  s     
ÿþý

zDockWindow._left_dclickc                 C   s   dS )z7 Handles the right mouse button being pressed.
        Nr8   ©r:   r“   r8   r8   r<   r|   \  s    zDockWindow._right_downc                 C   s’  | j }|du�rŽ| | ¡ | ¡ d¡}|du�rŽd}| j}t|tƒ}|r€|jdur€| ¡ sj| 	¡ sj| 
¡ r€|j| _|j ||¡}|du �rb| | _| j  ¡ }t|tƒ}|| _|rº|j | _}|}	|rÈ|	j}	| ¡ rØdt_ndt_|t_|t_| t_| d¡}
t|
ƒdk�o|
d jt_| jdkt_|  ¡ }|  ¡ \}}t ttt!ƒ |t!ƒ tt"t!ƒ t||t!ƒ tdd	�}| #| $|| ¡| ¡ d
 | ¡ d
 ¡ d| _dS )z8 Handles the right mouse button being released.
        NTr)   ZRestoreFr   r>   Zpopup)r,   é
   )%r�   r«   r¬   r­   r@   rG   r   rH   r±   r²   r³   Ú
_menu_selfZdockable_menur´   r"   Ú_objectrM   ZIsMaximizableÚmin_max_actionr,   ÚenabledÚundock_actionÚedit_actionZget_controlsÚlenÚlockedÚlock_actionÚcheckedÚidÚsave_actionÚ_get_feature_menuÚ_get_layout_menusr   r   Úlayout_actionZ	PopupMenuZcreate_menu)r:   r“   r�   r;   Z
popup_menur»   Zis_dock_controlÚsectionZis_splitterÚgroupÚcontrolsZfeature_menuZrestore_menuZdelete_menur8   r8   r<   r~   e  s€    


ÿþüûú	



ÿï


ýzDockWindow.right_upc                 C   s¼   | j dur| j  ¡  d| _ | jdur2| j |¡ n†| j}|dur¸| jpX| | ¡ | ¡ ¡}|  	||¡ || j
urž| j
dur†| j
 |¡ |dur˜| |¡ || _
t|tƒr¸| |¡r¸|| _ dS )z3 Handles the mouse moving over the window.
        N)Ú_last_dock_controlÚreset_feature_popuprš   Z
mouse_mover�   rÁ   r«   r¬   r­   Ú_set_cursorÚ_hoverÚ
hover_exitZhover_enterrG   r   Úfeature_activater°   r8   r8   r<   r€   ´  s*    



ÿ


ÿzDockWindow._mouse_movec                 C   s*   | j dur| j  |¡ d| _ |  |¡ dS )z/ Handles the mouse leaving the window.
        N)rÕ   rÖ   rÔ   r¾   r8   r8   r<   r‚   Ø  s    
zDockWindow._mouse_leavec                 C   s&   |du r|   ¡  n|   | |¡¡ dS )z1 Sets the cursor for a specified object.
        N)r™   Z
get_cursor)r:   r“   r;   r8   r8   r<   rÔ   ä  s    
zDockWindow._set_cursorc                 C   s   |   | j¡ dS )zM Handles the user asking for a DockControl to be maximized/restored.
        N)rž   rÁ   r�   r8   r8   r<   r*   ò  s    zDockWindow.on_min_maxc                 C   s   | j j| jdd� dS )z@ Handles the user requesting an element to be undocked.
        FrR   N)r•   rT   rÁ   r�   r8   r8   r<   r.   û  s    zDockWindow.on_undockc                 C   s   | j  d¡ dS )z> Handles the user requesting an element to be hidden.
        FN)rÁ   r£   r�   r8   r8   r<   Úon_hide  s    zDockWindow.on_hidec                 C   s*   | j }t|tƒr|j}|  |¡ d¡ dS )z= Handles the user requesting an element to be shown.
        TN)rÁ   rG   r   rM   Ú_hidden_group_forr£   r9   r8   r8   r<   Úon_show  s    
zDockWindow.on_showc                 C   s   | j  | j¡ |  ¡  dS )zJ Handles the user requesting that the current layout be switched.
        N)r�   r¹   r@   r’   r�   r8   r8   r<   r2     s    zDockWindow.on_switch_layoutc                 C   s   | j  ¡  |  ¡  dS )zI Handles the user requesting that the layout be locked/unlocked.
        N)r�   rº   r’   r�   r8   r8   r<   r/   #  s    
zDockWindow.on_lock_layoutc                 C   s6   t |  ¡ d�}|j| jd�jr2|  |j| j ¡ ¡ dS )z? Handles the user requesting that the layout be saved.
        )rf   r    N)	rZ   Ú_get_layout_namesÚedit_traitsr@   ÚresultÚ_set_layoutr,   r�   ZGetStructure)r:   Zlayout_namer8   r8   r<   r3   -  s    zDockWindow.on_save_layoutc                 C   s"   | j  | j|  |¡¡ |  ¡  dS )zH Handles the user requesting a specified layout to be restored.
        N)r�   ZSetStructurer@   Ú_get_layoutr’   ©r:   r,   r8   r8   r<   Úon_restore_layout8  s    zDockWindow.on_restore_layoutc                 C   s"   t d| d| jd�r|  |¡ dS )zF Handles the user reqesting a specified layout to be deleted.
        zDelete the '%s' layout?zDelete Layout Warningrb   N)r   r@   Ú_delete_layoutrà   r8   r8   r<   Úon_delete_layoutB  s    ýzDockWindow.on_delete_layoutc              	   C   sv   |du r| j }tf i | dddd¡¤Ž}|j| jd�jrr|j ¡ }|dkrP||_|jf i | ddd¡¤Ž |  	¡  dS )z6 Handles the user requesting to edit an item.
        Nr,   Ú	user_namer1   Ú
user_styler    r>   )
rÁ   ÚControlInfoÚgetrÜ   r@   rÝ   r,   rd   rJ   r’   )r:   r;   Zcontrol_infor,   r8   r8   r<   r4   P  s    ÿ
ÿzDockWindow.on_editc                 C   s,   t D ]"}|jdkr|jdkr| |¡ qdS )z Enables all features.
        r>   r   N©r%   Úfeature_nameÚstateÚtoggle_feature©r:   r-   Úfeaturer8   r8   r<   r5   e  s    z!DockWindow.on_enable_all_featuresc                 C   s,   t D ]"}|jdkr|jdkr| |¡ qdS )z  Disables all features.
        r>   r   Nrè   rì   r8   r8   r<   r6   p  s    z"DockWindow.on_disable_all_featuresc                 C   s   |j  |¡ dS )z\ Toggles the enabled/disabled state of the action's associated
            feature.
        N)Ú_featurerë   ©r:   r-   r8   r8   r<   Úon_toggle_feature{  s    zDockWindow.on_toggle_featurec                 C   s8   | j }|dkr4|  ¡ }|dur4| |¡}| ¡  |S dS )z8 Gets the layout dictionary for the DockWindow.
        r>   N©rÊ   Ú
_get_dw_dbrç   rI   )r:   rÊ   ÚdbÚlayoutsr8   r8   r<   Ú_get_layouts‡  s    
zDockWindow._get_layoutsc                 C   s    |   ¡ }|durt| ¡ ƒS g S )zK Gets the names of all current layouts defined for the DockWindow.
        N)rõ   ÚlistÚkeys)r:   rô   r8   r8   r<   rÛ   ˜  s    zDockWindow._get_layout_namesc                 C   s   |   ¡ }|dur| |¡S dS )z; Gets the layout data for a specified layout name.
        N)rõ   rç   )r:   r,   rô   r8   r8   r<   rß   ¥  s    
zDockWindow._get_layoutc                 C   sN   | j }|dkrJ| jdd�}|durJ| |¡}|durB||= |||< | ¡  dS )z> Deletes the layout data for a specified layout name.
        r>   Úc©ÚmodeNrñ   )r:   r,   rÊ   ró   rô   r8   r8   r<   râ   ²  s    
zDockWindow._delete_layoutc                 C   sT   | j }|dkrP| jdd�}|durP| |¡}|du r8i }|||< |||< | ¡  dS )z; Sets the layout data for a specified layout name.
        r>   rø   rù   Nrñ   )r:   r,   ZlayoutrÊ   ró   rô   r8   r8   r<   rÞ   Ã  s    
zDockWindow._set_layoutÚrc                 C   s2   zt jtj tƒ d¡|dd�W S    Y d S 0 d S )NrV   rj   )ÚflagÚprotocol)ÚshelveÚopenÚosÚpathÚjoinr   )r:   rú   r8   r8   r<   rò   Õ  s    ýzDockWindow._get_dw_dbc              
   C   sÆ   d t _t_tD ]:}|jdkr|jdkr:dt_t jrJ qLqdt _tjr qLqg }tD ].}|jdkrT| t|jd|d|jdkd�¡ qTt|ƒdkr°|j	t
d	ƒd
� tƒ g|dd…< tt tg| d	diŽS )z* Returns the 'Features' sub_menu.
        Fr>   r   Trð   r0   )r,   r-   rî   r1   rÉ   r   r,   )ÚkeyZFeatures)Úenable_features_actionrÃ   Údisable_features_actionr%   ré   rê   Úappendr   rÆ   Úsortr   r   r   )r:   rí   Úactionsr8   r8   r<   rÌ   ã  s@    þ


ûÿ

þÿzDockWindow._get_feature_menuc                 C   sr   |   ¡ }t|ƒdkr2tddd�g}tddd�g}n$| ¡  dd„ |D ƒ}dd„ |D ƒ}t|dd	iŽt|dd
iŽgS )zc Gets the sub-menus for the 'Restore layout' and 'Delete layout' menu
            options.
        r   z<empty>F)r,   rÃ   c                 S   s    g | ]}t |d t|ƒ d�‘qS )zself.on_restore_layout(%s)r+   ©r   Úrepr©Ú.0r,   r8   r8   r<   Ú
<listcomp>  s   ýÿz0DockWindow._get_layout_menus.<locals>.<listcomp>c                 S   s    g | ]}t |d t|ƒ d�‘qS )zself.on_delete_layout(%s)r+   r	  r  r8   r8   r<   r    s   ýÿr,   zRestore LayoutzDelete Layout)rÛ   rÆ   r   r  r   )r:   rf   Zrestore_actionsZdelete_actionsr8   r8   r<   rÍ     s    üüþzDockWindow._get_layout_menusc           	      C   sÀ   t |ttfƒrº| j}| j}|du r(| j}| |¡ d| _z^| jj| j	||f Ž }t
tddƒ}t|dƒr†|j|u r†t|dƒr†d|j |_| ||¡ |W S    t|d|jj dd� Y n0 tjS )	z> Handles a Python object being dropped on the window.
        NÚnodeÚobjÚnamespace_namez@@%szMAn error occurred while attempting to add an item of type '%s' to the window.zCannot add item to windowra   )rG   r'   r   r@   Ú
_dock_infoÚ_leave_infoÚdrawr•   rP   Úhandler_argsÚgetattrr   Úhasattrr  r  rÊ   Zdockre   rE   rF   ro   ÚDragNone)	r:   ÚxÚyÚdataÚdrag_resultr»   Ú	dock_infor@   Zbindingr8   r8   r<   Úwx_dropped_on0  s<    
ÿÿþýÿüzDockWindow.wx_dropped_onc           	      C   sæ   t |tƒ}|st |tƒrÊ|r6| jj| j|f Ž s6tjS | j}|du rbt	}t |tƒr\|j
| _nd| _| j}| j ||| jd¡ | _}|j|jks²|j|jus²|j|jks²|j|jkrÆ| |¡ | |¡ |S |  |||¡durà|S tjS )zA Handles a Python object being dragged over the control.
        NéP   F)rG   r'   r   r•   r=   r  ro   r  r  r#   Z	tab_widthZ
_dock_sizer@   r�   Z
DockInfoAtr`   ZregionZboundsZ
tab_boundsr  Ú_can_drop_on_feature)	r:   r  r  r  r  Zui_providerZcur_dock_infor»   r  r8   r8   r<   Úwx_drag_anyY  s<    
ÿ


ÿ

ÿ
þ
ý
ü

zDockWindow.wx_drag_anyc                 C   s,   | j dur(| j  | j¡ | j d | _| _ dS )z= Handles a dragged Python object leaving the window.
        N)r  r  r@   r  )r:   r  r8   r8   r<   Úwx_drag_leaveŒ  s    
zDockWindow.wx_drag_leavec                 C   s   dS )z= Adds a menu item to the menu bar being constructed.
        Nr8   )r:   Z	menu_itemr8   r8   r<   Úadd_to_menuŸ  s    zDockWindow.add_to_menuc                 C   s   dS )zA Adds a tool bar item to the tool bar being constructed.
        Nr8   )r:   Ztoolbar_itemr8   r8   r<   Úadd_to_toolbar¨  s    zDockWindow.add_to_toolbarc                 C   s   dS )zM Returns whether the action should be defined in the user interface.
        Tr8   rï   r8   r8   r<   Úcan_add_to_menu±  s    zDockWindow.can_add_to_menuc                 C   s   dS )za Returns whether the toolbar action should be defined in the user
            interface.
        Tr8   rï   r8   r8   r<   Úcan_add_to_toolbar»  s    zDockWindow.can_add_to_toolbarc                 C   sZ   |j }|dd… dkr,t|tƒ d| jiƒ n*t| |ƒ}z
|ƒ  W n   ||ƒ Y n0 dS )zE Performs the action described by a specified Action object.
        Né   zself.r:   )r-   ÚevalÚglobalsrÀ   r  )r:   Zaction_objectr-   Úmethodr8   r8   r<   ÚperformÅ  s    

zDockWindow.performc                 C   s   | j d ur| j  ¡ S d S rŽ   )r@   ZGetSizerr�   r8   r8   r<   Ú
_get_sizerØ  s    

zDockWindow._get_sizerc                 C   s   | j  |¡ d S rŽ   )r@   ZSetSizer)r:   r�   r8   r8   r<   Ú
_set_sizerÝ  s    zDockWindow._set_sizerc                 C   s0   |du rdS t |jƒt |jƒkr$|S |j}q dS )z? Finds the first group with any hidden items (if any).
        N)rÆ   r¼   Zvisible_contentsrM   )r:   rÐ   r8   r8   r<   rÙ   æ  s
    zDockWindow._hidden_group_forc                 C   s‚   | j durd| j  ||¡}t|tƒrdt||| jƒ}| ||¡rd| j}|durZ||urZ| ¡  || _dS | jdur~| j ¡  d| _dS )zi Returns a feature that the pointer is over and which can accept the
            specified data.
        N)	r�   r«   rG   r   Ú	FakeEventr@   r×   rÒ   rÓ   )r:   r  r  r  r;   r“   Zldcr8   r8   r<   r  õ  s    



zDockWindow._can_drop_on_feature)N)N)N)rû   )SrF   rX   rY   r   ro   rp   r@   r   Údock_window_handlerr•   r   r  r
   rU   r   rƒ   r!   r1   r   r�   r   rÊ   ZDefaultPositionZDefaultSizeZFULL_REPAINT_ON_RESIZErn   r�   r   r”   rW   r™   rœ   r’   rž   r¥   r¢   rI   r§   rr   r©   rt   rv   rx   rz   r|   r~   r€   r‚   rÔ   r*   r.   rØ   rÚ   r2   r/   r3   rá   rã   r4   r5   r6   rð   rõ   rÛ   rß   râ   rÞ   rò   rÌ   rÍ   r  r   r!  r"  r#  r$  r%  r*  r+  r,  rÙ   r  Ú__classcell__r8   r8   r�   r<   rh   	  sŠ   
	ú+
	
		O$
			




,!)3		

	rh   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
r-  c                 C   s   |||  | _ | _| _d S rŽ   )r  r  r;   )r:   r  r  r;   r8   r8   r<   rn     s    zFakeEvent.__init__c                 C   s   | j S rŽ   )r  r�   r8   r8   r<   r¬     s    zFakeEvent.GetXc                 C   s   | j S rŽ   )r  r�   r8   r8   r<   r­     s    zFakeEvent.GetYc                 C   s   | j S rŽ   )r;   r�   r8   r8   r<   ÚGetEventObject  s    zFakeEvent.GetEventObjectN)rF   rX   rY   rn   r¬   r­   r0  r8   r8   r8   r<   r-    s   r-  c                	   @   sn   e Zd Zeƒ ZedƒZeƒ ZeZ	edƒZ
eeeeddƒeddd�ƒeeddƒeddd�ƒƒdd	d
dgd�ZdS )ræ   Fzname<100>{Label}Ú3zuser_name{Remember label})Z	show_leftz
style<101>zuser_style{Remember style}zEdit propertiesr[   r\   r]   r^   N)rF   rX   rY   r   r,   r
   rä   rÊ   r!   r1   rå   r   r   r   Ztraits_viewr8   r8   r8   r<   ræ   $  s(   
þ
þû
óræ   )KÚ__doc__Úoperatorr   r   rþ   r¶   ro   Z
traits.apir   r   r   r   r   r   r	   r
   r   Ztraits.trait_baser   Ztraitsui.apir   r   r   r   r   r   Ztraitsui.helperr   Ztraitsui.menur   r   r   Ztraitsui.dockable_view_elementr   Ztraitsui.dock_window_themer   r   Z
pyface.apir   Zpyface.wx.drag_and_dropr   r   Zpyface.message_dialogre   Z
dock_sizerr   r   r    r!   r"   r#   r$   r%   Z	idockabler&   Zidock_ui_providerr'   Úplatformr¨   r–   rÂ   rÄ   rÈ   rÎ   rË   rÅ   r  r  r7   r.  rZ   rh   r;   r-  ræ   r8   r8   r8   r<   Ú<module>   s`   
, (

ÿÿÿ	`4        