Table of Contents

Class PortalContentContainer

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

A portal content control that acts as a proper container for child controls. Unlike DropdownPortalContent and MenuPortalContent which paint manually, this container hosts arbitrary child controls (ListControl, ButtonControl, ScrollablePanelControl, etc.) with layout, mouse routing, keyboard delegation, and focus tracking.

public class PortalContentContainer : PortalContentBase, IDOMPaintable, IMouseAwareControl, IWindowControl, IDisposable, IHasPortalBounds, IContainer, IContainerControl
Inheritance
PortalContentContainer
Implements
Inherited Members
Extension Methods

Properties

BackgroundColor

Gets or sets the background color for the container and its child controls.

public Color BackgroundColor { get; set; }

Property Value

Color

Children

Gets the child controls in this container.

public IReadOnlyList<IWindowControl> Children { get; }

Property Value

IReadOnlyList<IWindowControl>

ForegroundColor

Gets or sets the foreground (text) color for the container and its child controls.

public Color ForegroundColor { get; set; }

Property Value

Color

GetConsoleWindowSystem

Gets the console window system instance, or null if not attached to a window system.

public ConsoleWindowSystem? GetConsoleWindowSystem { get; }

Property Value

ConsoleWindowSystem

IsDirty

Gets or sets whether this container needs to be redrawn.

public bool IsDirty { get; set; }

Property Value

bool

PortalBounds

Gets or sets the absolute screen bounds for this portal overlay.

public Rectangle PortalBounds { get; set; }

Property Value

Rectangle

Methods

AddChild(IWindowControl)

Adds a child control to the portal container.

public void AddChild(IWindowControl child)

Parameters

child IWindowControl

ClearChildren()

Removes all child controls and disposes them.

public void ClearChildren()

GetChildren()

Gets the direct child controls of this container. Does not recursively include grandchildren - recursion happens in caller.

public IReadOnlyList<IWindowControl> GetChildren()

Returns

IReadOnlyList<IWindowControl>

Read-only list of direct child controls (may include other containers)

Remarks

IMPORTANT: For HorizontalGridControl, this should return columns AND splitters in order: [Column1, Splitter1, Column2, Splitter2, Column3]

Splitters are IInteractiveControl and should be included in Tab navigation.

GetPortalBounds()

Returns the absolute position and size for this portal overlay. Subclasses must implement this to provide their bounds.

public override Rectangle GetPortalBounds()

Returns

Rectangle

GetVisibleHeightForControl(IWindowControl)

Gets the actual visible height for a control within the container viewport. Returns null if the control is not found or visibility cannot be determined.

public int? GetVisibleHeightForControl(IWindowControl control)

Parameters

control IWindowControl

The control to check

Returns

int?

The number of visible lines, or null if unknown

Invalidate(bool, IWindowControl?)

Marks this container as needing to be redrawn.

public void Invalidate(bool redrawAll, IWindowControl? callerControl = null)

Parameters

redrawAll bool

If true, forces a complete redraw of all content.

callerControl IWindowControl

The control that triggered the invalidation, if any.

MeasureDOM(LayoutConstraints)

public LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

Returns

LayoutSize

PaintPortalContent(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)

Paints the portal content. Called by PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color) after setting actual bounds.

protected override void PaintPortalContent(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultFg, Color defaultBg)

Parameters

buffer CharacterBuffer
bounds LayoutRect
clipRect LayoutRect
defaultFg Color
defaultBg Color

ProcessKey(ConsoleKeyInfo)

Processes keyboard input by delegating to the focused child or cycling focus with Tab. Returns true if the key was handled.

public bool ProcessKey(ConsoleKeyInfo key)

Parameters

key ConsoleKeyInfo

Returns

bool

ProcessMouseEvent(MouseEventArgs)

Processes a mouse event. When BorderStyle is set, coordinates are already adjusted for the border offset.

public override bool ProcessMouseEvent(MouseEventArgs args)

Parameters

args MouseEventArgs

Returns

bool

RemoveChild(IWindowControl)

Removes a child control from the portal container.

public void RemoveChild(IWindowControl child)

Parameters

child IWindowControl

SetFocusOnFirstChild()

Sets focus on the first focusable child control.

public void SetFocusOnFirstChild()

SetFocusOnLastChild()

Sets focus on the last focusable child control.

public void SetFocusOnLastChild()