o
    ]iV                     @   sH   d dl mZ d dlmZ ddlmZ G dd dZG dd dejZd	S )
    )CommentType)Image   )	xmlwriterc                   @   sF   e Zd ZdZ	ddedededededed	dfd
dZddddZdS )
ButtonTypez?
    A class to represent a button in an Excel worksheet.

    Nrowcolheightwidthbutton_numberoptionsreturnc                 C   sd   || _ || _|| _|| _d| d| _d| | _d| _d| _d| _d| _	d| _
g | _| | dS )a  
        Initialize a ButtonType instance.

        Args:
            row (int): The row number of the button.
            col (int): The column number of the button.
            height (int): The height of the button.
            width (int): The width of the button.
            button_number (int): The button number.
            options (dict): Additional options for the button.
        z
[0]!Button_ClickzButton Nr   r   )r   r   r
   r	   macrocaptiondescriptionx_scaley_scalex_offsety_offsetvertices_set_user_options)selfr   r   r	   r
   r   r    r   S/var/www/html/stock_analysis/be/venv/lib/python3.10/site-packages/xlsxwriter/vml.py__init__   s   zButtonType.__init__c                 C   s   |du rdS | d| j| _| d| j| _| d| j| _| d| j| _| d| j| _| d| j| _| drBd	|d  | _| d
rO| j|d
  | _| dr\| j|d  | _td| j | _td| j | _dS )zh
        This method handles the additional optional parameters to
        ``insert_button()``.
        Nr
   r	   r   r   r   r   r   z[0]!r   r   g      ?)	getr
   r	   r   r   r   r   r   int)r   r   r   r   r   r   C   s    


zButtonType._set_user_optionsNr   N)__name__
__module____qualname____doc__r   dictr   r   r   r   r   r   r      s&    
'r   c                   @   s  e Zd ZdZ			d[	d\ddZdd Zd\dd	Zd\d
dZd\ddZd\ddZ	d\ddZ
d\ddZd\ddZd\ddZd\ddZd\ddZd\ddZd\ddZd\d d!Zd"eddfd#d$Zd%eddfd&d'Zd(eddfd)d*Zd\d+d,Zd\d-d.Zd\d/d0Zd\d1d2Zd%eddfd3d4Zd]d5ed6eddfd7d8Zd6eddfd9d:Z d"eddfd;d<Z!d\d=d>Z"d\d?d@Z#d\dAdBZ$d\dCdDZ%d\dEdFZ&d\dGdHZ'd\dIdJZ(d\dKdLZ)d\dMdNZ*d\dOdPZ+d\dQdRZ,d\dSdTZ-d\dUdVZ.d\dWdXZ/d\dYdZZ0dS )^Vmlz8
    A class for writing the Excel XLSX Vml file.


    Nr   c                 C   s   d}|    | | |r%|   |D ]}|d7 }| ||| |d7 }q|r?|   |D ]}|d7 }| ||| |d7 }q-|r[|   d}	|D ]}
|d7 }| ||	|
 |	d7 }	qI| d | 	  d S )Nr   xml)
_write_xml_namespace_write_shapelayout_write_button_shapetype_write_button_shape_write_comment_shapetype_write_comment_shape_write_image_shapetype_write_image_shape_xml_end_tag
_xml_close)r   data_idvml_shape_idcomments_databuttons_dataheader_imagesz_indexbuttoncommentindeximager   r   r   _assemble_xml_filew   s0   	




zVml._assemble_xml_filec                 C   s@   |dd \}}}}|d9 }|d9 }|d9 }|d9 }||||fS )N            ?r   )r   r   lefttopr
   r	   r   r   r   _pixels_to_points   s   zVml._pixels_to_pointsc                 C   sB   d}|d }|d }|d }d|fd|fd|fg}|  d| d S )	Nzurn:schemas-microsoft-com:vmlzoffice:officezoffice:excelzxmlns:vzxmlns:ozxmlns:xr&   )_xml_start_tag)r   schemaxmlnsxmlns_oxmlns_x
attributesr   r   r   r'      s   zVml._write_xml_namespacec                 C   s*   dg}|  d| | | | d d S )Nv:exteditzo:shapelayout)rC   _write_idmapr/   r   r1   rH   r   r   r   r(      s   
zVml._write_shapelayoutc                 C   s   dd|fg}|  d| d S )NrI   datazo:idmap_xml_empty_tagrM   r   r   r   rL      s   zVml._write_idmapc                 C   sZ   d}d}d}d}d|fd|fd|fd|fg}|  d	| |   | d
d | d	 d S )N_x0000_t20221600,21600   m,l,21600r21600,l21600,xeid	coordsizeo:sptpathv:shapetypetrect)rC   _write_stroke_write_comment_pathr/   r   shape_idrV   sptrX   rH   r   r   r   r+      s   zVml._write_comment_shapetypec                 C   s^   d}d}d}d}d|fd|fd|fd|fg}|  d	| |   |   |   | d	 d S )
N_x0000_t201rR      rT   rU   rV   rW   rX   rY   )rC   r\   _write_button_path_write_shapetype_lockr/   r^   r   r   r   r)      s   zVml._write_button_shapetypec           	      C   s   d}d}d}d}d}d}d}d|fd|fd	|fd
|fd|fd|fd|fg}|  d| |   |   |   |   | d d S )N
_x0000_t75rR   K   rZ   zm@4@5l@4@11@9@11@9@5xefrU   rV   rW   zo:preferrelativerX   filledstrokedrY   )rC   r\   _write_formulas_write_image_path_write_aspect_ratio_lockr/   )	r   r_   rV   r`   o_preferrelativerX   rh   ri   rH   r   r   r   r-     s*   
zVml._write_image_shapetypec                 C      d}d|fg}|  d| d S )Nmiter	joinstylezv:strokerO   )r   rp   rH   r   r   r   r\   7     
zVml._write_strokec                 C   s0   g }|r	| d | d|f | d| d S )N)gradientshapeokrZ   o:connecttypev:path)appendrP   )r   rr   connecttyperH   r   r   r   r]   ?  s
   
zVml._write_comment_pathc                 C   sF   d}d}d}d}d}d|fd|fd|fd|fd|fg}|  d| d S )	Nrg   r[   shadowoko:extrusionokstrokeokfillokrs   rt   rO   )r   rw   extrusionokry   rz   rv   rH   r   r   r   rc   J  s   zVml._write_button_pathc                 C   s2   d}d}d}d|fd|fd|fg}|  d| d S )Nrg   rZ   r[   rx   rr   rs   rt   rO   )r   r{   rr   rv   rH   r   r   r   rk   \     zVml._write_image_pathc                 C   (   d}d}d|fd|fg}|  d| d S )NrK   rZ   rJ   	shapetypeo:lockrO   )r   extr~   rH   r   r   r   rd   j     zVml._write_shapetype_lockc                 C   r}   )NrK   rZ   rJ   rotationr   rO   )r   r   r   rH   r   r   r   _write_rotation_lockv  r   zVml._write_rotation_lockc                 C   r}   )NrK   rZ   rJ   aspectratior   rO   )r   r   r   rH   r   r   r   rl     r   zVml._write_aspect_ratio_lockr8   c                 C   s   d}d}d}dt | }| |j\}}}	}
|jrd}d|dd|dd	|	dd
|
dd| d| }d|fd|fd|fd|j fd|fg}| d| |   |   | 	d d | 
  | | | d d S )Nz#_x0000_t202autohidden_x0000_svisibleposition:absolute;margin-left:.15gpt;margin-top:	pt;width:
pt;height:pt;z-index:z;visibility:rU   typestyle	fillcoloro:insetmodev:shapenone)strrA   r   
is_visiblecolor_vml_rgb_hex_valuerC   _write_comment_fill_write_shadowr]   _write_comment_textbox_write_comment_client_datar/   )r   r_   r6   r8   
shape_type	insetmode
visibilityr?   r@   r
   r	   r   rH   r   r   r   r,     sD   
zVml._write_comment_shaper7   c                 C   s   d}dt | }| |j\}}}}d|dd|dd|dd|dd| d	}	d
|fd|fg}
|jd ur=|
d|jf |
d|	f |
d |
d |
d |
d | d|
 |   |   | | | 	| | 
d d S )Nz#_x0000_t201r   r   r   r   r   r   r   z;mso-wrap-style:tightrU   r   altr   )zo:buttonrZ   )r   buttonFace [67])strokecolorzwindowText [64])r   r   r   )r   rA   r   r   ru   rC   _write_button_fillr   _write_button_textbox_write_button_client_datar/   )r   r_   r6   r7   r   r?   r@   r
   r	   r   rH   r   r   r   r*     s>   






zVml._write_button_shaper:   c                 C   s   d}dt | }|j}|j}|j}|j}|j}	|j}
|j}|d | }|	d | }	dt|d d d  }dt|	d d d  }	d|d	d
|	d	d| }d|fd|fd|fd|fg}| 	d| | 
|
| |   | d d S )Nz#_x0000_t75r   g      R@r>   g      X@H   g      ?z3position:absolute;margin-left:0;margin-top:0;width:r   r   r   rU   zo:spidr   r   r   )r   
image_name_width_x_dpi_y_dpi_height_ref_id_header_positionr   rC   _write_imagedatar   r/   )r   r_   r6   r:   r   namer
   x_dpiy_dpir	   ref_idpositionr   rH   r   r   r   r.     s<   
zVml._write_image_shapec                 C   rn   )Nz#ffffe1color2v:fillrO   )r   color_2rH   r   r   r   r   %  rq   zVml._write_comment_fillc                 C   r}   )Nr   rZ   r   zo:detectmouseclickr   rO   )r   r   detectmouseclickrH   r   r   r   r   -  r   zVml._write_button_fillc                 C   s2   d}d}d}d|fd|fd|fg}|  d| d S )NrZ   blackonr   obscuredzv:shadowrO   )r   r   r   r   rH   r   r   r   r   9  r|   zVml._write_shadowc                 C   s2   d}d|fg}|  d| | d | d d S )Nmso-direction-alt:autor   	v:textboxr?   )rC   
_write_divr/   )r   r   rH   r   r   r   r   G  s
   

zVml._write_comment_textboxc                 C   s8   d}d|fdg}|  d| | d|j | d d S )Nr   r   )zo:singleclickrg   r   center)rC   r   r   r/   )r   r7   r   rH   r   r   r   r   T  s
   zVml._write_button_textboxalignr   c                 C   s:   d| }d|fg}|  d| |r| | | d d S )Nztext-align:r   div)rC   _write_button_fontr/   )r   r   r   r   rH   r   r   r   r   a  s   

zVml._write_divc                 C   s4   d}d}d}d|fd|fd|fg}|  d|| d S )NCalibri   z#000000facesizer   font_xml_data_element)r   r   r   r   r   rH   r   r   r   r   o  s   zVml._write_button_fontc                 C   sr   d}d|fg}|  d| |   |   | |j |   | |j | |j	 |j
r2|   | d d S )NNote
ObjectTypex:ClientData)rC   _write_move_with_cells_write_size_with_cells_write_anchorr   _write_auto_fill
_write_rowr   _write_columnr   r   _write_visibler/   )r   r8   object_typerH   r   r   r   r   }  s   
zVml._write_comment_client_datac                 C   s`   d}d|fg}|  d| | |j |   |   | |j |   |   | 	d d S )NButtonr   r   )
rC   r   r   _write_print_objectr   _write_fmla_macror   _write_text_halign_write_text_valignr/   )r   r7   r   rH   r   r   r   r     s   
zVml._write_button_client_datac                 C      |  d d S )Nzx:MoveWithCellsrO   r   r   r   r   r        zVml._write_move_with_cellsc                 C   r   )Nzx:SizeWithCellsrO   r   r   r   r   r     r   zVml._write_size_with_cellsc                 C   r   )Nz	x:VisiblerO   r   r   r   r   r     r   zVml._write_visiblec                 C   sX   |d d \}}}}}}}}	||||||||	g}
dd |
D }
d |
}| d| d S )Nr<   c                 S   s   g | ]}t |qS r   )r   ).0ir   r   r   
<listcomp>  s    z%Vml._write_anchor.<locals>.<listcomp>z, zx:Anchor)joinr   )r   r   	col_start	row_startx1y1col_endrow_endx2y2stringsrN   r   r   r   r     s
   
zVml._write_anchorc                 C   s   d}|  d| d S )NFalsez
x:AutoFillr   r   rN   r   r   r   r     s   zVml._write_auto_fillc                 C      |  d| d S )Nzx:Rowr   r   r   r   r   r        zVml._write_rowc                 C   r   )Nzx:Columnr   r   r   r   r   r     r   zVml._write_columnc                 C      |  dd d S )Nzx:PrintObjectr   r   r   r   r   r   r     r   zVml._write_print_objectc                 C   r   )Nzx:TextHAlignCenterr   r   r   r   r   r     r   zVml._write_text_halignc                 C   r   )Nzx:TextVAlignr   r   r   r   r   r   r     r   zVml._write_text_valignc                 C   r   )Nzx:FmlaMacror   r   r   r   r   r     r   zVml._write_fmla_macroc                 C   s(   ddt | fd|fg}| d| d S )Nzo:relidrIdzo:titlezv:imagedata)r   rP   )r   r   o_titlerH   r   r   r   r     s   zVml._write_imagedatac                 C   s   |  d | d | d | d | d | d | d | d | d	 | d
 | d | d | d | d d S )Nz
v:formulaszif lineDrawn pixelLineWidth 0z
sum @0 1 0z
sum 0 0 @1zprod @2 1 2zprod @3 21600 pixelWidthzprod @3 21600 pixelHeightz
sum @0 0 1zprod @6 1 2zprod @7 21600 pixelWidthzsum @8 21600 0zprod @7 21600 pixelHeightzsum @10 21600 0)rC   _write_formular/   r   r   r   r   rj     s   












zVml._write_formulasc                 C   s   d|fg}|  d| d S )Neqnzv:frO   )r   r   rH   r   r   r   r     s   
zVml._write_formula)NNNr   r   )1r    r!   r"   r#   r;   rA   r'   r(   rL   r+   r)   r-   r\   r]   rc   rk   rd   r   rl   r   r,   r   r*   r   r.   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rj   r   r   r   r   r   r%   k   s`    
4



	


$





41
2



 












	r%   N)	xlsxwriter.commentsr   xlsxwriter.imager    r   r   	XMLwriterr%   r   r   r   r   <module>   s
   
U