CLayout
Abstract base class for geometry managers that arrange child widgets. A layout owns an ordered collection of layout items and provides common spacing, content-margin and parent-widget management.
Module layouts/CLayout.js. This class is available through the browser modules in the download.
Declared members
parentWidget(): CWidget | null;Returns the widget managed by this layout, or `null` if none is set.
setParentWidget(widget: CWidget | null): void;Sets the widget managed by this layout and reparents contained widgets.
addWidget(widget: CWidget): void;Adds a widget to the layout.
setAlignment(widget: CWidget, alignment: CAlignment | 0): boolean;Sets alignment for a directly managed widget; returns false when not found.
addStretch(stretch: number): void;Adds an empty stretch item with the specified stretch factor.
count(): number;Returns the number of items in the layout.
widgetAt(index: number): CWidget | null;Returns the widget at the specified item index, or `null`.
removeWidget(widget: CWidget): void;Removes the specified widget from the layout.
spacing(): number;Returns the spacing between layout items in pixels.
setSpacing(spacing: number): void;Sets the spacing between layout items in pixels.
contentsMargins(): CMargins;Returns a copy of the layout's content margins.
setContentsMargins(left: number, top: number, right: number, bottom: number): void;Sets the content margins in pixels.
clear(): void;Removes all items from the layout.
protected addItem(item: CLayoutItem): boolean;Adds a layout item and returns whether it was accepted.
protected insertItem(index: number, item: CLayoutItem): boolean;Inserts a layout item and returns whether it was accepted.
protected itemAt(index: number): CLayoutItem | null;Returns the layout item at the specified index, or `null`.
protected items(): readonly CLayoutItem[];Returns the layout items as a read-only array.
hasHeightForWidth(): boolean;Whether any managed widget has a width-dependent preferred height.
heightForWidth(_width: number): number;Layouts with width-dependent geometry override this calculation.
abstract sizeHint(): CSize;Returns the preferred size required by the layout.
abstract update(): void;Recalculates and applies the geometry of managed widgets.
protected static layoutAxisBounds(widget: CWidget, horizontal: boolean, geometryFallback?: boolean, width?: number): CLayoutAxisBounds;protected static layoutItemAxisBounds(item: CLayoutItem, horizontal: boolean, width?: number): CLayoutAxisBounds;Axis constraints for widget items and non-widget spacer items.
protected static itemAxisAlignment(item: CLayoutItem, horizontal: boolean): number;protected static itemWidth(item: CLayoutItem, available: number): number;Actual width within an allocated cell, respecting alignment and policy bounds.
protected static setAlignedItemGeometry(item: CLayoutItem, x: number, y: number, width: number, height: number): void;Places the item inside a cell; flags only constrain their respective axis.
protected static layoutAxisSizes(available: number, minimums: number[], preferred: number[], maximums: number[], weights: number[], priorities: number[]): number[];Internal bounded allocation; larger priorities receive extra space first.