ViewEventArgs.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.View"/> class.</summary>
  6. /// <param name="view"></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>The view-relative bounds of the <see cref="View"/> before it was laid out.</summary>
  19. public Rectangle OldBounds { get; set; }
  20. }
  21. /// <summary>Event args for draw events</summary>
  22. public class DrawEventArgs : EventArgs
  23. {
  24. /// <summary>Creates a new instance of the <see cref="DrawEventArgs"/> class.</summary>
  25. /// <param name="rect">
  26. /// Gets the view-relative rectangle describing the currently visible viewport into the
  27. /// <see cref="View"/>.
  28. /// </param>
  29. public DrawEventArgs (Rectangle rect) { Rectangle = rect; }
  30. /// <summary>If set to true, the draw operation will be canceled, if applicable.</summary>
  31. public bool Cancel { get; set; }
  32. /// <summary>Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.</summary>
  33. public Rectangle Rectangle { get; }
  34. }
  35. /// <summary>Defines the event arguments for <see cref="View.SetFocus()"/></summary>
  36. public class FocusEventArgs : EventArgs
  37. {
  38. /// <summary>Constructs.</summary>
  39. /// <param name="view">The view that gets or loses focus.</param>
  40. public FocusEventArgs (View view) { View = view; }
  41. /// <summary>
  42. /// Indicates if the current focus event has already been processed and the driver should stop notifying any other
  43. /// event subscriber. Its important to set this value to true specially when updating any View's layout from inside the
  44. /// subscriber method.
  45. /// </summary>
  46. public bool Handled { get; set; }
  47. /// <summary>Indicates the current view that gets or loses focus.</summary>
  48. public View View { get; set; }
  49. }