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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2004 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
30 using System.ComponentModel;
31 using System.ComponentModel.Design;
33 namespace System.Windows.Forms {
34 public class ContainerControl : ScrollableControl, IContainerControl {
35 private Control active_control;
36 private Control focused_control;
37 private Control unvalidated_control;
39 #region Public Constructors
40 public ContainerControl() {
41 active_control = null;
42 focused_control = null;
43 unvalidated_control = null;
45 #endregion // Public Constructors
47 #region Public Instance Properties
49 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
50 public Control ActiveControl {
52 return active_control;
56 if ((active_control==value) || (value==null)) {
60 active_control = value;
62 if (!Contains(value) && this != value) {
63 throw new ArgumentException("Not a child control");
66 // Scroll control into view
68 // Let the control know it's selected
74 public override BindingContext BindingContext {
76 if (base.BindingContext == null) {
77 base.BindingContext = new BindingContext();
79 return base.BindingContext;
83 base.BindingContext = value;
88 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
89 public Form ParentForm {
95 while (parent != null) {
99 parent = parent.parent;
105 #endregion // Public Instance Properties
107 #region Protected Instance Methods
108 protected override CreateParams CreateParams {
110 return base.CreateParams;
113 #endregion // Public Instance Methods
115 #region Public Instance Methods
117 public bool Validate() {
118 throw new NotImplementedException();
121 public bool ActivateControl(Control control) {
122 return Select(control);
124 #endregion // Public Instance Methods
126 #region Protected Instance Methods
127 [EditorBrowsable (EditorBrowsableState.Advanced)]
128 protected override void AdjustFormScrollbars(bool displayScrollbars) {
132 protected override void Dispose(bool disposing) {
133 base.Dispose(disposing);
136 [EditorBrowsable (EditorBrowsableState.Advanced)]
137 protected override void OnControlRemoved(ControlEventArgs e) {
138 if (e.Control == this.unvalidated_control) {
139 this.unvalidated_control = null;
142 if (e.Control == this.active_control) {
143 this.unvalidated_control = null;
146 base.OnControlRemoved(e);
149 protected override void OnCreateControl() {
150 base.OnCreateControl();
153 [EditorBrowsable (EditorBrowsableState.Advanced)]
154 protected override bool ProcessDialogChar(char charCode) {
156 if (ProcessMnemonic(charCode)) {
160 return base.ProcessDialogChar(charCode);
163 protected override bool ProcessDialogKey(Keys keyData) {
167 key = keyData & Keys.KeyCode;
172 if (ProcessTabKey((Control.ModifierKeys & Keys.Shift) == 0)) {
192 if (SelectNextControl(active_control, forward, false, false, true)) {
200 return base.ProcessDialogKey(keyData);
203 protected override bool ProcessMnemonic(char charCode) {
211 c = GetNextControl(c, true);
213 // This is stupid. I want to be able to call c.ProcessMnemonic directly
214 if (c.ProcessControlMnemonic(charCode)) {
224 } while (c != active_control);
229 protected virtual bool ProcessTabKey(bool forward) {
230 return SelectNextControl(active_control, forward, true, true, true);
233 protected override void Select(bool directed, bool forward) {
234 base.Select(directed, forward);
237 protected virtual void UpdateDefaultButton() {
241 [EditorBrowsable (EditorBrowsableState.Advanced)]
242 protected override void WndProc(ref Message m) {
245 #endregion // Protected Instance Methods