Clipping.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using Terminal.Gui;
  2. namespace UICatalog.Scenarios;
  3. [ScenarioMetadata ("Clipping", "Used to test that things clip correctly")]
  4. [ScenarioCategory ("Tests")]
  5. public class Clipping : Scenario
  6. {
  7. public override void Init ()
  8. {
  9. Application.Init ();
  10. Top = new ();
  11. Top.ColorScheme = Colors.ColorSchemes ["Base"];
  12. }
  13. public override void Setup ()
  14. {
  15. //Win.X = 1;
  16. //Win.Y = 2;
  17. //Win.Width = Dim.Fill () - 4;
  18. //Win.Height = Dim.Fill () - 2;
  19. var label = new Label
  20. {
  21. X = 0, Y = 0, Text = "ScrollView (new Rectangle (3, 3, 50, 20)) with a 200, 100 ContentSize..."
  22. };
  23. Top.Add (label);
  24. var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
  25. scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
  26. scrollView.ContentSize = new (200, 100);
  27. //ContentOffset = Point.Empty,
  28. scrollView.AutoHideScrollBars = true;
  29. scrollView.ShowVerticalScrollIndicator = true;
  30. scrollView.ShowHorizontalScrollIndicator = true;
  31. var embedded1 = new View
  32. {
  33. Title = "1",
  34. X = 3,
  35. Y = 3,
  36. Width = Dim.Fill (3),
  37. Height = Dim.Fill (3),
  38. ColorScheme = Colors.ColorSchemes ["Dialog"],
  39. Id = "1",
  40. BorderStyle = LineStyle.Rounded,
  41. Arrangement = ViewArrangement.Movable
  42. };
  43. var embedded2 = new View
  44. {
  45. Title = "2",
  46. X = 3,
  47. Y = 3,
  48. Width = Dim.Fill (3),
  49. Height = Dim.Fill (3),
  50. ColorScheme = Colors.ColorSchemes ["Error"],
  51. Id = "2",
  52. BorderStyle = LineStyle.Rounded,
  53. Arrangement = ViewArrangement.Movable
  54. };
  55. embedded1.Add (embedded2);
  56. var embedded3 = new View
  57. {
  58. Title = "3",
  59. X = 3,
  60. Y = 3,
  61. Width = Dim.Fill (3),
  62. Height = Dim.Fill (3),
  63. ColorScheme = Colors.ColorSchemes ["TopLevel"],
  64. Id = "3",
  65. BorderStyle = LineStyle.Rounded,
  66. Arrangement = ViewArrangement.Movable
  67. };
  68. var testButton = new Button { X = 2, Y = 2, Text = "click me" };
  69. testButton.Accept += (s, e) => { MessageBox.Query (10, 5, "Test", "test message", "Ok"); };
  70. embedded3.Add (testButton);
  71. embedded2.Add (embedded3);
  72. scrollView.Add (embedded1);
  73. Top.Add (scrollView);
  74. }
  75. }