MdiClient.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 [email protected]
  24. //
  25. //
  26. // NOT COMPLETE
  27. using System.Collections;
  28. using System.ComponentModel;
  29. using System.Drawing;
  30. namespace System.Windows.Forms {
  31. [DesignTimeVisible(false)]
  32. [ToolboxItem(false)]
  33. public sealed class MdiClient : Control {
  34. #region Local Variables
  35. private int mdi_created;
  36. private Form active;
  37. #endregion // Local Variables
  38. #region Public Classes
  39. public new class ControlCollection : Control.ControlCollection {
  40. MdiClient owner;
  41. public ControlCollection(MdiClient owner) : base(owner) {
  42. this.owner = owner;
  43. controls = new ArrayList ();
  44. }
  45. public override void Add(Control value) {
  46. if ((value is Form) == false || !(((Form)value).IsMdiChild)) {
  47. throw new ArgumentException("Form must be MdiChild");
  48. }
  49. base.Add (value);
  50. SetChildIndex (value, 0); // always insert at front
  51. // newest member is the active one
  52. owner.ActiveMdiChild = (Form) value;
  53. }
  54. public override void Remove(Control value) {
  55. base.Remove (value);
  56. }
  57. }
  58. #endregion // Public Classes
  59. #region Public Constructors
  60. public MdiClient() {
  61. BackColor = SystemColors.AppWorkspace;
  62. Dock = DockStyle.Fill;
  63. SetStyle (ControlStyles.Selectable, false);
  64. }
  65. #endregion // Public Constructors
  66. protected override Control.ControlCollection CreateControlsInstance ()
  67. {
  68. return new MdiClient.ControlCollection (this);
  69. }
  70. protected override void WndProc(ref Message m) {
  71. /*
  72. switch ((Msg) m.Msg) {
  73. case Msg.WM_PAINT: {
  74. Console.WriteLine ("ignoring paint");
  75. return;
  76. }
  77. }
  78. */
  79. base.WndProc (ref m);
  80. }
  81. #region Public Instance Properties
  82. [Localizable(true)]
  83. public override System.Drawing.Image BackgroundImage {
  84. get {
  85. return base.BackgroundImage;
  86. }
  87. set {
  88. base.BackgroundImage = value;
  89. }
  90. }
  91. public Form[] MdiChildren {
  92. get {
  93. Form[] children;
  94. children = new Form[Controls.Count];
  95. Controls.CopyTo(children, 0);
  96. return children;
  97. }
  98. }
  99. #endregion // Public Instance Properties
  100. #region Protected Instance Properties
  101. protected override CreateParams CreateParams {
  102. get {
  103. return base.CreateParams;
  104. }
  105. }
  106. #endregion // Protected Instance Properties
  107. #region Public Instance Methods
  108. public void LayoutMdi(MdiLayout value) {
  109. throw new NotImplementedException();
  110. }
  111. #endregion // Public Instance Methods
  112. #region Protected Instance Methods
  113. #endregion // Protected Instance Methods
  114. internal int ChildrenCreated {
  115. get { return mdi_created; }
  116. set { mdi_created = value; }
  117. }
  118. internal Form ActiveMdiChild {
  119. get { return active; }
  120. set { active = value; }
  121. }
  122. }
  123. }