o
    gi                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ G dd deZdS )zv
This implementation of LayoutElement acts just like Paragraph.
It also adds an outline in the document outline tree.
    N)Decimal)Color)HexColor)Font)	Rectangle)DestinationType)Hyphenation)	Alignment)	Paragraph)Document)Pagec                C       s  e Zd ZdZddeddededededddedddededejddddddddededededddejejf d	e	d
e
je dedededededededededede
je de
jee	f dededede
je de
je de
je de
je de
je de
je d ed!e
je	 d"ed#ed$ed%ed&ed'ed(ed)efB fd*d+Zededfd eded,efd-d.Zd/ed0ef fd1d2Z  ZS )3Headingz
    This implementation of LayoutElement acts just like Paragraph.
    It also adds an outline in the document outline tree.
    NF000000r      	Helvetica   textbackground_colorborder_bottomborder_colorborder_leftborder_radius_bottom_leftborder_radius_bottom_rightborder_radius_top_leftborder_radius_top_rightborder_right
border_topborder_widthfixed_leadingfont
font_color	font_sizehorizontal_alignmenthyphenationmargin_bottommargin_leftmargin_right
margin_topmultiplied_leadingoutline_leveloutline_textpadding_bottompadding_leftpadding_rightpadding_toprespect_newlines_in_textrespect_spaces_in_texttext_alignmentvertical_alignmentc"           "         s  t  jd"i d|d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d|d ur?|nt||d|pKtdd|pRtdd|d urZ|nt||d|d|d|d|d|d|d|d|d| d |! |p|| _|| _d!| _d S )#Nr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r   r&   r'   r(   r+   r,   r-   r.   r/   r0   r   r1   r2   F )super__init__r   _get_margin_for_outline_levelr   _outline_text_outline_level_has_added_outline)"selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   	__class__r3   W/home/ubuntu/.local/lib/python3.10/site-packages/borb/pdf/canvas/layout/text/heading.pyr5   !   s   $	




 !"#
%
zHeading.__init__returnc                 C   s>   t dt dt dt dt dt dd| d t d| S )	Ngq=
ףp?gV-?g\(\?gS?gjt @g7A`@)r                  r   )r   get)r)   r!   r3   r3   r=   r6   r   s   z%Heading._get_margin_for_outline_levelpageavailable_spacec                    sl   |  }t|tsJ | js(|  }|dusJ |j| j| jt	j
t|d d| _tt| || dS )aJ  
        This method paints this LayoutElement on the given Page, in the available space
        :param page:                the Page on which to paint this LayoutElement
        :param available_space:     the available space (as a Rectangle) on which to paint this LayoutElement
        :return:                    None
        N)r   leveldestination_typepage_nrT)get_root
isinstancer   r9   get_page_infoget_page_numberadd_outliner7   r8   r   FITintr4   r   paint)r:   rE   rF   prI   r;   r3   r=   rQ      s   	zHeading.paint)__name__
__module____qualname____doc__r   r   r	   LEFTTOPstrtypingOptionalr   boolUnionr   r   rP   r5   staticmethodr6   r   r   rQ   __classcell__r3   r3   r;   r=   r      s    	
 !"Qr   )rV   rZ   decimalr   borb.pdf.canvas.color.colorr   r   borb.pdf.canvas.font.fontr   "borb.pdf.canvas.geometry.rectangler   1borb.pdf.canvas.layout.annotation.link_annotationr   .borb.pdf.canvas.layout.hyphenation.hyphenationr   %borb.pdf.canvas.layout.layout_elementr	   %borb.pdf.canvas.layout.text.paragraphr
   borb.pdf.document.documentr   borb.pdf.page.pager   r   r3   r3   r3   r=   <module>   s   