Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BoxLayout

A layout which arranges its widgets in a single row or column. The namespace for the BoxLayout class statics.

Hierarchy

Implements

  • IIterable<Widget>
  • IDisposable

Index

Type aliases

Static Alignment

Alignment: "start" | "center" | "end" | "justify"

A type alias for a box layout alignment.

Static Direction

Direction: "left-to-right" | "right-to-left" | "top-to-bottom" | "bottom-to-top"

A type alias for a box layout direction.

Constructors

constructor

Properties

Private _alignment

_alignment: Alignment = "start"

Private _box

_box: IBoxSizing | null = null

Private _direction

_direction: Direction = "top-to-bottom"

Private _dirty

_dirty: boolean = false

Private _fixed

_fixed: number = 0

Private _items

_items: LayoutItem[] = []

Private _sizers

_sizers: BoxSizer[] = []

Private _spacing

_spacing: number = 4

Accessors

alignment

  • Get the content alignment for the box layout.

    Notes

    This is the alignment of the widgets in the layout direction.

    The alignment has no effect if the widgets can expand to fill the entire box layout.

    Returns Alignment

  • Set the content alignment for the box layout.

    Notes

    This is the alignment of the widgets in the layout direction.

    The alignment has no effect if the widgets can expand to fill the entire box layout.

    Parameters

    Returns void

direction

fitPolicy

  • Get the fit policy for the layout.

    Notes

    The fit policy controls the computed size constraints which are applied to the parent widget by the layout.

    Some layout implementations may ignore the fit policy.

    Returns FitPolicy

  • Set the fit policy for the layout.

    Notes

    The fit policy controls the computed size constraints which are applied to the parent widget by the layout.

    Some layout implementations may ignore the fit policy.

    Changing the fit policy will clear the current size constraint for the parent widget and then re-fit the parent.

    Parameters

    Returns void

isDisposed

  • get isDisposed(): boolean

parent

  • get parent(): Widget | null
  • set parent(value: Widget | null): void
  • Get the parent widget of the layout.

    Notes

    This is set automatically when installing the layout on the parent widget. The parent widget should not be set directly by user code.

    Returns Widget | null

  • Set the parent widget of the layout.

    Notes

    This is set automatically when installing the layout on the parent widget. The parent widget should not be set directly by user code.

    Parameters

    Returns void

spacing

  • get spacing(): number
  • set spacing(value: number): void
  • Get the inter-element spacing for the box layout.

    Returns number

  • Set the inter-element spacing for the box layout.

    Parameters

    • value: number

    Returns void

widgets

  • get widgets(): ReadonlyArray<Widget>

Methods

Private _fit

  • _fit(): void
  • Fit the layout to the total size required by the widgets.

    Returns void

Private _update

  • _update(offsetWidth: number, offsetHeight: number): void
  • Update the layout position and size of the widgets.

    The parent offset dimensions should be -1 if unknown.

    Parameters

    • offsetWidth: number
    • offsetHeight: number

    Returns void

addWidget

  • addWidget(widget: Widget): void
  • Add a widget to the end of the layout.

    Parameters

    • widget: Widget

      The widget to add to the layout.

      Notes

      If the widget is already contained in the layout, it will be moved.

    Returns void

Protected attachWidget

  • attachWidget(index: number, widget: Widget): void
  • Attach a widget to the parent's DOM node.

    Parameters

    • index: number

      The current index of the widget in the layout.

    • widget: Widget

      The widget to attach to the parent.

      Notes

      This is a reimplementation of the superclass method.

    Returns void

Protected detachWidget

  • detachWidget(index: number, widget: Widget): void
  • Detach a widget from the parent's DOM node.

    Parameters

    • index: number

      The previous index of the widget in the layout.

    • widget: Widget

      The widget to detach from the parent.

      Notes

      This is a reimplementation of the superclass method.

    Returns void

dispose

  • dispose(): void

Protected init

  • init(): void

insertWidget

  • insertWidget(index: number, widget: Widget): void
  • Insert a widget into the layout at the specified index.

    Parameters

    • index: number

      The index at which to insert the widget.

    • widget: Widget

      The widget to insert into the layout.

      Notes

      The index will be clamped to the bounds of the widgets.

      If the widget is already added to the layout, it will be moved.

      Undefined Behavior

      An index which is non-integral.

    Returns void

iter

Protected moveWidget

  • moveWidget(fromIndex: number, toIndex: number, widget: Widget): void
  • Move a widget in the parent's DOM node.

    Parameters

    • fromIndex: number

      The previous index of the widget in the layout.

    • toIndex: number

      The current index of the widget in the layout.

    • widget: Widget

      The widget to move in the parent.

      Notes

      This is a reimplementation of the superclass method.

    Returns void

Protected onAfterAttach

  • onAfterAttach(msg: Message): void
  • A message handler invoked on an 'after-attach' message.

    Notes

    The default implementation of this method forwards the message to all widgets. It assumes all widget nodes are attached to the parent widget node.

    This may be reimplemented by subclasses as needed.

    Parameters

    • msg: Message

    Returns void

Protected onAfterDetach

  • onAfterDetach(msg: Message): void
  • A message handler invoked on an 'after-detach' message.

    Notes

    The default implementation of this method forwards the message to all widgets. It assumes all widget nodes are attached to the parent widget node.

    This may be reimplemented by subclasses as needed.

    Parameters

    • msg: Message

    Returns void

Protected onAfterHide

  • onAfterHide(msg: Message): void
  • A message handler invoked on an 'after-hide' message.

    Notes

    The default implementation of this method forwards the message to all non-hidden widgets. It assumes all widget nodes are attached to the parent widget node.

    This may be reimplemented by subclasses as needed.

    Parameters

    • msg: Message

    Returns void

Protected onAfterShow

  • onAfterShow(msg: Message): void
  • A message handler invoked on an 'after-show' message.

    Notes

    The default implementation of this method forwards the message to all non-hidden widgets. It assumes all widget nodes are attached to the parent widget node.

    This may be reimplemented by subclasses as needed.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeAttach

  • onBeforeAttach(msg: Message): void

Protected onBeforeDetach

  • onBeforeDetach(msg: Message): void
  • A message handler invoked on a 'before-detach' message.

    Notes

    The default implementation of this method forwards the message to all widgets. It assumes all widget nodes are attached to the parent widget node.

    This may be reimplemented by subclasses as needed.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeHide

  • onBeforeHide(msg: Message): void
  • A message handler invoked on a 'before-hide' message.

    Notes

    The default implementation of this method forwards the message to all non-hidden widgets. It assumes all widget nodes are attached to the parent widget node.

    This may be reimplemented by subclasses as needed.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeShow

  • onBeforeShow(msg: Message): void

Protected onChildHidden

Protected onChildRemoved

  • A message handler invoked on a 'child-removed' message.

    Notes

    This will remove the child widget from the layout.

    Subclasses should not typically reimplement this method.

    Parameters

    Returns void

Protected onChildShown

Protected onFitRequest

  • onFitRequest(msg: Message): void

Protected onResize

Protected onUpdateRequest

  • onUpdateRequest(msg: Message): void

processParentMessage

  • processParentMessage(msg: Message): void
  • Process a message sent to the parent widget.

    Parameters

    • msg: Message

      The message sent to the parent widget.

      Notes

      This method is called by the parent widget to process a message.

      Subclasses may reimplement this method as needed.

    Returns void

removeWidget

  • removeWidget(widget: Widget): void
  • Remove a widget from the layout.

    Parameters

    • widget: Widget

      The widget to remove from the layout.

      Notes

      A widget is automatically removed from the layout when its parent is set to null. This method should only be invoked directly when removing a widget from a layout which has yet to be installed on a parent widget.

      This method does not modify the widget's parent.

    Returns void

removeWidgetAt

  • removeWidgetAt(index: number): void
  • Remove the widget at a given index from the layout.

    Parameters

    • index: number

      The index of the widget to remove.

      Notes

      A widget is automatically removed from the layout when its parent is set to null. This method should only be invoked directly when removing a widget from a layout which has yet to be installed on a parent widget.

      This method does not modify the widget's parent.

      Undefined Behavior

      An index which is non-integral.

    Returns void

Static getSizeBasis

  • getSizeBasis(widget: Widget): number
  • Get the box layout size basis for the given widget.

    Parameters

    • widget: Widget

      The widget of interest.

    Returns number

    The box layout size basis for the widget.

Static getStretch

  • getStretch(widget: Widget): number
  • Get the box layout stretch factor for the given widget.

    Parameters

    • widget: Widget

      The widget of interest.

    Returns number

    The box layout stretch factor for the widget.

Static setSizeBasis

  • setSizeBasis(widget: Widget, value: number): void
  • Set the box layout size basis for the given widget.

    Parameters

    • widget: Widget

      The widget of interest.

    • value: number

      The value for the size basis.

    Returns void

Static setStretch

  • setStretch(widget: Widget, value: number): void
  • Set the box layout stretch factor for the given widget.

    Parameters

    • widget: Widget

      The widget of interest.

    • value: number

      The value for the stretch factor.

    Returns void

Generated using TypeDoc