* TreeView.cs: Don't draw the selected node when we lose
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / MdiClient.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24 //
25 //
26
27 // NOT COMPLETE
28
29 using System.Collections;
30 using System.ComponentModel;
31 using System.Drawing;
32
33 namespace System.Windows.Forms {
34         [DesignTimeVisible(false)]
35         [ToolboxItem(false)]
36         public sealed class MdiClient : Control {
37                 #region Local Variables
38                 private int mdi_created;
39                 private Form active;
40                 #endregion      // Local Variables
41
42                 #region Public Classes
43                 public new class ControlCollection : Control.ControlCollection {
44                         MdiClient       owner;
45                         
46                         public ControlCollection(MdiClient owner) : base(owner) {
47                                 this.owner = owner;
48                                 controls = new ArrayList ();
49                         }
50
51                         public override void Add(Control value) {
52                                 if ((value is Form) == false || !(((Form)value).IsMdiChild)) {
53                                         throw new ArgumentException("Form must be MdiChild");
54                                 }
55                                 base.Add (value);
56                                 SetChildIndex (value, 0); // always insert at front
57                                 // newest member is the active one
58                                 owner.ActiveMdiChild = (Form) value;
59                         }
60
61                         public override void Remove(Control value) {
62                                 base.Remove (value);
63                         }
64                 }
65                 #endregion      // Public Classes
66
67                 #region Public Constructors
68                 public MdiClient() {
69                         BackColor = SystemColors.AppWorkspace;
70                         Dock = DockStyle.Fill;
71                         SetStyle (ControlStyles.Selectable, false);
72                 }
73                 #endregion      // Public Constructors
74
75                 protected override Control.ControlCollection CreateControlsInstance ()
76                 {
77                         return new MdiClient.ControlCollection (this);
78                 }
79
80                 protected override void WndProc(ref Message m) {
81                         /*
82                         switch ((Msg) m.Msg) {
83                                 case Msg.WM_PAINT: {                            
84                                         Console.WriteLine ("ignoring paint");
85                                         return;
86                                 }
87                         }
88                         */
89                         base.WndProc (ref m);
90                 }
91                 #region Public Instance Properties
92                 [Localizable(true)]
93                 public override System.Drawing.Image BackgroundImage {
94                         get {
95                                 return base.BackgroundImage;
96                         }
97                         set {
98                                 base.BackgroundImage = value;
99                         }
100                 }
101
102                 public Form[] MdiChildren {
103                         get {
104                                 Form[]  children;
105
106                                 children = new Form[Controls.Count];
107                                 Controls.CopyTo(children, 0);
108
109                                 return children;
110                         }
111                 }
112                 #endregion      // Public Instance Properties
113
114 #region Protected Instance Properties
115                 protected override CreateParams CreateParams {
116                         get {
117                                 return base.CreateParams;
118                         }
119                 }
120                 #endregion      // Protected Instance Properties
121
122                 #region Public Instance Methods
123                 public void LayoutMdi(MdiLayout value) {
124                         throw new NotImplementedException();
125                 }
126                 #endregion      // Public Instance Methods
127
128                 #region Protected Instance Methods
129                 #endregion      // Protected Instance Methods
130
131                 internal int ChildrenCreated {
132                         get { return mdi_created; }
133                         set { mdi_created = value; }
134                 }
135
136                 internal Form ActiveMdiChild {
137                         get { return active; }
138                         set { active = value; }
139                 }
140         }
141 }