Form.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. // $Revision: 1.6 $
  27. // $Modtime: $
  28. // $Log: Form.cs,v $
  29. // Revision 1.6 2004/08/22 21:10:30 pbartok
  30. // - Removed OverlappedWindow style from Control, instead it's default
  31. // now is child
  32. // - Made form windows OverlappedWindow by default
  33. //
  34. // Revision 1.5 2004/08/19 21:30:37 pbartok
  35. // - Added handling of WM_CLOSE
  36. //
  37. // Revision 1.4 2004/08/11 22:20:59 pbartok
  38. // - Signature fixes
  39. //
  40. // Revision 1.3 2004/08/04 21:13:47 pbartok
  41. // - Added AutoScale properties
  42. //
  43. // Revision 1.2 2004/07/13 15:31:45 jordi
  44. // commit: new properties and fixes form size problems
  45. //
  46. // Revision 1.1 2004/07/09 05:21:25 pbartok
  47. // - Initial check-in
  48. //
  49. //
  50. // NOT COMPLETE
  51. using System;
  52. using System.Drawing;
  53. using System.ComponentModel;
  54. using System.Collections;
  55. using System.Runtime.InteropServices;
  56. using System.Threading;
  57. namespace System.Windows.Forms {
  58. public class Form : ContainerControl {
  59. #region Local Variables
  60. private static bool autoscale;
  61. private static Size autoscale_base_size;
  62. #endregion // Local Variables
  63. #region Public Constructor & Destructor
  64. public Form() {
  65. Console.WriteLine("Form Constructor called");
  66. //XplatUI.Version();
  67. }
  68. #endregion // Public Constructor & Destructor
  69. #region Public Static Properties
  70. #endregion // Public Static Properties
  71. #region Public Instance Properties
  72. protected override Size DefaultSize {
  73. get {
  74. return new Size (250, 250);
  75. }
  76. }
  77. #endregion // Public Instance Properties
  78. #region Protected Instance Properties
  79. public bool AutoScale {
  80. get {
  81. return autoscale;
  82. }
  83. set {
  84. autoscale=value;
  85. }
  86. }
  87. public virtual Size AutoScaleBaseSize {
  88. get {
  89. return autoscale_base_size;
  90. }
  91. set {
  92. autoscale_base_size=value;
  93. }
  94. }
  95. #endregion // Public Instance Properties
  96. #region Public Static Methods
  97. #endregion // Public Static Methods
  98. #region Public Instance Methods
  99. [MonoTODO("Need to add MDI support")]
  100. protected override CreateParams CreateParams {
  101. get {
  102. CreateParams create_params = new CreateParams();
  103. create_params.Caption = "";
  104. create_params.ClassName=XplatUI.DefaultClassName;
  105. create_params.ClassStyle = 0;
  106. create_params.ExStyle=0;
  107. create_params.Parent=IntPtr.Zero;
  108. create_params.Param=0;
  109. create_params.X = Left;
  110. create_params.Y = Top;
  111. create_params.Width = Width;
  112. create_params.Height = Height;
  113. create_params.Style = (int)WindowStyles.WS_OVERLAPPEDWINDOW;
  114. create_params.Style |= (int)WindowStyles.WS_VISIBLE;
  115. return create_params;
  116. }
  117. }
  118. #endregion // Public Instance Methods
  119. #region Protected Instance Methods
  120. protected override void WndProc(ref Message m) {
  121. switch((Msg)m.Msg) {
  122. case Msg.WM_CLOSE: {
  123. CancelEventArgs args = new CancelEventArgs(false);
  124. OnClosing(args);
  125. if (!args.Cancel) {
  126. OnClosed(EventArgs.Empty);
  127. base.WndProc(ref m);
  128. break;
  129. }
  130. break;
  131. }
  132. default: {
  133. base.WndProc (ref m);
  134. break;
  135. }
  136. }
  137. }
  138. #endregion // Protected Instance Methods
  139. #region Events
  140. protected virtual void OnActivated(EventArgs e) {
  141. if (Activated != null) {
  142. Activated(this, e);
  143. }
  144. }
  145. protected virtual void OnClosed(EventArgs e) {
  146. if (Closed != null) {
  147. Closed(this, e);
  148. }
  149. }
  150. protected virtual void OnClosing(System.ComponentModel.CancelEventArgs e) {
  151. if (Closing != null) {
  152. Closing(this, e);
  153. }
  154. }
  155. protected virtual void OnDeactivate(EventArgs e) {
  156. if (Deactivate != null) {
  157. Deactivate(this, e);
  158. }
  159. }
  160. protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e) {
  161. if (InputLanguageChanged!=null) {
  162. InputLanguageChanged(this, e);
  163. }
  164. }
  165. protected virtual void OnInputLanguageChanging(InputLanguageChangingEventArgs e) {
  166. if (InputLanguageChanging!=null) {
  167. InputLanguageChanging(this, e);
  168. }
  169. }
  170. protected virtual void OnLoad(EventArgs e) {
  171. if (Load != null) {
  172. Load(this, e);
  173. }
  174. }
  175. protected virtual void OnMaximizedBoundsChanged(EventArgs e) {
  176. if (MaximizedBoundsChanged != null) {
  177. MaximizedBoundsChanged(this, e);
  178. }
  179. }
  180. protected virtual void OnMaximumSizeChanged(EventArgs e) {
  181. if (MaximumSizeChanged != null) {
  182. MaximumSizeChanged(this, e);
  183. }
  184. }
  185. protected virtual void OnMdiChildActivate(EventArgs e) {
  186. if (MdiChildActivate != null) {
  187. MdiChildActivate(this, e);
  188. }
  189. }
  190. protected virtual void OnMenuComplete(EventArgs e) {
  191. if (MenuComplete != null) {
  192. MenuComplete(this, e);
  193. }
  194. }
  195. protected virtual void OnMenuStart(EventArgs e) {
  196. if (MenuStart != null) {
  197. MenuStart(this, e);
  198. }
  199. }
  200. protected virtual void OnMinimumSizeChanged(EventArgs e) {
  201. if (MinimumSizeChanged != null) {
  202. MinimumSizeChanged(this, e);
  203. }
  204. }
  205. public event EventHandler Activated;
  206. public event EventHandler Closed;
  207. public event CancelEventHandler Closing;
  208. public event EventHandler Deactivate;
  209. public event InputLanguageChangedEventHandler InputLanguageChanged;
  210. public event InputLanguageChangingEventHandler InputLanguageChanging;
  211. public event EventHandler Load;
  212. public event EventHandler MaximizedBoundsChanged;
  213. public event EventHandler MaximumSizeChanged;
  214. public event EventHandler MdiChildActivate;
  215. public event EventHandler MenuComplete;
  216. public event EventHandler MenuStart;
  217. public event EventHandler MinimumSizeChanged;
  218. #endregion // Events
  219. }
  220. }