B
    @\!                 @   s  d Z ddlmZmZmZmZ ddlZeeZ	ddl
mZ ddlmZ ddlmZmZmZmZmZmZmZ ddlmZ dd	lmZmZ dd
lmZ dZeG dd deZG dd deZG dd deZ eG dd deZ!G dd de!Z"G dd de!Z#dS )z& Various kinds of layout components.

    )absolute_importdivisionprint_functionunicode_literalsN   )
SizingMode)abstract)BoolEnumIntInstanceListSeqString)warning)BOTH_CHILD_AND_ROOTEMPTY_LAYOUT)Model)BoxColumn	LayoutDOMRowSpacer	WidgetBoxc               @   sZ   e Zd ZdZeddZeddZedddZe	e
ddd	Zeed
deedd ZdS )r   z4 An abstract base class for layout components.

    z:
    An optional width for the component (in pixels).
    )helpz;
    An optional height for the component (in pixels).
    Fz
    Whether the widget will be disabled when rendered. If ``True``,
    the widget will be greyed-out, and not respond to UI events.
    Zfixeda^  
    How the item being displayed should size itself. Possible values are
    ``"fixed"``, ``"scale_width"``, ``"scale_height"``, ``"scale_both"``, and
    ``"stretch_both"``.

    ``"stretch_both"`` elements are completely responsive (independently in width and height) and
    will resize to occupy all available space, even if this changes the aspect ratio of the element.
    This is sometimes called outside-in, and is a typical behavior for desktop applications.

    ``"fixed"`` elements are not responsive. They will retain their original width and height
    regardless of any subsequent browser window resize events.

    ``"scale_width"`` elements will responsively resize to fit to the width available, *while
    maintaining the original aspect ratio*. This is a typical behavior for modern websites. For a
    ``Plot``, the aspect ratio ``plot_width/plot_height`` is maintained.

    ``"scale_height"`` elements will responsively resize to fit to the height available, *while
    maintaining the original aspect ratio*. For a ``Plot``, the aspect ratio
    ``plot_width/plot_height`` is maintained. A plot with ``"scale_height"`` mode needs
    to be wrapped in a ``Row`` or ``Column`` to be responsive.

    ``"scale_both"`` elements will responsively resize to for both the width and height available,
    *while maintaining the original aspect ratio*.

    )defaultr   a  
    A list of CSS class names to add to this DOM element. Note: the class names are
    simply added as-is, no other guarantees are provided.

    It is also permissible to assign from tuples, however these are adapted -- the
    property will always contain a list.
    c             C   s   t | S )N)list)x r   3lib/python3.7/site-packages/bokeh/models/layouts.py<lambda>h   s    zLayoutDOM.<lambda>N)__name__
__module____qualname____doc__r   widthheightr	   disabledr
   r   sizing_moder   r   Zacceptsr   Zcss_classesr   r   r   r   r   4   s   r   c               @   s   e Zd ZdZdS )r   zK A container for space used to fill an empty spot in a row or column.

    N)r!   r"   r#   r$   r   r   r   r   r   k   s   r   c                   sP   e Zd ZdZ fddZeedd Zeedd Z	e
edd	d
Z  ZS )r   z9 A container for widgets that are part of a layout.

    c                sL   t |dkrd|krtdnt |dkr6t||d< tt| jf | d S )Nr   childrenz;'children' keyword cannot be used with positional arguments)len
ValueErrorr   superr   __init__)selfargskwargs)	__class__r   r   r-   u   s
    
zWidgetBox.__init__c             C   s&   ddl m} t|| js"t| S d S )Nr   )chain)	itertoolsr2   r   r)   str)r.   r2   r   r   r   _check_empty_layout|   s    zWidgetBox._check_empty_layoutc             C   sN   g }x2| j D ](}|jd k	r||jjkr|t| qW |rFd|S d S d S )Nz, )r)   documentrootsappendr4   join)r.   problemscr   r   r   _check_child_is_also_root   s    
z#WidgetBox._check_child_is_also_rootzbokeh.models.widgets.Widgetz7
    The list of widgets to put in the layout box.
    )r   )r!   r"   r#   r$   r-   r   r   r5   r   r<   r   r   r)   __classcell__r   r   )r1   r   r   q   s   r   c                   sX   e Zd ZdZ fddZdd Zeedd Zee	dd	 Z
eeed
dZ  ZS )r   zC Abstract base class for Row and Column. Do not use directly.

    c                sf   t |dkrd|krtdnt |dkr6t||d< |dg }| ||d< tt| jf | d S )Nr   r)   z;'children' keyword cannot be used with positional arguments)r*   r+   r   get_wrap_childrenr,   r   r-   )r.   r/   r0   Zunwrapped_children)r1   r   r   r-      s    
zBox.__init__c             C   sR   ddl m} g }x<|D ]4}t||r@t|g|j|j|j|jd}|| qW |S )z Wrap any Widgets of a list of child layouts in a WidgetBox.
        This allows for the convenience of just spelling Row(button1, button2).
           )Widget)r)   r(   r%   r&   r'   )	Zwidgets.widgetrA   
isinstancer   r(   r%   r&   r'   r8   )r.   r)   rA   Zwrapped_childrenZchildr   r   r   r?      s    


zBox._wrap_childrenc             C   s&   ddl m} t|| js"t| S d S )Nr   )r2   )r3   r2   r   r)   r4   )r.   r2   r   r   r   r5      s    zBox._check_empty_layoutc             C   sN   g }x2| j D ](}|jd k	r||jjkr|t| qW |rFd|S d S d S )Nz, )r)   r6   r7   r8   r4   r9   )r.   r:   r;   r   r   r   r<      s    
zBox._check_child_is_also_rootzj
    The list of children, which can be other components including plots, rows, columns, and widgets.
    )r   )r!   r"   r#   r$   r-   r?   r   r   r5   r   r<   r   r   r   r)   r=   r   r   )r1   r   r      s   r   c               @   s   e Zd ZdZdS )r   z Lay out child components in a single horizontal row.

    Children can be specified as positional arguments, as a single argument
    that is a sequence, or using the ``children`` keyword argument.
    N)r!   r"   r#   r$   r   r   r   r   r      s   r   c               @   s   e Zd ZdZdS )r   z Lay out child components in a single vertical row.

    Children can be specified as positional arguments, as a single argument
    that is a sequence, or using the ``children`` keyword argument.
    N)r!   r"   r#   r$   r   r   r   r   r      s   r   )$r$   Z
__future__r   r   r   r   ZloggingZ	getLoggerr!   logZ
core.enumsr   Zcore.has_propsr   Zcore.propertiesr	   r
   r   r   r   r   r   Zcore.validationr   Zcore.validation.warningsr   r   Zmodelr   __all__r   r   r   r   r   r   r   r   r   r   <module>	   s$   
$6!C