U
    -yag  ã                   @   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ÚstartÚ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 | _ddddgdd	d
dgddddgg| _d| _d| _tj| _d| _d| _| ¡ D ]8\}}|t| jj ¡ ƒkrÄt| ||ƒ qštd| j ƒ‚qšd S )NéÈ   éd   ç      à?g      Ð?ZNorthZSouthZEastZWestén   éx   é‚   ÚAÚBÚCÚDÚnwé   r
   r   z&invalid argument supplied for class %s)r   r   r   r   r   Ú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© r;   úT/var/www/html/myvenv/lib/python3.8/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   Úredr   )r7   ÚdÚtr;   r;   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strokeWidthrC   ÚpreProcessDatar   ÚlenÚfloatr   ÚrangeZLiner   ZstrokeDashArrayr   r   r   ÚreverseÚ	enumerater   ÚStringÚstrr!   r   r   )r7   ÚgÚrectr   ÚrowsÚcolsZrow_stepZcol_stepÚiÚx1Zx2r   Úliner   Úy1Úy2ÚjÚrowZdatumÚsr;   r;   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 r;   )rJ   )Ú.0r   r;   r;   r<   Ú
<listcomp>–   s     z.TableWidget.preProcessData.<locals>.<listcomp>)ÚmaxrN   rJ   Úextend)r7   r   Zmax_rowZrowNor[   r;   r;   r<   rI   �   s    zTableWidget.preProcessData)r"   r"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZAttrMapZAttrMapValueZisNumberZisColorOrNoneZisListOfNumbersOrNoneZisBoxAnchorZisStringZOneOfr3   r=   rG   r]   rI   r;   r;   r;   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   rb   rG   rE   ÚosÚsaveÚgetcwdr;   r;   r;   r<   Ú<module>   s    
