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
Children
Gets the child controls in this container.
public IReadOnlyList<IWindowControl> Children { get; }
Property Value
ForegroundColor
Gets or sets the foreground (text) color for the container and its child controls.
public Color ForegroundColor { get; set; }
Property Value
GetConsoleWindowSystem
Gets the console window system instance, or null if not attached to a window system.
public ConsoleWindowSystem? GetConsoleWindowSystem { get; }
Property Value
IsDirty
Gets or sets whether this container needs to be redrawn.
public bool IsDirty { get; set; }
Property Value
PortalBounds
Gets or sets the absolute screen bounds for this portal overlay.
public Rectangle PortalBounds { get; set; }
Property Value
Methods
AddChild(IWindowControl)
Adds a child control to the portal container.
public void AddChild(IWindowControl child)
Parameters
childIWindowControl
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
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
controlIWindowControlThe 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
redrawAllboolIf true, forces a complete redraw of all content.
callerControlIWindowControlThe control that triggered the invalidation, if any.
MeasureDOM(LayoutConstraints)
public LayoutSize MeasureDOM(LayoutConstraints constraints)
Parameters
constraintsLayoutConstraints
Returns
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
bufferCharacterBufferboundsLayoutRectclipRectLayoutRectdefaultFgColordefaultBgColor
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
keyConsoleKeyInfo
Returns
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
argsMouseEventArgs
Returns
RemoveChild(IWindowControl)
Removes a child control from the portal container.
public void RemoveChild(IWindowControl child)
Parameters
childIWindowControl
SetFocusOnFirstChild()
Sets focus on the first focusable child control.
public void SetFocusOnFirstChild()
SetFocusOnLastChild()
Sets focus on the last focusable child control.
public void SetFocusOnLastChild()