NodeWithChilds.cs 633 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // $Id$
  2. using System.Collections.Generic;
  3. namespace SceneGraph
  4. {
  5. /// <summary>
  6. /// A base class that allows constructing scene graph nodes that have
  7. /// several childs
  8. /// </summary>
  9. public class NodeWithChilds : Node
  10. {
  11. private List<Node> Childs = new List<Node>();
  12. protected void DrawChilds(Gdk.Rectangle cliprect)
  13. {
  14. foreach(Node Child in Childs) {
  15. Child.Draw(cliprect);
  16. }
  17. }
  18. public void AddChild(Node Child)
  19. {
  20. Childs.Add(Child);
  21. }
  22. public void RemoveChild(Node Child)
  23. {
  24. Childs.Remove(Child);
  25. }
  26. public virtual void Draw(Gdk.Rectangle cliprect)
  27. {
  28. DrawChilds(cliprect);
  29. }
  30. }
  31. }