You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB

using Mindmagma.Curses;
namespace SCI.CursesWrapper;
public class ContentWindow : Window {
public ContentWindow (nint rootScreen, InputHandler inputHandler) :
base (
0, 1,
CursesWrapper.GetWidth (rootScreen),
CursesWrapper.GetHeight (rootScreen) - 2,
inputHandler
)
{ }
/// <summary>
/// Removes current children and creates a new
/// nested child window without inner padding
/// </summary>
/// <returns>New child window</returns>
public Window CreateInnerWindow () {
Clean ();
if (TargetInputHandler is not null) {
return new Window (-1, -1, -2, -2, TargetInputHandler, this) {
BorderEnabled = false
};
} else {
return new Window (-1, -1, -2, -2, this) {
BorderEnabled = false
};
}
}
/// <summary>
/// Removes current children and creates a new
/// nested scrollable child window without inner padding
/// </summary>
/// <returns>New scrollable child window</returns>
/// <exception cref="NullReferenceException">Throws when TargetInputHandler is null</exception>
public ScrollWindow CreateInnerScrollWindow () {
if (TargetInputHandler is null) throw new NullReferenceException (
"Input handler of Content Window cannot be null when creating child ScrollWindow"
);
return new ScrollWindow (-1, -1, -2, -2, TargetInputHandler, this) {
BorderEnabled = false
};
}
/// <summary>
/// Removes all children elements and redraws the window
/// </summary>
public void Clean () {
foreach (var window in ChildWindows.ToList ()) {
window.Destroy (true);
}
// Clear window and redraw
NCurses.ClearWindow (WindowId);
SetBorder (true);
Draw ();
}
}