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) {
52 return String.Format("'{0}' ({1:X})", Control.FromHandle(handle), handle.ToInt32());
54 #endregion // Private Methods
58 static public Keys ModifierKeys {
60 return driver.ModifierKeys;
64 static public MouseButtons MouseButtons {
66 return driver.MouseButtons;
70 static public Point MousePosition {
72 return driver.MousePosition;
77 #endregion // Subclasses
79 #region Constructor & Destructor
81 // Compose name with current domain id because on Win32 we register class name
82 // and name must be unique to process. If we load MWF into multiple appdomains
83 // and try to register same class name we fail.
84 default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID().ToString();
87 //if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) {
88 // driver=XplatUIX11_new.GetInstance ();
90 if (Environment.GetEnvironmentVariable ("MONO_MWF_MAC_FORCE_X11") != null) {
91 driver = XplatUIX11.GetInstance ();
93 IntPtr buf = Marshal.AllocHGlobal (8192);
94 // This is a hacktastic way of getting sysname from uname ()
95 if (uname (buf) != 0) {
96 // WTF: We cannot run uname
97 driver=XplatUIX11.GetInstance ();
99 string os = Marshal.PtrToStringAnsi (buf);
101 driver=XplatUICarbon.GetInstance ();
103 driver=XplatUIX11.GetInstance ();
105 Marshal.FreeHGlobal (buf);
108 driver=XplatUIWin32.GetInstance();
111 driver.InitializeDriver();
113 // Initialize things that need to be done after the driver is ready
114 DataFormats.GetFormat(0);
117 // Signal that the Application loop can be run.
118 // This allows UIA to initialize a11y support for MWF
119 // before the main loop begins.
120 Application.FirePreRun ();
123 #endregion // Constructor & Destructor
125 #region Public Static Properties
127 public static bool RunningOnUnix {
129 int p = (int) Environment.OSVersion.Platform;
131 return (p == 4 || p == 6 || p == 128);
135 public static int ActiveWindowTrackingDelay {
136 get { return driver.ActiveWindowTrackingDelay; }
139 internal static string DefaultClassName {
141 return default_class_name;
145 default_class_name=value;
149 static public Size Border3DSize {
151 return driver.Border3DSize;
155 static public Size BorderSize {
157 return driver.BorderSize;
161 static public Size CaptionButtonSize {
163 return driver.CaptionButtonSize;
167 static public int CaptionHeight {
169 return driver.CaptionHeight;
173 public static int CaretBlinkTime { get { return driver.CaretBlinkTime; } }
174 public static int CaretWidth { get { return driver.CaretWidth; } }
176 static public Size CursorSize {
178 return driver.CursorSize;
182 static public Size DoubleClickSize {
184 return driver.DoubleClickSize;
188 static public int DoubleClickTime {
190 return driver.DoubleClickTime;
194 static public bool DragFullWindows {
196 return driver.DragFullWindows;
200 static public Size DragSize {
202 return driver.DragSize;
206 static public Size FixedFrameBorderSize {
208 return driver.FixedFrameBorderSize;
212 public static int FontSmoothingContrast { get { return driver.FontSmoothingContrast; } }
213 public static int FontSmoothingType { get { return driver.FontSmoothingType; } }
215 public static Size FrameBorderSize {
217 return driver.FrameBorderSize;
221 public static int HorizontalResizeBorderThickness { get { return driver.HorizontalResizeBorderThickness; } }
223 static public int HorizontalScrollBarHeight {
225 return driver.HorizontalScrollBarHeight;
229 static public Size IconSize {
231 return driver.IconSize;
235 public static bool IsActiveWindowTrackingEnabled { get { return driver.IsActiveWindowTrackingEnabled; } }
236 public static bool IsComboBoxAnimationEnabled { get { return driver.IsComboBoxAnimationEnabled; } }
237 public static bool IsDropShadowEnabled { get { return driver.IsDropShadowEnabled; } }
238 public static bool IsFontSmoothingEnabled { get { return driver.IsFontSmoothingEnabled; } }
239 public static bool IsHotTrackingEnabled { get { return driver.IsHotTrackingEnabled; } }
240 public static bool IsIconTitleWrappingEnabled { get { return driver.IsIconTitleWrappingEnabled; } }
241 public static bool IsKeyboardPreferred { get { return driver.IsKeyboardPreferred; } }
242 public static bool IsListBoxSmoothScrollingEnabled { get { return driver.IsListBoxSmoothScrollingEnabled; } }
243 public static bool IsMenuAnimationEnabled { get { return driver.IsMenuAnimationEnabled; } }
244 public static bool IsMenuFadeEnabled { get { return driver.IsMenuFadeEnabled; } }
245 public static bool IsMinimizeRestoreAnimationEnabled { get { return driver.IsMinimizeRestoreAnimationEnabled; } }
246 public static bool IsSelectionFadeEnabled { get { return driver.IsSelectionFadeEnabled; } }
247 public static bool IsSnapToDefaultEnabled { get { return driver.IsSnapToDefaultEnabled; } }
248 public static bool IsTitleBarGradientEnabled { get { return driver.IsTitleBarGradientEnabled; } }
249 public static bool IsToolTipAnimationEnabled { get { return driver.IsToolTipAnimationEnabled; } }
251 static public int KeyboardSpeed {
253 return driver.KeyboardSpeed;
257 static public int KeyboardDelay {
259 return driver.KeyboardDelay;
263 static public Size MaxWindowTrackSize {
265 return driver.MaxWindowTrackSize;
269 static public bool MenuAccessKeysUnderlined {
271 return driver.MenuAccessKeysUnderlined;
275 static public Size MenuBarButtonSize { get { return driver.MenuBarButtonSize; } }
277 public static Size MenuButtonSize {
279 return driver.MenuButtonSize;
283 static public int MenuShowDelay { get { return driver.MenuShowDelay; } }
285 static public Size MinimizedWindowSize {
287 return driver.MinimizedWindowSize;
291 static public Size MinimizedWindowSpacingSize {
293 return driver.MinimizedWindowSpacingSize;
297 static public Size MinimumWindowSize {
299 return driver.MinimumWindowSize;
303 static public Size MinimumFixedToolWindowSize {
304 get { return driver.MinimumFixedToolWindowSize; }
307 static public Size MinimumSizeableToolWindowSize {
308 get { return driver.MinimumSizeableToolWindowSize; }
311 static public Size MinimumNoBorderWindowSize {
312 get { return driver.MinimumNoBorderWindowSize; }
315 static public Size MinWindowTrackSize {
317 return driver.MinWindowTrackSize;
321 public static int MouseSpeed {
322 get { return driver.MouseSpeed; }
325 static public Size SmallIconSize {
327 return driver.SmallIconSize;
331 static public int MenuHeight {
333 return driver.MenuHeight;
337 static public int MouseButtonCount {
339 return driver.MouseButtonCount;
343 static public bool MouseButtonsSwapped {
345 return driver.MouseButtonsSwapped;
349 static public Size MouseHoverSize {
351 return driver.MouseHoverSize;
355 static public int MouseHoverTime {
357 return driver.MouseHoverTime;
361 static public int MouseWheelScrollDelta {
363 return driver.MouseWheelScrollDelta;
367 static public bool MouseWheelPresent {
369 return driver.MouseWheelPresent;
373 public static LeftRightAlignment PopupMenuAlignment {
374 get { return driver.PopupMenuAlignment; }
378 public static PowerStatus PowerStatus {
379 get { return driver.PowerStatus; }
383 public static bool RequiresPositiveClientAreaSize {
385 return driver.RequiresPositiveClientAreaSize;
389 public static int SizingBorderWidth {
390 get { return driver.SizingBorderWidth; }
393 public static Size SmallCaptionButtonSize {
394 get { return driver.SmallCaptionButtonSize; }
397 public static bool UIEffectsEnabled {
398 get { return driver.UIEffectsEnabled; }
401 static public bool UserClipWontExposeParent {
403 return driver.UserClipWontExposeParent;
407 public static int VerticalResizeBorderThickness { get { return driver.VerticalResizeBorderThickness; } }
409 static public int VerticalScrollBarWidth {
411 return driver.VerticalScrollBarWidth;
415 static public Rectangle VirtualScreen {
417 return driver.VirtualScreen;
421 static public Rectangle WorkingArea {
423 return driver.WorkingArea;
427 public static bool ThemesEnabled {
429 return XplatUI.driver.ThemesEnabled;
433 public static int ToolWindowCaptionHeight {
435 return driver.ToolWindowCaptionHeight;
439 public static Size ToolWindowCaptionButtonSize {
441 return driver.ToolWindowCaptionButtonSize;
444 #endregion // Public Static Properties
448 internal static event EventHandler Idle {
450 driver.Idle += value;
453 driver.Idle -= value;
459 #region Public Static Methods
460 internal static void Activate(IntPtr handle) {
462 Console.WriteLine("Activate({0}): Called", Window(handle));
464 driver.Activate(handle);
467 internal static void AudibleAlert(AlertType alert) {
469 Console.WriteLine("AudibleAlert(): Called");
471 driver.AudibleAlert(alert);
474 internal static bool CalculateWindowRect(ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect) {
476 Console.WriteLine("CalculateWindowRect({0}, {1}, {2}): Called", ClientRect, cp, menu);
478 return driver.CalculateWindowRect(ref ClientRect, cp, menu, out WindowRect);
481 internal static void CaretVisible(IntPtr handle, bool visible) {
483 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
485 driver.CaretVisible(handle, visible);
488 internal static void CreateCaret(IntPtr handle, int width, int height) {
490 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
492 driver.CreateCaret(handle, width, height);
495 internal static IntPtr CreateWindow(CreateParams cp) {
496 #if DriverDebug || DriverDebugCreate
499 handle = driver.CreateWindow(cp);
501 Console.WriteLine("CreateWindow(): Called, returning {0:X}", handle.ToInt32());
504 return driver.CreateWindow(cp);
508 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
509 #if DriverDebug || DriverDebugCreate
510 Console.WriteLine("CreateWindow(): Called");
512 return driver.CreateWindow(Parent, X, Y, Width, Height);
515 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
517 Console.WriteLine("ClientToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
519 driver.ClientToScreen(handle, ref x, ref y);
522 internal static int[] ClipboardAvailableFormats(IntPtr handle) {
524 Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
526 return driver.ClipboardAvailableFormats(handle);
529 internal static void ClipboardClose(IntPtr handle) {
531 Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
533 driver.ClipboardClose(handle);
536 internal static int ClipboardGetID(IntPtr handle, string format) {
538 Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
540 return driver.ClipboardGetID(handle, format);
543 internal static IntPtr ClipboardOpen(bool primary_selection) {
545 Console.WriteLine("ClipboardOpen(): Called");
547 return driver.ClipboardOpen (primary_selection);
550 internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
552 Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, type, converter);
554 driver.ClipboardStore(handle, obj, type, converter);
557 internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
559 Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
561 return driver.ClipboardRetrieve(handle, type, converter);
564 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
566 Console.WriteLine("DefineCursor(...): Called");
568 return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
571 internal static IntPtr DefineStdCursor(StdCursor id) {
572 return driver.DefineStdCursor(id);
575 internal static Bitmap DefineStdCursorBitmap(StdCursor id) {
576 return driver.DefineStdCursorBitmap(id);
579 internal static IntPtr DefWndProc(ref Message msg) {
580 return driver.DefWndProc(ref msg);
583 internal static void DestroyCaret(IntPtr handle) {
585 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
587 driver.DestroyCaret(handle);
590 internal static void DestroyCursor(IntPtr cursor) {
592 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
594 driver.DestroyCursor(cursor);
597 internal static void DestroyWindow(IntPtr handle) {
598 #if DriverDebug || DriverDebugDestroy
599 Console.WriteLine("DestroyWindow({0}): Called", Window(handle));
601 driver.DestroyWindow(handle);
604 internal static IntPtr DispatchMessage(ref MSG msg) {
605 return driver.DispatchMessage(ref msg);
608 internal static void DoEvents() {
612 internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
614 Console.WriteLine("DrawReversibleRectangle({0}, {1}, {2}): Called", Window(handle), rect, line_width);
616 driver.DrawReversibleRectangle(handle, rect, line_width);
619 internal static void FillReversibleRectangle (Rectangle rectangle, Color backColor)
622 Console.WriteLine("FillReversibleRectangle({0}, {1}): Called", rectangle, backColor);
624 driver.FillReversibleRectangle (rectangle, backColor);
627 internal static void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
630 Console.WriteLine("DrawReversibleFrame({0}, {1}, {2}): Called", rectangle, backColor, style);
632 driver.DrawReversibleFrame (rectangle, backColor, style);
635 internal static void DrawReversibleLine (Point start, Point end, Color backColor)
638 Console.WriteLine("DrawReversibleLine({0}, {1}, {2}): Called", start, end, backColor);
640 driver.DrawReversibleLine (start, end, backColor);
643 internal static void EnableThemes() {
644 driver.EnableThemes();
647 internal static void EnableWindow(IntPtr handle, bool Enable) {
648 #if DriverDebug || DriverDebugState
649 Console.WriteLine("EnableWindow({0}, {1}): Called", Window(handle), Enable);
651 driver.EnableWindow(handle, Enable);
654 internal static void EndLoop(Thread thread) {
656 Console.WriteLine("EndLoop({0:X}): Called", thread.GetHashCode());
658 driver.EndLoop(thread);
661 internal static IntPtr GetActive() {
663 Console.WriteLine("GetActive(): Called");
665 return driver.GetActive();
668 internal static SizeF GetAutoScaleSize(Font font) {
670 Console.WriteLine("GetAutoScaleSize({0}): Called", font);
672 return driver.GetAutoScaleSize(font);
675 internal static Region GetClipRegion(IntPtr handle) {
677 Console.WriteLine("GetClipRegion({0}): Called", Window(handle));
679 return driver.GetClipRegion(handle);
682 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
684 Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
686 driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
689 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
691 Console.WriteLine("GetCursorPos({0}): Called", Window(handle));
693 driver.GetCursorPos(handle, out x, out y);
696 internal static void GetDisplaySize(out Size size) {
698 Console.WriteLine("GetDisplaySize(): Called");
700 driver.GetDisplaySize(out size);
703 internal static IntPtr GetFocus() {
705 Console.WriteLine("GetFocus(): Called, Result:{0}", Window(driver.GetFocus()));
707 return driver.GetFocus();
710 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
712 Console.WriteLine("GetFontMetrics(): Called");
714 return driver.GetFontMetrics(g, font, out ascent, out descent);
717 internal static Point GetMenuOrigin(IntPtr handle) {
719 Console.WriteLine("GetMenuOrigin({0}): Called", Window(handle));
721 return driver.GetMenuOrigin(handle);
724 internal static bool GetMessage(object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
725 return driver.GetMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
728 internal static IntPtr GetParent(IntPtr handle) {
730 Console.WriteLine("GetParent({0}): Called", Window(handle));
732 return driver.GetParent(handle);
735 internal static IntPtr GetPreviousWindow(IntPtr handle) {
736 return driver.GetPreviousWindow(handle);
739 internal static bool GetText(IntPtr handle, out string text) {
741 Console.WriteLine("GetText({0}): Called", Window(handle));
743 return driver.GetText(handle, out text);
746 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) {
748 Console.WriteLine("GetWindowPos({0}): Called", Window(handle));
750 driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
753 /* this method can (and does, on X11) return
754 * (FormWindowState)(-1), when the state of the window
755 * cannot be determined (in the X11 case, when the
756 * window isn't mapped.) Checking for the additional
757 * return value is less expensive than
758 * throwing/catching an exception. */
759 internal static FormWindowState GetWindowState(IntPtr handle) {
761 Console.WriteLine("GetWindowState({0}): Called", Window(handle));
763 return driver.GetWindowState(handle);
766 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
768 Console.WriteLine("GrabInfo(): Called");
770 driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
773 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
775 Console.WriteLine("GrabWindow({0}, {1}): Called", Window(handle), Window(ConfineToHwnd));
777 driver.GrabWindow(handle, ConfineToHwnd);
780 internal static void HandleException(Exception e) {
781 driver.HandleException(e);
784 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
786 Console.WriteLine("Invalidate({0}, {1}, {2}): Called", Window(handle), rc, clear);
788 driver.Invalidate(handle, rc, clear);
791 internal static void InvalidateNC (IntPtr handle)
794 Console.WriteLine("InvalidateNC({0}): Called", Window(handle));
796 driver.InvalidateNC(handle);
800 internal static bool IsEnabled(IntPtr handle) {
801 #if DriverDebug || DriverDebugState
802 Console.WriteLine("IsEnabled({0}): Called, Result={1}", Window(handle), driver.IsEnabled(handle));
804 return driver.IsEnabled(handle);
807 internal static bool IsKeyLocked (VirtualKeys key)
809 #if DriverDebug || DriverDebugState
810 Console.WriteLine("IsKeyLocked({0}): Called, Result={1}", key, driver.IsKeyLocked(key));
812 return driver.IsKeyLocked (key);
815 internal static bool IsVisible(IntPtr handle) {
816 #if DriverDebug || DriverDebugState
817 Console.WriteLine("IsVisible({0}): Called, Result={1}", Window(handle), driver.IsVisible(handle));
819 return driver.IsVisible(handle);
822 internal static void KillTimer (Timer timer)
825 Console.WriteLine("KillTimer({0}): Called", timer);
827 driver.KillTimer (timer);
830 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
832 Console.WriteLine("MenuToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
834 driver.MenuToScreen(handle, ref x, ref y);
837 internal static void OverrideCursor(IntPtr cursor) {
839 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
841 driver.OverrideCursor(cursor);
844 internal static void PaintEventEnd (ref Message msg, IntPtr handle, bool client) {
845 #if DriverDebug || DriverDebugPaint
846 Console.WriteLine("PaintEventEnd({0}, {1}, {2}): Called from thread {3}", msg, Window(handle), client, Thread.CurrentThread.GetHashCode());
848 driver.PaintEventEnd (ref msg, handle, client);
851 internal static PaintEventArgs PaintEventStart (ref Message msg, IntPtr handle, bool client) {
852 #if DriverDebug || DriverDebugPaint
853 Console.WriteLine("PaintEventStart({0}, {1}, {2}): Called from thread {3}", msg, Window(handle), client, Thread.CurrentThread.GetHashCode());
855 return driver.PaintEventStart (ref msg, handle, client);
858 internal static bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
859 return driver.PeekMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
862 internal static bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
864 Console.WriteLine("PostMessage({0}, {1}, {2:X}, {3:X}): Called", Window(hwnd), message, wParam.ToInt32(), lParam.ToInt32());
866 return driver.PostMessage(hwnd, message, wParam, lParam);
869 internal static bool PostMessage(ref MSG msg) {
871 Console.WriteLine("PostMessage({0}): Called", msg);
873 return driver.PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
876 internal static void PostQuitMessage(int exitCode) {
878 Console.WriteLine("PostQuitMessage({0}): Called", exitCode);
880 driver.PostQuitMessage(exitCode);
883 internal static void RaiseIdle (EventArgs e)
886 Console.WriteLine("RaiseIdle({0}): Called", e.ToString ());
889 driver.RaiseIdle (e);
892 internal static void RequestAdditionalWM_NCMessages(IntPtr handle, bool hover, bool leave) {
894 Console.WriteLine("RequestAdditionalWM_NCMessages({0}, {1}, {2}): Called", Window(handle), hover, leave);
896 driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
899 internal static void RequestNCRecalc(IntPtr handle) {
901 Console.WriteLine("RequestNCRecalc({0}): Called", Window(handle));
903 driver.RequestNCRecalc(handle);
906 internal static void ResetMouseHover(IntPtr handle) {
908 Console.WriteLine("ResetMouseHover({0}): Called", Window(handle));
910 driver.ResetMouseHover(handle);
913 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
915 Console.WriteLine("ScreenToClient({0}, {1}, {2}): Called", Window(handle), x, y);
917 driver.ScreenToClient (handle, ref x, ref y);
920 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
922 Console.WriteLine("ScreenToMenu({0}, {1}, {2}): Called", Window(handle), x, y);
924 driver.ScreenToMenu(handle, ref x, ref y);
927 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
929 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}, {4}): Called", Window(handle), rectangle, XAmount, YAmount, with_children);
931 driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
934 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
936 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}): Called", Window(handle), XAmount, YAmount, with_children);
938 driver.ScrollWindow(handle, XAmount, YAmount, with_children);
941 internal static void SendAsyncMethod (AsyncMethodData data) {
943 Console.WriteLine("SendAsyncMethod({0}): Called", data);
945 driver.SendAsyncMethod (data);
948 internal static int SendInput (IntPtr hwnd, Queue keys) {
950 Console.WriteLine("SendInput({0}, {1}): Called", hwnd, keys);
952 return driver.SendInput (hwnd, keys);
955 internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) {
957 Console.WriteLine("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window(handle), message, wParam.ToInt32(), lParam.ToInt32());
959 return driver.SendMessage (handle, message, wParam, lParam);
962 internal static void SendMessage (ref Message m) {
964 Console.WriteLine("SendMessage ({0}): Called", m);
966 m.Result = driver.SendMessage(m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
969 internal static void SetAllowDrop (IntPtr handle, bool value)
972 Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
974 driver.SetAllowDrop (handle, value);
977 internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
979 Console.WriteLine("SetBorderStyle({0}, {1}): Called", Window(handle), border_style);
981 driver.SetBorderStyle(handle, border_style);
984 internal static void SetCaretPos(IntPtr handle, int x, int y) {
986 Console.WriteLine("SetCaretPos({0}, {1}, {2}): Called", Window(handle), x, y);
988 driver.SetCaretPos(handle, x, y);
991 internal static void SetClipRegion(IntPtr handle, Region region) {
993 Console.WriteLine("SetClipRegion({0}, {1}): Called", Window(handle), region);
995 driver.SetClipRegion(handle, region);
998 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
1000 Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
1002 driver.SetCursor(handle, cursor);
1005 internal static void SetCursorPos(IntPtr handle, int x, int y) {
1007 Console.WriteLine("SetCursorPos({0}, {1}, {2}): Called", Window(handle), x, y);
1009 driver.SetCursorPos(handle, x, y);
1012 internal static void SetFocus(IntPtr handle) {
1014 Console.WriteLine("SetFocus({0}): Called", Window(handle));
1016 driver.SetFocus(handle);
1019 internal static void SetForegroundWindow(IntPtr handle) {
1021 Console.WriteLine("SetForegroundWindow({0}): Called", Window(handle));
1023 driver.SetForegroundWindow(handle);
1026 internal static void SetIcon(IntPtr handle, Icon icon) {
1028 Console.WriteLine("SetIcon({0}, {1}): Called", Window(handle), icon);
1030 driver.SetIcon(handle, icon);
1033 internal static void SetMenu(IntPtr handle, Menu menu) {
1035 Console.WriteLine("SetMenu({0}, {1}): Called", Window(handle), menu);
1037 driver.SetMenu(handle, menu);
1040 internal static void SetModal(IntPtr handle, bool Modal) {
1041 #if DriverDebug || DriverDebugState
1042 Console.WriteLine("SetModal({0}, {1}): Called", Window(handle), Modal);
1044 driver.SetModal(handle, Modal);
1047 internal static IntPtr SetParent(IntPtr handle, IntPtr hParent) {
1049 Console.WriteLine("SetParent({0}, {1:X}): Called", Window(handle), Window(hParent));
1051 return driver.SetParent(handle, hParent);
1054 internal static void SetTimer (Timer timer)
1057 Console.WriteLine("SetTimer({0}): Called", timer);
1059 driver.SetTimer (timer);
1062 internal static bool SetTopmost(IntPtr handle, bool Enabled) {
1064 Console.WriteLine("SetTopMost({0}, {1}): Called", Window(handle), Enabled);
1066 return driver.SetTopmost(handle, Enabled);
1069 internal static bool SetOwner(IntPtr handle, IntPtr hWndOwner) {
1071 Console.WriteLine("SetOwner({0}, {1}): Called", Window(handle), Window(hWndOwner));
1073 return driver.SetOwner(handle, hWndOwner);
1076 internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
1078 #if DriverDebug || DriverDebugState
1079 Console.WriteLine("SetVisible({0}, {1}, {2}): Called", Window(handle), visible, activate);
1081 return driver.SetVisible (handle, visible, activate);
1084 internal static void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
1085 #if DriverDebug || DriverDebugState
1086 Console.WriteLine("SetWindowMinMax({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max);
1088 driver.SetWindowMinMax(handle, maximized, min, max);
1091 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
1093 Console.WriteLine("SetWindowPos({0}, {1}, {2}, {3}, {4}): Called", Window(handle), x, y, width, height);
1095 driver.SetWindowPos(handle, x, y, width, height);
1098 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
1099 #if DriverDebug || DriverDebugState
1100 Console.WriteLine("SetWindowState({0} {1}): Called", Window(handle), state);
1102 driver.SetWindowState(handle, state);
1105 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
1107 Console.WriteLine("SetWindowStyle({0}): Called", Window(handle));
1109 driver.SetWindowStyle(handle, cp);
1112 internal static double GetWindowTransparency (IntPtr handle)
1115 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
1117 return driver.GetWindowTransparency(handle);
1120 internal static void SetWindowTransparency(IntPtr handle, double transparency, Color key)
1123 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
1125 driver.SetWindowTransparency(handle, transparency, key);
1128 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
1130 Console.WriteLine("SetZOrder({0}, {1:X}, {2}, {3}): Called", Window(handle), Window(AfterhWnd), Top, Bottom);
1132 return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
1135 internal static void ShowCursor(bool show) {
1137 Console.WriteLine("ShowCursor({0}): Called", show);
1139 driver.ShowCursor(show);
1142 internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
1144 Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", Window(handle), data, allowedEffects);
1146 return driver.StartDrag (handle, data, allowedEffects);
1149 internal static object StartLoop(Thread thread) {
1151 Console.WriteLine("StartLoop({0:X}): Called", thread.GetHashCode());
1153 return driver.StartLoop(thread);
1156 internal static TransparencySupport SupportsTransparency() {
1158 Console.WriteLine("SupportsTransparency(): Called, result={0}", driver.SupportsTransparency());
1160 return driver.SupportsTransparency();
1163 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
1165 Console.WriteLine("SystrayAdd({0}, {1}): Called", Window(handle), tip);
1167 return driver.SystrayAdd(handle, tip, icon, out tt);
1170 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
1172 Console.WriteLine("SystrayChange({0}, {1}): Called", Window(handle), tip);
1174 driver.SystrayChange(handle, tip, icon, ref tt);
1177 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
1179 Console.WriteLine("SystrayRemove({0}): Called", Window(handle));
1181 driver.SystrayRemove(handle, ref tt);
1185 internal static void SystrayBalloon(IntPtr handle, int timeout, string title, string text, ToolTipIcon icon) {
1187 Console.WriteLine("SystrayBalloon ({0}, {1}, {2}, {3}, {4}): Called", Window(handle), timeout, title, text, icon);
1189 driver.SystrayBalloon(handle, timeout, title, text, icon);
1193 internal static bool Text(IntPtr handle, string text) {
1195 Console.WriteLine("Text({0}, {1}): Called", Window(handle), text);
1197 return driver.Text(handle, text);
1200 internal static bool TranslateMessage(ref MSG msg) {
1201 return driver.TranslateMessage(ref msg);
1204 internal static void UngrabWindow(IntPtr handle) {
1206 Console.WriteLine("UngrabWindow({0}): Called", Window(handle));
1208 driver.UngrabWindow(handle);
1211 internal static void UpdateWindow(IntPtr handle) {
1213 Console.WriteLine("UpdateWindow({0}): Called", Window(handle));
1215 driver.UpdateWindow(handle);
1219 internal static void CreateOffscreenDrawable (IntPtr handle,
1220 int width, int height,
1221 out object offscreen_drawable)
1224 Console.WriteLine("CreateOffscreenDrawable({2}, {0},{1}): Called", width, height, Window(handle));
1226 driver.CreateOffscreenDrawable (handle, width, height,
1227 out offscreen_drawable);
1230 internal static void DestroyOffscreenDrawable (object offscreen_drawable)
1233 Console.WriteLine("DestroyOffscreenDrawable(): Called");
1235 driver.DestroyOffscreenDrawable (offscreen_drawable);
1238 internal static Graphics GetOffscreenGraphics (object offscreen_drawable)
1241 Console.WriteLine("GetOffscreenGraphics(): Called");
1243 return driver.GetOffscreenGraphics (offscreen_drawable);
1246 internal static void BlitFromOffscreen (IntPtr dest_handle,
1248 object offscreen_drawable,
1249 Graphics offscreen_dc,
1253 Console.WriteLine("BlitFromOffscreen({0}): Called", Window(dest_handle));
1255 driver.BlitFromOffscreen (dest_handle, dest_dc, offscreen_drawable, offscreen_dc, r);
1259 // Santa's little helper
1260 internal static void Version() {
1261 Console.WriteLine("Xplat version $Revision: $");
1264 internal static void AddKeyFilter (IKeyFilter value)
1266 lock (key_filters) {
1267 key_filters.Add (value);
1271 internal static bool FilterKey (KeyFilterData key)
1273 lock (key_filters) {
1274 for (int i = 0; i < key_filters.Count; i++) {
1275 IKeyFilter filter = (IKeyFilter) key_filters[i];
1276 if (filter.PreFilterKey (key))
1282 #endregion // Public Static Methods
1285 public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
1286 public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
1287 #endregion // Delegates
1289 [DllImport ("libc")]
1290 static extern int uname (IntPtr buf);