XplatUI.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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.2 $
  27. // $Modtime: $
  28. // $Log: XplatUI.cs,v $
  29. // Revision 1.2 2004/08/04 20:11:24 pbartok
  30. // - Added Invalidate handling
  31. //
  32. // Revision 1.1 2004/07/09 05:21:25 pbartok
  33. // - Initial check-in
  34. //
  35. //
  36. // NOT COMPLETE
  37. using System;
  38. using System.Drawing;
  39. using System.ComponentModel;
  40. using System.Collections;
  41. using System.Diagnostics;
  42. using System.Runtime.InteropServices;
  43. //
  44. // Random architecture notes
  45. // We need
  46. // * windows
  47. // - create
  48. // - set location/size
  49. // - define cursor
  50. // - destroy
  51. // - reparent?
  52. // - show/hide
  53. // * Keyboard
  54. // * Mouse
  55. //
  56. /// X11 Version
  57. namespace System.Windows.Forms {
  58. public class XplatUI {
  59. #region Local Variables
  60. static XplatUIDriver driver;
  61. static String default_class_name;
  62. #endregion // Local Variables
  63. #region Subclasses
  64. public class Defaults {
  65. static public Color BackColor {
  66. get {
  67. return driver.BackColor;
  68. }
  69. }
  70. static public Color ForeColor {
  71. get {
  72. return driver.ForeColor;
  73. }
  74. }
  75. static public Font Font {
  76. get {
  77. return driver.Font;
  78. }
  79. }
  80. }
  81. public class State {
  82. static public Keys ModifierKeys {
  83. get {
  84. return driver.ModifierKeys;
  85. }
  86. }
  87. static public MouseButtons MouseButtons {
  88. get {
  89. return driver.MouseButtons;
  90. }
  91. }
  92. static public Point MousePosition {
  93. get {
  94. return driver.MousePosition;
  95. }
  96. }
  97. static public bool DropTarget {
  98. get {
  99. return driver.DropTarget;
  100. }
  101. set {
  102. driver.DropTarget=value;
  103. }
  104. }
  105. }
  106. #endregion // Subclasses
  107. #region Constructor & Destructor
  108. static XplatUI() {
  109. // Don't forget to throw the mac in here somewhere, too
  110. default_class_name="SWFClass";
  111. if (Environment.OSVersion.Platform == (PlatformID)128) {
  112. driver=XplatUIX11.GetInstance();
  113. } else {
  114. driver=XplatUIWin32.GetInstance();
  115. }
  116. Console.WriteLine("#region #line XplatUI Constructor called");
  117. }
  118. ~XplatUI() {
  119. Console.WriteLine("XplatUI Destructor called");
  120. }
  121. #endregion // Constructor & Destructor
  122. #region Public Static Properties
  123. internal static string DefaultClassName {
  124. get {
  125. return default_class_name;
  126. }
  127. set {
  128. default_class_name=value;
  129. }
  130. }
  131. #endregion // Public Static Properties
  132. #region Public Static Methods
  133. internal static void Exit() {
  134. driver.Exit();
  135. }
  136. internal static bool Text(IntPtr hWnd, string text) {
  137. return driver.Text(hWnd, text);
  138. }
  139. internal static bool SetVisible(IntPtr hWnd, bool visible) {
  140. return driver.SetVisible(hWnd, visible);
  141. }
  142. internal static bool IsVisible(IntPtr hWnd) {
  143. return driver.IsVisible(hWnd);
  144. }
  145. internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
  146. return driver.SetParent(hWnd, hParent);
  147. }
  148. internal static IntPtr GetParent(IntPtr hWnd) {
  149. return driver.GetParent(hWnd);
  150. }
  151. internal static void Version() {
  152. Console.WriteLine("Xplat version $revision: $");
  153. }
  154. internal static IntPtr CreateWindow(CreateParams cp) {
  155. return driver.CreateWindow(cp);
  156. }
  157. internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
  158. return driver.CreateWindow(Parent, X, Y, Width, Height);
  159. }
  160. internal static void DestroyWindow(IntPtr handle) {
  161. driver.DestroyWindow(handle);
  162. }
  163. internal static void RefreshWindow(IntPtr handle) {
  164. driver.RefreshWindow(handle);
  165. }
  166. internal static PaintEventArgs PaintEventStart(IntPtr handle) {
  167. return driver.PaintEventStart(handle);
  168. }
  169. internal static void PaintEventEnd(IntPtr handle) {
  170. driver.PaintEventEnd(handle);
  171. }
  172. internal static void SetWindowPos(IntPtr handle, Rectangle rc) {
  173. driver.SetWindowPos(handle, rc);
  174. }
  175. internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
  176. driver.MoveWindow(hWnd, x, y, width, height);
  177. }
  178. internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
  179. driver.SetWindowPos(handle, x, y, width, height);
  180. }
  181. internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
  182. driver.Invalidate(handle, rc, clear);
  183. }
  184. internal static void Activate(IntPtr handle) {
  185. driver.Activate(handle);
  186. }
  187. internal static IntPtr DefWndProc(ref Message msg) {
  188. return driver.DefWndProc(ref msg);
  189. }
  190. internal static void HandleException(Exception e) {
  191. driver.HandleException(e);
  192. }
  193. internal static void DoEvents() {
  194. driver.DoEvents();
  195. }
  196. internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
  197. return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
  198. }
  199. internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
  200. return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
  201. }
  202. internal static bool TranslateMessage(ref MSG msg) {
  203. return driver.TranslateMessage(ref msg);
  204. }
  205. internal static bool DispatchMessage(ref MSG msg) {
  206. return driver.DispatchMessage(ref msg);
  207. }
  208. // Santa's little helper
  209. internal static void Where() {
  210. Console.WriteLine("Here: {0}", new StackTrace().ToString());
  211. }
  212. internal static void Run() {
  213. driver.Run();
  214. }
  215. #endregion // Public Static Methods
  216. }
  217. }