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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2004-2006 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
27 // define to log API calls to stdout
29 #undef DriverDebugPaint
30 #undef DriverDebugCreate
31 #undef DriverDebugDestroy
32 #undef DriverDebugState
36 using System.ComponentModel;
37 using System.Collections;
38 using System.Diagnostics;
39 using System.Runtime.InteropServices;
40 using System.Threading;
42 namespace System.Windows.Forms {
43 internal class XplatUI {
44 #region Local Variables
45 static XplatUIDriver driver;
46 // static String default_class_name;
47 internal static ArrayList key_filters = new ArrayList ();
48 #endregion // Local Variables
50 #region Private Methods
51 internal static string Window (IntPtr handle)
53 return String.Format ("'{0}' ({1:X})", Control.FromHandle (handle), handle.ToInt32 ());
56 [Conditional ("DriverDebug")]
57 static void DriverDebug (string format, params object [] args)
59 Console.WriteLine (String.Format (format, args));
62 #endregion // Private Methods
66 static public Keys ModifierKeys {
68 return driver.ModifierKeys;
72 static public MouseButtons MouseButtons {
74 return driver.MouseButtons;
78 static public Point MousePosition {
80 return driver.MousePosition;
85 #endregion // Subclasses
87 #region Constructor & Destructor
90 // Compose name with current domain id because on Win32 we register class name
91 // and name must be unique to process. If we load MWF into multiple appdomains
92 // and try to register same class name we fail.
93 // default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID ().ToString ();
96 //if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) {
97 // driver=XplatUIX11_new.GetInstance ();
99 if (Environment.GetEnvironmentVariable ("MONO_MWF_MAC_FORCE_X11") != null) {
100 driver = XplatUIX11.GetInstance ();
102 IntPtr buf = Marshal.AllocHGlobal (8192);
103 // This is a hacktastic way of getting sysname from uname ()
104 if (uname (buf) != 0) {
105 // WTF: We cannot run uname
106 driver=XplatUIX11.GetInstance ();
108 string os = Marshal.PtrToStringAnsi (buf);
110 driver=XplatUICarbon.GetInstance ();
112 driver=XplatUIX11.GetInstance ();
114 Marshal.FreeHGlobal (buf);
117 driver=XplatUIWin32.GetInstance ();
120 driver.InitializeDriver ();
122 // Initialize things that need to be done after the driver is ready
123 DataFormats.GetFormat (0);
125 // Signal that the Application loop can be run.
126 // This allows UIA to initialize a11y support for MWF
127 // before the main loop begins.
128 Application.FirePreRun ();
130 #endregion // Constructor & Destructor
132 #region Public Static Properties
134 public static bool RunningOnUnix {
136 int p = (int) Environment.OSVersion.Platform;
138 return (p == 4 || p == 6 || p == 128);
142 public static int ActiveWindowTrackingDelay {
143 get { return driver.ActiveWindowTrackingDelay; }
146 // Compose name with current domain id because on Win32 we register class name
147 // and name must be unique to process. If we load MWF into multiple appdomains
148 // and try to register same class name we fail.
149 internal static string GetDefaultClassName (Type type)
151 return "SWFClass" + Thread.GetDomainID ().ToString () + "." + type.ToString ();
154 static public Size Border3DSize {
156 return driver.Border3DSize;
160 static public Size BorderSize {
162 return driver.BorderSize;
166 static public Size CaptionButtonSize {
168 return driver.CaptionButtonSize;
172 static public int CaptionHeight {
174 return driver.CaptionHeight;
178 public static int CaretBlinkTime { get { return driver.CaretBlinkTime; } }
179 public static int CaretWidth { get { return driver.CaretWidth; } }
181 static public Size CursorSize {
183 return driver.CursorSize;
187 static public Size DoubleClickSize {
189 return driver.DoubleClickSize;
193 static public int DoubleClickTime {
195 return driver.DoubleClickTime;
199 static public bool DragFullWindows {
201 return driver.DragFullWindows;
205 static public Size DragSize {
207 return driver.DragSize;
211 static public Size FixedFrameBorderSize {
213 return driver.FixedFrameBorderSize;
217 public static int FontSmoothingContrast { get { return driver.FontSmoothingContrast; } }
218 public static int FontSmoothingType { get { return driver.FontSmoothingType; } }
220 public static Size FrameBorderSize {
222 return driver.FrameBorderSize;
226 public static int HorizontalResizeBorderThickness { get { return driver.HorizontalResizeBorderThickness; } }
228 static public int HorizontalScrollBarHeight {
230 return driver.HorizontalScrollBarHeight;
234 static public Size IconSize {
236 return driver.IconSize;
240 public static bool IsActiveWindowTrackingEnabled { get { return driver.IsActiveWindowTrackingEnabled; } }
241 public static bool IsComboBoxAnimationEnabled { get { return driver.IsComboBoxAnimationEnabled; } }
242 public static bool IsDropShadowEnabled { get { return driver.IsDropShadowEnabled; } }
243 public static bool IsFontSmoothingEnabled { get { return driver.IsFontSmoothingEnabled; } }
244 public static bool IsHotTrackingEnabled { get { return driver.IsHotTrackingEnabled; } }
245 public static bool IsIconTitleWrappingEnabled { get { return driver.IsIconTitleWrappingEnabled; } }
246 public static bool IsKeyboardPreferred { get { return driver.IsKeyboardPreferred; } }
247 public static bool IsListBoxSmoothScrollingEnabled { get { return driver.IsListBoxSmoothScrollingEnabled; } }
248 public static bool IsMenuAnimationEnabled { get { return driver.IsMenuAnimationEnabled; } }
249 public static bool IsMenuFadeEnabled { get { return driver.IsMenuFadeEnabled; } }
250 public static bool IsMinimizeRestoreAnimationEnabled { get { return driver.IsMinimizeRestoreAnimationEnabled; } }
251 public static bool IsSelectionFadeEnabled { get { return driver.IsSelectionFadeEnabled; } }
252 public static bool IsSnapToDefaultEnabled { get { return driver.IsSnapToDefaultEnabled; } }
253 public static bool IsTitleBarGradientEnabled { get { return driver.IsTitleBarGradientEnabled; } }
254 public static bool IsToolTipAnimationEnabled { get { return driver.IsToolTipAnimationEnabled; } }
256 static public int KeyboardSpeed {
258 return driver.KeyboardSpeed;
262 static public int KeyboardDelay {
264 return driver.KeyboardDelay;
268 static public Size MaxWindowTrackSize {
270 return driver.MaxWindowTrackSize;
274 static public bool MenuAccessKeysUnderlined {
276 return driver.MenuAccessKeysUnderlined;
280 static public Size MenuBarButtonSize { get { return driver.MenuBarButtonSize; } }
282 public static Size MenuButtonSize {
284 return driver.MenuButtonSize;
288 static public int MenuShowDelay { get { return driver.MenuShowDelay; } }
290 static public Size MinimizedWindowSize {
292 return driver.MinimizedWindowSize;
296 static public Size MinimizedWindowSpacingSize {
298 return driver.MinimizedWindowSpacingSize;
302 static public Size MinimumWindowSize {
304 return driver.MinimumWindowSize;
308 static public Size MinimumFixedToolWindowSize {
309 get { return driver.MinimumFixedToolWindowSize; }
312 static public Size MinimumSizeableToolWindowSize {
313 get { return driver.MinimumSizeableToolWindowSize; }
316 static public Size MinimumNoBorderWindowSize {
317 get { return driver.MinimumNoBorderWindowSize; }
320 static public Size MinWindowTrackSize {
322 return driver.MinWindowTrackSize;
326 public static int MouseSpeed {
327 get { return driver.MouseSpeed; }
330 static public Size SmallIconSize {
332 return driver.SmallIconSize;
336 static public int MenuHeight {
338 return driver.MenuHeight;
342 static public int MouseButtonCount {
344 return driver.MouseButtonCount;
348 static public bool MouseButtonsSwapped {
350 return driver.MouseButtonsSwapped;
354 static public Size MouseHoverSize {
356 return driver.MouseHoverSize;
360 static public int MouseHoverTime {
362 return driver.MouseHoverTime;
366 static public int MouseWheelScrollDelta {
368 return driver.MouseWheelScrollDelta;
372 static public bool MouseWheelPresent {
374 return driver.MouseWheelPresent;
378 public static LeftRightAlignment PopupMenuAlignment {
379 get { return driver.PopupMenuAlignment; }
382 public static PowerStatus PowerStatus {
383 get { return driver.PowerStatus; }
386 public static bool RequiresPositiveClientAreaSize {
388 return driver.RequiresPositiveClientAreaSize;
392 public static int SizingBorderWidth {
393 get { return driver.SizingBorderWidth; }
396 public static Size SmallCaptionButtonSize {
397 get { return driver.SmallCaptionButtonSize; }
400 public static bool UIEffectsEnabled {
401 get { return driver.UIEffectsEnabled; }
404 static public bool UserClipWontExposeParent {
406 return driver.UserClipWontExposeParent;
410 public static int VerticalResizeBorderThickness { get { return driver.VerticalResizeBorderThickness; } }
412 static public int VerticalScrollBarWidth {
414 return driver.VerticalScrollBarWidth;
418 static public Rectangle VirtualScreen {
420 return driver.VirtualScreen;
424 static public Rectangle WorkingArea {
426 return driver.WorkingArea;
430 public static Screen[] AllScreens {
432 return driver.AllScreens;
436 public static bool ThemesEnabled {
438 return XplatUI.driver.ThemesEnabled;
442 public static int ToolWindowCaptionHeight {
444 return driver.ToolWindowCaptionHeight;
448 public static Size ToolWindowCaptionButtonSize {
450 return driver.ToolWindowCaptionButtonSize;
453 #endregion // Public Static Properties
457 internal static event EventHandler Idle {
459 driver.Idle += value;
462 driver.Idle -= value;
468 #region Public Static Methods
469 internal static void Activate (IntPtr handle)
471 DriverDebug ("Activate ({0}): Called", Window (handle));
472 driver.Activate (handle);
475 internal static void AudibleAlert (AlertType alert)
477 DriverDebug ("AudibleAlert (): Called");
478 driver.AudibleAlert (alert);
481 internal static void BeginMoveResize (IntPtr handle)
483 driver.BeginMoveResize (handle);
486 internal static bool CalculateWindowRect (ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect)
488 DriverDebug ("CalculateWindowRect ({0}, {1}, {2}): Called", ClientRect, cp, menu);
489 return driver.CalculateWindowRect (ref ClientRect, cp, menu, out WindowRect);
492 internal static void CaretVisible (IntPtr handle, bool visible)
494 DriverDebug ("CaretVisible ({0:X}, {1}): Called", handle.ToInt32 (), visible);
495 driver.CaretVisible (handle, visible);
498 internal static void CreateCaret (IntPtr handle, int width, int height)
500 DriverDebug ("CreateCaret ({0:X}), {1}, {2}: Called", handle.ToInt32 (), width, height);
501 driver.CreateCaret (handle, width, height);
504 internal static IntPtr CreateWindow (CreateParams cp)
506 #if DriverDebug || DriverDebugCreate
509 handle = driver.CreateWindow (cp);
511 Console.WriteLine ("CreateWindow (): Called, returning {0:X}", handle.ToInt32 ());
514 return driver.CreateWindow (cp);
518 internal static IntPtr CreateWindow (IntPtr Parent, int X, int Y, int Width, int Height)
520 #if DriverDebug || DriverDebugCreate
521 Console.WriteLine ("CreateWindow (): Called");
523 return driver.CreateWindow (Parent, X, Y, Width, Height);
526 internal static void ClientToScreen (IntPtr handle, ref int x, ref int y)
529 Console.WriteLine ("ClientToScreen ({0}, {1}, {2}): Called", Window (handle), x, y);
531 driver.ClientToScreen (handle, ref x, ref y);
534 internal static int[] ClipboardAvailableFormats (IntPtr handle)
536 DriverDebug ("ClipboardAvailableTypes ({0:X}): Called", handle.ToInt32 ());
537 return driver.ClipboardAvailableFormats (handle);
540 internal static void ClipboardClose (IntPtr handle)
542 DriverDebug ("ClipboardClose ({0:X}): Called", handle.ToInt32 ());
543 driver.ClipboardClose (handle);
546 internal static int ClipboardGetID (IntPtr handle, string format)
548 DriverDebug ("ClipboardGetID ({0:X}, {1}): Called", handle.ToInt32 (), format);
549 return driver.ClipboardGetID (handle, format);
552 internal static IntPtr ClipboardOpen (bool primary_selection)
554 DriverDebug ("ClipboardOpen (): Called");
555 return driver.ClipboardOpen (primary_selection);
558 internal static void ClipboardStore (IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter, bool copy)
560 DriverDebug ("ClipboardStore ({0:X}, {1}, {2}, {3}, {4}): Called", handle.ToInt32 (), obj, type, converter, copy);
561 driver.ClipboardStore (handle, obj, type, converter, copy);
564 internal static object ClipboardRetrieve (IntPtr handle, int type, XplatUI.ClipboardToObject converter)
566 DriverDebug ("ClipboardRetrieve ({0:X}, type, {1}): Called", handle.ToInt32 (), converter);
567 return driver.ClipboardRetrieve (handle, type, converter);
570 internal static IntPtr DefineCursor (Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot)
572 DriverDebug ("DefineCursor (...): Called");
573 return driver.DefineCursor (bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
576 internal static IntPtr DefineStdCursor (StdCursor id)
578 return driver.DefineStdCursor (id);
581 internal static Bitmap DefineStdCursorBitmap (StdCursor id)
583 return driver.DefineStdCursorBitmap (id);
586 internal static IntPtr DefWndProc (ref Message msg)
588 return driver.DefWndProc (ref msg);
591 internal static void DestroyCaret (IntPtr handle)
593 DriverDebug ("DestroyCaret ({0:X}): Called", handle.ToInt32 ());
594 driver.DestroyCaret (handle);
597 internal static void DestroyCursor (IntPtr cursor)
599 DriverDebug ("DestroyCursor ({0:X}): Called", cursor.ToInt32 ());
600 driver.DestroyCursor (cursor);
603 internal static void DestroyWindow (IntPtr handle)
605 DriverDebug ("DestroyWindow ({0}): Called", Window (handle));
606 driver.DestroyWindow (handle);
609 internal static IntPtr DispatchMessage (ref MSG msg)
611 return driver.DispatchMessage (ref msg);
614 internal static void DoEvents ()
619 internal static void DrawReversibleRectangle (IntPtr handle, Rectangle rect, int line_width)
621 DriverDebug ("DrawReversibleRectangle ({0}, {1}, {2}): Called", Window (handle), rect, line_width);
622 driver.DrawReversibleRectangle (handle, rect, line_width);
625 internal static void FillReversibleRectangle (Rectangle rectangle, Color backColor)
627 DriverDebug ("FillReversibleRectangle ({0}, {1}): Called", rectangle, backColor);
628 driver.FillReversibleRectangle (rectangle, backColor);
631 internal static void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
633 DriverDebug ("DrawReversibleFrame ({0}, {1}, {2}): Called", rectangle, backColor, style);
634 driver.DrawReversibleFrame (rectangle, backColor, style);
637 internal static void DrawReversibleLine (Point start, Point end, Color backColor)
639 DriverDebug ("DrawReversibleLine ({0}, {1}, {2}): Called", start, end, backColor);
640 driver.DrawReversibleLine (start, end, backColor);
643 internal static void EnableThemes ()
645 driver.EnableThemes ();
648 internal static void EnableWindow (IntPtr handle, bool Enable)
650 DriverDebug ("EnableWindow ({0}, {1}): Called", Window (handle), Enable);
651 driver.EnableWindow (handle, Enable);
654 internal static void EndLoop (Thread thread)
656 DriverDebug ("EndLoop ({0:X}): Called", thread.GetHashCode ());
657 driver.EndLoop (thread);
660 internal static IntPtr GetActive ()
662 DriverDebug ("GetActive (): Called");
663 return driver.GetActive ();
666 internal static SizeF GetAutoScaleSize (Font font)
668 DriverDebug ("GetAutoScaleSize ({0}): Called", font);
669 return driver.GetAutoScaleSize (font);
672 internal static Region GetClipRegion (IntPtr handle)
674 DriverDebug ("GetClipRegion ({0}): Called", Window (handle));
675 return driver.GetClipRegion (handle);
678 internal static void GetCursorInfo (IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y)
680 DriverDebug ("GetCursorInfo ({0}): Called", cursor.ToInt32 ());
681 driver.GetCursorInfo (cursor, out width, out height, out hotspot_x, out hotspot_y);
684 internal static void GetCursorPos (IntPtr handle, out int x, out int y)
686 DriverDebug ("GetCursorPos ({0}): Called", Window (handle));
687 driver.GetCursorPos (handle, out x, out y);
690 internal static void GetDisplaySize (out Size size)
692 DriverDebug ("GetDisplaySize (): Called");
693 driver.GetDisplaySize (out size);
696 internal static IntPtr GetFocus ()
698 DriverDebug ("GetFocus (): Called, Result:{0}", Window (driver.GetFocus ()));
699 return driver.GetFocus ();
702 internal static bool GetFontMetrics (Graphics g, Font font, out int ascent, out int descent)
704 DriverDebug ("GetFontMetrics (): Called");
705 return driver.GetFontMetrics (g, font, out ascent, out descent);
708 internal static Point GetMenuOrigin (IntPtr handle)
710 DriverDebug ("GetMenuOrigin ({0}): Called", Window (handle));
711 return driver.GetMenuOrigin (handle);
714 internal static bool GetMessage (object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax)
716 return driver.GetMessage (queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
719 internal static IntPtr GetParent (IntPtr handle)
721 DriverDebug ("GetParent ({0}): Called", Window (handle));
722 return driver.GetParent (handle);
725 internal static IntPtr GetPreviousWindow (IntPtr handle)
727 return driver.GetPreviousWindow (handle);
730 internal static bool GetText (IntPtr handle, out string text)
732 DriverDebug ("GetText ({0}): Called", Window (handle));
733 return driver.GetText (handle, out text);
736 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)
738 DriverDebug ("GetWindowPos ({0}): Called", Window (handle));
739 driver.GetWindowPos (handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
742 /* this method can (and does, on X11) return
743 * (FormWindowState) (-1), when the state of the window
744 * cannot be determined (in the X11 case, when the
745 * window isn't mapped.) Checking for the additional
746 * return value is less expensive than
747 * throwing/catching an exception. */
748 internal static FormWindowState GetWindowState (IntPtr handle)
750 DriverDebug ("GetWindowState ({0}): Called", Window (handle));
751 return driver.GetWindowState (handle);
754 internal static void GrabInfo (out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea)
756 DriverDebug ("GrabInfo (): Called");
757 driver.GrabInfo (out handle, out GrabConfined, out GrabArea);
760 internal static void GrabWindow (IntPtr handle, IntPtr ConfineToHwnd)
762 DriverDebug ("GrabWindow ({0}, {1}): Called", Window (handle), Window (ConfineToHwnd));
763 driver.GrabWindow (handle, ConfineToHwnd);
766 internal static void HandleException (Exception e)
768 driver.HandleException (e);
771 internal static void Invalidate (IntPtr handle, Rectangle rc, bool clear)
773 DriverDebug ("Invalidate ({0}, {1}, {2}): Called", Window (handle), rc, clear);
774 driver.Invalidate (handle, rc, clear);
777 internal static void InvalidateNC (IntPtr handle)
779 DriverDebug ("InvalidateNC ({0}): Called", Window (handle));
780 driver.InvalidateNC (handle);
784 internal static bool IsEnabled (IntPtr handle)
786 #if DriverDebug || DriverDebugState
787 Console.WriteLine ("IsEnabled ({0}): Called, Result={1}", Window (handle), driver.IsEnabled (handle));
789 return driver.IsEnabled (handle);
792 internal static bool IsKeyLocked (VirtualKeys key)
794 #if DriverDebug || DriverDebugState
795 Console.WriteLine ("IsKeyLocked ({0}): Called, Result={1}", key, driver.IsKeyLocked (key));
797 return driver.IsKeyLocked (key);
800 internal static bool IsVisible (IntPtr handle)
802 #if DriverDebug || DriverDebugState
803 Console.WriteLine ("IsVisible ({0}): Called, Result={1}", Window (handle), driver.IsVisible (handle));
805 return driver.IsVisible (handle);
808 internal static void KillTimer (Timer timer)
810 DriverDebug ("KillTimer ({0}): Called", timer);
811 driver.KillTimer (timer);
814 internal static void MenuToScreen (IntPtr handle, ref int x, ref int y)
816 DriverDebug ("MenuToScreen ({0}, {1}, {2}): Called", Window (handle), x, y);
817 driver.MenuToScreen (handle, ref x, ref y);
820 internal static void OverrideCursor (IntPtr cursor)
822 DriverDebug ("OverrideCursor ({0:X}): Called", cursor.ToInt32 ());
823 driver.OverrideCursor (cursor);
826 internal static void PaintEventEnd (ref Message msg, IntPtr handle, bool client)
828 #if DriverDebug || DriverDebugPaint
829 Console.WriteLine ("PaintEventEnd ({0}, {1}, {2}): Called from thread {3}", msg, Window (handle), client, Thread.CurrentThread.GetHashCode ());
831 driver.PaintEventEnd (ref msg, handle, client);
834 internal static PaintEventArgs PaintEventStart (ref Message msg, IntPtr handle, bool client)
836 #if DriverDebug || DriverDebugPaint
837 Console.WriteLine ("PaintEventStart ({0}, {1}, {2}): Called from thread {3}", msg, Window (handle), client, Thread.CurrentThread.GetHashCode ());
839 return driver.PaintEventStart (ref msg, handle, client);
842 internal static bool PeekMessage (Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags)
844 return driver.PeekMessage (queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
847 internal static bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam)
849 DriverDebug ("PostMessage ({0}, {1}, {2:X}, {3:X}): Called", Window (hwnd), message, wParam.ToInt32 (), lParam.ToInt32 ());
850 return driver.PostMessage (hwnd, message, wParam, lParam);
853 internal static bool PostMessage (ref MSG msg)
855 DriverDebug ("PostMessage ({0}): Called", msg);
856 return driver.PostMessage (msg.hwnd, msg.message, msg.wParam, msg.lParam);
859 internal static void PostQuitMessage (int exitCode)
861 DriverDebug ("PostQuitMessage ({0}): Called", exitCode);
862 driver.PostQuitMessage (exitCode);
865 internal static void RaiseIdle (EventArgs e)
867 DriverDebug ("RaiseIdle ({0}): Called", e.ToString ());
869 driver.RaiseIdle (e);
872 internal static void RequestAdditionalWM_NCMessages (IntPtr handle, bool hover, bool leave)
874 DriverDebug ("RequestAdditionalWM_NCMessages ({0}, {1}, {2}): Called", Window (handle), hover, leave);
875 driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
878 internal static void RequestNCRecalc (IntPtr handle)
880 DriverDebug ("RequestNCRecalc ({0}): Called", Window (handle));
881 driver.RequestNCRecalc (handle);
884 internal static void ResetMouseHover (IntPtr handle)
886 DriverDebug ("ResetMouseHover ({0}): Called", Window (handle));
887 driver.ResetMouseHover (handle);
890 internal static void ScreenToClient (IntPtr handle, ref int x, ref int y)
892 DriverDebug ("ScreenToClient ({0}, {1}, {2}): Called", Window (handle), x, y);
893 driver.ScreenToClient (handle, ref x, ref y);
896 internal static void ScreenToMenu (IntPtr handle, ref int x, ref int y)
898 DriverDebug ("ScreenToMenu ({0}, {1}, {2}): Called", Window (handle), x, y);
899 driver.ScreenToMenu (handle, ref x, ref y);
902 internal static void ScrollWindow (IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children)
904 DriverDebug ("ScrollWindow ({0}, {1}, {2}, {3}, {4}): Called", Window (handle), rectangle, XAmount, YAmount, with_children);
905 driver.ScrollWindow (handle, rectangle, XAmount, YAmount, with_children);
908 internal static void ScrollWindow (IntPtr handle, int XAmount, int YAmount, bool with_children)
910 DriverDebug ("ScrollWindow ({0}, {1}, {2}, {3}): Called", Window (handle), XAmount, YAmount, with_children);
911 driver.ScrollWindow (handle, XAmount, YAmount, with_children);
914 internal static void SendAsyncMethod (AsyncMethodData data)
916 DriverDebug ("SendAsyncMethod ({0}): Called", data);
917 driver.SendAsyncMethod (data);
920 internal static int SendInput (IntPtr hwnd, Queue keys)
922 DriverDebug ("SendInput ({0}, {1}): Called", hwnd, keys);
923 return driver.SendInput (hwnd, keys);
926 internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam)
928 DriverDebug ("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window (handle), message, wParam.ToInt32 (), lParam.ToInt32 ());
929 return driver.SendMessage (handle, message, wParam, lParam);
932 internal static void SendMessage (ref Message m)
934 DriverDebug ("SendMessage ({0}): Called", m);
935 m.Result = driver.SendMessage (m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
938 internal static void SetAllowDrop (IntPtr handle, bool value)
940 DriverDebug ("SetAllowDrop ({0}, {1}): Called", handle, value);
941 driver.SetAllowDrop (handle, value);
944 internal static void SetBorderStyle (IntPtr handle, FormBorderStyle border_style)
946 DriverDebug ("SetBorderStyle ({0}, {1}): Called", Window (handle), border_style);
947 driver.SetBorderStyle (handle, border_style);
950 internal static void SetCaretPos (IntPtr handle, int x, int y)
952 DriverDebug ("SetCaretPos ({0}, {1}, {2}): Called", Window (handle), x, y);
953 driver.SetCaretPos (handle, x, y);
956 internal static void SetClipRegion (IntPtr handle, Region region)
958 DriverDebug ("SetClipRegion ({0}, {1}): Called", Window (handle), region);
959 driver.SetClipRegion (handle, region);
962 internal static void SetCursor (IntPtr handle, IntPtr cursor)
964 DriverDebug ("SetCursor ({0}, {1:X}): Called", Window (handle), cursor.ToInt32 ());
965 driver.SetCursor (handle, cursor);
968 internal static void SetCursorPos (IntPtr handle, int x, int y)
970 DriverDebug ("SetCursorPos ({0}, {1}, {2}): Called", Window (handle), x, y);
971 driver.SetCursorPos (handle, x, y);
974 internal static void SetFocus (IntPtr handle)
976 DriverDebug ("SetFocus ({0}): Called", Window (handle));
977 driver.SetFocus (handle);
980 internal static void SetForegroundWindow (IntPtr handle)
982 DriverDebug ("SetForegroundWindow ({0}): Called", Window (handle));
983 driver.SetForegroundWindow (handle);
986 internal static void SetIcon (IntPtr handle, Icon icon)
988 DriverDebug ("SetIcon ({0}, {1}): Called", Window (handle), icon);
989 driver.SetIcon (handle, icon);
992 internal static void SetMenu (IntPtr handle, Menu menu)
994 DriverDebug ("SetMenu ({0}, {1}): Called", Window (handle), menu);
995 driver.SetMenu (handle, menu);
998 internal static void SetModal (IntPtr handle, bool Modal)
1000 DriverDebug ("SetModal ({0}, {1}): Called", Window (handle), Modal);
1001 driver.SetModal (handle, Modal);
1004 internal static IntPtr SetParent (IntPtr handle, IntPtr hParent)
1006 DriverDebug ("SetParent ({0}, {1:X}): Called", Window (handle), Window (hParent));
1007 return driver.SetParent (handle, hParent);
1010 internal static void SetTimer (Timer timer)
1012 DriverDebug ("SetTimer ({0}): Called", timer);
1013 driver.SetTimer (timer);
1016 internal static bool SetTopmost (IntPtr handle, bool Enabled)
1018 DriverDebug ("SetTopMost ({0}, {1}): Called", Window (handle), Enabled);
1019 return driver.SetTopmost (handle, Enabled);
1022 internal static bool SetOwner (IntPtr handle, IntPtr hWndOwner)
1024 DriverDebug ("SetOwner ({0}, {1}): Called", Window (handle), Window (hWndOwner));
1025 return driver.SetOwner (handle, hWndOwner);
1028 internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
1030 #if DriverDebug || DriverDebugState
1031 Console.WriteLine ("SetVisible ({0}, {1}, {2}): Called", Window (handle), visible, activate);
1033 return driver.SetVisible (handle, visible, activate);
1036 internal static void SetWindowMinMax (IntPtr handle, Rectangle maximized, Size min, Size max)
1038 #if DriverDebug || DriverDebugState
1039 Console.WriteLine ("SetWindowMinMax ({0}, {1}, {2}, {3}): Called", Window (handle), maximized, min, max);
1041 driver.SetWindowMinMax (handle, maximized, min, max);
1044 internal static void SetWindowPos (IntPtr handle, int x, int y, int width, int height)
1046 DriverDebug ("SetWindowPos ({0}, {1}, {2}, {3}, {4}): Called", Window (handle), x, y, width, height);
1047 driver.SetWindowPos (handle, x, y, width, height);
1050 internal static void SetWindowState (IntPtr handle, FormWindowState state)
1052 #if DriverDebug || DriverDebugState
1053 Console.WriteLine ("SetWindowState ({0} {1}): Called", Window (handle), state);
1055 driver.SetWindowState (handle, state);
1058 internal static void SetWindowStyle (IntPtr handle, CreateParams cp)
1060 DriverDebug ("SetWindowStyle ({0}): Called", Window (handle));
1061 driver.SetWindowStyle (handle, cp);
1064 internal static double GetWindowTransparency (IntPtr handle)
1066 DriverDebug ("SetWindowTransparency ({0}): Called", Window (handle));
1067 return driver.GetWindowTransparency (handle);
1070 internal static void SetWindowTransparency (IntPtr handle, double transparency, Color key)
1072 DriverDebug ("SetWindowTransparency ({0}): Called", Window (handle));
1073 driver.SetWindowTransparency (handle, transparency, key);
1076 internal static bool SetZOrder (IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom)
1078 DriverDebug ("SetZOrder ({0}, {1:X}, {2}, {3}): Called", Window (handle), Window (AfterhWnd), Top, Bottom);
1079 return driver.SetZOrder (handle, AfterhWnd, Top, Bottom);
1082 internal static void ShowCursor (bool show)
1084 DriverDebug ("ShowCursor ({0}): Called", show);
1085 driver.ShowCursor (show);
1088 internal static DragDropEffects StartDrag (IntPtr handle, object data, DragDropEffects allowedEffects)
1090 DriverDebug ("StartDrag ({0}, {1}, {2}): Called", Window (handle), data, allowedEffects);
1091 return driver.StartDrag (handle, data, allowedEffects);
1094 internal static object StartLoop (Thread thread)
1096 DriverDebug ("StartLoop ({0:X}): Called", thread.GetHashCode ());
1097 return driver.StartLoop (thread);
1100 internal static TransparencySupport SupportsTransparency ()
1102 DriverDebug ("SupportsTransparency (): Called, result={0}", driver.SupportsTransparency ());
1103 return driver.SupportsTransparency ();
1106 internal static bool SystrayAdd (IntPtr handle, string tip, Icon icon, out ToolTip tt)
1108 DriverDebug ("SystrayAdd ({0}, {1}): Called", Window (handle), tip);
1109 return driver.SystrayAdd (handle, tip, icon, out tt);
1112 internal static void SystrayChange (IntPtr handle, string tip, Icon icon, ref ToolTip tt)
1114 DriverDebug ("SystrayChange ({0}, {1}): Called", Window (handle), tip);
1115 driver.SystrayChange (handle, tip, icon, ref tt);
1118 internal static void SystrayRemove (IntPtr handle, ref ToolTip tt)
1120 DriverDebug ("SystrayRemove ({0}): Called", Window (handle));
1121 driver.SystrayRemove (handle, ref tt);
1124 internal static void SystrayBalloon (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
1126 DriverDebug ("SystrayBalloon ({0}, {1}, {2}, {3}, {4}): Called", Window (handle), timeout, title, text, icon);
1127 driver.SystrayBalloon (handle, timeout, title, text, icon);
1130 internal static bool Text (IntPtr handle, string text)
1132 DriverDebug ("Text ({0}, {1}): Called", Window (handle), text);
1133 return driver.Text (handle, text);
1136 internal static bool TranslateMessage (ref MSG msg)
1138 return driver.TranslateMessage (ref msg);
1141 internal static void UngrabWindow (IntPtr handle)
1143 DriverDebug ("UngrabWindow ({0}): Called", Window (handle));
1144 driver.UngrabWindow (handle);
1147 internal static void UpdateWindow (IntPtr handle)
1149 DriverDebug ("UpdateWindow ({0}): Called", Window (handle));
1150 driver.UpdateWindow (handle);
1154 internal static void CreateOffscreenDrawable (IntPtr handle,
1155 int width, int height,
1156 out object offscreen_drawable)
1158 DriverDebug ("CreateOffscreenDrawable ({2}, {0},{1}): Called", width, height, Window (handle));
1159 driver.CreateOffscreenDrawable (handle, width, height,
1160 out offscreen_drawable);
1163 internal static void DestroyOffscreenDrawable (object offscreen_drawable)
1165 DriverDebug ("DestroyOffscreenDrawable (): Called");
1166 driver.DestroyOffscreenDrawable (offscreen_drawable);
1169 internal static Graphics GetOffscreenGraphics (object offscreen_drawable)
1171 DriverDebug ("GetOffscreenGraphics (): Called");
1172 return driver.GetOffscreenGraphics (offscreen_drawable);
1175 internal static void BlitFromOffscreen (IntPtr dest_handle,
1177 object offscreen_drawable,
1178 Graphics offscreen_dc,
1181 DriverDebug ("BlitFromOffscreen ({0}): Called", Window (dest_handle));
1182 driver.BlitFromOffscreen (dest_handle, dest_dc, offscreen_drawable, offscreen_dc, r);
1186 // Santa's little helper
1187 internal static void Version ()
1189 Console.WriteLine ("Xplat version $Revision: $");
1192 internal static void AddKeyFilter (IKeyFilter value)
1194 lock (key_filters) {
1195 key_filters.Add (value);
1199 internal static bool FilterKey (KeyFilterData key)
1201 lock (key_filters) {
1202 for (int i = 0; i < key_filters.Count; i++) {
1203 IKeyFilter filter = (IKeyFilter) key_filters[i];
1204 if (filter.PreFilterKey (key))
1210 #endregion // Public Static Methods
1213 public delegate bool ClipboardToObject (int type, IntPtr data, out object obj);
1214 public delegate bool ObjectToClipboard (ref int type, object obj, out byte[] data);
1215 #endregion // Delegates
1217 [DllImport ("libc")]
1218 static extern int uname (IntPtr buf);