2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUI.cs
index d8a0600a673a5f054133d4b9880603984b3d14bd..903f7d9a21be41dc1d88ac3070442b895d43b661 100644 (file)
 //
 // Authors:
 //     Peter Bartok    pbartok@novell.com
-//
-//
-// $Revision: 1.26 $
-// $Modtime: $
-// $Log: XplatUI.cs,v $
-// Revision 1.26  2004/11/08 20:53:03  pbartok
-// - Added argument to SetTopmost
-//
-// Revision 1.25  2004/10/18 04:50:54  pbartok
-// - Added method for enabling/disabling windows
-// - Added method for setting window modality
-// - Added method for setting topmost window
-//
-// Revision 1.24  2004/10/02 19:07:36  pbartok
-// - Added ClientToScreen coordinate translation method
-//
-// Revision 1.23  2004/09/21 00:54:15  jackson
-// New message loop that uses poll so we don't get a busy loop
-//
-// Revision 1.22  2004/09/13 21:18:32  pbartok
-// - Added Z-Ordering methods
-//
-// Revision 1.21  2004/09/11 00:57:35  pbartok
-// - Added method to retrieve text from window
-//
-// Revision 1.20  2004/08/24 11:29:44  jackson
-// Move timers to the driver level. On X they are queued by the driver and checked on idle.
-//
-// Revision 1.19  2004/08/23 19:39:30  pbartok
-// - Added method to move mouse cursor
-//
-// Revision 1.18  2004/08/21 20:51:27  pbartok
-// - Added method to get default display size
-//
-// Revision 1.17  2004/08/21 20:23:56  pbartok
-// - Added method to query current grab state
-// - Added argument to allow confining a grab to a window
-//
-// Revision 1.16  2004/08/20 20:03:20  pbartok
-// - Added method for setting the window background
-//
-// Revision 1.15  2004/08/20 19:14:35  jackson
-// Expose functionality to send async messages through the driver
-//
-// Revision 1.14  2004/08/13 21:42:15  pbartok
-// - Changed signature for GetCursorPos
-//
-// Revision 1.13  2004/08/13 19:00:15  jordi
-// implements PointToClient (ScreenToClient)
-//
-// 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
 
@@ -122,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 {
@@ -174,6 +71,7 @@ namespace System.Windows.Forms {
                                        driver.DropTarget=value;
                                }
                        }
+
                }
                #endregion      // Subclasses
 
@@ -183,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();
                        }
@@ -206,6 +107,96 @@ 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 {
@@ -270,8 +261,20 @@ 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) {
@@ -290,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) {
@@ -334,7 +337,7 @@ 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);
                }
 
@@ -362,6 +365,34 @@ namespace System.Windows.Forms {
                        return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
                }
 
+               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);
                }
@@ -382,6 +413,34 @@ namespace System.Windows.Forms {
                        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);
@@ -403,7 +462,28 @@ namespace System.Windows.Forms {
                                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);
+               }
+
+
                // Santa's little helper
                internal static void Where() {
                        Console.WriteLine("Here: {0}", new StackTrace().ToString());