XplatUIDriver.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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.24 $
  27. // $Modtime: $
  28. // $Log: XplatUIDriver.cs,v $
  29. // Revision 1.24 2004/10/02 19:07:36 pbartok
  30. // - Added ClientToScreen coordinate translation method
  31. //
  32. // Revision 1.23 2004/09/21 00:54:15 jackson
  33. // New message loop that uses poll so we don't get a busy loop
  34. //
  35. // Revision 1.22 2004/09/13 21:18:32 pbartok
  36. // - Added Z-Ordering methods
  37. //
  38. // Revision 1.21 2004/09/11 00:57:35 pbartok
  39. // - Added method to retrieve text from window
  40. //
  41. // Revision 1.20 2004/08/24 11:29:44 jackson
  42. // Move timers to the driver level. On X they are queued by the driver and checked on idle.
  43. //
  44. // Revision 1.19 2004/08/23 19:39:30 pbartok
  45. // - Added method to move mouse cursor
  46. //
  47. // Revision 1.18 2004/08/21 20:51:27 pbartok
  48. // - Added method to get default display size
  49. //
  50. // Revision 1.17 2004/08/21 20:23:56 pbartok
  51. // - Added method to query current grab state
  52. // - Added argument to allow confining a grab to a window
  53. //
  54. // Revision 1.16 2004/08/20 20:03:20 pbartok
  55. // - Added method for setting the window background
  56. //
  57. // Revision 1.15 2004/08/20 19:19:28 jackson
  58. // Expose functionality to send async messages through the driver
  59. //
  60. // Revision 1.14 2004/08/13 21:42:15 pbartok
  61. // - Changed signature for GetCursorPos
  62. //
  63. // Revision 1.13 2004/08/13 19:00:15 jordi
  64. // implements PointToClient (ScreenToClient)
  65. //
  66. // Revision 1.12 2004/08/13 18:53:14 pbartok
  67. // - Changed GetWindowPos to also provide client area size
  68. //
  69. // Revision 1.11 2004/08/12 22:59:03 pbartok
  70. // - Implemented method to get current mouse position
  71. //
  72. // Revision 1.10 2004/08/11 22:20:59 pbartok
  73. // - Signature fixes
  74. //
  75. // Revision 1.9 2004/08/11 19:19:44 pbartok
  76. // - We had SetWindowPos and MoveWindow to set window positions and size,
  77. // removed MoveWindow. We have GetWindowPos, so it made sense to keep
  78. // SetWindowPos as matching counterpart
  79. // - Added some X11 sanity checking
  80. //
  81. // Revision 1.8 2004/08/11 18:55:46 pbartok
  82. // - Added method to calculate difference between decorated window and raw
  83. // client area
  84. //
  85. // Revision 1.7 2004/08/10 17:39:22 pbartok
  86. // - Added GetWindowPos method
  87. //
  88. // Revision 1.6 2004/08/10 14:34:15 jackson
  89. // Use default colors from the theme
  90. //
  91. // Revision 1.5 2004/08/09 20:55:59 pbartok
  92. // - Removed Run method, was only required for initial development
  93. //
  94. // Revision 1.4 2004/08/09 20:51:25 pbartok
  95. // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
  96. //
  97. // Revision 1.3 2004/08/04 20:11:24 pbartok
  98. // - Added Invalidate handling
  99. //
  100. // Revision 1.2 2004/08/03 23:09:02 jordi
  101. // fixes spelling mistake
  102. //
  103. // Revision 1.1 2004/07/09 05:21:25 pbartok
  104. // - Initial check-in
  105. //
  106. //
  107. // COMPLETE
  108. using System.Drawing;
  109. namespace System.Windows.Forms {
  110. internal abstract class XplatUIDriver {
  111. internal abstract IntPtr InitializeDriver();
  112. internal abstract void ShutdownDriver(IntPtr token);
  113. internal delegate IntPtr WndProc(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
  114. #region XplatUI Driver Properties
  115. internal virtual Color ForeColor {
  116. get {
  117. return ThemeEngine.Current.DefaultWindowForeColor;
  118. }
  119. }
  120. internal virtual Color BackColor {
  121. get {
  122. return ThemeEngine.Current.DefaultWindowBackColor;
  123. }
  124. }
  125. internal virtual Font Font {
  126. get {
  127. return ThemeEngine.Current.DefaultFont;
  128. }
  129. }
  130. internal virtual Keys ModifierKeys {
  131. get {
  132. return Keys.None;
  133. }
  134. }
  135. internal virtual MouseButtons MouseButtons {
  136. get {
  137. return MouseButtons.None;
  138. }
  139. }
  140. internal virtual Point MousePosition {
  141. get {
  142. return Point.Empty;
  143. }
  144. }
  145. internal virtual bool DropTarget {
  146. get {
  147. return false;
  148. }
  149. set {
  150. }
  151. }
  152. #endregion // XplatUI Driver Properties
  153. internal abstract event EventHandler Idle;
  154. #region XplatUI Driver Methods
  155. internal abstract void Exit();
  156. internal abstract void EnableThemes();
  157. internal abstract void GetDisplaySize(out Size size);
  158. internal abstract IntPtr CreateWindow(CreateParams cp);
  159. internal abstract IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height);
  160. internal abstract void DestroyWindow(IntPtr handle);
  161. internal abstract bool GetText(IntPtr handle, out string text);
  162. internal abstract bool Text(IntPtr handle, string text);
  163. internal abstract bool SetVisible(IntPtr handle, bool visible);
  164. internal abstract bool IsVisible(IntPtr handle);
  165. internal abstract IntPtr SetParent(IntPtr handle, IntPtr parent);
  166. internal abstract IntPtr GetParent(IntPtr handle);
  167. internal abstract void RefreshWindow(IntPtr handle);
  168. internal abstract void SetWindowBackground(IntPtr handle, Color color);
  169. internal abstract PaintEventArgs PaintEventStart(IntPtr handle);
  170. internal abstract void PaintEventEnd(IntPtr handle);
  171. internal abstract void SetWindowPos(IntPtr handle, int x, int y, int width, int height);
  172. internal abstract void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height, out int client_width, out int client_height);
  173. internal abstract void Activate(IntPtr handle);
  174. internal abstract void Invalidate(IntPtr handle, Rectangle rc, bool clear);
  175. internal abstract IntPtr DefWndProc(ref Message msg);
  176. internal abstract void HandleException(Exception e);
  177. internal abstract void DoEvents();
  178. internal abstract bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
  179. internal abstract bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
  180. internal abstract bool TranslateMessage(ref MSG msg);
  181. internal abstract bool DispatchMessage(ref MSG msg);
  182. internal abstract bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom);
  183. internal abstract bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect);
  184. internal abstract void GetCursorPos(IntPtr handle, out int x, out int y);
  185. internal abstract void SetCursorPos(IntPtr handle, int x, int y);
  186. internal abstract void ScreenToClient(IntPtr handle, ref int x, ref int y);
  187. internal abstract void ClientToScreen(IntPtr handle, ref int x, ref int y);
  188. internal abstract void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd);
  189. internal abstract void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea);
  190. internal abstract void ReleaseWindow(IntPtr hWnd);
  191. internal abstract void SendAsyncMethod (AsyncMethodData method);
  192. internal abstract void SetTimer (Timer timer);
  193. internal abstract void KillTimer (Timer timer);
  194. #endregion // XplatUI Driver Methods
  195. }
  196. }