1
2
3
4
5
6 using System;
7
8 namespace System.Screen
9 {
10 public class ContainerControl : Control
11 {
12 public nothrow ContainerControl(ControlCreateParams& createParams) : base(createParams), controls(this)
13 {
14 }
15 public void AddChild(Control* child)
16 {
17 controls.AddChild(child);
18 }
19 public void InsertChildBefore(Component* child, Component* before)
20 {
21 controls.InsertBefore(child, before);
22 }
23 public void InsertChildAfter(Component* child, Component* after)
24 {
25 controls.InsertAfter(child, after);
26 }
27 public override bool HandleWriteScreen(WriteScreenMessage* message)
28 {
29 bool messageRectIsDefault = message->GetRect().IsDefault();
30 WriteScreenEventArgs args(message->GetRect());
31 OnWriteScreen(args);
32 Component* child = controls.FirstChild();
33 while (child != null)
34 {
35 if (child is Control*)
36 {
37 Control* controlChild = cast<Control*>(child);
38 if (messageRectIsDefault)
39 {
40 controlChild->OnWriteScreen(args);
41 }
42 else if (controlChild->GetRect().IntersectsWith(message->GetRect()))
43 {
44 controlChild->OnWriteScreen(args);
45 }
46 }
47 child = child->NextSibling();
48 }
49 return true;
50 }
51 public nothrow Container& Controls()
52 {
53 return controls;
54 }
55 private Container controls;
56 }
57 }