3
8Ad]g…  ã               @   s  d Z ddlmZm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mZ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mZmZ dd
l m!Z! ddl"Z"ddl#Z#e"j$e%ƒZ&dZ'G dd„ deƒZ(G dd„ de(ƒZ)G dd„ de)ƒZ*G dd„ de)ƒZ+G dd„ de(ƒZ,dS )zv Defines the table column descriptor used by the editor and editor factory
    classes for numeric and table editors.
é    )Úabsolute_importÚprint_functionN)ÚAnyÚBoolÚCallableÚColorÚConstantÚEitherÚEnumÚ
ExpressionÚFloatÚFontÚHasPrivateTraitsÚInstanceÚIntÚPropertyÚStr)Úuser_name_forÚxgetattré   )ÚEditorFactory)ÚMenu)ÚImageÚAViewÚEditorStyle)ÚViewz???c               @   s¸  e Zd ZdZeeƒZedƒZe	dƒZ
eZee	dƒdƒZee	dƒdƒZe	dƒZeddd	d
gƒZed	dd	dgƒZedƒZedƒZeZeZedƒZedƒZedƒZedƒZedƒZe e!ƒZ"eZ#e$dIƒZ%e$dJƒZ&e$dKƒZ'eddddƒZ(e)Z*e$dd�Z+dd„ Z,dd„ Z-dd„ Z.dd„ Z/dd „ Z0d!d"„ Z1d#d$„ Z2d%d&„ Z3d'd(„ Z4d)d*„ Z5d+d,„ Z6d-d.„ Z7d/d0„ Z8d1d2„ Z9d3d4„ Z:d5d6„ Z;d7d8„ Z<d9d:„ Z=d;d<„ Z>d=d>„ Z?d?d@„ Z@dAdB„ ZAdCdD„ ZBdEdF„ ZCdGdH„ ZDdS )LÚTableColumnz, Represents a column in a table editor.
    ÚtextÚblackÚwhiteNiîóô iÌÙÝ ÚleftÚcenterÚrightÚtopÚbottomé   é   TFg      ð?ÚinteractiveÚfixedZstretchZresize_to_contents)Ztrait_valuec             C   s   |S )z1 Returns the actual object being edited.
        © )ÚselfÚobjectr)   r)   úq/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traitsui-6.1.2-py3.6.egg/traitsui/table_column.pyÚ
get_object­   s    zTableColumn.get_objectc             C   s   | j S )z' Gets the label of the column.
        )Úlabel)r*   r)   r)   r,   Ú	get_label¶   s    zTableColumn.get_labelc             C   s   | j S )z* Returns the width of the column.
        )Úwidth)r*   r)   r)   r,   Ú	get_width¿   s    zTableColumn.get_widthc             C   s   | j S )z/ Returns the edit width of the column.
        )Ú
edit_width)r*   r+   r)   r)   r,   Úget_edit_widthÈ   s    zTableColumn.get_edit_widthc             C   s   | j S )z[ Returns the height of the column cell's row while it is being
            edited.
        )Úedit_height)r*   r+   r)   r)   r,   Úget_edit_heightÑ   s    zTableColumn.get_edit_heightc             C   s   | j S )zF Gets the type of data for the column for a specified object.
        )Útype)r*   r+   r)   r)   r,   Úget_typeÛ   s    zTableColumn.get_typec             C   s   | j S )zG Returns the text color for the column for a specified object.
        )Útext_color_)r*   r+   r)   r)   r,   Úget_text_colorä   s    zTableColumn.get_text_colorc             C   s   | j S )zF Returns the text font for the column for a specified object.
        )Ú	text_font)r*   r+   r)   r)   r,   Úget_text_fontí   s    zTableColumn.get_text_fontc             C   s   | j |ƒr| jS | jS )z^ Returns the cell background color for the column for a specified
            object.
        )Úis_editableÚcell_color_Úread_only_cell_color_)r*   r+   r)   r)   r,   Úget_cell_colorö   s    
zTableColumn.get_cell_colorc             C   s   | j S )zd Returns the cell background graph color for the column for a
            specified object.
        )Zgraph_color_)r*   r+   r)   r)   r,   Úget_graph_color  s    zTableColumn.get_graph_colorc             C   s   | j S )z] Returns the horizontal alignment for the column for a specified
            object.
        )Úhorizontal_alignment)r*   r+   r)   r)   r,   Úget_horizontal_alignment  s    z$TableColumn.get_horizontal_alignmentc             C   s   | j S )z[ Returns the vertical alignment for the column for a specified
            object.
        )Úvertical_alignment)r*   r+   r)   r)   r,   Úget_vertical_alignment  s    z"TableColumn.get_vertical_alignmentc             C   s   | j S )zM Returns the image to display for the column for a specified object.
        )Úimage)r*   r+   r)   r)   r,   Ú	get_image!  s    zTableColumn.get_imagec             C   s   | j S )zD Returns the renderer for the column of a specified object.
        )Úrenderer)r*   r+   r)   r)   r,   Úget_renderer*  s    zTableColumn.get_rendererc             C   s   | j S )zH Returns whether the column is editable for a specified object.
        )Úeditable)r*   r+   r)   r)   r,   r<   3  s    zTableColumn.is_editablec             C   s   | j S )zg Returns whether the column is automatically edited/viewed for a
            specified object.
        )Úauto_editable)r*   r+   r)   r)   r,   Úis_auto_editable=  s    zTableColumn.is_auto_editablec             C   s   | j S )zs Returns whether a specified value is valid for dropping on the
            column for a specified object.
        )Ú	droppable)r*   r+   Úvaluer)   r)   r,   Úis_droppableH  s    zTableColumn.is_droppablec             C   s   | j S )zz Returns the context menu to display when the user right-clicks on
            the column for a specified object.
        )Úmenu)r*   r+   r)   r)   r,   Úget_menuS  s    zTableColumn.get_menuc             C   s   | j S )zq Returns the tooltip to display when the user mouses over the column
            for a specified object.
        )Útooltip)r*   r+   r)   r)   r,   Úget_tooltip^  s    zTableColumn.get_tooltipc             C   s   | j S )zH Returns the view to display when clicking a non-editable cell.
        )Úview)r*   r+   r)   r)   r,   Úget_viewh  s    zTableColumn.get_viewc             C   s   | j S )z> Returns the maximum value a numeric column can have.
        )Úmaximum)r*   r+   r)   r)   r,   Úget_maximumq  s    zTableColumn.get_maximumc             C   s   dS )z4 Called when the user clicks on the column.
        Nr)   )r*   r+   r)   r)   r,   Úon_clickz  s    zTableColumn.on_clickc             C   s   dS )z4 Called when the user clicks on the column.
        Nr)   )r*   r+   r)   r)   r,   Ú	on_dclickƒ  s    zTableColumn.on_dclickc             C   s(   | j |ƒ| j |ƒk| j |ƒ| j |ƒk  S )zk Returns the result of comparing the column of two different objects.

        This is deprecated.
        )Úkey)r*   Zobject1Zobject2r)   r)   r,   ÚcmpŒ  s    zTableColumn.cmpc             C   s   | j ƒ S )z@ Returns the string representation of the table column.
        )r/   )r*   r)   r)   r,   Ú__str__˜  s    zTableColumn.__str__g      ð¿g      ð¿g      ð¿)EÚ__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚUndefinedLabelr.   r
   r6   r   Z
text_colorr   r:   r	   Z
cell_colorZread_only_cell_colorZgraph_colorrA   rC   r   Zhorizontal_marginZvertical_marginr   rE   r   rG   r   ÚvisiblerI   rJ   Zshow_checkboxrL   r   r   rO   rQ   r   r0   r2   r4   Zresize_moder   rS   rU   r-   r/   r1   r3   r5   r7   r9   r;   r?   r@   rB   rD   rF   rH   r<   rK   rN   rP   rR   rT   rV   rW   rX   rZ   r[   r)   r)   r)   r,   r   H   sh   
				
			


		

				r   c            	   @   sÖ   e Zd ZdZeZeZee	ƒZ
eZedƒZeZeddddgddd	gd
dddddgdgddddgdgddgdgddgddgƒ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d2S )3ÚObjectColumnz# A column for editing objects.
    z%sÚnamer.   r6   z|[Column Information]z!horizontal_alignment{Horizontal}@zvertical_alignment{Vertical}@z|[Alignment]rI   Ú9rL   ra   z-[Options]>z	|{Column}ztext_color@zcell_color@zread_only_cell_color@z|[UI Colors]z	|{Colors}z
text_font@z	|[Font]<>z|{Font}zmenu@z|{Menu}zeditor@z	|{Editor}c             C   s   | j dk	r| j S t| jƒS )z' Gets the label of the column.
        N)Ú_labelr   rc   )r*   r)   r)   r,   Ú
_get_labelØ  s    
zObjectColumn._get_labelc             C   s(   | j | }| _ ||kr$| jd||ƒ d S )Nr.   )re   Útrait_property_changed)r*   r.   Úoldr)   r)   r,   Ú
_set_labelß  s    zObjectColumn._set_labelc             C   sJ   yt | j|ƒ| jƒS  tk
rD } zddlm} |ƒ  dS d}~X nX dS )zJ Gets the unformatted value of the column for a specified object.
        r   )Úraise_to_debugN)r   r-   rc   Ú	ExceptionZtraitsui.apirj   )r*   r+   Úerj   r)   r)   r,   Úget_raw_valueè  s    zObjectColumn.get_raw_valuec          	   C   sN   y,| j dk	r| j | j|ƒƒS | j| j|ƒf S    tjd| jj ƒ dS dS )zH Gets the formatted value of the column for a specified object.
        Nz*Error occurred trying to format a %s valuezFormat!)Úformat_funcrm   ÚformatÚloggerÚ	exceptionÚ	__class__r\   )r*   r+   r)   r)   r,   Ú	get_valueò  s    
zObjectColumn.get_valuec             C   s
   | j |ƒS )z/Returns the drag value for the column.
        )rm   )r*   r+   r)   r)   r,   Úget_drag_value  s    zObjectColumn.get_drag_valuec             C   s   | j |ƒ\}}t|||ƒ dS )z> Sets the value of the column for a specified object.
        N)Útarget_nameÚsetattr)r*   r+   rM   Útargetrc   r)   r)   r,   Ú	set_value  s    zObjectColumn.set_valuec             C   s,   | j dk	r| j S | j|ƒ\}}|j|ƒjƒ S )z? Gets the editor for the column of a specified object.
        N)Úeditorru   Ú
base_traitÚ
get_editor)r*   r+   rw   rc   r)   r)   r,   r{     s    
zObjectColumn.get_editorc             C   s   | j S )zE Gets the editor style for the column of a specified object.
        )Ústyle)r*   r+   r)   r)   r,   Ú	get_style$  s    zObjectColumn.get_stylec             C   s
   | j |ƒS )z/ Returns the value to use for sorting.
        )rm   )r*   r+   r)   r)   r,   rY   -  s    zObjectColumn.keyc          
   C   s>   | j r:y&| j|ƒ\}}|j|ƒj|||ƒ dS    Y nX dS )zs Returns whether a specified value is valid for dropping on the
            column for a specified object.
        TF)rL   ru   rz   Úvalidate)r*   r+   rM   rw   rc   r)   r)   r,   rN   7  s    zObjectColumn.is_droppablec             C   sL   | j |ƒ}| j}|jdƒ}|dk r*||fS t||d|… ƒ||d d… fS )z< Returns the target object and name for the column.
        Ú.r   Nr   )r-   rc   Úrfindr   )r*   r+   rc   Úcolr)   r)   r,   ru   I  s    

zObjectColumn.target_nameN)r\   r]   r^   r_   r   rc   r   r.   r   r   ry   r   r|   ro   r   rn   r   Útraits_viewrf   ri   rm   rs   rt   rx   r{   r}   rY   rN   ru   r)   r)   r)   r,   rb   ¢  sJ   
	
	
	
rb   c               @   s,   e Zd ZdZeZedƒZei ƒZ	dd„ Z
dS )ÚExpressionColumnz. A column for displaying computed values.
    Fc             C   s>   yt | j| jd|iƒS  tk
r8   tjd| j ƒ dS X dS )zJ Gets the unformatted value of the column for a specified object.
        r+   z,Error evaluating table column expression: %sN)ÚevalZexpression_Úglobalsrk   rp   rq   Ú
expression)r*   r+   r)   r)   r,   rm   o  s    
zExpressionColumn.get_raw_valueN)r\   r]   r^   r_   r   r†   r   rI   r   r…   rm   r)   r)   r)   r,   rƒ   Y  s
   rƒ   c                   s¼   e Zd ZdZeZedƒZeZ	edƒZ
edƒZ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‡ fd d!„Zd"d#„ Zd$d%„ Z‡  ZS )&ÚNumericColumnz* A column for editing Numeric arrays.
    r   iØÿØ z%sr!   c             C   s   | j dk	r| j S | jS )z' Gets the label of the column.
        N)re   rc   )r*   r)   r)   r,   rf   �  s    
zNumericColumn._get_labelc             C   s(   | j | }| _ ||kr$| jd||ƒ d S )Nr.   )re   rg   )r*   r.   rh   r)   r)   r,   ri   ¤  s    zNumericColumn._set_labelc             C   s   | j S )zJ Gets the type of data for the column for a specified object row.
        )r6   )r*   r+   r)   r)   r,   r7   ­  s    zNumericColumn.get_typec             C   s   | j |ƒr| jS | jS )zK Returns the text color for the column for a specified object row.
        )Ú_is_selectedZselected_text_color_r8   )r*   r+   r)   r)   r,   r9   ¶  s    
zNumericColumn.get_text_colorc             C   s   | j |ƒr| jS | jS )zJ Returns the text font for the column for a specified object row.
        )rˆ   Úselected_text_fontr:   )r*   r+   r)   r)   r,   r;   Á  s    
zNumericColumn.get_text_fontc             C   s&   | j |ƒr | j|ƒr| jS | jS | jS )zb Returns the cell background color for the column for a specified
            object row.
        )r<   rˆ   Zselected_cell_color_r=   r>   )r*   r+   r)   r)   r,   r?   Í  s
    

zNumericColumn.get_cell_colorc             C   s   | j S )za Returns the horizontal alignment for the column for a specified
            object row.
        )rA   )r*   r+   r)   r)   r,   rB   Ü  s    z&NumericColumn.get_horizontal_alignmentc             C   s   | j S )z_ Returns the vertical alignment for the column for a specified
            object row.
        )rC   )r*   r+   r)   r)   r,   rD   æ  s    z$NumericColumn.get_vertical_alignmentc             C   s   | j S )zL Returns whether the column is editable for a specified object row.
        )rI   )r*   r+   r)   r)   r,   r<   ð  s    zNumericColumn.is_editablec             C   s   | j S )zw Returns whether a specified value is valid for dropping on the
            column for a specified object row.
        )rL   )r*   r+   ÚrowrM   r)   r)   r,   rN   ú  s    zNumericColumn.is_droppablec             C   s   | j S )z~ Returns the context menu to display when the user right-clicks on
            the column for a specified object row.
        )rO   )r*   r+   rŠ   r)   r)   r,   rP     s    zNumericColumn.get_menuc             C   s8   y(t || jƒ}y| j|f S    dS W n
   dS dS )zB Gets the value of the column for a specified object row.
        zFormat!z
Undefined!N)Úgetattrrc   ro   )r*   r+   rM   r)   r)   r,   rs     s    zNumericColumn.get_valuec             C   s"   | j |ƒ}t|| ƒ|ƒ||< dS )zB Sets the value of the column for a specified object row.
        N)Úget_data_columnr6   )r*   r+   rŠ   rM   Úcolumnr)   r)   r,   rx     s    
zNumericColumn.set_valuec                s   t t| ƒj|ƒS )zC Gets the editor for the column of a specified object row.
        )Úsuperr‡   r{   )r*   r+   )rr   r)   r,   r{   )  s    zNumericColumn.get_editorc             C   s   t || jƒS )zB Gets the entire contents of the specified object column.
        )r‹   rc   )r*   r+   r)   r)   r,   rŒ   2  s    zNumericColumn.get_data_columnc             C   s   t |dƒr|jdk	rdS dS )z= Returns whether a specified object row is selected.
        Úmodel_selectionNTF)Úhasattrr�   )r*   r+   r)   r)   r,   rˆ   ;  s    

zNumericColumn._is_selected)r\   r]   r^   r_   r   r.   r   Zselected_text_colorr   r‰   Zselected_cell_colorr   ro   rA   rf   ri   r7   r9   r;   r?   rB   rD   r<   rN   rP   rs   rx   r{   rŒ   rˆ   Ú__classcell__r)   r)   )rr   r,   r‡   ~  s.   		




		r‡   c               @   sf   e Zd ZdZeZeZdZe	ddddgddd	ggƒZ
d
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )Ú
ListColumnz! A column for editing lists.
    FÚindexr.   r6   z|[Column Information]ztext_color@zcell_color@z|[UI Colors]c             C   s   | j dk	r| j S d| jd  S )z' Gets the label of the column.
        Nz	Column %dr   )re   r“   )r*   r)   r)   r,   rf   d  s    
zListColumn._get_labelc             C   s(   | j | }| _ ||kr$| jd||ƒ d S )Nr.   )re   rg   )r*   r.   rh   r)   r)   r,   ri   k  s    zListColumn._set_labelc             C   s   t j|| j ƒS )z> Gets the value of the column for a specified object.
        )ÚsixÚ	text_typer“   )r*   r+   r)   r)   r,   rs   t  s    zListColumn.get_valuec             C   s   ||| j < dS )z> Sets the value of the column for a specified object.
        N)r“   )r*   r+   rM   r)   r)   r,   rx   }  s    zListColumn.set_valuec             C   s   dS )z? Gets the editor for the column of a specified object.
        Nr)   )r*   r+   r)   r)   r,   r{   †  s    zListColumn.get_editorc             C   s
   || j  S )z/ Returns the value to use for sorting.
        )r“   )r*   r+   r)   r)   r,   rY   �  s    zListColumn.keyN)r\   r]   r^   r_   r   r.   r   r“   rI   r   r‚   rf   ri   rs   rx   r{   rY   r)   r)   r)   r,   r’   H  s   				r’   )-r_   Ú
__future__r   r   ÚosZ
traits.apir   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   Ztraits.trait_baser   r   Zeditor_factoryr   rO   r   Z	ui_traitsr   r   r   rS   r   Úloggingr”   Ú	getLoggerr\   rp   r`   r   rb   rƒ   r‡   r’   r)   r)   r)   r,   Ú<module>   s*   D
  \ 8% K