#nullable disable
using System.Collections;
using System.Collections.Specialized;
namespace Terminal.Gui.Views;
///
/// Provides data and rendering for . Implement this interface to provide custom rendering
/// or to wrap custom data sources.
///
///
///
/// The default implementation is which renders items using
/// .
///
///
/// Implementors must manage their own marking state and raise when the
/// underlying data changes.
///
///
public interface IListDataSource : IDisposable
{
///
/// Raised when items are added, removed, moved, or the entire collection is refreshed.
///
///
/// subscribes to this event to update its display and content size when the data
/// changes. Implementations should raise this event whenever the underlying collection changes, unless
/// is .
///
event NotifyCollectionChangedEventHandler CollectionChanged;
/// Gets the number of items in the data source.
int Count { get; }
/// Determines whether the specified item is marked.
/// The zero-based index of the item.
/// if the item is marked; otherwise .
///
/// calls this method to determine whether to render the item with a mark indicator when
/// is .
///
bool IsMarked (int item);
/// Gets the width in columns of the widest item in the data source.
///
/// uses this value to set its horizontal content size for scrolling.
///
int Length { get; }
/// Renders the specified item to the .
/// The to render to.
///
/// if the item is currently selected; otherwise .
///
/// The zero-based index of the item to render.
/// The column in where rendering starts.
/// The line in where rendering occurs.
/// The width available for rendering.
/// The horizontal scroll offset.
///
///
/// calls this method for each visible item during rendering. The color scheme will be
/// set based on selection state before this method is called.
///
///
/// Implementations must fill the entire to avoid rendering artifacts.
///
///
void Render (
ListView listView,
bool selected,
int item,
int col,
int line,
int width,
int viewportX = 0
);
/// Sets the marked state of the specified item.
/// The zero-based index of the item.
/// to mark the item; to unmark it.
///
/// calls this method when the user toggles marking (e.g., via the SPACE key) if
/// is .
///
void SetMark (int item, bool value);
///
/// Gets or sets whether the event should be suppressed.
///
///
/// Set to to prevent from being raised during bulk
/// operations. Set back to to resume event notifications.
///
bool SuspendCollectionChangedEvent { get; set; }
/// Returns the underlying data source as an .
/// The data source as an .
///
/// uses this method to access individual items for events like
/// and to enable keyboard search via
/// .
///
IList ToList ();
}