ViewEventArgs.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. namespace Terminal.Gui;
  2. /// <summary>Args for events that relate to specific <see cref="View"/></summary>
  3. public class ViewEventArgs : EventArgs
  4. {
  5. /// <summary>Creates a new instance of the <see cref="Terminal.Gui.ViewEventArgs"/> class.</summary>
  6. /// <param name="view">The view that the event is about.</param>
  7. public ViewEventArgs (View view) { View = view; }
  8. /// <summary>The view that the event is about.</summary>
  9. /// <remarks>
  10. /// Can be different from the sender of the <see cref="EventHandler"/> for example if event describes the adding a
  11. /// child then sender may be the parent while <see cref="View"/> is the child being added.
  12. /// </remarks>
  13. public View View { get; }
  14. }
  15. /// <summary>Event arguments for the <see cref="View.LayoutComplete"/> event.</summary>
  16. public class LayoutEventArgs : EventArgs
  17. {
  18. /// <summary>Creates a new instance of the <see cref="Terminal.Gui.LayoutEventArgs"/> class.</summary>
  19. /// <param name="oldContentSize">The view that the event is about.</param>
  20. public LayoutEventArgs (Size oldContentSize) { OldContentSize = oldContentSize; }
  21. /// <summary>The viewport of the <see cref="View"/> before it was laid out.</summary>
  22. public Size OldContentSize { get; set; }
  23. }
  24. /// <summary>Event args for draw events</summary>
  25. public class DrawEventArgs : EventArgs
  26. {
  27. /// <summary>Creates a new instance of the <see cref="DrawEventArgs"/> class.</summary>
  28. /// <param name="newViewport">
  29. /// The Content-relative rectangle describing the new visible viewport into the
  30. /// <see cref="View"/>.
  31. /// </param>
  32. /// <param name="oldViewport">
  33. /// The Content-relative rectangle describing the old visible viewport into the
  34. /// <see cref="View"/>.
  35. /// </param>
  36. public DrawEventArgs (Rectangle newViewport, Rectangle oldViewport)
  37. {
  38. NewViewport = newViewport;
  39. OldViewport = oldViewport;
  40. }
  41. /// <summary>If set to true, the draw operation will be canceled, if applicable.</summary>
  42. public bool Cancel { get; set; }
  43. /// <summary>Gets the Content-relative rectangle describing the old visible viewport into the <see cref="View"/>.</summary>
  44. public Rectangle OldViewport { get; }
  45. /// <summary>Gets the Content-relative rectangle describing the currently visible viewport into the <see cref="View"/>.</summary>
  46. public Rectangle NewViewport { get; }
  47. }
  48. /// <summary>Defines the event arguments for <see cref="View.SetFocus()"/></summary>
  49. public class FocusEventArgs : EventArgs
  50. {
  51. /// <summary>Constructs.</summary>
  52. /// <param name="leaving">The view that is losing focus.</param>
  53. /// <param name="entering">The view that is gaining focus.</param>
  54. public FocusEventArgs (View leaving, View entering) {
  55. Leaving = leaving;
  56. Entering = entering;
  57. }
  58. /// <summary>
  59. /// Indicates if the current focus event has already been processed and the driver should stop notifying any other
  60. /// event subscriber. Its important to set this value to true specially when updating any View's layout from inside the
  61. /// subscriber method.
  62. /// </summary>
  63. public bool Handled { get; set; }
  64. /// <summary>Indicates the view that is losing focus.</summary>
  65. public View Leaving { get; set; }
  66. /// <summary>Indicates the view that is gaining focus.</summary>
  67. public View Entering { get; set; }
  68. }