a
    ¥Q•hî+  ã                   @   sT   d Z dZdZddlZe d¡ZdZddlmZ ej	Z	G dd	„ d	ƒZ
G d
d„ dƒZdS )z3.5.14z.A frame is a container for content on a page.
)ÚShowBoundaryValueÚFrameé    Nzreportlab.platypus)Úx1Úy1ÚwidthÚheightÚleftPaddingÚbottomPaddingÚrightPaddingÚ
topPadding)Ú	rl_configc                   @   s   e Zd Zddd„Zdd„ ZdS )	r   ©r   r   r   çš™™™™™¹?Nc                 C   s   || _ || _|| _d S ©N)Úcolorr   Ú	dashArray)Úselfr   r   r   © r   úR/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/platypus/frames.pyÚ__init__   s    zShowBoundaryValue.__init__c                 C   s   | j d uo| jdkS )Nr   )r   r   ©r   r   r   r   Ú__bool__   s    zShowBoundaryValue.__bool__)r   r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s   
r   c                   @   s–   e Zd ZdZd#dd„Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zd$dd„ZeZdd„ Zedd„ ƒZd%dd„Zdd„ Zdd „ Zd!d"„ ZdS )&r   ah  
    A Frame is a piece of space in a document that is filled by the
    "flowables" in the story.  For example in a book like document most
    pages have the text paragraphs in one or two frames.  For generality
    a page might have several frames (for example for 3 column text or
    for text that wraps around a graphic).

    After creation a Frame is not usually manipulated directly by the
    applications program -- it is used internally by the platypus modules.

    Here is a diagramatid abstraction for the definitional part of a Frame::

                width                    x2,y2
        +---------------------------------+
        | l  top padding                r | h
        | e +-------------------------+ i | e
        | f |                         | g | i
        | t |                         | h | g
        |   |                         | t | h
        | p |                         |   | t
        | a |                         | p |
        | d |                         | a |
        |   |                         | d |
        |   +-------------------------+   |
        |    bottom padding               |
        +---------------------------------+
        (x1,y1) <-- lower left corner

    NOTE!! Frames are stateful objects.  No single frame should be used in
    two documents at the same time (especially in the presence of multithreading.
    é   Nr   c                 C   sŠ   |	| _ || _|| jd< || jd< || jd< || jd< || jd< || jd< || jd< || jd< |
| _|d u rptj}|| _|  ¡  |  ¡  d S )	NÚ_x1Ú_y1Ú_widthÚ_heightÚ_leftPaddingÚ_bottomPaddingÚ_rightPaddingÚ_topPadding)	ÚidÚ_debugÚ__dict__ÚshowBoundaryr   ÚoverlapAttachedSpaceÚ_oASpaceÚ_geomÚ_reset)r   r   r   r   r   r   r	   r
   r   r$   r'   r(   r%   r   r   r   r   @   s    







zFrame.__init__c                 C   s"   |t v r| jd|  S t|ƒ‚d S ©NÚ_)Ú	_geomAttrr&   ÚAttributeError)r   Úar   r   r   Ú__getattr__Z   s    zFrame.__getattr__c                 C   s.   |t v r || jd| < |  ¡  n
|| j|< d S r,   )r.   r&   r*   )r   r0   Úvr   r   r   Ú__setattr__^   s    
zFrame.__setattr__c                 K   sV   | j  di ¡s4tD ] }d| }| j | | j d |< q| ¡ D ]\}}t| ||ƒ q<d S ©NZ
_savedGeomr-   )r&   Ú
setdefaultr.   ÚitemsÚsetattr)r   ÚkwdsÚgaÚkr2   r   r   r   Ú	_saveGeome   s    zFrame._saveGeomc                 C   sH   | j  dd ¡rDtD ](}d| }| j | d | j |< | j d= q|  ¡  d S r4   )r&   Úgetr.   r*   )r   r9   r   r   r   Ú_restoreGeomm   s    
zFrame._restoreGeomc                 C   s\   | j | j | _| j| j | _| j| j | _| j| j  | j | j	 | _
| j| j | j | _d S r   )r   r   Ú_x2r   r   Ú_y2r!   Ú_y1pr    r"   Ú_aWr#   Ú_aHr   r   r   r   r*   u   s
    zFrame._geomc                 C   s@   |   ¡  | j| j | _| j| j | _d| _d| _d| _	d| _
d S )Né   r   g        )r=   r   r    Ú_xr?   r#   Ú_yÚ_atTopÚ_prevASpaceÚ_leftExtraIndentÚ_rightExtraIndentr   r   r   r   r+   ~   s    zFrame._resetc                 C   s   | j | j | j S r   )rA   rH   rI   r   r   r   r   Ú_getAvailableWidthŒ   s    zFrame._getAvailableWidthc              
   C   s®  | |_ ||_�zvt|ddƒrJ| | ¡ W dD ]}t||ƒr,t||ƒ q,dS | j}| j}d}|  ¡ }t|ddƒ}	| j	s¨| 
¡ }| jr¨t|ddƒs’|	r˜| j}t|| j dƒ}|| | }
|
dksÀ|	rÒ| ||
¡\}}
n$W dD ]}t||ƒrØt||ƒ qØdS |
|7 }
||
8 }||t k �r†tj�s^|
| jk�s2||k�r^|�s^dd	lm} |d
|j||
|| jf ƒ‚W dD ]}t||ƒ�rdt||ƒ �qddS | ¡ }t| ddƒ}|�r¸|d j�r¸|d }|j}|j}|j}| j| | }| j| }|�s||
 | }t||| ƒ}td|| ƒ}n„||
 | }|| j| j k}|dk�sN|dk�sN|�r†|dk�r†td|�r^| jn|| j ƒ}| j}|dk�r’d|d _nd } }}|  || ||||¡ |dk�r¸| !¡  |j"|| j#| j$ ||| d� ||_| j%�röt& 'd| (¡  ¡ ||8 }| j�r t|ddƒ�r| j}|| _|| jk�r2d| _	|| _W dD ]}t||ƒ�r>t||ƒ �q>dS W dD ]}t||ƒ�rft||ƒ �qfn$dD ]}t||ƒ�rŠt||ƒ �qŠ0 dS )zô Draws the flowable at the current position.
        Returns 1 if successful, 0 if it would not fit.
        Raises a LayoutError if the object is too wide,
        or if it is too high for a totally empty frame,
        to avoid infinite loopsÚframeActionN©ÚcanvÚ_framerC   r   Ú	_ZEROSIZEFÚ_SPACETRANSFER)ÚLayoutErrorz>Flowable %s (%sx%s points) too large for frame (%sx%s points).Ú	_frameBGséÿÿÿÿÚframezframe-permanentzframe-permanent-1)Ú_sWzdrew %s))rN   rM   ÚgetattrrK   ÚhasattrÚdelattrrE   r@   rJ   rF   ÚgetSpaceBeforer)   rG   ÚmaxÚwrapÚ_FUZZr   ÚallowTableBoundsErrorsrB   Úreportlab.platypus.doctemplaterQ   Ú	__class__ÚgetSpaceAfterÚactiveÚleftÚrightÚstartr   r   r?   r#   r   ÚrenderÚpopÚdrawOnrD   rH   r%   ÚloggerÚdebugÚidentity)r   ÚflowablerM   ÚtrySplitr0   ÚyÚpÚsÚaWZzeroSizeÚhÚwrQ   ÚsaÚfbgÚbgÚfbglÚfbgrÚbgmÚfbwÚfbxÚfbhÚfbyZattr   r   r   Ú_add�   s®    
G
·6
È$ÿ,Ò
$

ûþz
Frame._addc           	   
   C   sº   | j }| j}d}| js4| ¡ }| jr4t|| j dƒ}|| | }|dkrXt|ddƒsXg S | |_||_	z0| 
| j|¡}W dD ]}t||ƒrzt||ƒ qzn dD ]}t||ƒršt||ƒ qš0 |S )z7Ask the flowable to split using up the available space.r   rO   FrL   )rE   r@   rF   rY   r)   rZ   rG   rV   rN   rM   ÚsplitrA   rW   rX   )	r   rk   rM   rm   rn   ro   rq   Úrr0   r   r   r   r~   ç   s*    
þ
zFrame.splitc                 C   sÒ   ddl m}m} t|tttfƒp(t||ƒ}d}	d}
|rJ||dƒ}|dk}n2t|tƒr||r|||jdƒ}|dk}|r||j	}	|j
}
|r²|  ¡  |  |¡ |	dkr¤|  |	¡ |
r²|  |
¡ |  ||||¡ |rÎ|  ¡  dS )zAdraw the frame boundary as a rectangle (primarily for debugging).r   )ÚColorÚtoColorrS   N)Zreportlab.lib.colorsr€   r�   Ú
isinstanceÚstrÚtupleÚlistr   r   r   r   Ú	saveStateÚsetStrokeColorÚsetLineWidthÚsetDashÚrectÚrestoreState)rM   Zsbr   r   r   r   r€   r�   Ússrr   ÚdaÚcr   r   r   Ú_drawBoundaryÿ   s(    


zFrame._drawBoundaryc              	   C   s2   |   ||p| j| j| j| j| j | j| j ¡ d S r   )r�   r'   r   r   r>   r?   )r   rM   Z__boundary__r   r   r   ÚdrawBoundary  s    ÿzFrame.drawBoundaryc                 C   sZ   | j rt d| j ¡ | jr&|  |¡ t|ƒdkrV|d }| j||dd�rV|d= q&qVq&dS )z‡Consumes objects from the front of the list until the
        frame is full.  If it cannot fit one object, raises
        an exception.z&enter Frame.addFromlist() for frame %sr   )rl   N)r%   rh   ri   r$   r'   r�   ÚlenÚadd)r   ZdrawlistrM   Úheadr   r   r   ÚaddFromList  s    
zFrame.addFromListc                 G   s   | j  dg ¡ |¡ d S )NÚ_generated_content)r&   r5   Úextend)r   ÚCr   r   r   Úadd_generated_content,  s    zFrame.add_generated_contentc                 C   s   d|   ¡ | j| jrdpdf S )Nz(%s x %s%s)Ú*Ú )rJ   rB   rF   r   r   r   r   Ú_aSpaceString/  s    zFrame._aSpaceString)r   r   r   r   Nr   NN)r   )N)r   r   r   Ú__doc__r   r1   r3   r;   r=   r*   r+   rJ   r}   r’   r~   Ústaticmethodr�   r�   r”   r˜   r›   r   r   r   r   r       s*      þ
	
V

r   )Ú__version__rœ   Ú__all__ÚloggingÚ	getLoggerrh   r.   Ú	reportlabr   r\   r   r   r   r   r   r   Ú<module>   s   

