a
    ¦¾de  ã                   @   sˆ   d Z ddlmZ ddlmZ ddlmZ ddlT ddlT ddl	m
Z
 G dd„ deƒZed	kr„eƒ  ¡ Zdd
lZejdge ¡ d
d� d
S )z3.3.0é    )ÚWidget)Úshapes)Úcolors)Ú*)ÚDrawingc                   @   s  e Zd ZdZeeedd�eedd�eedd�eedd�eedd�eedd�eed	d�eed
d�eedd�eedd�eedd�eedd�eddd�ee	dd�ee
dd�eedd�eedd�eeddƒdd�eeddddƒdd�d�Zd&dd„Zd d!„ Zd"d#„ Zd$d%„ ZdS )'ÚTableWidgetz%A two dimensions table of labels
    z x position of left edge of table)Údescz"y position of bottom edge of tableztable widthztable heightztable border colorztable fill colorzborder line widthz"table inner horizontal lines colorz table inner vertical lines colorz"table inner horizontal lines widthz table inner vertical lines widthzDash array for dividerLines.Nz6a list of list of strings to be displayed in the cellsz%location of the table anchoring pointztext font in the tablezfont size of the tablez
font colorÚleftÚrightzAlignment of text within cellsÚstartZmiddleÚendÚnumeric)ÚxÚyÚwidthÚheightÚborderStrokeColorÚ	fillColorÚborderStrokeWidthÚhorizontalDividerStrokeColorÚverticalDividerStrokeColorÚhorizontalDividerStrokeWidthÚverticalDividerStrokeWidthÚdividerDashArrayÚdataÚ	boxAnchorÚfontNameÚfontSizeÚ	fontColorÚ	alignmentÚ
textAnchoré
   c                 K   sÌ   || _ || _d| _d| _tj| _d | _d| _tj| _	tj| _
d| _d| _d | _g d¢g d¢g d¢g| _d| _d	| _tj| _d
| _d| _| ¡ D ]8\}}|t| jj ¡ ƒv r¸t| ||ƒ qŽtd| j ƒ‚qŽd S )NéÈ   éd   ç      à?g      Ð?)ZNorthZSouthZEastZWest)r#   én   éx   é‚   )ÚAÚBÚCÚDÚnwé   r
   r   z&invalid argument supplied for class %s)r   r   r   r   r   Zblackr   r   r   r   r   r   r   r   r   r   r   r   r   r    ÚitemsÚlistÚ	__class__Ú_attrMapÚkeysÚsetattrÚ
ValueError)Úselfr   r   ÚkwÚkÚv© r9   úY/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/graphics/widgets/table.pyÚ__init__)   s,    zTableWidget.__init__c                 C   sD   t ddƒ}tƒ }|j|dd� d|j_d|j_d|j_tj|j_	|S )z3 returns a sample of this widget with data
        i�  r"   Útable)Úname)é   é   é   Nr   )
r   r   Úaddr<   r   r   r   r   Zredr   )r5   ÚdÚtr9   r9   r:   ÚdemoF   s    

zTableWidget.democ                 C   s  t  ¡ }| js| jrNt  | j| j| j| j¡}| j|_| j|_	| j
|_| |¡ |  | j¡}t| jƒ}t| jd ƒ}| jt|ƒ }| jt|ƒ }| jrôt|ƒD ]V}| j}	| j| j }
| j||  }t  |	||
|¡}| j|_| j|_| j|_	| |¡ qœ| j�r^t|ƒD ]X}| j||  }| j}| j| j }t  ||||¡}| j|_| j|_| j|_	| |¡ �q| j ¡  t| jƒD ]”\}}| j||  d|  d| j  }t|ƒD ]`\}}|�r¢| j||  d|  }t j||t|ƒ| jd�}| j|_| j|_| j |_| |¡ �q¢�qr|S )z# returns a group of shapes
        r   r$   )r    )!r   ÚGroupr   r   ZRectr   r   r   r   ZstrokeColorr   ZstrokeWidthrA   ÚpreProcessDatar   ÚlenÚfloatr   ÚrangeZLiner   ZstrokeDashArrayr   r   r   ÚreverseÚ	enumerater   ÚStringÚstrr    r   r   )r5   ÚgZrectr   ÚrowsÚcolsZrow_stepZcol_stepÚiÚx1Zx2r   Úliner   Úy1Úy2ÚjÚrowZdatumÚsr9   r9   r:   ÚdrawR   sX    


 zTableWidget.drawc                 C   sX   |sdggS t dd„ |D ƒƒ}t|ƒD ],\}}t|ƒ|k r&| dg|t|ƒ  ¡ q&|S )zªpreprocess and return a new array with at least one row
        and column (use a None) if needed, and all rows the same
        length (adding Nones if needed)

        Nc                 S   s   g | ]}t |ƒ‘qS r9   )rG   )Ú.0r   r9   r9   r:   Ú
<listcomp>–   ó    z.TableWidget.preProcessData.<locals>.<listcomp>)ÚmaxrK   rG   Úextend)r5   r   Zmax_rowZrowNorW   r9   r9   r:   rF   �   s    zTableWidget.preProcessData)r!   r!   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZAttrMapZAttrMapValueZisNumberZisColorOrNoneZisListOfNumbersOrNoneZisBoxAnchorZisStringZOneOfr1   r;   rD   rY   rF   r9   r9   r9   r:   r      s4   
















í
;r   Ú__main__NZpdf)ÚformatsZoutDirZfnRoot)Ú__version__Zreportlab.graphics.widgetbaser   Zreportlab.graphicsr   Zreportlab.libr   Zreportlab.lib.validatorsZreportlab.lib.attrmapZreportlab.graphics.shapesr   r   r_   rD   rB   ÚosÚsaveÚgetcwdr9   r9   r9   r:   Ú<module>   s    
