using System;

namespace InABox.Core
{
    public interface IBaseEditor
    {
        Visible Visible { get; set; }

        Editable Editable { get; set; }

        string ToolTip { get; set; }

        Alignment Alignment { get; set; }

        int Width { get; set; }

        string Format { get; set; }

        int ColumnSequence { get; set; }

        int EditorSequence { get; set; }

        string Caption { get; set; }

        string? Page { get; set; }

        Summary Summary { get; set; }

        BaseEditor CloneEditor();
        public object Clone();
    }

    public abstract class BaseEditor : Attribute, IEnclosedEntity, ICloneable, IBaseEditor
    {
        protected BaseEditor()
        {
            Editable = Editable.Enabled;
            Visible = Visible.Optional;
            Alignment = Alignment.MiddleLeft;
            Width = 0;
            Format = "";
            ColumnSequence = 0;
            EditorSequence = 0;
            Caption = "";
            Summary = Summary.None;
            ToolTip = "";
        }

        [EnumLookupEditor(typeof(Visible))]
        public Visible Visible { get; set; }

        [EnumLookupEditor(typeof(Editable))]
        public Editable Editable { get; set; }

        [NullEditor]
        public string ToolTip { get; set; }

        [NullEditor]
        public Alignment Alignment { get; set; }

        [NullEditor]
        public int Width { get; set; }

        [NullEditor]
        public string Format { get; set; }

        [NullEditor]
        public int ColumnSequence { get; set; }

        [NullEditor]
        public int EditorSequence { get; set; }

        [NullEditor]
        public string Caption { get; set; }

        [NullEditor]
        public string? Page { get; set; }

        [NullEditor]
        public Summary Summary { get; set; }

        public BaseEditor CloneEditor()
        {
            var result = DoClone();
            result.Visible = Visible;
            result.Editable = Editable;
            result.Alignment = Alignment;
            result.Width = Width;
            result.Format = Format;
            result.ColumnSequence = ColumnSequence;
            result.EditorSequence = EditorSequence;
            result.Caption = Caption;
            result.Page = Page;
            result.Summary = Summary;
            result.ToolTip = ToolTip;

            return result;
        }

        public object Clone() => CloneEditor();

        protected abstract BaseEditor DoClone();
    }
}