Canvas Toolkit
← Class index

CTreeView

Widgets · extends CAbstractItemView

Implements the tree view widget.

import { CTreeView } from "canvas-toolkit-lib";

Declared members

static readonly RowHeight = 24;
static readonly IndentWidth = 20;
readonly expanded: CSignal<[CModelIndex]>;

Public expanded member.

readonly collapsed: CSignal<[CModelIndex]>;

Public collapsed member.

constructor(parent?: CWidget | null);

Creates a new instance.

visualRect(index: CModelIndex): CRect;

Returns the item rectangle in content-widget coordinates.

header(): CHeaderView;

Provides header behavior.

viewport(): CWidget;

Provides viewport behavior.

widget(): CWidget;

Returns the tree content widget.

horizontalScrollBar(): CScrollBar;

Provides horizontal scroll bar behavior.

verticalScrollBar(): CScrollBar;

Provides vertical scroll bar behavior.

scrollX(): number;

Provides scroll x behavior.

scrollY(): number;

Provides scroll y behavior.

setScrollX(x: number): void;

Sets the scroll x.

setScrollY(y: number): void;

Sets the scroll y.

scrollTo(x: number, y: number): void;

Provides scroll to behavior.

isExpanded(index: CModelIndex): boolean;

Returns whether the expanded condition is active.

setExpanded(index: CModelIndex, expanded: boolean): void;

Sets the expanded.

expand(index: CModelIndex): void;

Provides expand behavior.

collapse(index: CModelIndex): void;

Provides collapse behavior.

toggleExpanded(index: CModelIndex): void;

Toggles expanded.

sizeHint(): CSize;

Returns the preferred size of the widget.

setGeometry(x: number, y: number, width: number, height: number): void;

Sets the geometry.

resize(width: number, height: number): void;

Provides resize behavior.

paintRows(painter: CPainter): void;

Provides paint rows behavior.

contentMousePressEvent(event: CMouseEvent): void;

Handles the content mouse press event.

contentMouseDoubleClickEvent(event: CMouseEvent): void;

Starts editing the tree cell under a double click.

contentKeyPressEvent(event: CKeyEvent): void;

Handles the content key press event.

protected editorParent(): CWidget;

Returns the widget used as editor parent.

protected modelChanged(_oldModel: CAbstractItemModel | null, newModel: CAbstractItemModel | null): void;

Updates tree state after the model changes.

protected modelDataChanged(): void;

Rebuilds visible rows after model data changes.

protected modelReset(): void;

Clears expansion and rebuilds rows after a model reset.

protected modelRowsInserted(): void;

Rebuilds visible tree rows after rows are inserted or removed.

protected modelRowsRemoved(): void;
protected currentIndexChanged(index: CModelIndex): void;

Scrolls to and repaints a newly selected current index.

protected editorClosed(): void;

Restores focus to the tree content after editing.