ViewEventArgs.cs 2.3 KB

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