using System.Linq; using System.Text.Json.Serialization; using NStack; using static Terminal.Gui.Configuration.ConfigurationManager; namespace Terminal.Gui { /// /// The FrameView is a container frame that draws a frame around the contents. It is similar to /// a GroupBox in Windows. /// public class FrameView : View { //internal class FrameViewConfig : Configuration.Config { // /// // /// // /// // /// // [JsonConverter (typeof (JsonStringEnumConverter))] // public BorderStyle? DefaultBorderStyle { get; set; } // public override void Apply () // { // if (DefaultBorderStyle.HasValue) { // FrameView.DefaultBorderStyle = DefaultBorderStyle.Value; // } // } // public override void CopyUpdatedProperitesFrom (FrameViewConfig changedConfig) // { // if (changedConfig.DefaultBorderStyle.HasValue) { // DefaultBorderStyle = changedConfig.DefaultBorderStyle; // } // } // public override void GetHardCodedDefaults () // { // DefaultBorderStyle = FrameView.DefaultBorderStyle; // } //} //[Configuration.ConfigProperty] //internal static FrameViewConfig Config { get; set; } = new FrameViewConfig (); /// /// Initializes a new instance of the class using layout. /// /// Frame. /// Title. /// Views. /// The . public FrameView (Rect frame, ustring title = null, View [] views = null, Border border = null) : base (frame) { SetInitialProperties (frame, title, views, border); } /// /// Initializes a new instance of the class using layout. /// /// Title. /// The . public FrameView (ustring title, Border border = null) { SetInitialProperties (Rect.Empty, title, null, border); } /// /// Initializes a new instance of the class using layout. /// public FrameView () : this (title: string.Empty) { BorderFrame.Thickness = new Thickness (1); BorderFrame.BorderStyle = Border.BorderStyle; BorderFrame.ColorScheme = ColorScheme; BorderFrame.Data = "BorderFrame"; } /// /// The default for . The default is . /// /// /// This property can be set in a Theme to change the default for all s. /// [SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))] public static BorderStyle DefaultBorderStyle { get; set; } = BorderStyle.Single; void SetInitialProperties (Rect frame, ustring title, View [] views = null, Border border = null) { this.Title = title; if (border == null) { Border = new Border () { BorderStyle = DefaultBorderStyle, //Title = title }; } else { Border = border; //if (ustring.IsNullOrEmpty (border.Title)) { // border.Title = title; //} } } public override void BeginInit () { base.BeginInit (); } /// public override bool OnEnter (View view) { if (Subviews.Count == 0 || !Subviews.Any (subview => subview.CanFocus)) { Application.Driver?.SetCursorVisibility (CursorVisibility.Invisible); } return base.OnEnter (view); } } }