Class ColumnContainer
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A container control that holds child controls vertically within a column of a HorizontalGridControl. Supports layout constraints, focus management, and dynamic content sizing.
public class ColumnContainer : IContainer, IInteractiveControl, IFocusableControl, IMouseAwareControl, IWindowControl, IDisposable, ILayoutAware, IDOMPaintable
- Inheritance
-
ColumnContainer
- Implements
- Inherited Members
- Extension Methods
Constructors
ColumnContainer(HorizontalGridControl)
Initializes a new instance of the ColumnContainer class.
public ColumnContainer(HorizontalGridControl horizontalGridContent)
Parameters
horizontalGridContentHorizontalGridControlThe parent horizontal grid that contains this column.
Properties
ActualWidth
Gets the actual rendered width of the control, or null if not yet rendered.
public int? ActualWidth { get; }
Property Value
- int?
BackgroundColor
Gets or sets the background color for the container and its child controls.
public Color BackgroundColor { get; set; }
Property Value
- Color
CanFocusWithMouse
Whether this control can receive focus via mouse clicks
public bool CanFocusWithMouse { get; }
Property Value
CanReceiveFocus
Whether this control can receive focus
public bool CanReceiveFocus { get; }
Property Value
Container
Gets or sets the parent container that hosts this control.
public IContainer? Container { get; set; }
Property Value
Contents
Gets the list of child controls in this column.
public IReadOnlyList<IWindowControl> Contents { get; }
Property Value
DoubleClickEnabled
Gets or sets whether double-click events are enabled for white space clicks. Default: true.
public bool DoubleClickEnabled { get; set; }
Property Value
DoubleClickThresholdMs
Gets or sets the double-click threshold in milliseconds. Two clicks within this time window are considered a double-click. Default: 500ms, minimum: 100ms.
public int DoubleClickThresholdMs { get; set; }
Property Value
FlexFactor
Gets or sets the flex factor for proportional sizing when Width is null. A value of 1.0 means equal share.
public double FlexFactor { get; set; }
Property Value
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; set; }
Property Value
HasFocus
Gets or sets whether this control currently has keyboard focus.
public bool HasFocus { get; set; }
Property Value
HorizontalAlignment
Gets or sets the horizontal alignment of the control within its container.
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
HorizontalGridContent
Gets or sets the parent horizontal grid control.
public HorizontalGridControl HorizontalGridContent { get; set; }
Property Value
IsDirty
Gets or sets a value indicating whether this column needs to be re-rendered.
public bool IsDirty { get; set; }
Property Value
IsEnabled
Gets or sets whether this control is enabled and can receive input.
public bool IsEnabled { get; set; }
Property Value
Margin
Gets or sets the margin (spacing) around the control.
public Margin Margin { get; set; }
Property Value
MaxWidth
Gets or sets the maximum width constraint for flexible columns. Null means unlimited.
public int? MaxWidth { get; set; }
Property Value
- int?
MinWidth
Gets or sets the minimum width constraint for flexible columns. Null means no minimum, defaults to 1 during layout.
public int? MinWidth { get; set; }
Property Value
- int?
Name
Gets or sets the unique name identifier for this control, used for lookup.
public string? Name { get; set; }
Property Value
StickyPosition
Gets or sets whether this control should stick to the top or bottom during scrolling.
public StickyPosition StickyPosition { get; set; }
Property Value
Tag
Gets or sets an arbitrary object value that can be used to store custom data.
public object? Tag { get; set; }
Property Value
VerticalAlignment
Gets or sets the vertical alignment of the control within its container.
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Visible
Gets or sets whether this control is visible.
public bool Visible { get; set; }
Property Value
WantsMouseEvents
Whether this control wants to receive mouse events
public bool WantsMouseEvents { get; }
Property Value
Width
Gets or sets the explicit width of the control, or null for automatic sizing.
public int? Width { get; set; }
Property Value
- int?
Methods
AddContent(IWindowControl)
Adds a child control to this column.
public void AddContent(IWindowControl content)
Parameters
contentIWindowControlThe control to add.
ClearContents()
Removes all child controls from this column.
public void ClearContents()
ContainsControl(IInteractiveControl)
Checks if the column contains the specified control.
public bool ContainsControl(IInteractiveControl control)
Parameters
controlIInteractiveControlThe control to check for.
Returns
- bool
True if the control is in this column; otherwise, false.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetActualWidth()
Gets the actual rendered width of this column based on content.
public int? GetActualWidth()
Returns
- int?
The maximum width required by content, or null if no content.
GetControlAtPosition(Point)
Finds the control at the specified position within the column.
public IInteractiveControl? GetControlAtPosition(Point position)
Parameters
positionPointPosition relative to the column.
Returns
- IInteractiveControl
The control at the position, or null if no control found.
GetControlRelativePosition(IInteractiveControl, Point)
Calculates the position relative to a specific control within the column.
public Point GetControlRelativePosition(IInteractiveControl control, Point columnPosition)
Parameters
controlIInteractiveControlThe target control.
columnPositionPointPosition relative to the column.
Returns
- Point
Position relative to the control.
GetInteractiveContents()
Gets all interactive controls contained in this column.
public List<IInteractiveControl> GetInteractiveContents()
Returns
- List<IInteractiveControl>
A list of interactive controls.
GetLayoutRequirements()
Gets the control's layout requirements. Called during the measure phase before painting.
public LayoutRequirements GetLayoutRequirements()
Returns
GetLogicalContentSize()
Gets the logical size of the control's content without rendering.
public Size GetLogicalContentSize()
Returns
- Size
The size representing the content's natural dimensions.
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()
Marks this control as needing to be re-rendered.
public void Invalidate()
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.
InvalidateOnlyColumnContents(IWindowControl?)
Invalidates only the child controls within this column without triggering parent invalidation.
public void InvalidateOnlyColumnContents(IWindowControl? callerControl = null)
Parameters
callerControlIWindowControlOptional caller control to exclude from invalidation.
MeasureDOM(LayoutConstraints)
Measures the control's desired size given the available constraints.
public LayoutSize MeasureDOM(LayoutConstraints constraints)
Parameters
constraintsLayoutConstraintsThe layout constraints (min/max width/height).
Returns
- LayoutSize
The desired size of the control.
OnLayoutAllocated(LayoutAllocation)
Notifies the control of its layout allocation. Called after layout calculation, before painting.
public void OnLayoutAllocated(LayoutAllocation allocation)
Parameters
allocationLayoutAllocation
PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)
Paints the control's content directly to a CharacterBuffer.
public void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultFg, Color defaultBg)
Parameters
bufferCharacterBufferThe buffer to paint to.
boundsLayoutRectThe absolute bounds where the control should paint.
clipRectLayoutRectThe clipping rectangle (visible area).
defaultFgColordefaultBgColor
ProcessKey(ConsoleKeyInfo)
Processes a keyboard input event.
public bool ProcessKey(ConsoleKeyInfo key)
Parameters
keyConsoleKeyInfoThe key information for the pressed key.
Returns
- bool
True if the key was handled by this control; otherwise, false.
ProcessMouseEvent(MouseEventArgs)
Processes a mouse event for this control
public bool ProcessMouseEvent(MouseEventArgs args)
Parameters
argsMouseEventArgsMouse event arguments with control-relative coordinates
Returns
- bool
True if the event was handled and should not propagate further
RemoveContent(IWindowControl)
Removes a child control from this column and disposes it.
public void RemoveContent(IWindowControl content)
Parameters
contentIWindowControlThe control to remove.
SetFocus(bool, FocusReason)
Sets focus to this control
public void SetFocus(bool focus, FocusReason reason = FocusReason.Programmatic)
Parameters
focusboolWhether to give or remove focus
reasonFocusReasonThe reason for the focus change
Events
GotFocus
Event fired when the control gains focus
public event EventHandler? GotFocus
Event Type
LostFocus
Event fired when the control loses focus
public event EventHandler? LostFocus
Event Type
MouseClick
Event fired when the control is clicked
public event EventHandler<MouseEventArgs>? MouseClick
Event Type
MouseDoubleClick
Event fired when the control is double-clicked
public event EventHandler<MouseEventArgs>? MouseDoubleClick
Event Type
MouseEnter
Event fired when the mouse enters the control area
public event EventHandler<MouseEventArgs>? MouseEnter
Event Type
MouseLeave
Event fired when the mouse leaves the control area
public event EventHandler<MouseEventArgs>? MouseLeave
Event Type
MouseMove
Event fired when the mouse moves over the control
public event EventHandler<MouseEventArgs>? MouseMove