Window.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. namespace Terminal.Gui.Views;
  2. /// <summary>
  3. /// An overlapped container for other views with a border and optional title.
  4. /// </summary>
  5. /// <remarks>
  6. /// <para>
  7. /// Window has <see cref="View.BorderStyle"/> set to <see cref="float"/>, <see cref="View.Arrangement"/>
  8. /// set to <see cref="ViewArrangement.Overlapped"/>, and
  9. /// uses the "Base" <see cref="Scheme"/> scheme by default.
  10. /// </para>
  11. /// <para>
  12. /// To enable Window to be sized and moved by the user, adjust <see cref="View.Arrangement"/>.
  13. /// </para>
  14. /// </remarks>
  15. /// <seealso cref="FrameView"/>
  16. public class Window : Toplevel
  17. {
  18. private static ShadowStyle _defaultShadow = ShadowStyle.None; // Resources/config.json overrides
  19. private static LineStyle _defaultBorderStyle = LineStyle.Single; // Resources/config.json overrides
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="Window"/> class.
  22. /// </summary>
  23. public Window ()
  24. {
  25. CanFocus = true;
  26. TabStop = TabBehavior.TabGroup;
  27. Arrangement = ViewArrangement.Overlapped;
  28. SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Base);
  29. BorderStyle = DefaultBorderStyle;
  30. base.ShadowStyle = DefaultShadow;
  31. }
  32. /// <summary>
  33. /// Gets or sets whether all <see cref="Window"/>s are shown with a shadow effect by default.
  34. /// </summary>
  35. [ConfigurationProperty (Scope = typeof (ThemeScope))]
  36. public static ShadowStyle DefaultShadow
  37. {
  38. get => _defaultShadow;
  39. set => _defaultShadow = value;
  40. }
  41. // TODO: enable this
  42. ///// <summary>
  43. ///// The default <see cref="LineStyle"/> for <see cref="Window"/>'s border. The default is <see cref="LineStyle.Single"/>.
  44. ///// </summary>
  45. ///// <remarks>
  46. ///// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all <see cref="Window"/>s.
  47. ///// </remarks>
  48. /////[ConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
  49. ////public static Scheme DefaultScheme { get; set; } = Colors.Schemes ["Base"];
  50. /// <summary>
  51. /// The default <see cref="LineStyle"/> for <see cref="Window"/>'s border. The default is
  52. /// <see cref="LineStyle.Single"/>.
  53. /// </summary>
  54. /// <remarks>
  55. /// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all <see cref="Window"/>
  56. /// s.
  57. /// </remarks>
  58. [ConfigurationProperty (Scope = typeof (ThemeScope))]
  59. public static LineStyle DefaultBorderStyle
  60. {
  61. get => _defaultBorderStyle;
  62. set => _defaultBorderStyle = value;
  63. }
  64. }