U
    [ed!                     @   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re 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   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 r3   d/var/www/html/services/stratfitenv/lib/python3.8/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+   )r2   txtyr3   r3   r4   _getDrawingDimensionsJ   s    
 zSlideBox._getDrawingDimensionsc              
   C   sJ   | j d }| j}| j}g }td|D ] }|t||d|d | q$|S )Nr6   r   )r   r   r   rangeappendr   ZlinearlyInterpolatedColor)r2   	numShadesfillColorStartfillColorEnd
colorsListir3   r3   r4   
_getColorsR   s    
zSlideBox._getColorsNc                 C   s,   |s|   \}}t||}||   |S )N)r9   r   adddraw)r2   Zdrawingr7   r8   r3   r3   r4   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`"?vertical   r6   g       @middle)textrH   rF   
textAnchorfontNamefontSize)rF   rG   rH   Zpointsend)rL   rH   rM   rN   rO   )0r   r&   r   r)   r+   r'   r9   rB   r	   r#   r   r   Zfaceascentr   rA   r:   r   r   xyr   widthr   heightZorientationr<   r=   r>   rF   rG   r!   r"   r   strr   r   r    r   r   r   r   r   r   r(   r,   r*   shift)
r2   gZysrR   rS   rQ   r?   fsrZxtr3   r3   r4   rC   d   s     



      
&zSlideBox.draw)N)__name__
__module____qualname____doc__ZAttrMapZAttrMapValueZisStringZisNumberZisColorOrNoneZisColorZisIntZisNumberOrNoneZisNoneOrStringZ_attrMapr5   r9   rA   rD   rC   r3   r3   r3   r4   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   r[   drD   saver3   r3   r3   r4   <module>   s    -