ContainerControl.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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) 2004 Novell, Inc.
  21. //
  22. // Authors:
  23. // Peter Bartok [email protected]
  24. //
  25. //
  26. // NOT COMPLETE
  27. namespace System.Windows.Forms {
  28. public class ContainerControl : ScrollableControl, IContainerControl {
  29. private Control active_control;
  30. private Control focused_control;
  31. #region Public Constructors
  32. public ContainerControl() {
  33. }
  34. #endregion // Public Constructors
  35. #region Public Instance Properties
  36. public Control ActiveControl {
  37. get {
  38. return active_control;
  39. }
  40. set {
  41. if ((active_control==value) || (value==null)) {
  42. return;
  43. }
  44. active_control = value;
  45. if (!Contains(value)) {
  46. throw new ArgumentException("Not a child control");
  47. }
  48. XplatUI.SetFocus(active_control.window.Handle);
  49. }
  50. }
  51. public override BindingContext BindingContext {
  52. get {
  53. if (base.BindingContext == null) {
  54. base.BindingContext = new BindingContext();
  55. }
  56. return base.BindingContext;
  57. }
  58. set {
  59. base.BindingContext = value;
  60. }
  61. }
  62. public Form ParentForm {
  63. get {
  64. Control parent;
  65. parent = this.parent;
  66. while (parent != null) {
  67. if (parent is Form) {
  68. return (Form)parent;
  69. }
  70. parent = parent.parent;
  71. }
  72. return null;
  73. }
  74. }
  75. #endregion // Public Instance Properties
  76. #region Protected Instance Methods
  77. protected override CreateParams CreateParams {
  78. get {
  79. return base.CreateParams;
  80. }
  81. }
  82. #endregion // Public Instance Methods
  83. #region Public Instance Methods
  84. public bool Validate() {
  85. throw new NotImplementedException();
  86. }
  87. bool IContainerControl.ActivateControl(Control control) {
  88. throw new NotImplementedException();
  89. }
  90. #endregion // Public Instance Methods
  91. #region Protected Instance Methods
  92. protected override void AdjustFormScrollbars(bool displayScrollbars) {
  93. }
  94. protected override void Dispose(bool disposing) {
  95. }
  96. protected override void OnControlRemoved(ControlEventArgs e) {
  97. }
  98. protected override void OnCreateControl() {
  99. }
  100. protected override bool ProcessDialogChar(char charCode) {
  101. throw new NotImplementedException();
  102. }
  103. protected override bool ProcessDialogKey(Keys keyData) {
  104. Keys key;
  105. bool forward;
  106. key = keyData & Keys.KeyCode;
  107. forward = true;
  108. switch (key) {
  109. case Keys.Tab: {
  110. if (ProcessTabKey((keyData & Keys.Shift) == 0)) {
  111. return true;
  112. }
  113. break;
  114. }
  115. case Keys.Left: {
  116. forward = false;
  117. goto case Keys.Down;
  118. }
  119. case Keys.Up: {
  120. forward = false;
  121. goto case Keys.Down;
  122. }
  123. case Keys.Right: {
  124. goto case Keys.Down;
  125. }
  126. case Keys.Down: {
  127. Control control;
  128. control = active_control;
  129. if (control.SelectNextControl(active_control, forward, false, false, true)) {
  130. return true;
  131. }
  132. break;
  133. }
  134. }
  135. return base.ProcessDialogKey(keyData);
  136. }
  137. protected override bool ProcessMnemonic(char charCode) {
  138. throw new NotImplementedException();
  139. }
  140. protected virtual bool ProcessTabKey(bool forward) {
  141. return SelectNextControl(active_control, forward, true, true, true);
  142. }
  143. protected override void Select(bool directed, bool forward) {
  144. base.Select(directed, forward);
  145. }
  146. protected virtual void UpdateDefaultButton() {
  147. }
  148. protected override void WndProc(ref Message m) {
  149. base.WndProc(ref m);
  150. }
  151. #endregion // Protected Instance Methods
  152. }
  153. }