Form.cs 6.3 KB

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