using System;
using InABox.Core;

namespace InABox.DynamicGrid
{
    public interface IDynamicEditorForm
    {
        
        event OnBeforeLoad OnBeforeLoad; 
        void BeforeLoad();
        
        event OnAfterLoad OnAfterLoad;
        void AfterLoad();
        
        event OnValidateData? OnValidateData;

        OnCustomiseColumns? OnCustomiseColumns { set; }
        OnDefineLookupFilter? OnDefineFilter { set; }

        OnDefineLookup? OnDefineLookups { set; }

        DefineEditorEventHandler? OnDefineEditor { set; }
        event OnFormCustomiseEditor? OnFormCustomiseEditor;
        OnReconfigureEditors? OnReconfigureEditors { set; }

        event OnAfterEditorValueChanged? OnAfterEditorValueChanged;
        event EditorValueChangedHandler? OnEditorValueChanged;

        event OnSelectPage? OnSelectPage;
        DynamicGridSaveEvent? OnSaveItem { set; }

        DynamicEditorPages? Pages { get; }

        bool ReadOnly { get; set; }

        BaseObject[] Items { get; set; }

        void Setup(Type type, DynamicEditorPages? pages = null, DynamicEditorButtons? buttons = null,
            Func<Type, CoreTable?>? pageDataHandler = null, bool preloadPages = false);

        IDynamicEditorControl FindEditor(string columnName);
        object? GetEditorValue(string columnName);
        void SetEditorValue(string columnName, object? value);

        void SetLayoutType<T>() where T : DynamicEditorGridLayout;

        void UnloadEditorPages(bool saved);
    }
}