2 // System.Windows.Forms.ContainerControl.cs
5 // Miguel de Icaza (miguel@ximian.com)
6 // stubbed out by Jaak Simm (jaaksimm@firm.ee)
7 // Dennis Hayes (dennish@Raytek.com)
8 // WINELib implementation started by John Sohn (jsohn@columbus.rr.com)
10 // (C) Ximian, Inc., 2002/3
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System
.ComponentModel
;
37 namespace System
.Windows
.Forms
{
40 /// Provides focus management functionality for controls that can function as a container for other controls.
43 public class ContainerControl
: ScrollableControl
, IContainerControl
{
45 private Control activeControl
;
47 public ContainerControl () : base ()
49 controlStyles_
|= ControlStyles
.ContainerControl
;
54 public Control ActiveControl
{
56 return(activeControl
);
59 if ((value==activeControl
) || (value==null)) {
63 if (!Contains(value)) {
64 throw new ArgumentException("Not a child control");
67 // FIXME; need to let Wine know
74 // not ready for BindingContext
75 public override BindingContext BindingContext
{
77 throw new NotImplementedException ();
84 protected override CreateParams CreateParams
{
85 get { return base.CreateParams; }
88 public Form ParentForm
{
91 return(Parent
.FindForm());
99 /// internal .NET framework supporting methods, not stubbed out:
100 /// - protected virtual void UpdateDefaultButton()
102 protected override void AdjustFormScrollbars (
103 bool displayScrollbars
)
106 base.AdjustFormScrollbars (displayScrollbars
);
109 protected override void Dispose (bool disposing
)
112 base.Dispose(disposing
);
115 public bool ActivateControl(Control control
)
117 Control parent
=Parent
;
118 ContainerControl container
;
121 // We might have a container inside a container, etc...
122 // if we do, make sure that the whole chain up knows about the activation
124 container
=parent
.GetContainerControl() as ContainerControl
;
125 if ((container
!=null) && (container
.ActiveControl
!=this)) {
126 container
.ActivateControl(this);
130 if (activeControl
!=control
) {
131 // FIXME - let wine know
132 activeControl
=control
;
138 protected override void OnControlRemoved (ControlEventArgs e
)
140 if ((e
.Control
==activeControl
) || (e
.Control
.Contains(activeControl
))) {
143 base.OnControlRemoved(e
);
146 protected override void OnCreateControl ()
148 base.OnCreateControl ();
149 OnBindingContextChanged(EventArgs
.Empty
);
151 // end of [event methods]
153 protected override bool ProcessDialogChar (char charCode
)
155 // Only process if we own the whole thing
157 if (ProcessMnemonic(charCode
)) {
161 return base.ProcessDialogChar(charCode
);
165 protected override bool ProcessDialogKey (Keys keyData
)
167 if ( keyData
== Keys
.Tab
) {
168 return ProcessTabKey ( Control
.ModifierKeys
!= Keys
.Shift
);
169 } else if ((keyData
==Keys
.Left
) || (keyData
==Keys
.Right
) || (keyData
==Keys
.Up
) || (keyData
==Keys
.Down
)) {
170 // Select the next control
175 if ((keyData
==Keys
.Left
) || (keyData
==Keys
.Up
)) {
179 if (activeControl
!=null) {
180 select=activeControl
.Parent
;
183 select.SelectNextControl(activeControl
, forward
, false, false, true);
186 return base.ProcessDialogKey(keyData
);
190 protected override bool ProcessMnemonic (char charCode
)
193 return base.ProcessMnemonic(charCode
);
197 protected virtual bool ProcessTabKey ( bool forward
)
199 Control newFocus
= getNextFocusedControl ( this, forward
);
200 if ( newFocus
!= null )
201 return newFocus
.Focus ( );
205 // Not an overridden function?
206 protected override void Select(bool directed
,bool forward
)
208 base.Select(directed
, forward
);
211 protected virtual void UpdateDefaultButton() {
216 public bool Validate ()
218 throw new NotImplementedException ();
221 protected override void WndProc(ref Message m
)