o
    vh                     @   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rDe  Zdd
lZejdge d
d d
S d
S )z3.3.0    )Widget)shapes)colors)*)Drawingc                
   @   sV  e Zd ZdZed8i deedddeedddeeddd	eed
ddeedddeedddeedddeedddeedddeedddeedddeedddeddddee	ddd ee
d!dd"eed#dd$eed%dd&eed'd(d)dd*eed+d,d-d.d)dZd9d0d1Zd2d3 Zd4d5 Zd6d7 ZdS ):TableWidgetz%A two dimensions table of labels
    xz x position of left edge of table)descyz"y position of bottom edge of tablewidthztable widthheightztable heightborderStrokeColorztable border color	fillColorztable fill colorborderStrokeWidthzborder line widthhorizontalDividerStrokeColorz"table inner horizontal lines colorverticalDividerStrokeColorz table inner vertical lines colorhorizontalDividerStrokeWidthz"table inner horizontal lines widthverticalDividerStrokeWidthz table inner vertical lines widthdividerDashArrayzDash array for dividerLines.dataNz6a list of list of strings to be displayed in the cells	boxAnchorz%location of the table anchoring pointfontNameztext font in the tablefontSizezfont size of the table	fontColorz
font color	alignmentleftrightzAlignment of text within cells
textAnchorstartmiddleendnumeric
   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 ]\}}|t| jj v r\t| || qGtd| j d S )N   d         ?g      ?)NorthSouthEastWest)r$   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?   ^/var/www/html/hyperkenya/venv/lib/python3.10/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   addrB   r   r   r   r   redr   )r;   dtr?   r?   r@   demoF   s   

zTableWidget.democ                 C   s  t  }| js
| jr't | j| j| j| j}| j|_| j|_	| j
|_|| | | j}t| j}t| jd }| jt| }| jt| }| jrzt|D ]+}| j}	| j| j }
| j||  }t |	||
|}| j|_| j|_| j|_	|| qN| jrt|D ]+}| j||  }| j}| j| j }t ||||}| j|_| j|_| j|_	|| q| j  t| jD ]G\}}| j||  d|  d| j  }t|D ].\}}|r| j||  d|  }t j||t|| jd}| j|_| j|_| j |_|| qq|S )z# returns a group of shapes
        r   r%   )r   )!r   Groupr   r   Rectr   r
   r   r   strokeColorr   strokeWidthrG   preProcessDatar   lenfloatr   rangeLiner   strokeDashArrayr   r   r   reverse	enumerater   Stringstrr   r   r   )r;   grectr   rowscolsrow_stepcol_stepix1x2r
   liner   y1y2jrowdatumsr?   r?   r@   drawR   s\   


 
zTableWidget.drawc                 C   sX   |sdggS t dd |D }t|D ]\}}t||k r)|dg|t|   q|S )zpreprocess 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?   )rQ   ).0r   r?   r?   r@   
<listcomp>   s    z.TableWidget.preProcessData.<locals>.<listcomp>)maxrW   rQ   extend)r;   r   max_rowrowNorg   r?   r?   r@   rP      s   zTableWidget.preProcessDatar?   )r"   r"   )__name__
__module____qualname____doc__AttrMapAttrMapValueisNumberisColorOrNoneisListOfNumbersOrNoneisBoxAnchorisStringOneOfr7   rA   rK   rj   rP   r?   r?   r?   r@   r      sZ    	

;r   __main__Npdf)formatsoutDirfnRoot)__version__reportlab.graphics.widgetbaser   reportlab.graphicsr   reportlab.libr   reportlab.lib.validatorsreportlab.lib.attrmapreportlab.graphics.shapesr   r   rq   rK   rI   ossavegetcwdr?   r?   r?   r@   <module>   s    
