Window.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. namespace Terminal.Gui;
  2. /// <summary>
  3. /// A <see cref="Toplevel"/> <see cref="View"/> with <see cref="View.BorderStyle"/> set to
  4. /// <see cref="LineStyle.Single"/>. Provides a container for other views.
  5. /// </summary>
  6. /// <remarks>
  7. /// <para>
  8. /// If any subview is a button and the <see cref="Button.IsDefault"/> property is set to true, the Enter key will
  9. /// invoke the <see cref="Command.Accept"/> command on that subview.
  10. /// </para>
  11. /// </remarks>
  12. public class Window : Toplevel
  13. {
  14. /// <summary>
  15. /// Gets or sets whether all <see cref="Window"/>s are shown with a shadow effect by default.
  16. /// </summary>
  17. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
  18. public static ShadowStyle DefaultShadow { get; set; } = ShadowStyle.None;
  19. /// <summary>
  20. /// Initializes a new instance of the <see cref="Window"/> class.
  21. /// </summary>
  22. public Window ()
  23. {
  24. CanFocus = true;
  25. TabStop = TabBehavior.TabGroup;
  26. Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped | ViewArrangement.Resizable;
  27. ColorScheme = Colors.ColorSchemes ["Base"]; // TODO: make this a theme property
  28. BorderStyle = DefaultBorderStyle;
  29. ShadowStyle = DefaultShadow;
  30. KeyBindings.Add (Key.Enter, Command.Accept);
  31. }
  32. // TODO: enable this
  33. ///// <summary>
  34. ///// The default <see cref="LineStyle"/> for <see cref="Window"/>'s border. The default is <see cref="LineStyle.Single"/>.
  35. ///// </summary>
  36. ///// <remarks>
  37. ///// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all <see cref="Window"/>s.
  38. ///// </remarks>
  39. /////[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
  40. ////public static ColorScheme DefaultColorScheme { get; set; } = Colors.ColorSchemes ["Base"];
  41. /// <summary>
  42. /// The default <see cref="LineStyle"/> for <see cref="Window"/>'s border. The default is
  43. /// <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"/>
  47. /// s.
  48. /// </remarks>
  49. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
  50. public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
  51. }