o
    vh{                     @   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   h/var/www/html/hyperkenya/venv/lib/python3.10/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___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 )NrA   rB   rC   rE   rH   r   r   r   r*   s   s   

zRTriangle.drawNrL   r   r   r   r   rM   d       rM   c                   @   r;   )OctagonzvThis widget draws an Octagon.

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

    c                 C   rN   rO   )r   r   r   r   yellowr   r   r   r   r   r   r      rQ   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$   rD   r   r   r   )
r)   r   r   rF   rG   r   r   r   r   r+   )r   r/   rI   athirdoctagonr   r   r   r*      s$   

zOctagon.drawNrL   r   r   r   r   rS      rR   rS   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   r\   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   rF   Rectr   r   r   r   r+   Liner\   r]   )r   r/   rI   box
crossLine1
crossLine2r   r   r   r*      s*   
 
4
4
zCrossbox.drawNr   r2   r3   r4   r6   r	   r7   r9   r8   r:   r   r*   r   r   r   r   rZ          	rZ   c                   @   rY   )TickboxzThis draws a black box with a red tick in it - another 'checkbox'.

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

)r[   	tickColor	tickwidthc                 C   r^   r_   )r   r   r   r   r   rm   r-   r   r`   r   rn   r   r   r   r   r      ra   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!   rb   rc   ffffff?rd   rC   )r)   r   r   rF   re   r   r   r   r   r+   PolyLinerm   rn   )r   r/   rI   rg   tickLiner   r   r   r*      s"   
 
40
zTickbox.drawNrj   r   r   r   r   rl      rk   rl   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 rO   )
r	   r   r   r   r   r   rT   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!   rU      r$   rb   r   iT  r
   r   sincospi     f@)r)   r   r   rF   r+   Circler   r   r   r   maxr   Ellipseappendmathry   rz   r{   rp   )r   r/   rI   icenterxcenteryradiusyradiusxradiusstartangledegreesendangledegreesdegreedelta
pointslistary   rz   r{   degreestoradiansradiansdelta
startangleendangleangler   r   smiler   r   r   r*     sV   
&4

zSmileyFace.drawNrL   r   r   r   r   rr         rr   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   )r[   	stopColorc                 C   .   d| _ d| _d| _tj| _tj| _tj| _	d S rO   )
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 )NrU   r!   r
   rV   K   r         ?皙?STOPr#   zHelvetica-Bold)r   r&   r'   fontName)r)   r   r   rF   rG   r   r   r   r+   r   r   r,   )r   r/   rI   rW   outerOctagoninnerOctagonr   r   r   r*   Z  sJ   

   $$  
 zStopSign.drawNr   r2   r3   r4   r6   r	   r7   r9   r:   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   )r[   innerBarColorc                 C   r   rO   )
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
   rs   r    r   r   r   皙?皙?)widthheightr   r   strokeLineCapr   )r)   r   r   rF   r   r+   r}   r   r   r   r   re   )r   r/   rI   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'

        )r[   c                 C   s&   d| _ d| _d| _tj| _tj| _d S rO   )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      $@rs      r   iZ   r   rx   r|   rb   )r)   r   r   rF   r   r}   r   r   r   r+   r   r   ry   rz   r{   rp   )r   r/   rI   r   outerCircler   r   r   r   r   r   r   r   r   r   ry   rz   r{   r   r   r   r   r   r   r   crossbarr   r   r   r*     sB   
<


zNotAllowed.drawN)	r   r2   r3   r4   r6   r	   r:   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   re   r   r   grayinsertr   )	r   r/   rI   newxnewycigarrette1cigarrette2cigarrette3cigarrette4r   r   r   r*     s2   


zNoSmoking.drawNrL   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   rA   )	r   r   r   r   r-   r   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 )NrA   r!   r   rC   r    r   g      @r   g      @)rD   r   r   )r)   r   r   rF   r   rG   r   r   r   r+   r   )	r   r/   rI   ewrJ   outerTriangleinnerTriangleexmarkexdotr   r   r   r*     s^   


  ((
  
zDangerSign.drawNrL   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'

)r[   	tickcolor
crosscolor	testValuec                 C   s,   d| _ d| _d| _tj| _tj| _d| _d S )Nr   r   r
   )	r   r   r   r   rP   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   rl   r   rm   rZ   r   r\   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   yn2labelFontSizer   r   r   r1   w  s<   

""z
YesNo.demoN)r   r2   r3   r4   r6   r	   r7   isColor	isBooleanr:   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'

        )r[   	diskColorc                 C   s   d| _ d| _d| _tj| _d S rO   )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?rc   g333333?rd   )x1y1x2y2r   r   r   gffffff?r   ro   gQ?gQ?gQ?)r)   r   r   rF   re   r   r   r   r+   r   
whitesmoke	royalbluerf   r-   silver)r   r/   rI   diskBodylabellabelsplashline1line2line3
metalcover	coverslotr   r   r   r*     sf   
 
,
,
4
4
4
 
(
zFloppyDisk.drawN)r   r2   r3   r4   r6   r	   r7   r   r:   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 rO   )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!   rU         rC   r)   r   r   rF   r   r   r+   rG   r   r   r   )r   r/   rI   r   r   s2s3s5r   r   r   r*     s*   
	zArrowOne.drawNrL   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   rO   )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!   rU   r            g     2@rC   r   )	r   r/   rI   r   r   r   r   r   s24r   r   r   r*     s,   
	zArrowTwo.drawNrL   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   )r[   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   rF   r   r   r   r   r   r   r   endswithPathr   r   moveTolineTor+   )r   r/   rI   igr   r   hsizeLgsPx0y0r   r   r   r   r   r*   E  s*   

*
L
zCrossHair.drawN)r   r2   r3   r4   r6   r	   r7   EitherOrisStringisNumberOrNoner:   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(   rZ   r   r   r+   r,   r   r   r   r   r-   rl   r   r   r   rr   r   r   r   r   r   r   r   
drawToFileprint)r   r.   cbtbr   
tempstringssnesfdsnansa1a2fdr   r   r   testb  s   
"
"
"
"
"
"
"
"
"
"
"
"r  __main__N)!__version__r4   reportlab.libr   reportlab.lib.validatorsreportlab.lib.attrmapreportlab.lib.utilsr   r   reportlab.graphicsr   reportlab.graphics.widgetbaser   r   r	   r<   rM   rS   rZ   rl   rr   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
