
    AHj                        d Z ddlmZ ddlmZ ddlmZ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
e      Z G d ded      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Zy')(z
Container widgets for quick styling.

With the exception of `Center` and `Middle` containers will fill all of the space in the parent widget.

    )annotations)ClassVar)BindingBindingType)Layout)
GridLayout)reactive)Widgetc                      e Zd ZdZdZy)	Containerz.Simple container widget, with vertical layout.z
    Container {
        width: 1fr;
        height: 1fr;
        layout: vertical;
        overflow: hidden hidden;
    }
    N__name__
__module____qualname____doc__DEFAULT_CSS     J/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/containers.pyr   r      s    8Kr   r   c                  d    e Zd ZU dZdZdZ edddd       edd	d
d       edddd       edddd       edddd       edddd       edddd       edddd       edddd       ed d!d"d      g
Zd#ed$<   	 d%d%d%dd%d%d%d&	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d) fd'Z	e
d* fd(       Z xZS )+ScrollableContainerzNA scrollable container with vertical layout, and auto scrollbars on both axis.Fz
    ScrollableContainer {
        width: 1fr;
        height: 1fr;
        layout: vertical;
        overflow: auto auto;
    }
    up	scroll_upz	Scroll Up)showdownscroll_downzScroll Downleftscroll_leftzScroll Leftrightscroll_rightzScroll Righthomescroll_homezScroll Homeend
scroll_endz
Scroll Endpageuppage_upzPage Uppagedown	page_downz	Page Downzctrl+pageup	page_leftz	Page Leftzctrl+pagedown
page_rightz
Page RightzClassVar[list[BindingType]]BINDINGSN)nameidclassesdisabled	can_focuscan_focus_childrencan_maximizec               \    t        	|   |||||d ||| _        ||| _        || _        y)a  
        Construct a scrollable container.

        Args:
            *children: Child widgets.
            name: The name of the widget.
            id: The ID of the widget in the DOM.
            classes: The CSS classes for the widget.
            disabled: Whether the widget is disabled or not.
            can_focus: Can this container be focused?
            can_focus_children: Can this container's children be focused?
            can_maximized: Allow this container to maximize? `None` to use default logic.,
        r,   r-   r.   r/   N)super__init__r0   r1   r2   )
selfr,   r-   r.   r/   r0   r1   r2   children	__class__s
            r   r6   zScrollableContainer.__init__L   sF    2 		
  &DN)&8D#(r   c                H    | j                   
t        |   S | j                   S N)r2   r5   allow_maximize)r7   r9   s    r   r<   z"ScrollableContainer.allow_maximizer   s&    $7))   r   )r8   r
   r,   
str | Noner-   r=   r.   r=   r/   boolr0   bool | Noner1   r?   r2   r?   returnNone)r@   r>   )r   r   r   r   ALLOW_MAXIMIZEr   r   r+   __annotations__r6   propertyr<   __classcell__r9   s   @r   r   r       s?   X NK 	k;U;}5A}5AeD}5A|\>)YU;
K5A{KeD|%H-H) &  "!%*.$($)$) $) 	$)
 $) $) $) ($) "$) 
$)L ! !r   r   T)r0   c                      e Zd ZdZdZy)Verticalz>An expanding container with vertical layout and no scrollbars.z~
    Vertical {
        width: 1fr;
        height: 1fr;
        layout: vertical;
        overflow: hidden hidden;
    }
    Nr   r   r   r   rH   rH   y   s    HKr   rH   c                      e Zd ZdZdZy)VerticalGroupzAA non-expanding container with vertical layout and no scrollbars.z
    VerticalGroup {
        width: 1fr;
        height: auto;
        layout: vertical;
        overflow: hidden hidden;
    }
    Nr   r   r   r   rJ   rJ      s    KKr   rJ   c                      e Zd ZdZdZy)VerticalScrollzJA container with vertical layout and an automatic scrollbar on the Y axis.zp
    VerticalScroll {
        layout: vertical;
        overflow-x: hidden;
        overflow-y: auto;
    }
    Nr   r   r   r   rL   rL      s    TKr   rL   c                      e Zd ZdZdZy)
Horizontalz@An expanding container with horizontal layout and no scrollbars.z
    Horizontal {
        width: 1fr;
        height: 1fr;
        layout: horizontal;
        overflow: hidden hidden;
    }
    Nr   r   r   r   rN   rN      s    JKr   rN   c                      e Zd ZdZdZy)HorizontalGroupzCA non-expanding container with horizontal layout and no scrollbars.z
    HorizontalGroup {
        width: 1fr;
        height: auto;
        layout: horizontal;
        overflow: hidden hidden;
    }
    Nr   r   r   r   rP   rP      s    MKr   rP   c                      e Zd ZdZdZy)HorizontalScrollzLA container with horizontal layout and an automatic scrollbar on the X axis.zt
    HorizontalScroll {
        layout: horizontal;
        overflow-y: hidden;
        overflow-x: auto;
    }
    Nr   r   r   r   rR   rR      s    VKr   rR   c                      e Zd ZdZdZy)Center0A container which aligns children on the X axis.zd
    Center {
        align-horizontal: center;
        width: 1fr;
        height: auto;
    }
    Nr   r   r   r   rT   rT          :Kr   rT   c                      e Zd ZdZdZy)RightrU   zb
    Right {
        align-horizontal: right;
        width: 1fr;
        height: auto;
    }
    Nr   r   r   r   rX   rX      rV   r   rX   c                      e Zd ZdZdZy)Middlez0A container which aligns children on the Y axis.zb
    Middle {
        align-vertical: middle;
        width: auto;
        height: 1fr;
    }
    Nr   r   r   r   rZ   rZ      rV   r   rZ   c                      e Zd ZdZdZy)CenterMiddlez3A container which aligns its children on both axis.ze
    CenterMiddle {
        align: center middle;
        width: 1fr;
        height: 1fr;
    }
    Nr   r   r   r   r\   r\      s    =Kr   r\   c                      e Zd ZdZdZy)GridzA container with grid layout.zU
    Grid {
        width: 1fr;
        height: 1fr;
        layout: grid;
    }
    Nr   r   r   r   r^   r^      s    'Kr   r^   c                       e Zd ZU dZdZ ed      Zded<    edd      Zded	<    ed
      Z	ded<   dddd
ddd
d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZ
ddZ xZS )ItemGridz3A container with grid layout and automatic columns.zZ
    ItemGrid {
        width: 1fr;
        height: auto;
        layout: grid;
    }
    Tzreactive[bool]stretch_heightN)layoutzreactive[int | None]min_column_widthFregular)r,   r-   r.   r/   rc   ra   rd   c                   t        	|   |||||d | j                  t        j                  |       | j                  t        j
                  |       | j                  t        j                  |       y)a  
        Construct a ItemGrid.

        Args:
            *children: Child widgets.
            name: The name of the widget.
            id: The ID of the widget in the DOM.
            classes: The CSS classes for the widget.
            disabled: Whether the widget is disabled or not.
            stretch_height: Expand the height of widgets to the row height.
            min_column_width: The smallest permitted column width.
            regular: All rows should have the same number of items.
        r4   N)r5   r6   set_reactiver`   ra   rc   rd   )
r7   r,   r-   r.   r/   rc   ra   rd   r8   r9   s
            r   r6   zItemGrid.__init__  sb    0 	DR8	
 	(11>B(335EF(**G4r   c                    t        |t              r4| j                  |_        | j                  |_        | j                  |_        y y r;   )
isinstancer   ra   rc   rd   )r7   rb   s     r   
pre_layoutzItemGrid.pre_layout/  s8    fj)$($7$7F!&*&;&;F#!\\FN *r   )r8   r
   r,   r=   r-   r=   r.   r=   r/   r>   rc   z
int | Nonera   r>   rd   r>   r@   rA   )rb   r   r@   rA   )r   r   r   r   r   r	   ra   rC   rc   rd   r6   ri   rE   rF   s   @r   r`   r`     s    =K &.d^NN3-5d4-H*H&uoG^-
  "'+#55 5 	5
 5 5 %5 5 5 
5>*r   r`   N)r   
__future__r   typingr   textual.bindingr   r   textual.layoutr   textual.layouts.gridr   textual.reactiver	   textual.widgetr
   r   r   rH   rJ   rL   rN   rP   rR   rT   rX   rZ   r\   r^   r`   r   r   r   <module>rq      s    #  0 ! + % !
 
V!&D V!r
v 

F 
	( 	
 

f 
	* 		V 		F 		V 		6 		6 	2*v 2*r   