Clipping.cs 2.5 KB

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