1
2
3
4
5
6 using System;
7 using System.Collections;
8
9 namespace System.Windows
10 {
11 public nothrow ControlCreateParams& PanelControlCreateParams(ControlCreateParams& controlCreateParams)
12 {
13 return controlCreateParams.SetWindowClassName("System.Windows.Panel");
14 }
15
16 public class PanelCreateParams
17 {
18 public nothrow PanelCreateParams(ControlCreateParams& controlCreateParams_) : controlCreateParams(controlCreateParams_)
19 {
20 }
21 public nothrow PanelCreateParams& Defaults()
22 {
23 return *this;
24 }
25 public ControlCreateParams& controlCreateParams;
26 }
27
28 public class Panel : ContainerControl
29 {
30 private enum Flags : sbyte
31 {
32 none = 0, dontPaint = 1 << 0
33 }
34 public Panel(const string& windowClassName, const string& text, const Point& location, const Size& size, Dock dock, Anchors anchors,
35 const Color& backgroundColor) :
36 base(windowClassName, DefaultWindowClassStyle(), DefaultChildWindowStyle(), DefaultExtendedWindowStyle(),
37 backgroundColor, text, location, size, dock, anchors)
38 {
39 }
40 public Panel(const Point& location, const Size& size, Dock dock, Anchors anchors) :
41 this("System.Windows.Panel", "panel", location, size, dock, anchors, DefaultControlBackgroundColor())
42 {
43 }
44 public Panel(PanelCreateParams& createParams) : base(createParams.controlCreateParams)
45 {
46 }
47 public override void PrintWindowTree(int level)
48 {
49 LogView* log = Application.GetLogView();
50 if (log != null)
51 {
52 log->WriteLine(string(' ', level) + "Panel." + Text() + ".handle=" + ToHexString(cast<ulong>(Handle())) + " " + ParentText() + "[" + Rect(Point(), GetSize()).ToString() + "]");
53 }
54 Component* child = Children().FirstChild();
55 while (child != null)
56 {
57 if (child is Control*)
58 {
59 Control* childControl = cast<Control*>(child);
60 childControl->PrintWindowTree(level + 1);
61 }
62 child = child->NextSibling();
63 }
64 }
65 protected override void OnPaint(PaintEventArgs& args)
66 {
67 try
68 {
69 if (DontPaint()) return;
70 if (Debug.Paint())
71 {
72 Rect r(Location(), GetSize());
73 LogView* log = Application.GetLogView();
74 if (log != null)
75 {
76 log->WriteLine("Panel.OnPaint: " + r.ToString());
77 }
78 }
79 args.graphics.Clear(BackgroundColor());
80 base->OnPaint(args);
81 }
82 catch (const Exception& ex)
83 {
84 MessageBox.Show(ex.Message());
85 }
86 }
87 public inline nothrow bool DontPaint() const
88 {
89 return (flags & Flags.dontPaint) != Flags.none;
90 }
91 public nothrow void SetDontPaint()
92 {
93 flags = cast<Flags>(flags | Flags.dontPaint);
94 }
95 public nothrow void ResetDontPaint()
96 {
97 flags = cast<Flags>(flags & ~Flags.dontPaint);
98 }
99 private Flags flags;
100 }
101 }