XplatUIDriver.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.14 $
  27. // $Modtime: $
  28. // $Log: XplatUIDriver.cs,v $
  29. // Revision 1.14 2004/08/13 21:42:15 pbartok
  30. // - Changed signature for GetCursorPos
  31. //
  32. // Revision 1.13 2004/08/13 19:00:15 jordi
  33. // implements PointToClient (ScreenToClient)
  34. //
  35. // Revision 1.12 2004/08/13 18:53:14 pbartok
  36. // - Changed GetWindowPos to also provide client area size
  37. //
  38. // Revision 1.11 2004/08/12 22:59:03 pbartok
  39. // - Implemented method to get current mouse position
  40. //
  41. // Revision 1.10 2004/08/11 22:20:59 pbartok
  42. // - Signature fixes
  43. //
  44. // Revision 1.9 2004/08/11 19:19:44 pbartok
  45. // - We had SetWindowPos and MoveWindow to set window positions and size,
  46. // removed MoveWindow. We have GetWindowPos, so it made sense to keep
  47. // SetWindowPos as matching counterpart
  48. // - Added some X11 sanity checking
  49. //
  50. // Revision 1.8 2004/08/11 18:55:46 pbartok
  51. // - Added method to calculate difference between decorated window and raw
  52. // client area
  53. //
  54. // Revision 1.7 2004/08/10 17:39:22 pbartok
  55. // - Added GetWindowPos method
  56. //
  57. // Revision 1.6 2004/08/10 14:34:15 jackson
  58. // Use default colors from the theme
  59. //
  60. // Revision 1.5 2004/08/09 20:55:59 pbartok
  61. // - Removed Run method, was only required for initial development
  62. //
  63. // Revision 1.4 2004/08/09 20:51:25 pbartok
  64. // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
  65. //
  66. // Revision 1.3 2004/08/04 20:11:24 pbartok
  67. // - Added Invalidate handling
  68. //
  69. // Revision 1.2 2004/08/03 23:09:02 jordi
  70. // fixes spelling mistake
  71. //
  72. // Revision 1.1 2004/07/09 05:21:25 pbartok
  73. // - Initial check-in
  74. //
  75. //
  76. // COMPLETE
  77. using System.Drawing;
  78. namespace System.Windows.Forms {
  79. internal abstract class XplatUIDriver {
  80. internal abstract IntPtr InitializeDriver();
  81. internal abstract void ShutdownDriver(IntPtr token);
  82. internal delegate IntPtr WndProc(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
  83. #region XplatUI Driver Properties
  84. internal virtual Color ForeColor {
  85. get {
  86. return ThemeEngine.Current.DefaultWindowForeColor;
  87. }
  88. }
  89. internal virtual Color BackColor {
  90. get {
  91. return ThemeEngine.Current.DefaultWindowBackColor;
  92. }
  93. }
  94. internal virtual Font Font {
  95. get {
  96. return ThemeEngine.Current.DefaultFont;
  97. }
  98. }
  99. internal virtual Keys ModifierKeys {
  100. get {
  101. return Keys.None;
  102. }
  103. }
  104. internal virtual MouseButtons MouseButtons {
  105. get {
  106. return MouseButtons.None;
  107. }
  108. }
  109. internal virtual Point MousePosition {
  110. get {
  111. return Point.Empty;
  112. }
  113. }
  114. internal virtual bool DropTarget {
  115. get {
  116. return false;
  117. }
  118. set {
  119. }
  120. }
  121. #endregion // XplatUI Driver Properties
  122. #region XplatUI Driver Methods
  123. internal abstract void Exit();
  124. internal abstract void EnableThemes();
  125. internal abstract IntPtr CreateWindow(CreateParams cp);
  126. internal abstract IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height);
  127. internal abstract void DestroyWindow(IntPtr handle);
  128. internal abstract bool Text(IntPtr handle, string text);
  129. internal abstract bool SetVisible(IntPtr handle, bool visible);
  130. internal abstract bool IsVisible(IntPtr handle);
  131. internal abstract IntPtr SetParent(IntPtr handle, IntPtr parent);
  132. internal abstract IntPtr GetParent(IntPtr handle);
  133. internal abstract void RefreshWindow(IntPtr handle);
  134. internal abstract PaintEventArgs PaintEventStart(IntPtr handle);
  135. internal abstract void PaintEventEnd(IntPtr handle);
  136. internal abstract void SetWindowPos(IntPtr handle, int x, int y, int width, int height);
  137. 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);
  138. internal abstract void Activate(IntPtr handle);
  139. internal abstract void Invalidate(IntPtr handle, Rectangle rc, bool clear);
  140. internal abstract IntPtr DefWndProc(ref Message msg);
  141. internal abstract void HandleException(Exception e);
  142. internal abstract void DoEvents();
  143. internal abstract bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
  144. internal abstract bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
  145. internal abstract bool TranslateMessage(ref MSG msg);
  146. internal abstract bool DispatchMessage(ref MSG msg);
  147. internal abstract bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect);
  148. internal abstract void GetCursorPos(IntPtr handle, out int x, out int y);
  149. internal abstract void ScreenToClient(IntPtr handle, ref int x, ref int y);
  150. internal abstract void GrabWindow(IntPtr hWnd);
  151. internal abstract void ReleaseWindow(IntPtr hWnd);
  152. #endregion // XplatUI Driver Methods
  153. }
  154. }