2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUI.cs
index f04e7e3035ca1ab5949655627cb838cbaa62e4c2..903f7d9a21be41dc1d88ac3070442b895d43b661 100644 (file)
 //
 // Authors:
 //     Peter Bartok    pbartok@novell.com
-//
-//
-// $Revision: 1.1 $
-// $Modtime: $
-// $Log: XplatUI.cs,v $
-// Revision 1.1  2004/07/09 05:21:25  pbartok
-// - Initial check-in
-//
-//
+
 
 // NOT COMPLETE
 
@@ -40,48 +32,16 @@ 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 {
-       public class XplatUI {
+       internal class XplatUI {
                #region Local Variables
                static XplatUIDriver            driver;
                static String                   default_class_name;
                #endregion      // Local Variables
 
                #region Subclasses
-               public class Defaults {
-                       static public Color BackColor {
-                               get {
-                                       return driver.BackColor;
-                               }
-                       }
-
-                       static public Color ForeColor {
-                               get {
-                                       return driver.ForeColor;
-                               }
-                       }
-
-                       static public Font Font {
-                               get {
-                                       return driver.Font;
-                               }
-                       }
-               }
 
                public class State {
                        static public Keys ModifierKeys {
@@ -111,6 +71,7 @@ namespace System.Windows.Forms {
                                        driver.DropTarget=value;
                                }
                        }
+
                }
                #endregion      // Subclasses
 
@@ -120,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();
                        }
@@ -143,17 +107,128 @@ 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();
+               }
+
                internal static bool Text(IntPtr hWnd, string text) {
                        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);
                }
@@ -186,38 +261,58 @@ 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 PaintEventArgs PaintEventStart(IntPtr handle) {
-                       return driver.PaintEventStart(handle);
+               internal static void SetWindowState(IntPtr handle, FormWindowState state) {
+                       driver.SetWindowState(handle, state);
                }
 
-               internal static void PaintEventEnd(IntPtr handle) {
-                       driver.PaintEventEnd(handle);
+               internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
+                       driver.SetWindowStyle(handle, cp);
+               }
+
+               internal static void UpdateWindow(IntPtr handle) {
+                       driver.UpdateWindow(handle);
                }
 
-               internal static void SetWindowPos(IntPtr handle, Rectangle rc) {
-                       driver.SetWindowPos(handle, rc);
+               internal static void SetWindowBackground(IntPtr handle, Color color) {
+                       driver.SetWindowBackground(handle, color);
+               }
+                       
+               internal static PaintEventArgs PaintEventStart(IntPtr handle) {
+                       return driver.PaintEventStart(handle);
                }
 
-               internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
-                       driver.MoveWindow(hWnd, x, y, width, height);
+               internal static void PaintEventEnd(IntPtr handle) {
+                       driver.PaintEventEnd(handle);
                }
 
                internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
                        driver.SetWindowPos(handle, x, y, width, height);
                }
 
-               internal static void Invalidate(IntPtr handle, Rectangle rc) {
-                       driver.Invalidate(handle, rc);
+               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) {
+                       driver.Invalidate(handle, rc, clear);
                }
 
                internal static void Activate(IntPtr handle) {
                        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);
                }
@@ -242,19 +337,157 @@ 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);
                }
 
-               // Santa's little helper
-               internal static void Where() {
-                       Console.WriteLine("Here: {0}", new StackTrace().ToString());
+               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 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 Run() {
-                       driver.Run();
+               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);
+               }
+
+
+               // Santa's little helper
+               internal static void Where() {
+                       Console.WriteLine("Here: {0}", new StackTrace().ToString());
+               }
                #endregion      // Public Static Methods
 
        }