o
    ex                     @   s  d Z dZddlmZ ddlT ddlT ddlmZmZ ddl	m
Z
 ddlmZ ddl	mZ G d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZG d#d$ d$eZG d%d& d&eZG d'd( d(eZG d)d* d*eZd+d, Ze d-kre  d.S d.S )/z3.3.0a  This file is a collection of widgets to produce some common signs and symbols.

Widgets include:

- ETriangle (an equilateral triangle),
- RTriangle (a right angled triangle),
- Octagon,
- Crossbox,
- Tickbox,
- SmileyFace,
- StopSign,
- NoEntry,
- NotAllowed (the red roundel from 'no smoking' signs),
- NoSmoking,
- DangerSign (a black exclamation point in a yellow triangle),
- YesNo (returns a tickbox or a crossbox depending on a testvalue),
- FloppyDisk,
- ArrowOne, and
- ArrowTwo
- CrossHair
    )colors)*)isStr	asUnicode)shapes)Widget)	renderPDFc                
   @   sl   e Zd ZdZdZeeeddeeddeeddeeddeeeeeeeedZ	dd	 Z
d
d ZdS )_SymbolzcAbstract base widget
    possible attributes:
    'x', 'y', 'size', 'fillColor', 'strokeColor'
       zsymbol x coordinatedesczsymbol y coordinatezsymbol x coordinate adjustment)xydxdysize	fillColorstrokeColorstrokeWidthc                 C   sJ   | j jdks
J dd | _ | _ | _| _d| _tj| _	d | _
d| _d S )Nr	   z#Abstract class _Symbol instantiatedr   d   皙?)	__class____name__r   r   r   r   r   r   redr   r   r   self r   ZD:\Projects\ConvertPro\env\Lib\site-packages\reportlab/graphics/widgets/signsandsymbols.py__init__8   s   
z_Symbol.__init__c              
   C   sr   t dd}t| j}|  }d|_d|_|  || |t j	|j|d  |jd |jj
tjddd	 |S )
N   r   2   r         middle
   r   
textAnchorfontSize)r   Drawingfloatr   r   r   r   drawaddStringr   r   black)r   Dsobr   r   r   demo@   s   

z_Symbol.demoN)r   
__module____qualname____doc__Z_nodocAttrMapAttrMapValueisNumberisColorOrNone_attrMapr   r1   r   r   r   r   r	   (   s    




r	   c                   @       e Zd ZdZdd Zdd ZdS )	ETriangle#This draws an equilateral triangle.c                 C      t |  d S N)r	   r   r   r   r   r   r   P      zETriangle.__init__c                 C   sj   t | j}t }|d }tj| j| j| j| | j| j|d  | j| g| j| j|d d}|	| |S )N      ?r!         I@pointsr   r   r   
r)   r   r   GroupPolygonr   r   r   r   r+   r   r/   gaetriangler   r   r   r*   S   s   

zETriangle.drawNr   r2   r3   r4   r   r*   r   r   r   r   r;   M   s    r;   c                   @   r:   )	RTrianglezThis draws a right-angled triangle.

        possible attributes:
        'x', 'y', 'size', 'fillColor', 'strokeColor'

        c                 C   $   d| _ d| _d| _tj| _d | _d S Nr   r   )r   r   r   r   greenr   r   r   r   r   r   r   l   
   
zRTriangle.__init__c                 C   sb   t | j}t }|d }tj| j| j| j| | j| j| j| g| j| j|d d}|	| |S )Nr@   rA   rB   rD   rG   r   r   r   r*   s   s   

zRTriangle.drawNrK   r   r   r   r   rL   d       rL   c                   @   r:   )OctagonzvThis widget draws an Octagon.

        possible attributes:
        'x', 'y', 'size', 'fillColor', 'strokeColor'

    c                 C   rM   rN   )r   r   r   r   yellowr   r   r   r   r   r   r      rP   zOctagon.__init__c                 C   s   t | j}t }|d }tj| j| | j| j| j| | j| j|d  | j| | j| | j|d  | j| | j| | j|d  | j| | j| | j|d  | jg| j| jdd}|	| |S )N   r!   r$   rC   r   r   r   )
r)   r   r   rE   rF   r   r   r   r   r+   )r   r/   rH   athirdZoctagonr   r   r   r*      s$   

zOctagon.drawNrK   r   r   r   r   rR      rQ   rR   c                   @   6   e Zd ZdZeeeeeedZ	dd Z
dd ZdS )CrossboxzThis draws a black box with a red cross in it - a 'checkbox'.

        possible attributes:
        'x', 'y', 'size', 'crossColor', 'strokeColor', 'crosswidth'

    )BASE
crossColor
crosswidthc                 C   4   d| _ d| _d| _tj| _tj| _tj| _	d| _
d S Nr   r   r$   )r   r   r   r   whiter   r   rZ   r-   r   r[   r   r   r   r   r         
zCrossbox.__init__c              	   C   s   t | j}t }tj| jd | jd |d |d | j| jdd}|	| tj
| j|d  | j|d  | j|d  | j|d  | j| j| jd}|	| tj
| j|d  | j|d  | j|d  | j|d  | j| j| jd}|	| |S )Nr
   r!   r   r   r   333333?333333?)r)   r   r   rE   Rectr   r   r   r   r+   LinerZ   r[   )r   r/   rH   boxZ
crossLine1Z
crossLine2r   r   r   r*      s*   
 
4
4
zCrossbox.drawNr   r2   r3   r4   r5   r	   r6   r8   r7   r9   r   r*   r   r   r   r   rX          	rX   c                   @   rW   )TickboxzThis draws a black box with a red tick in it - another 'checkbox'.

        possible attributes:
        'x', 'y', 'size', 'tickColor', 'strokeColor', 'tickwidth'

)rY   	tickColor	tickwidthc                 C   r\   r]   )r   r   r   r   r   ri   r-   r   r^   r   rj   r   r   r   r   r      r_   zTickbox.__init__c                 C   s   t | j}t }tj| jd | jd |d |d | j| jdd}|	| tj
| j|d  | j|d  | j|d  | j|d  | j|d  | j|d  | j|d  | j|d  g| j| j| jd}|	| |S )Nr
   r!   r`   ra   ffffff?rb   rB   )r)   r   r   rE   rc   r   r   r   r   r+   PolyLineri   rj   )r   r/   rH   re   ZtickLiner   r   r   r*      s"   
 
40
zTickbox.drawNrf   r   r   r   r   rh      rg   rh   c                   @   r:   )
SmileyFacezkThis draws a classic smiley face.

        possible attributes:
        'x', 'y', 'size', 'fillColor'

    c                 C   s0   t |  d| _d| _d| _tj| _tj| _	d S rN   )
r	   r   r   r   r   r   rS   r   r-   r   r   r   r   r   r     s   
zSmileyFace.__init__c                 C   s  t | j}t }|tj| j|d  | j|d  |d | j| j	t
|d | jd dD ]+}|tj| j|d |  | j|d d  |d |d | j	| j	t
|d | jd q-| j|d  }| j|d  }|d }|}|}d	}	d
}
d}g }|j}ddlm}m}m} |d }|| }|	| }|
| }||k r|d|  }||k s|}||k r||||  }||||  }|| || || }||k stj|| j	| j	t
|d | jd}|| |S )Nr!   g      C@cxcyrr   r   r   )r
   r!   rT      r$   r`   r   iT  r
   r   sincospi     f@)r)   r   r   rE   r+   Circler   r   r   r   maxr   ZEllipseappendmathrt   ru   rv   rl   )r   r/   rH   icenterxcenteryradiusyradiusxradiusstartangledegreesendangledegreesdegreedelta
pointslistart   ru   rv   degreestoradiansradiansdelta
startangleendangleangler   r   smiler   r   r   r*     sV   
&4

zSmileyFace.drawNrK   r   r   r   r   rm         rm   c                   @   4   e Zd ZdZeeeedddZdd Z	dd Z
d	S )
StopSignzbThis draws a (British) stop sign.

        possible attributes:
        'x', 'y', 'size'

        zcolor of the word stopr   )rY   	stopColorc                 C   .   d| _ d| _d| _tj| _tj| _tj| _	d S rN   )
r   r   r   r   r-   r   	orangeredr   
ghostwhiter   r   r   r   r   r   R     zStopSign.__init__c                 C   s  t | j}t }|d }tj| j| | j| j| j| | j| j|d  | j| | j| | j|d  | j| | j| | j|d  | j| | j| | j|d  | jg| jd dd}|| tj| j| |d  | j|d  | j|d  | j| |d  | j|d  | j|d  |d  | j| |d  | j| |d  | j|d  |d  | j| |d  | j| |d  | j|d  |d  | j| |d  | j| |d  | j|d  |d  | j|d  gd | j	dd}|| | j
r|tj| j|d  | j|d  d	| j
d
|d dd |S )NrT   r!   r
   rU   K   r         ?皙?STOPr#   zHelvetica-Bold)r   r&   r'   ZfontName)r)   r   r   rE   rF   r   r   r   r+   r   r   r,   )r   r/   rH   rV   ZouterOctagonZinnerOctagonr   r   r   r*   Z  sJ   

   $$  
 zStopSign.drawNr   r2   r3   r4   r5   r	   r6   r8   r9   r   r*   r   r   r   r   r   G  s    
r   c                   @   r   )
NoEntryzThis draws a (British) No Entry sign - a red circle with a white line on it.

        possible attributes:
        'x', 'y', 'size'

        zcolor of the inner barr   )rY   innerBarColorc                 C   r   rN   )
r   r   r   r   r-   r   r   r   r   r   r   r   r   r   r     r   zNoEntry.__init__c                 C   s   t | j}t }| jr'|tj| j|d  | j|d  |d d | jdd | j	rI|tj| j|d  | j|d  |d |d  | j	d dd | j
}|rl|tj| j|d  | j|d  |d |d	 ||ddd
 |S )Nr!   r
   rn   r    r   r   r   皙?皙?)widthheightr   r   ZstrokeLineCapr   )r)   r   r   rE   r   r+   rx   r   r   r   r   rc   )r   r/   rH   r   r   r   r   r*     s   
6><zNoEntry.drawNr   r   r   r   r   r     s    
r   c                   @   s*   e Zd ZdZeedZdd Zdd ZdS )
NotAllowedzThis draws a 'forbidden' roundel (as used in the no-smoking sign).

        possible attributes:
        'x', 'y', 'size'

        )rY   c                 C   s&   d| _ d| _d| _tj| _tj| _d S rN   )r   r   r   r   r   r   r^   r   r   r   r   r   r     s
   zNotAllowed.__init__c                 C   sp  t | j}t }| j}tj| j|d  | j|d  |d |d  | j||d d}|	| | j| }| j|d  |d  }||d  }|d }|d }	d}
d}d}g }|j
}d	d
lm}m}m} |d }|| }|
| }|| }||k r|d|  }||k sv|}||k r||||  }||||  }|| || || }||k stj||||d d}|	| |S )Nr!   r$   g      $@rn      r   iZ   r   rs   rw   r`   )r)   r   r   rE   r   rx   r   r   r   r+   rz   r{   rt   ru   rv   rl   )r   r/   rH   r   ZouterCircler}   r~   r   r   r   r   r   r   r   r   rt   ru   rv   r   r   r   r   r   r   r   Zcrossbarr   r   r   r*     sB   
<


zNotAllowed.drawN)	r   r2   r3   r4   r5   r	   r9   r   r*   r   r   r   r   r     s
    
r   c                   @   r:   )	NoSmokingz^This draws a no-smoking sign.

        possible attributes:
        'x', 'y', 'size'

        c                 C   r=   r>   )r   r   r   r   r   r   r     r?   zNoSmoking.__init__c           	   	   C   s6  t | j}t| }| j|d  |d  }| j|d  |d  }tj|||d |d tj	tj
dd}||d  |d  }|d| tj|||d	 |d tjd dd}||d
  }|d| tj|||d	 |d tjd dd}||d
  }|d| tj|||d	 |d tjd dd}||d
  }|d| |S )Nr!   g      @       r   r   r   r   r   r   r   r   @   P   #   )r)   r   r   r*   r   r   r   rc   r   r   grayinsertr   )	r   r/   rH   ZnewxZnewyZcigarrette1Zcigarrette2Zcigarrette3Zcigarrette4r   r   r   r*     s2   


zNoSmoking.drawNrK   r   r   r   r   r     s    r   c                   @   r:   )
DangerSignzThis draws a 'danger' sign: a yellow box with a black exclamation point.

        possible attributes:
        'x', 'y', 'size', 'strokeColor', 'fillColor', 'strokeWidth'

        c                 C   s2   d| _ d| _d| _tj| _tj| _| jd | _d S )Nr   r   r@   )	r   r   r   r   r-   r   Zgoldr   r   r   r   r   r   r     s   zDangerSign.__init__c           	      C   s&  t | j}t }| j}|d }| j}|d }tj| j| j| j| | j| j|d  | j| gd | jdd}|	| tj| j|d  | j|d  | j| |d  | j|d  | j|d  | j| |d  g| j
d dd}|	| tj| j|d  |d  | j|d  | j|d  |d  | j|d  | j|d  |d  |d  | j|d	  | j|d  |d  |d  | j|d	  g| jd d
}|	| tj| j|d  |d  | j| | j|d  |d  | j| | j|d  |d  | j|d  | j|d  |d  | j|d  g| jd d
}|	| |S )Nr@   r!   r   rB   r    r   g      @r   g      @)rC   r   r   )r)   r   r   rE   r   rF   r   r   r   r+   r   )	r   r/   rH   ewrI   ZouterTriangleZinnerTriangleZexmarkZexdotr   r   r   r*     s^   


  ((
  
zDangerSign.drawNrK   r   r   r   r   r     r   r   c                   @   sD   e Zd ZdZeeeeeeeedZ	dd Z
dd Zdd Zd	S )
YesNoaI  This widget draw a tickbox or crossbox depending on 'testValue'.

        If this widget is supplied with a 'True' or 1 as a value for
        testValue, it will use the tickbox widget. Otherwise, it will
        produce a crossbox.

        possible attributes:
        'x', 'y', 'size', 'tickcolor', 'crosscolor', 'testValue'

)rY   	tickcolor
crosscolor	testValuec                 C   s,   d| _ d| _d| _tj| _tj| _d| _d S )Nr   r   r
   )	r   r   r   r   rO   r   r   r   r   r   r   r   r   r   a  s   
zYesNo.__init__c                 C   sH   | j rt }| j|_nt }| j|_| j|_| j|_| j	|_	|
  |S r>   )r   rh   r   ri   rX   r   rZ   r   r   r   r*   )r   ynr   r   r   r*   i  s   
z
YesNo.drawc              
   C   s  t dd}t }d|_d|_d|_d|_|  || t }d|_d|_d|_d|_|  || d	}|t j	|j|jd
  |jd|  dt
jd|d |t j	|j|jd
  |jd|  dt
jd|d d}|t j	|jd |jd | jjt
jd|d |S )Nr   r         F   r   x   r
      r!   333333?ztestValue=0r#   r%   ztestValue=1r$   U      )r   r(   r   r   r   r   r   r*   r+   r,   r   r-   r   r   )r   r.   r   Zyn2labelFontSizer   r   r   r1   w  s<   

""z
YesNo.demoN)r   r2   r3   r4   r5   r	   r6   isColorZ	isBooleanr9   r   r*   r1   r   r   r   r   r   O  s    r   c                   @   s0   e Zd ZdZeeeedZdd Z	dd Z
dS )
FloppyDiskzyThis widget draws an icon of a floppy disk.

        possible attributes:
        'x', 'y', 'size', 'diskcolor'

        )rY   	diskColorc                 C   s   d| _ d| _d| _tj| _d S rN   )r   r   r   r   r-   r   r   r   r   r   r     s   zFloppyDisk.__init__c              	   C   s8  t | j}t }tj| j| j|d  |||d  | jd dd}|| tj| j|d  | j| |d  |d |d t	j
d dd}|| tj| j|d  | j| |d  |d |d t	jd dd}|| tj| j|d	  | jd
|  | j|d  | jd
|  t	jt	jdd}|| tj| j|d	  | jd|  | j|d  | jd|  t	jt	jdd}|| tj| j|d	  | jd|  | j|d  | jd|  t	jt	jdd}|| tj| j|d  | j|d |d t	jd dd}	||	 tj| j|d  | j|d  |d |d | jd dd}
||
 |S )Nr   r   r   r   r   r   gQ?g{Gz?ra   g333333?rb   )x1y1Zx2y2r   r   r   gffffff?r   rk   gQ?gQ?gQ?)r)   r   r   rE   rc   r   r   r   r+   r   Z
whitesmokeZ	royalbluerd   r-   silver)r   r/   rH   ZdiskBodylabelZlabelsplashline1line2line3Z
metalcoverZ	coverslotr   r   r   r*     sf   
 
,
,
4
4
4
 
(
zFloppyDisk.drawN)r   r2   r3   r4   r5   r	   r6   r   r9   r   r*   r   r   r   r   r     s    r   c                   @   r:   )ArrowOnezuThis widget draws an arrow (style one).

        possible attributes:
        'x', 'y', 'size', 'fillColor'

        c                 C   *   d| _ d| _d| _tj| _d| _d | _d S rN   )r   r   r   r   r   r   r   r   r   r   r   r   r        
zArrowOne.__init__c                 C   s   t | j}t }| j}| j}|d }|d }|d }|tj||| ||d|  || |d|  || |d|  || || || || || || g| j| j	| j
d |S )Nr!   rT         rB   r)   r   r   rE   r   r   r+   rF   r   r   r   )r   r/   rH   r   r   s2s3s5r   r   r   r*     s*   
	zArrowOne.drawNrK   r   r   r   r   r     s    r   c                   @   r:   )ArrowTwozuThis widget draws an arrow (style two).

        possible attributes:
        'x', 'y', 'size', 'fillColor'

        c                 C   r   rN   )r   r   r   r   bluer   r   r   r   r   r   r   r     r   zArrowTwo.__init__c           	      C   s   t | j}t }| j}| j}|d }|d }|d }|d }|tj||d|  ||d|  |d|  |d|  |d|  |d|  || || |d|  || |d|  |d|  g| j| j	| j
d |S )	Nr!   rT   r            g     2@rB   r   )	r   r/   rH   r   r   r   r   r   Zs24r   r   r   r*     s,   
	zArrowTwo.drawNrK   r   r   r   r   r   	  r   r   c                   @   s<   e Zd ZdZeeeeee	fdddZ
dd Zdd Zd	S )
	CrossHairr<   z( gap at centre as "x%" or points or Noner   )rY   innerGapc                 C   s<   d | _  | _ | _| _d| _d | _tj| _d| _	d| _
d S )Nr   r$   r   z20%)r   r   r   r   r   r   r   r-   r   r   r   r   r   r   r   r   =  s   
zCrossHair.__init__c                 C   sH  t | j}t }| j}| j| j }| j| j }d| j }|s4|| ||| |f||| ||| fg}nKt	|rUt
|}|drN|t |d d  d }nt |d }n|d }|| ||| |f|| ||| |f||| ||| f||| ||| fg}tj| j| jd}	|D ]\}
}}}|	|
| |	|| q||	 |S )Nr   %r   g      Y@)r   r   )r)   r   r   rE   r   r   r   r   r   r   r   endswithPathr   r   ZmoveToZlineTor+   )r   r/   rH   Zigr   r   ZhsizeLgsPZx0Zy0r   r   r   r   r   r*   E  s*   

*
L
zCrossHair.drawN)r   r2   r3   r4   r5   r	   r6   ZEitherOrZisStringZisNumberOrNoner9   r   r*   r   r   r   r   r   7  s    r   c               
   C   sD  d} t dd}t }d|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d
|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d|_d|_|| |jj	d }|t j|j|jd  |jd|   |t
jd| d	 |t jdddt
jd| d d	 t }d|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d
|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }	d|	_d|	_||	 |t j|	j|	jd  |	jd|   |	jj	t
jd| d	 t }
d
|
_d|
_||
 |t j|
j|
jd  |
jd|   |
jj	t
jd| d	 t }d|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d
|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t }d|_d|_|| |t j|j|jd  |jd|   |jj	t
jd| d	 t|dd td dS )z\This function produces a pdf with examples of all the signs and symbols from this file.
    r$   i  i  r   i  r!   r   r#   r%      i@  r      r   zT(The 'YesNo' widget returns a tickbox if testvalue=1, and a crossbox if testvalue=0)g      ?i  i     zsignsandsymbols.pdfzsignsandsymbols.pyzwrote file: signsandsymbols.pdfN)r   r(   rX   r   r   r+   r,   r   r   r   r   r-   rh   r   r   r   rm   r   r   r   r   r   r   r   Z
drawToFileprint)r   r.   cbtbr   Z
tempstringssneZsfZdsnansZa1Za2fdr   r   r   testb  s   
"
"
"
"
"
"
"
"
"
"
"
"r   __main__N)!__version__r4   Zreportlab.libr   Zreportlab.lib.validatorsZreportlab.lib.attrmapZreportlab.lib.utilsr   r   Zreportlab.graphicsr   Zreportlab.graphics.widgetbaser   r   r	   r;   rL   rR   rX   rh   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s<   % %1+B=%8*DEL).+n
