a
    ¦¾ded!  ã                   @   sª   d dl mZ d dlmZmZ d dlmZmZmZm	Z	m
Z
 d dlmZ d dlT d dlT d dlmZ d dlmZ d dlmZ G d	d
„ d
eƒZedkr¦eƒ Ze ¡ jdd� dS )é    )Úcolors)ÚblackÚwhite)ÚPolygonÚStringÚDrawingÚGroupÚRect)ÚWidget)Ú*)Úcm)ÚgetFont)Ú
ShadedRectc                    @   sZ  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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edd�eedd�eedd�eedd�d�Zdd„ Zd d!„ Zd"d#„ Zd)d%d&„Zd'd(„ Zd$S )*ÚSlideBoxzReturns a slidebox widgetz Name of font used for the labels)Údescz Size of font used for the labelszColour for for number outlineszColour for number insideszColor of first boxzColor of last boxzHow many boxes there arez)Which box is highlighted by the triangleszHeight of indicator triangleszWidth of indicator triangleszColour of indicator trianglesz$Colour of indicator triangle outlinezHeight of the boxeszWidth of the boxeszSpace between the boxesz)Colour used to outline the boxes (if any)z!Width of the box outline (if any)zPadding on left of drawingzPadding on right of drawingzPadding at top of drawingzPadding at bottom of drawingz0Colour of the background to the drawing (if any)z/Text used for the 'source' label (can be empty)z(Name of font used for the 'source' labelz Font size for the 'source' labelz0Colour ink for the 'source' label (bottom right))ÚlabelFontNameÚlabelFontSizeÚlabelStrokeColorÚlabelFillColorÚ
startColorÚendColorÚnumberOfBoxesÚtrianglePositionÚtriangleHeightÚtriangleWidthÚtriangleFillColorÚtriangleStrokeColorÚtriangleStrokeWidthÚ	boxHeightÚboxWidthÚ
boxSpacingÚboxOutlineColorÚboxOutlineWidthÚleftPaddingÚrightPaddingÚ
topPaddingÚbottomPaddingÚ
backgroundÚsourceLabelTextÚsourceLabelOffsetÚsourceLabelFontNameÚsourceLabelFontSizeÚsourceLabelFillColorc                 C   sØ   d| _ d| _t| _t| _t ddd¡| _t ddd¡| _	d	| _
d	| _d
t | _dt | _t| _t| _d| _dt | _dt | _dt | _t| _d| _d| _d| _d| _d| _d | _d| _dt | _d| _d| _t| _ d S )NzHelvetica-Boldé
   gí?gì?gÞÝÝÝÝÝÝ?g¹?gSSSSSSÓ?gñðððððà?é   g¸…ëQ¸¾?gR¸…ëQØ?g�Âõ(\�â?gš™™™™™á?g\�Âõ(\ç?g333333³?é   zSource: ReportLabgš™™™™™É?zHelvetica-Obliqueé   )!r   r   r   r   r   r   r   ZColorr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   )Úself© r2   ú[/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/graphics/charts/slidebox.pyÚ__init__,   s8    





zSlideBox.__init__c                 C   sj   | j | j }| j dkr*|| j d | j  }|| j | j }| j| j }|| j | j | j	 | j
 }||fS )Né   )r   r   r    r#   r$   r   r   r%   r&   r)   r+   )r1   ÚtxÚtyr2   r2   r3   Ú_getDrawingDimensionsJ   s    zSlideBox._getDrawingDimensionsc              
   C   sJ   | j d }| j}| j}g }td|ƒD ] }| t ||d|d |¡¡ q$|S )Nr5   r   )r   r   r   ÚrangeÚappendr   ZlinearlyInterpolatedColor)r1   Ú	numShadesÚfillColorStartÚfillColorEndÚ
colorsListÚir2   r2   r3   Ú
_getColorsR   s    
zSlideBox._getColorsNc                 C   s,   |s|   ¡ \}}t||ƒ}| |  ¡ ¡ |S )N)r8   r   ÚaddÚdraw)r1   Zdrawingr6   r7   r2   r2   r3   Údemo]   s
    
zSlideBox.democ           
      C   sà  t ƒ }| j| jd  | j | j }| jrX|  ¡ \}}| t| j	 | ||d d| jd�¡ t
| jƒjjd }|dkrvd}|| j }|  ¡ }d}td| jƒD ]Ö}tƒ }||_d|_| j|_| j|_d|_d|_|| |_||d  |_d |_d|_| |¡ | t|d| j| j| j| j d d�¡ | t!|| jd	  | j| d	 t"|d ƒ| j#| j$d
| j| jd�¡ || j | j% }q˜| j&| j }	| j&dk�rœ|	| j&d | j%  }	|	| jd  }	| t'| j(| j)| j*|	| j| jd  |	| j+d  | j| jd  |	| j+d  | j| jd  |	| j| jd  gd�¡ | t'| j(| j)| j*|	d| jd  |	| j+d  d| jd  |	| j+d  d| jd  |	d| jd  gd�¡ | j,d k�rÎ| t!|| j% d| jd  | j | j | j,| j-d| j.| jd�¡ | /| j	|¡ |S )Né   r   )ÚstrokeColorÚstrokeWidthÚ	fillColorg     @�@g`åÐ"Ûùæ?Zverticalé   r5   g       @Zmiddle)ÚtextrG   rE   Ú
textAnchorÚfontNameÚfontSize)rE   rF   rG   ZpointsÚend)rI   rG   rJ   rK   rL   )0r   r&   r   r)   r+   r'   r8   rA   r	   r#   r   r   ÚfaceÚascentr   r@   r9   r   r   ÚxÚyr   Úwidthr   ÚheightZorientationr;   r<   r=   rE   rF   r!   r"   r   Ústrr   r   r    r   r   r   r   r   r   r(   r,   r*   Úshift)
r1   ÚgZysrP   rQ   rO   r>   ÚfÚsrZxtr2   r2   r3   rB   d   s–    ý


ý
úýüýü
&ûzSlideBox.draw)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ZAttrMapZAttrMapValueZisStringZisNumberZisColorOrNoneZisColorZisIntZisNumberOrNoneZisNoneOrStringZ_attrMapr4   r8   r@   rC   rB   r2   r2   r2   r3   r      sH   



























ä
r   Ú__main__Zslidebox)ZfnRootN)Zreportlab.libr   Zreportlab.lib.colorsr   r   Zreportlab.graphics.shapesr   r   r   r   r	   Zreportlab.graphics.widgetbaser
   Zreportlab.lib.attrmapZreportlab.lib.validatorsZreportlab.lib.unitsr   Zreportlab.pdfbase.pdfmetricsr   Z reportlab.graphics.widgets.gridsr   r   rY   ÚdrC   Úsaver2   r2   r2   r3   Ú<module>   s    -