Implement AxHost.InvalidActiveXStateException
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms.X11Internal / XplatUIX11-new.cs
index 3ef6a55f8ebe713e363008585db96f030aa603f1..ef259b767aca23d4a8ee35079194fba93debe999 100644 (file)
@@ -150,7 +150,7 @@ namespace System.Windows.Forms.X11Internal {
 
 
                #region Public Properties
-               internal override int Caption {
+               internal override int CaptionHeight {
                        get { return 19; }
                }
 
@@ -184,11 +184,13 @@ namespace System.Windows.Forms.X11Internal {
 
                internal override Size MaxWindowTrackSize {
                        get { return new Size (WorkingArea.Width, WorkingArea.Height); }
-               } 
+               }
 
-               internal override Size MinimizedWindowSize {
-                       get { return new Size(1, 1); }
-               } 
+               internal override bool MenuAccessKeysUnderlined {
+                       get {
+                               return false;
+                       }
+               }
 
                internal override Size MinimizedWindowSpacingSize {
                        get { return new Size(1, 1); }
@@ -198,10 +200,6 @@ namespace System.Windows.Forms.X11Internal {
                        get { return new Size(1, 1); }
                } 
 
-               internal override Size MinWindowTrackSize {
-                       get { return new Size(1, 1); }
-               }
-
                internal override Keys ModifierKeys {
                        get { return display.ModifierKeys; }
                }
@@ -246,7 +244,13 @@ namespace System.Windows.Forms.X11Internal {
                #endregion      // Public properties
 
                #region Public Static Methods
-               internal override IntPtr InitializeDriver()
+               internal override void RaiseIdle (EventArgs e)
+               {
+                       X11ThreadQueue queue = ThreadQueue (Thread.CurrentThread);
+                       queue.OnIdle (e);
+               }
+
+               internal override IntPtr InitializeDriver ()
                {
                        lock (this) {
                                if (display == null)
@@ -290,21 +294,9 @@ namespace System.Windows.Forms.X11Internal {
                }
 
                // XXX this implementation should probably be shared between all non-win32 backends
-               internal override bool CalculateWindowRect (ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect)
+               internal override bool CalculateWindowRect (ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect)
                {
-                       FormBorderStyle border_style;
-                       TitleStyle      title_style;
-                       bool border_static;
-                       int caption_height;
-                       int tool_caption_height;
-
-                       // XXX this method should be static on Hwnd, not X11Hwnd
-                       X11Hwnd.DeriveStyles (Style, ExStyle, out border_style, out border_static, out title_style,
-                                             out caption_height, out tool_caption_height);
-
-                       WindowRect = Hwnd.GetWindowRectangle(border_style, border_static, menu, title_style,
-                                                            caption_height, tool_caption_height,
-                                                            ClientRect);
+                       WindowRect = Hwnd.GetWindowRectangle (cp, menu, ClientRect);
                        return true;
                }
 
@@ -383,7 +375,10 @@ namespace System.Windows.Forms.X11Internal {
                {
                        return display.DefineCursor (bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
                }
-
+               internal override Bitmap DefineStdCursorBitmap (StdCursor id) 
+               {
+                       return display.DefineStdCursorBitmap (id);
+               }
                internal override IntPtr DefineStdCursor (StdCursor id)
                {
                        return display.DefineStdCursor (id);
@@ -522,6 +517,11 @@ namespace System.Windows.Forms.X11Internal {
                        return IntPtr.Zero;
                }
 
+               // This is a nop on win32 and x11
+               internal override IntPtr GetPreviousWindow(IntPtr handle) {
+                       return handle;
+               }
+
                internal override void GetCursorPos (IntPtr handle, out int x, out int y)
                {
                        display.GetCursorPos ((X11Hwnd)Hwnd.ObjectFromHandle(handle),
@@ -536,7 +536,10 @@ namespace System.Windows.Forms.X11Internal {
                // XXX this should be shared amongst non-win32 backends
                internal override bool GetFontMetrics (Graphics g, Font font, out int ascent, out int descent)
                {
-                       return Xlib.GetFontMetrics(g.GetHdc(), font.ToHfont(), out ascent, out descent);
+                       FontFamily ff = font.FontFamily;
+                       ascent = ff.GetCellAscent (font.Style);
+                       descent = ff.GetCellDescent (font.Style);
+                       return true;
                }
 
 
@@ -678,14 +681,14 @@ namespace System.Windows.Forms.X11Internal {
                        display.OverrideCursor = cursor;
                }
 
-               internal override PaintEventArgs PaintEventStart (IntPtr handle, bool client)
+               internal override PaintEventArgs PaintEventStart (ref Message m, IntPtr handle, bool client)
                {
-                       return display.PaintEventStart (handle, client);
+                       return display.PaintEventStart (ref m, handle, client);
                }
 
-               internal override void PaintEventEnd (IntPtr handle, bool client)
+               internal override void PaintEventEnd (ref Message m, IntPtr handle, bool client)
                {
-                       display.PaintEventEnd (handle, client);
+                       display.PaintEventEnd (ref m, handle, client);
                }
 
 
@@ -1012,7 +1015,8 @@ namespace System.Windows.Forms.X11Internal {
                        display.SystrayRemove (handle, ref tt);
                }
 
-#if NET_2_0
+               NotifyIcon.BalloonWindow balloon_window;
+
                internal override void SystrayBalloon(IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
                {
                        Control control = Control.FromHandle(handle);
@@ -1020,15 +1024,19 @@ namespace System.Windows.Forms.X11Internal {
                        if (control == null)
                                return;
 
-                       NotifyIcon.BalloonWindow form = new NotifyIcon.BalloonWindow (handle);
-                       form.Title = title;
-                       form.Text = text;
-                       form.Timeout = timeout;
-                       form.Show ();
+                       if (balloon_window != null) {
+                               balloon_window.Close ();
+                               balloon_window.Dispose ();
+                       }
+
+                       balloon_window = new NotifyIcon.BalloonWindow (handle);
+                       balloon_window.Title = title;
+                       balloon_window.Text = text;
+                       balloon_window.Timeout = timeout;
+                       balloon_window.Show ();
                        
                        SendMessage(handle, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONSHOW);    
                }
-#endif
 
                internal override bool Text (IntPtr handle, string text)
                {