XplatUIDriver.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. // COMPLETE
  27. using System.Drawing;
  28. namespace System.Windows.Forms {
  29. internal abstract class XplatUIDriver {
  30. internal abstract IntPtr InitializeDriver();
  31. internal abstract void ShutdownDriver(IntPtr token);
  32. internal delegate IntPtr WndProc(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
  33. #region XplatUI Driver Properties
  34. internal virtual Color ForeColor {
  35. get {
  36. return ThemeEngine.Current.DefaultWindowForeColor;
  37. }
  38. }
  39. internal virtual Color BackColor {
  40. get {
  41. return ThemeEngine.Current.DefaultWindowBackColor;
  42. }
  43. }
  44. internal virtual Font Font {
  45. get {
  46. return ThemeEngine.Current.DefaultFont;
  47. }
  48. }
  49. internal virtual Keys ModifierKeys {
  50. get {
  51. return Keys.None;
  52. }
  53. }
  54. internal virtual MouseButtons MouseButtons {
  55. get {
  56. return MouseButtons.None;
  57. }
  58. }
  59. internal virtual Point MousePosition {
  60. get {
  61. return Point.Empty;
  62. }
  63. }
  64. internal virtual bool DropTarget {
  65. get {
  66. return false;
  67. }
  68. set {
  69. }
  70. }
  71. internal abstract Size CursorSize { get; }
  72. internal abstract bool DragFullWindows { get; }
  73. internal abstract Size DragSize { get; }
  74. internal abstract Size IconSize { get; }
  75. internal abstract Size MaxWindowTrackSize { get; }
  76. internal abstract Size MinimizedWindowSize { get; }
  77. internal abstract Size MinimizedWindowSpacingSize { get; }
  78. internal abstract Size MinimumWindowSize { get; }
  79. internal abstract Size MinWindowTrackSize { get; }
  80. internal abstract Size SmallIconSize { get; }
  81. internal abstract int MouseButtonCount { get; }
  82. internal abstract bool MouseButtonsSwapped { get; }
  83. internal abstract bool MouseWheelPresent { get; }
  84. internal abstract Rectangle VirtualScreen { get; }
  85. internal abstract Rectangle WorkingArea { get; }
  86. #endregion // XplatUI Driver Properties
  87. internal abstract event EventHandler Idle;
  88. #region XplatUI Driver Methods
  89. internal abstract void Exit();
  90. internal abstract void EnableThemes();
  91. internal abstract void GetDisplaySize(out Size size);
  92. internal abstract IntPtr CreateWindow(CreateParams cp);
  93. internal abstract IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height);
  94. internal abstract void DestroyWindow(IntPtr handle);
  95. internal abstract FormWindowState GetWindowState(IntPtr handle);
  96. internal abstract void SetWindowState(IntPtr handle, FormWindowState state);
  97. internal abstract void SetWindowStyle(IntPtr handle, CreateParams cp);
  98. internal abstract bool GetText(IntPtr handle, out string text);
  99. internal abstract bool Text(IntPtr handle, string text);
  100. internal abstract bool SetVisible(IntPtr handle, bool visible);
  101. internal abstract bool IsVisible(IntPtr handle);
  102. internal abstract IntPtr SetParent(IntPtr handle, IntPtr parent);
  103. internal abstract IntPtr GetParent(IntPtr handle);
  104. internal abstract void UpdateWindow(IntPtr handle);
  105. internal abstract void SetWindowBackground(IntPtr handle, Color color);
  106. internal abstract PaintEventArgs PaintEventStart(IntPtr handle);
  107. internal abstract void PaintEventEnd(IntPtr handle);
  108. internal abstract void SetWindowPos(IntPtr handle, int x, int y, int width, int height);
  109. internal abstract void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height);
  110. internal abstract void Activate(IntPtr handle);
  111. internal abstract void EnableWindow(IntPtr handle, bool Enable);
  112. internal abstract void SetModal(IntPtr handle, bool Modal);
  113. internal abstract void Invalidate(IntPtr handle, Rectangle rc, bool clear);
  114. internal abstract IntPtr DefWndProc(ref Message msg);
  115. internal abstract void HandleException(Exception e);
  116. internal abstract void DoEvents();
  117. internal abstract bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags);
  118. internal abstract bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
  119. internal abstract bool TranslateMessage(ref MSG msg);
  120. internal abstract IntPtr DispatchMessage(ref MSG msg);
  121. internal abstract bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom);
  122. internal abstract bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled);
  123. internal abstract bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect);
  124. internal abstract void SetCursor(IntPtr hwnd, IntPtr cursor);
  125. internal abstract void ShowCursor(bool show);
  126. internal abstract void OverrideCursor(IntPtr cursor);
  127. internal abstract IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot);
  128. internal abstract IntPtr DefineStdCursor(StdCursor id);
  129. internal abstract void DestroyCursor(IntPtr cursor);
  130. internal abstract void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y);
  131. internal abstract void GetCursorPos(IntPtr hwnd, out int x, out int y);
  132. internal abstract void SetCursorPos(IntPtr hwnd, int x, int y);
  133. internal abstract void ScreenToClient(IntPtr hwnd, ref int x, ref int y);
  134. internal abstract void ClientToScreen(IntPtr hwnd, ref int x, ref int y);
  135. internal abstract void GrabWindow(IntPtr hwnd, IntPtr ConfineToHwnd);
  136. internal abstract void GrabInfo(out IntPtr hwnd, out bool GrabConfined, out Rectangle GrabArea);
  137. internal abstract void ReleaseWindow(IntPtr hwnd);
  138. internal abstract void SendAsyncMethod (AsyncMethodData method);
  139. internal abstract void SetTimer (Timer timer);
  140. internal abstract void KillTimer (Timer timer);
  141. internal abstract void CreateCaret(IntPtr hwnd, int width, int height);
  142. internal abstract void DestroyCaret(IntPtr hwnd);
  143. internal abstract void SetCaretPos(IntPtr hwnd, int x, int y);
  144. internal abstract void CaretVisible(IntPtr hwnd, bool visible);
  145. internal abstract void SetFocus(IntPtr hwnd);
  146. internal abstract IntPtr GetActive();
  147. internal abstract void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear);
  148. internal abstract void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear);
  149. internal abstract bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent);
  150. internal abstract bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt);
  151. internal abstract bool SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt);
  152. internal abstract void SystrayRemove(IntPtr hwnd, ref ToolTip tt);
  153. // System information
  154. internal abstract int KeyboardSpeed { get; }
  155. internal abstract int KeyboardDelay { get; }
  156. #endregion // XplatUI Driver Methods
  157. }
  158. }