CDialog
Base class for top-level dialog windows. Provides modal and non-modal display, a title bar, acceptance/rejection semantics, and basic window dragging.
import { CDialog } from "canvas-toolkit-lib";Declared members
static readonly TitleBarHeight = 20;readonly accepted: CSignal<[]>;Emitted when the dialog is accepted.
readonly rejected: CSignal<[]>;Emitted when the dialog is rejected.
static readonly CloseButtonWidth = 24;constructor(parent?: CWidget | null);Creates a dialog. @param parent Optional owner widget.
rect(): CRect;Returns the full dialog rectangle, including the title bar. @returns The dialog rectangle.
contentsRect(): CRect;Returns the rectangle available to dialog contents. @returns The content rectangle.
sizeHint(): CSize;heightForWidth(width: number): number;setVisible(visible: boolean): void;isSizeGripEnabled(): boolean;Effective setting: automatic with a layout, unless explicitly overridden. A dialog fixed on both axes never exposes a resize grip.
setSizeGripEnabled(enabled: boolean): void;Overrides automatic behavior. The grip occupies its own bottom strip.
resetSizeGripEnabled(): void;Restores automatic enabling whenever this dialog has a layout.
setLayout(layout: CLayout): void;setGeometry(x: number, y: number, width: number, height: number): void;setMinimumSize(width: number, height: number): void;setMaximumSize(width: number, height: number): void;destroy(): void;protected childOffset(): CPoint;Returns the offset applied to child widgets below the title bar. @returns The child content offset.
windowTitle(): string;Returns the dialog window title. @returns The current window title.
setWindowTitle(title: string): void;Sets the dialog window title. @param title New window title.
isOpen(): boolean;Returns whether the dialog is currently open. @returns `true` if the dialog is open.
isModal(): boolean;Returns whether the dialog is modal. @returns `true` if the dialog is modal.
setModal(modal: boolean): void;Sets whether the dialog is modal. @param modal `true` to make the dialog modal.
result(): CDialogResult;Returns the current dialog result. @returns The current acceptance result.
defaultButton(): CPushButton | null;Returns the explicitly configured default button, including if disabled.
setDefaultButton(button: CPushButton | null): void;Sets the default button; null clears it. Buttons from other dialogs are ignored.
open(): void;Opens the dialog.
exec(): void;Opens the dialog modally.
close(): void;Closes the dialog without changing its current result.
accept(): void;Accepts and closes the dialog, then emits `accepted`.
reject(): void;Rejects and closes the dialog, then emits `rejected`.
protected keyPressEvent(event: CKeyEvent): void;Handles keyboard input for the dialog. Pressing Escape rejects the dialog. @param event Key event to handle.
protected paintEvent(painter: CPainter): void;Paints the dialog frame and title bar. @param painter Painter used to render the dialog.
protected mousePressEvent(event: CMouseEvent): void;Handles mouse presses on the title bar and close button. @param event Mouse event to handle.
protected mouseMoveEvent(event: CMouseEvent): void;Handles dialog dragging and close-button hover state. @param event Mouse event to handle.
protected mouseReleaseEvent(event: CMouseEvent): void;Finishes a title-bar drag or activates the close button. @param event Mouse event to handle.
protected mouseLeaveEvent(event: CMouseEvent): void;Clears title-bar hover state when the pointer leaves the dialog. @param event Mouse event to handle.
isCenterOnOpen(): boolean;Whether opening the dialog centers it on the logical canvas. Defaults to true.
setCenterOnOpen(enabled: boolean): void;Disable before open()/exec() to preserve an explicitly configured position.
centerOnCanvas(): void;Centers the complete window, including its title bar, on the logical canvas. Owner offsets are removed because dialog geometry uses parent coordinates.