2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUI.cs
index 501128bb9c77364fdaef76fd24d0e8f4b53d6245..903f7d9a21be41dc1d88ac3070442b895d43b661 100644 (file)
 //
 // Authors:
 //     Peter Bartok    pbartok@novell.com
-//
-//
-// $Revision: 1.12 $
-// $Modtime: $
-// $Log: XplatUI.cs,v $
-// Revision 1.12  2004/08/13 18:53:14  pbartok
-// - Changed GetWindowPos to also provide client area size
-//
-// Revision 1.11  2004/08/12 22:59:03  pbartok
-// - Implemented method to get current mouse position
-//
-// Revision 1.10  2004/08/11 22:20:59  pbartok
-// - Signature fixes
-//
-// Revision 1.9  2004/08/11 19:19:44  pbartok
-// - We had SetWindowPos and MoveWindow to set window positions and size,
-//   removed MoveWindow. We have GetWindowPos, so it made sense to keep
-//   SetWindowPos as matching counterpart
-// - Added some X11 sanity checking
-//
-// Revision 1.8  2004/08/11 18:55:46  pbartok
-// - Added method to calculate difference between decorated window and raw
-//   client area
-//
-// Revision 1.7  2004/08/10 17:39:22  pbartok
-// - Added GetWindowPos method
-//
-// Revision 1.6  2004/08/09 20:55:59  pbartok
-// - Removed Run method, was only required for initial development
-//
-// Revision 1.5  2004/08/09 20:51:25  pbartok
-// - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
-//
-// Revision 1.4  2004/08/09 17:02:29  jackson
-// Get default window properties from the theme
-//
-// Revision 1.3  2004/08/09 15:56:44  jackson
-// Remove defaults, these are handled by the theme now.
-//
-// Revision 1.2  2004/08/04 20:11:24  pbartok
-// - Added Invalidate handling
-//
-// Revision 1.1  2004/07/09 05:21:25  pbartok
-// - Initial check-in
-//
-//
+
 
 // NOT COMPLETE
 
@@ -77,19 +32,6 @@ using System.Collections;
 using System.Diagnostics;
 using System.Runtime.InteropServices;
 
-//
-// Random architecture notes
-// We need
-// * windows
-//   - create
-//   - set location/size
-//   - define cursor
-//   - destroy
-//   - reparent?
-//   - show/hide
-// * Keyboard
-// * Mouse
-//
 
 /// X11 Version
 namespace System.Windows.Forms {
@@ -129,6 +71,7 @@ namespace System.Windows.Forms {
                                        driver.DropTarget=value;
                                }
                        }
+
                }
                #endregion      // Subclasses
 
@@ -138,7 +81,10 @@ namespace System.Windows.Forms {
                        default_class_name="SWFClass";
 
                        if (Environment.OSVersion.Platform == (PlatformID)128) {
-                               driver=XplatUIX11.GetInstance();
+                               if (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null)
+                                       driver=XplatUIOSX.GetInstance();
+                               else
+                                       driver=XplatUIX11.GetInstance();
                        } else {
                                driver=XplatUIWin32.GetInstance();
                        }
@@ -161,13 +107,116 @@ namespace System.Windows.Forms {
                                default_class_name=value;
                        }
                }
+
+               static public Size CursorSize {
+                       get {
+                               return driver.CursorSize;
+                       }
+               }
+
+               static public bool DragFullWindows {
+                       get {
+                               return driver.DragFullWindows;
+                       }
+               }
+
+               static public Size DragSize {
+                       get {
+                               return driver.DragSize;
+                       }
+               }
+
+               static public Size IconSize {
+                       get {
+                               return driver.IconSize;
+                       }
+               }
+
+               static public Size MaxWindowTrackSize {
+                       get {
+                               return driver.MaxWindowTrackSize;
+                       }
+               }
+
+               static public Size MinimizedWindowSize {
+                       get {
+                               return driver.MinimizedWindowSize;
+                       }
+               }
+
+               static public Size MinimizedWindowSpacingSize {
+                       get {
+                               return driver.MinimizedWindowSpacingSize;
+                       }
+               }
+
+               static public Size MinimumWindowSize {
+                       get {
+                               return driver.MinimumWindowSize;
+                       }
+               }
+
+               static public Size MinWindowTrackSize {
+                       get {
+                               return driver.MinWindowTrackSize;
+                       }
+               }
+
+               static public Size SmallIconSize {
+                       get {
+                               return driver.SmallIconSize;
+                       }
+               }
+
+               static public int MouseButtonCount {
+                       get {
+                               return driver.MouseButtonCount;
+                       }
+               }
+
+               static public bool MouseButtonsSwapped {
+                       get {
+                               return driver.MouseButtonsSwapped;
+                       }
+               }
+
+               static public bool MouseWheelPresent {
+                       get {
+                               return driver.MouseWheelPresent;
+                       }
+               }
+
+               static public Rectangle VirtualScreen {
+                       get {
+                               return driver.VirtualScreen;
+                       }
+               }
+
+               static public Rectangle WorkingArea {
+                       get {
+                               return driver.WorkingArea;
+                       }
+               }
                #endregion      // Public Static Properties
 
+                internal static event EventHandler Idle {
+                        add {
+                                driver.Idle += value;
+                        }
+                        remove {
+                                driver.Idle -= value;
+                        }
+                }
+                
                #region Public Static Methods
                internal static void Exit() {
                        driver.Exit();
                }
 
+               internal static void GetDisplaySize(out Size size) {
+                       driver.GetDisplaySize(out size);
+               }
+
                internal static void EnableThemes() {
                        driver.EnableThemes();
                }
@@ -176,6 +225,10 @@ namespace System.Windows.Forms {
                        return driver.Text(hWnd, text);
                }
 
+               internal static bool GetText(IntPtr hWnd, out string text) {
+                       return driver.GetText(hWnd, out text);
+               }
+
                internal static bool SetVisible(IntPtr hWnd, bool visible) {
                        return driver.SetVisible(hWnd, visible);
                }
@@ -208,10 +261,26 @@ namespace System.Windows.Forms {
                        driver.DestroyWindow(handle);
                }
 
-               internal static void RefreshWindow(IntPtr handle) {
-                       driver.RefreshWindow(handle);
+               internal static FormWindowState GetWindowState(IntPtr handle) {
+                       return driver.GetWindowState(handle);
+               }
+
+               internal static void SetWindowState(IntPtr handle, FormWindowState state) {
+                       driver.SetWindowState(handle, state);
+               }
+
+               internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
+                       driver.SetWindowStyle(handle, cp);
+               }
+
+               internal static void UpdateWindow(IntPtr handle) {
+                       driver.UpdateWindow(handle);
                }
 
+               internal static void SetWindowBackground(IntPtr handle, Color color) {
+                       driver.SetWindowBackground(handle, color);
+               }
+                       
                internal static PaintEventArgs PaintEventStart(IntPtr handle) {
                        return driver.PaintEventStart(handle);
                }
@@ -224,8 +293,8 @@ namespace System.Windows.Forms {
                        driver.SetWindowPos(handle, x, y, width, height);
                }
 
-               internal static void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
-                       driver.GetWindowPos(handle, out x, out y, out width, out height, out client_width, out client_height);
+               internal static 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) {
+                       driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
                }
 
                internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
@@ -236,6 +305,14 @@ namespace System.Windows.Forms {
                        driver.Activate(handle);
                }
 
+               internal static void EnableWindow(IntPtr handle, bool Enable) {
+                       driver.EnableWindow(handle, Enable);
+               }
+
+               internal static void SetModal(IntPtr handle, bool Modal) {
+                       driver.SetModal(handle, Modal);
+               }
+
                internal static IntPtr DefWndProc(ref Message msg) {
                        return driver.DefWndProc(ref msg);
                }
@@ -260,24 +337,150 @@ namespace System.Windows.Forms {
                        return driver.TranslateMessage(ref msg);
                }
 
-               internal static bool DispatchMessage(ref MSG msg) {
+               internal static IntPtr DispatchMessage(ref MSG msg) {
                        return driver.DispatchMessage(ref msg);
                }
 
-               internal static void GrabWindow(IntPtr hWnd) {
-                       driver.GrabWindow(hWnd);
+               internal static void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd) {
+                       driver.GrabWindow(hWnd, ConfineToHwnd);
+               }
+
+               internal static void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea) {
+                       driver.GrabInfo(out hWnd, out GrabConfined, out GrabArea);
                }
 
                internal static void ReleaseWindow(IntPtr hWnd) {
                        driver.ReleaseWindow(hWnd);
                }
 
+               internal static bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom) {
+                       return driver.SetZOrder(hWnd, AfterhWnd, Top, Bottom);
+               }
+
+               internal static bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled) {
+                       return driver.SetTopmost(hWnd, hWndOwner, Enabled);
+               }
+
                internal static bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
                        return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
                }
 
-               internal static void GetCursorPos(IntPtr handle, ref int x, ref int y) {
-                       driver.GetCursorPos(handle, ref x, ref y);
+               internal static void SetCursor(IntPtr hwnd, IntPtr cursor) {
+                       driver.SetCursor(hwnd, cursor);
+               }
+
+               internal static void ShowCursor(bool show) {
+                       driver.ShowCursor(show);
+               }
+
+               internal static void OverrideCursor(IntPtr cursor) {
+                       driver.OverrideCursor(cursor);
+               }
+
+               internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
+                       return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
+               }
+
+               internal static IntPtr DefineStdCursor(StdCursor id) {
+                       return driver.DefineStdCursor(id);
+               }
+
+               internal static void DestroyCursor(IntPtr cursor) {
+                       driver.DestroyCursor(cursor);
+               }
+
+               internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+                       driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
+               }
+
+               internal static void SetCursorPos(IntPtr handle, int x, int y) {
+                       driver.SetCursorPos(handle, x, y);
+               }
+
+               internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
+                       driver.GetCursorPos(handle, out x, out y);
+               }
+
+               internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
+                       driver.ScreenToClient (handle, ref x, ref y);
+               }
+
+               internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
+                       driver.ClientToScreen(handle, ref x, ref y);
+               }
+
+               internal static void SendAsyncMethod (AsyncMethodData data) {
+                       driver.SendAsyncMethod (data);
+               }
+
+               internal static void CreateCaret(IntPtr hwnd, int width, int height) {
+                       driver.CreateCaret(hwnd, width, height);
+               }
+
+               internal static void DestroyCaret(IntPtr hwnd) {
+                       driver.DestroyCaret(hwnd);
+               }
+
+               internal static void SetCaretPos(IntPtr hwnd, int x, int y) {
+                       driver.SetCaretPos(hwnd, x, y);
+               }
+
+               internal static void CaretVisible(IntPtr hwnd, bool visible) {
+                       driver.CaretVisible(hwnd, visible);
+               }
+
+               internal static void SetFocus(IntPtr hwnd) {
+                       driver.SetFocus(hwnd);
+               }
+
+               internal static IntPtr GetActive() {
+                       return driver.GetActive();
+               }
+
+               internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
+                       return driver.GetFontMetrics(g, font, out ascent, out descent);
+               }
+                       
+               internal static void SetTimer (Timer timer)
+               {
+                       driver.SetTimer (timer);
+               }
+
+               internal static void KillTimer (Timer timer)
+               {
+                       driver.KillTimer (timer);
+               }
+
+               internal static int KeyboardSpeed {
+                       get {
+                               return driver.KeyboardSpeed;
+                       }
+               }
+
+               internal static int KeyboardDelay {
+                       get {
+                               return driver.KeyboardSpeed;
+                       }
+               }
+
+               internal static void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear) {
+                       driver.ScrollWindow(hwnd, rectangle, XAmount, YAmount, clear);
+               }
+
+               internal static void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
+                       driver.ScrollWindow(hwnd, XAmount, YAmount, clear);
+               }
+
+               internal static bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt) {
+                       return driver.SystrayAdd(hwnd, tip, icon, out tt);
+               }
+
+               internal static void SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt) {
+                       driver.SystrayChange(hwnd, tip, icon, ref tt);
+               }
+
+               internal static void SystrayRemove(IntPtr hwnd, ref ToolTip tt) {
+                       driver.SystrayRemove(hwnd, ref tt);
                }