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);
116 #endregion // Constructor & Destructor
118 #region Public Static Properties
120 public static bool RunningOnUnix {
122 #if NET_2_0 && !MWF_ON_MSRUNTIME
123 return (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX);
125 int platform = (int) Environment.OSVersion.Platform;
126 return (platform == 128);
131 public static int ActiveWindowTrackingDelay {
132 get { return driver.ActiveWindowTrackingDelay; }
135 internal static string DefaultClassName {
137 return default_class_name;
141 default_class_name=value;
145 static public Size Border3DSize {
147 return driver.Border3DSize;
151 static public Size BorderSize {
153 return driver.BorderSize;
157 static public Size CaptionButtonSize {
159 return driver.CaptionButtonSize;
163 static public int CaptionHeight {
165 return driver.CaptionHeight;
169 public static int CaretBlinkTime { get { return driver.CaretBlinkTime; } }
170 public static int CaretWidth { get { return driver.CaretWidth; } }
172 static public Size CursorSize {
174 return driver.CursorSize;
178 static public Size DoubleClickSize {
180 return driver.DoubleClickSize;
184 static public int DoubleClickTime {
186 return driver.DoubleClickTime;
190 static public bool DragFullWindows {
192 return driver.DragFullWindows;
196 static public Size DragSize {
198 return driver.DragSize;
202 static public Size FixedFrameBorderSize {
204 return driver.FixedFrameBorderSize;
208 public static int FontSmoothingContrast { get { return driver.FontSmoothingContrast; } }
209 public static int FontSmoothingType { get { return driver.FontSmoothingType; } }
211 public static Size FrameBorderSize {
213 return driver.FrameBorderSize;
217 public static int HorizontalResizeBorderThickness { get { return driver.HorizontalResizeBorderThickness; } }
219 static public int HorizontalScrollBarHeight {
221 return driver.HorizontalScrollBarHeight;
225 static public Size IconSize {
227 return driver.IconSize;
231 public static bool IsActiveWindowTrackingEnabled { get { return driver.IsActiveWindowTrackingEnabled; } }
232 public static bool IsComboBoxAnimationEnabled { get { return driver.IsComboBoxAnimationEnabled; } }
233 public static bool IsDropShadowEnabled { get { return driver.IsDropShadowEnabled; } }
234 public static bool IsFontSmoothingEnabled { get { return driver.IsFontSmoothingEnabled; } }
235 public static bool IsHotTrackingEnabled { get { return driver.IsHotTrackingEnabled; } }
236 public static bool IsIconTitleWrappingEnabled { get { return driver.IsIconTitleWrappingEnabled; } }
237 public static bool IsKeyboardPreferred { get { return driver.IsKeyboardPreferred; } }
238 public static bool IsListBoxSmoothScrollingEnabled { get { return driver.IsListBoxSmoothScrollingEnabled; } }
239 public static bool IsMenuAnimationEnabled { get { return driver.IsMenuAnimationEnabled; } }
240 public static bool IsMenuFadeEnabled { get { return driver.IsMenuFadeEnabled; } }
241 public static bool IsMinimizeRestoreAnimationEnabled { get { return driver.IsMinimizeRestoreAnimationEnabled; } }
242 public static bool IsSelectionFadeEnabled { get { return driver.IsSelectionFadeEnabled; } }
243 public static bool IsSnapToDefaultEnabled { get { return driver.IsSnapToDefaultEnabled; } }
244 public static bool IsTitleBarGradientEnabled { get { return driver.IsTitleBarGradientEnabled; } }
245 public static bool IsToolTipAnimationEnabled { get { return driver.IsToolTipAnimationEnabled; } }
247 static public int KeyboardSpeed {
249 return driver.KeyboardSpeed;
253 static public int KeyboardDelay {
255 return driver.KeyboardDelay;
259 static public Size MaxWindowTrackSize {
261 return driver.MaxWindowTrackSize;
265 static public bool MenuAccessKeysUnderlined {
267 return driver.MenuAccessKeysUnderlined;
271 static public Size MenuBarButtonSize { get { return driver.MenuBarButtonSize; } }
273 public static Size MenuButtonSize {
275 return driver.MenuButtonSize;
279 static public int MenuShowDelay { get { return driver.MenuShowDelay; } }
281 static public Size MinimizedWindowSize {
283 return driver.MinimizedWindowSize;
287 static public Size MinimizedWindowSpacingSize {
289 return driver.MinimizedWindowSpacingSize;
293 static public Size MinimumWindowSize {
295 return driver.MinimumWindowSize;
299 static public Size MinimumFixedToolWindowSize {
300 get { return driver.MinimumFixedToolWindowSize; }
303 static public Size MinimumSizeableToolWindowSize {
304 get { return driver.MinimumSizeableToolWindowSize; }
307 static public Size MinimumNoBorderWindowSize {
308 get { return driver.MinimumNoBorderWindowSize; }
311 static public Size MinWindowTrackSize {
313 return driver.MinWindowTrackSize;
317 public static int MouseSpeed {
318 get { return driver.MouseSpeed; }
321 static public Size SmallIconSize {
323 return driver.SmallIconSize;
327 static public int MenuHeight {
329 return driver.MenuHeight;
333 static public int MouseButtonCount {
335 return driver.MouseButtonCount;
339 static public bool MouseButtonsSwapped {
341 return driver.MouseButtonsSwapped;
345 static public Size MouseHoverSize {
347 return driver.MouseHoverSize;
351 static public int MouseHoverTime {
353 return driver.MouseHoverTime;
357 static public int MouseWheelScrollDelta {
359 return driver.MouseWheelScrollDelta;
363 static public bool MouseWheelPresent {
365 return driver.MouseWheelPresent;
369 public static LeftRightAlignment PopupMenuAlignment {
370 get { return driver.PopupMenuAlignment; }
374 public static PowerStatus PowerStatus {
375 get { return driver.PowerStatus; }
379 public static bool RequiresPositiveClientAreaSize {
381 return driver.RequiresPositiveClientAreaSize;
385 public static int SizingBorderWidth {
386 get { return driver.SizingBorderWidth; }
389 public static Size SmallCaptionButtonSize {
390 get { return driver.SmallCaptionButtonSize; }
393 public static bool UIEffectsEnabled {
394 get { return driver.UIEffectsEnabled; }
397 static public bool UserClipWontExposeParent {
399 return driver.UserClipWontExposeParent;
403 public static int VerticalResizeBorderThickness { get { return driver.VerticalResizeBorderThickness; } }
405 static public int VerticalScrollBarWidth {
407 return driver.VerticalScrollBarWidth;
411 static public Rectangle VirtualScreen {
413 return driver.VirtualScreen;
417 static public Rectangle WorkingArea {
419 return driver.WorkingArea;
423 public static bool ThemesEnabled {
425 return XplatUI.driver.ThemesEnabled;
429 public static int ToolWindowCaptionHeight {
431 return driver.ToolWindowCaptionHeight;
435 public static Size ToolWindowCaptionButtonSize {
437 return driver.ToolWindowCaptionButtonSize;
440 #endregion // Public Static Properties
444 internal static event EventHandler Idle {
446 driver.Idle += value;
449 driver.Idle -= value;
455 #region Public Static Methods
456 internal static void Activate(IntPtr handle) {
458 Console.WriteLine("Activate({0}): Called", Window(handle));
460 driver.Activate(handle);
463 internal static void AudibleAlert() {
465 Console.WriteLine("AudibleAlert(): Called");
467 driver.AudibleAlert();
470 internal static bool CalculateWindowRect(ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect) {
472 Console.WriteLine("CalculateWindowRect({0}, {1}, {2}): Called", ClientRect, cp, menu);
474 return driver.CalculateWindowRect(ref ClientRect, cp, menu, out WindowRect);
477 internal static void CaretVisible(IntPtr handle, bool visible) {
479 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
481 driver.CaretVisible(handle, visible);
484 internal static void CreateCaret(IntPtr handle, int width, int height) {
486 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
488 driver.CreateCaret(handle, width, height);
491 internal static IntPtr CreateWindow(CreateParams cp) {
492 #if DriverDebug || DriverDebugCreate
495 handle = driver.CreateWindow(cp);
497 Console.WriteLine("CreateWindow(): Called, returning {0:X}", handle.ToInt32());
500 return driver.CreateWindow(cp);
504 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
505 #if DriverDebug || DriverDebugCreate
506 Console.WriteLine("CreateWindow(): Called");
508 return driver.CreateWindow(Parent, X, Y, Width, Height);
511 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
513 Console.WriteLine("ClientToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
515 driver.ClientToScreen(handle, ref x, ref y);
518 internal static int[] ClipboardAvailableFormats(IntPtr handle) {
520 Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
522 return driver.ClipboardAvailableFormats(handle);
525 internal static void ClipboardClose(IntPtr handle) {
527 Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
529 driver.ClipboardClose(handle);
532 internal static int ClipboardGetID(IntPtr handle, string format) {
534 Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
536 return driver.ClipboardGetID(handle, format);
539 internal static IntPtr ClipboardOpen(bool primary_selection) {
541 Console.WriteLine("ClipboardOpen(): Called");
543 return driver.ClipboardOpen (primary_selection);
546 internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
548 Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, type, converter);
550 driver.ClipboardStore(handle, obj, type, converter);
553 internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
555 Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
557 return driver.ClipboardRetrieve(handle, type, converter);
560 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
562 Console.WriteLine("DefineCursor(...): Called");
564 return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
567 internal static IntPtr DefineStdCursor(StdCursor id) {
568 return driver.DefineStdCursor(id);
571 internal static Bitmap DefineStdCursorBitmap(StdCursor id) {
572 return driver.DefineStdCursorBitmap(id);
575 internal static IntPtr DefWndProc(ref Message msg) {
576 return driver.DefWndProc(ref msg);
579 internal static void DestroyCaret(IntPtr handle) {
581 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
583 driver.DestroyCaret(handle);
586 internal static void DestroyCursor(IntPtr cursor) {
588 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
590 driver.DestroyCursor(cursor);
593 internal static void DestroyWindow(IntPtr handle) {
594 #if DriverDebug || DriverDebugDestroy
595 Console.WriteLine("DestroyWindow({0}): Called", Window(handle));
597 driver.DestroyWindow(handle);
600 internal static IntPtr DispatchMessage(ref MSG msg) {
601 return driver.DispatchMessage(ref msg);
604 internal static void DoEvents() {
608 internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
610 Console.WriteLine("DrawReversibleRectangle({0}, {1}, {2}): Called", Window(handle), rect, line_width);
612 driver.DrawReversibleRectangle(handle, rect, line_width);
615 internal static void FillReversibleRectangle (Rectangle rectangle, Color backColor)
618 Console.WriteLine("FillReversibleRectangle({0}, {1}): Called", rectangle, backColor);
620 driver.FillReversibleRectangle (rectangle, backColor);
623 internal static void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
626 Console.WriteLine("DrawReversibleFrame({0}, {1}, {2}): Called", rectangle, backColor, style);
628 driver.DrawReversibleFrame (rectangle, backColor, style);
631 internal static void DrawReversibleLine (Point start, Point end, Color backColor)
634 Console.WriteLine("DrawReversibleLine({0}, {1}, {2}): Called", start, end, backColor);
636 driver.DrawReversibleLine (start, end, backColor);
639 internal static void EnableThemes() {
640 driver.EnableThemes();
643 internal static void EnableWindow(IntPtr handle, bool Enable) {
644 #if DriverDebug || DriverDebugState
645 Console.WriteLine("EnableWindow({0}, {1}): Called", Window(handle), Enable);
647 driver.EnableWindow(handle, Enable);
650 internal static void EndLoop(Thread thread) {
652 Console.WriteLine("EndLoop({0:X}): Called", thread.GetHashCode());
654 driver.EndLoop(thread);
657 internal static IntPtr GetActive() {
659 Console.WriteLine("GetActive(): Called");
661 return driver.GetActive();
664 internal static SizeF GetAutoScaleSize(Font font) {
666 Console.WriteLine("GetAutoScaleSize({0}): Called", font);
668 return driver.GetAutoScaleSize(font);
671 internal static Region GetClipRegion(IntPtr handle) {
673 Console.WriteLine("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 Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
682 driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
685 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
687 Console.WriteLine("GetCursorPos({0}): Called", Window(handle));
689 driver.GetCursorPos(handle, out x, out y);
692 internal static void GetDisplaySize(out Size size) {
694 Console.WriteLine("GetDisplaySize(): Called");
696 driver.GetDisplaySize(out size);
699 internal static IntPtr GetFocus() {
701 Console.WriteLine("GetFocus(): Called, Result:{0}", Window(driver.GetFocus()));
703 return driver.GetFocus();
706 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
708 Console.WriteLine("GetFontMetrics(): Called");
710 return driver.GetFontMetrics(g, font, out ascent, out descent);
713 internal static Point GetMenuOrigin(IntPtr handle) {
715 Console.WriteLine("GetMenuOrigin({0}): Called", Window(handle));
717 return driver.GetMenuOrigin(handle);
720 internal static bool GetMessage(object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
721 return driver.GetMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
724 internal static IntPtr GetParent(IntPtr handle) {
726 Console.WriteLine("GetParent({0}): Called", Window(handle));
728 return driver.GetParent(handle);
731 internal static IntPtr GetPreviousWindow(IntPtr handle) {
732 return driver.GetPreviousWindow(handle);
735 internal static bool GetText(IntPtr handle, out string text) {
737 Console.WriteLine("GetText({0}): Called", Window(handle));
739 return driver.GetText(handle, out text);
742 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) {
744 Console.WriteLine("GetWindowPos({0}): Called", Window(handle));
746 driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
749 /* this method can (and does, on X11) return
750 * (FormWindowState)(-1), when the state of the window
751 * cannot be determined (in the X11 case, when the
752 * window isn't mapped.) Checking for the additional
753 * return value is less expensive than
754 * throwing/catching an exception. */
755 internal static FormWindowState GetWindowState(IntPtr handle) {
757 Console.WriteLine("GetWindowState({0}): Called", Window(handle));
759 return driver.GetWindowState(handle);
762 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
764 Console.WriteLine("GrabInfo(): Called");
766 driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
769 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
771 Console.WriteLine("GrabWindow({0}, {1}): Called", Window(handle), Window(ConfineToHwnd));
773 driver.GrabWindow(handle, ConfineToHwnd);
776 internal static void HandleException(Exception e) {
777 driver.HandleException(e);
780 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
782 Console.WriteLine("Invalidate({0}, {1}, {2}): Called", Window(handle), rc, clear);
784 driver.Invalidate(handle, rc, clear);
787 internal static void InvalidateNC (IntPtr handle)
790 Console.WriteLine("InvalidateNC({0}): Called", Window(handle));
792 driver.InvalidateNC(handle);
796 internal static bool IsEnabled(IntPtr handle) {
797 #if DriverDebug || DriverDebugState
798 Console.WriteLine("IsEnabled({0}): Called, Result={1}", Window(handle), driver.IsEnabled(handle));
800 return driver.IsEnabled(handle);
803 internal static bool IsKeyLocked (VirtualKeys key)
805 #if DriverDebug || DriverDebugState
806 Console.WriteLine("IsKeyLocked({0}): Called, Result={1}", key, driver.IsKeyLocked(key));
808 return driver.IsKeyLocked (key);
811 internal static bool IsVisible(IntPtr handle) {
812 #if DriverDebug || DriverDebugState
813 Console.WriteLine("IsVisible({0}): Called, Result={1}", Window(handle), driver.IsVisible(handle));
815 return driver.IsVisible(handle);
818 internal static void KillTimer (Timer timer)
821 Console.WriteLine("KillTimer({0}): Called", timer);
823 driver.KillTimer (timer);
826 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
828 Console.WriteLine("MenuToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
830 driver.MenuToScreen(handle, ref x, ref y);
833 internal static void OverrideCursor(IntPtr cursor) {
835 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
837 driver.OverrideCursor(cursor);
840 internal static void PaintEventEnd (ref Message msg, IntPtr handle, bool client) {
841 #if DriverDebug || DriverDebugPaint
842 Console.WriteLine("PaintEventEnd({0}, {1}, {2}): Called from thread {3}", msg, Window(handle), client, Thread.CurrentThread.GetHashCode());
844 driver.PaintEventEnd (ref msg, handle, client);
847 internal static PaintEventArgs PaintEventStart (ref Message msg, IntPtr handle, bool client) {
848 #if DriverDebug || DriverDebugPaint
849 Console.WriteLine("PaintEventStart({0}, {1}, {2}): Called from thread {3}", msg, Window(handle), client, Thread.CurrentThread.GetHashCode());
851 return driver.PaintEventStart (ref msg, handle, client);
854 internal static bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
855 return driver.PeekMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
858 internal static bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
860 Console.WriteLine("PostMessage({0}, {1}, {2:X}, {3:X}): Called", Window(hwnd), message, wParam.ToInt32(), lParam.ToInt32());
862 return driver.PostMessage(hwnd, message, wParam, lParam);
865 internal static bool PostMessage(ref MSG msg) {
867 Console.WriteLine("PostMessage({0}): Called", msg);
869 return driver.PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
872 internal static void PostQuitMessage(int exitCode) {
874 Console.WriteLine("PostQuitMessage({0}): Called", exitCode);
876 driver.PostQuitMessage(exitCode);
879 internal static void RaiseIdle (EventArgs e)
882 Console.WriteLine("RaiseIdle({0}): Called", e.ToString ());
885 driver.RaiseIdle (e);
888 internal static void RequestAdditionalWM_NCMessages(IntPtr handle, bool hover, bool leave) {
890 Console.WriteLine("RequestAdditionalWM_NCMessages({0}, {1}, {2}): Called", Window(handle), hover, leave);
892 driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
895 internal static void RequestNCRecalc(IntPtr handle) {
897 Console.WriteLine("RequestNCRecalc({0}): Called", Window(handle));
899 driver.RequestNCRecalc(handle);
902 internal static void ResetMouseHover(IntPtr handle) {
904 Console.WriteLine("ResetMouseHover({0}): Called", Window(handle));
906 driver.ResetMouseHover(handle);
909 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
911 Console.WriteLine("ScreenToClient({0}, {1}, {2}): Called", Window(handle), x, y);
913 driver.ScreenToClient (handle, ref x, ref y);
916 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
918 Console.WriteLine("ScreenToMenu({0}, {1}, {2}): Called", Window(handle), x, y);
920 driver.ScreenToMenu(handle, ref x, ref y);
923 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
925 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}, {4}): Called", Window(handle), rectangle, XAmount, YAmount, with_children);
927 driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
930 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
932 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}): Called", Window(handle), XAmount, YAmount, with_children);
934 driver.ScrollWindow(handle, XAmount, YAmount, with_children);
937 internal static void SendAsyncMethod (AsyncMethodData data) {
939 Console.WriteLine("SendAsyncMethod({0}): Called", data);
941 driver.SendAsyncMethod (data);
944 internal static int SendInput (IntPtr hwnd, Queue keys) {
946 Console.WriteLine("SendInput({0}, {1}): Called", hwnd, keys);
948 return driver.SendInput (hwnd, keys);
951 internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) {
953 Console.WriteLine("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window(handle), message, wParam.ToInt32(), lParam.ToInt32());
955 return driver.SendMessage (handle, message, wParam, lParam);
958 internal static void SendMessage (ref Message m) {
960 Console.WriteLine("SendMessage ({0}): Called", m);
962 m.Result = driver.SendMessage(m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
965 internal static void SetAllowDrop (IntPtr handle, bool value)
968 Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
970 driver.SetAllowDrop (handle, value);
973 internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
975 Console.WriteLine("SetBorderStyle({0}, {1}): Called", Window(handle), border_style);
977 driver.SetBorderStyle(handle, border_style);
980 internal static void SetCaretPos(IntPtr handle, int x, int y) {
982 Console.WriteLine("SetCaretPos({0}, {1}, {2}): Called", Window(handle), x, y);
984 driver.SetCaretPos(handle, x, y);
987 internal static void SetClipRegion(IntPtr handle, Region region) {
989 Console.WriteLine("SetClipRegion({0}, {1}): Called", Window(handle), region);
991 driver.SetClipRegion(handle, region);
994 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
996 Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
998 driver.SetCursor(handle, cursor);
1001 internal static void SetCursorPos(IntPtr handle, int x, int y) {
1003 Console.WriteLine("SetCursorPos({0}, {1}, {2}): Called", Window(handle), x, y);
1005 driver.SetCursorPos(handle, x, y);
1008 internal static void SetFocus(IntPtr handle) {
1010 Console.WriteLine("SetFocus({0}): Called", Window(handle));
1012 driver.SetFocus(handle);
1015 internal static void SetForegroundWindow(IntPtr handle) {
1017 Console.WriteLine("SetForegroundWindow({0}): Called", Window(handle));
1019 driver.SetForegroundWindow(handle);
1022 internal static void SetIcon(IntPtr handle, Icon icon) {
1024 Console.WriteLine("SetIcon({0}, {1}): Called", Window(handle), icon);
1026 driver.SetIcon(handle, icon);
1029 internal static void SetMenu(IntPtr handle, Menu menu) {
1031 Console.WriteLine("SetMenu({0}, {1}): Called", Window(handle), menu);
1033 driver.SetMenu(handle, menu);
1036 internal static void SetModal(IntPtr handle, bool Modal) {
1037 #if DriverDebug || DriverDebugState
1038 Console.WriteLine("SetModal({0}, {1}): Called", Window(handle), Modal);
1040 driver.SetModal(handle, Modal);
1043 internal static IntPtr SetParent(IntPtr handle, IntPtr hParent) {
1045 Console.WriteLine("SetParent({0}, {1:X}): Called", Window(handle), Window(hParent));
1047 return driver.SetParent(handle, hParent);
1050 internal static void SetTimer (Timer timer)
1053 Console.WriteLine("SetTimer({0}): Called", timer);
1055 driver.SetTimer (timer);
1058 internal static bool SetTopmost(IntPtr handle, bool Enabled) {
1060 Console.WriteLine("SetTopMost({0}, {1}): Called", Window(handle), Enabled);
1062 return driver.SetTopmost(handle, Enabled);
1065 internal static bool SetOwner(IntPtr handle, IntPtr hWndOwner) {
1067 Console.WriteLine("SetOwner({0}, {1}): Called", Window(handle), Window(hWndOwner));
1069 return driver.SetOwner(handle, hWndOwner);
1072 internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
1074 #if DriverDebug || DriverDebugState
1075 Console.WriteLine("SetVisible({0}, {1}, {2}): Called", Window(handle), visible, activate);
1077 return driver.SetVisible (handle, visible, activate);
1080 internal static void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
1081 #if DriverDebug || DriverDebugState
1082 Console.WriteLine("SetWindowMinMax({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max);
1084 driver.SetWindowMinMax(handle, maximized, min, max);
1087 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
1089 Console.WriteLine("SetWindowPos({0}, {1}, {2}, {3}, {4}): Called", Window(handle), x, y, width, height);
1091 driver.SetWindowPos(handle, x, y, width, height);
1094 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
1095 #if DriverDebug || DriverDebugState
1096 Console.WriteLine("SetWindowState({0} {1}): Called", Window(handle), state);
1098 driver.SetWindowState(handle, state);
1101 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
1103 Console.WriteLine("SetWindowStyle({0}): Called", Window(handle));
1105 driver.SetWindowStyle(handle, cp);
1108 internal static double GetWindowTransparency (IntPtr handle)
1111 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
1113 return driver.GetWindowTransparency(handle);
1116 internal static void SetWindowTransparency(IntPtr handle, double transparency, Color key)
1119 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
1121 driver.SetWindowTransparency(handle, transparency, key);
1124 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
1126 Console.WriteLine("SetZOrder({0}, {1:X}, {2}, {3}): Called", Window(handle), Window(AfterhWnd), Top, Bottom);
1128 return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
1131 internal static void ShowCursor(bool show) {
1133 Console.WriteLine("ShowCursor({0}): Called", show);
1135 driver.ShowCursor(show);
1138 internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
1140 Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", Window(handle), data, allowedEffects);
1142 return driver.StartDrag (handle, data, allowedEffects);
1145 internal static object StartLoop(Thread thread) {
1147 Console.WriteLine("StartLoop({0:X}): Called", thread.GetHashCode());
1149 return driver.StartLoop(thread);
1152 internal static TransparencySupport SupportsTransparency() {
1154 Console.WriteLine("SupportsTransparency(): Called, result={0}", driver.SupportsTransparency());
1156 return driver.SupportsTransparency();
1159 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
1161 Console.WriteLine("SystrayAdd({0}, {1}): Called", Window(handle), tip);
1163 return driver.SystrayAdd(handle, tip, icon, out tt);
1166 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
1168 Console.WriteLine("SystrayChange({0}, {1}): Called", Window(handle), tip);
1170 driver.SystrayChange(handle, tip, icon, ref tt);
1173 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
1175 Console.WriteLine("SystrayRemove({0}): Called", Window(handle));
1177 driver.SystrayRemove(handle, ref tt);
1181 internal static void SystrayBalloon(IntPtr handle, int timeout, string title, string text, ToolTipIcon icon) {
1183 Console.WriteLine("SystrayBalloon ({0}, {1}, {2}, {3}, {4}): Called", Window(handle), timeout, title, text, icon);
1185 driver.SystrayBalloon(handle, timeout, title, text, icon);
1189 internal static bool Text(IntPtr handle, string text) {
1191 Console.WriteLine("Text({0}, {1}): Called", Window(handle), text);
1193 return driver.Text(handle, text);
1196 internal static bool TranslateMessage(ref MSG msg) {
1197 return driver.TranslateMessage(ref msg);
1200 internal static void UngrabWindow(IntPtr handle) {
1202 Console.WriteLine("UngrabWindow({0}): Called", Window(handle));
1204 driver.UngrabWindow(handle);
1207 internal static void UpdateWindow(IntPtr handle) {
1209 Console.WriteLine("UpdateWindow({0}): Called", Window(handle));
1211 driver.UpdateWindow(handle);
1215 internal static void CreateOffscreenDrawable (IntPtr handle,
1216 int width, int height,
1217 out object offscreen_drawable)
1220 Console.WriteLine("CreateOffscreenDrawable({2}, {0},{1}): Called", width, height, Window(handle));
1222 driver.CreateOffscreenDrawable (handle, width, height,
1223 out offscreen_drawable);
1226 internal static void DestroyOffscreenDrawable (object offscreen_drawable)
1229 Console.WriteLine("DestroyOffscreenDrawable(): Called");
1231 driver.DestroyOffscreenDrawable (offscreen_drawable);
1234 internal static Graphics GetOffscreenGraphics (object offscreen_drawable)
1237 Console.WriteLine("GetOffscreenGraphics(): Called");
1239 return driver.GetOffscreenGraphics (offscreen_drawable);
1242 internal static void BlitFromOffscreen (IntPtr dest_handle,
1244 object offscreen_drawable,
1245 Graphics offscreen_dc,
1249 Console.WriteLine("BlitFromOffscreen({0}): Called", Window(dest_handle));
1251 driver.BlitFromOffscreen (dest_handle, dest_dc, offscreen_drawable, offscreen_dc, r);
1255 // Santa's little helper
1256 internal static void Version() {
1257 Console.WriteLine("Xplat version $Revision: $");
1260 internal static void AddKeyFilter (IKeyFilter value)
1262 lock (key_filters) {
1263 key_filters.Add (value);
1267 internal static bool FilterKey (KeyFilterData key)
1269 lock (key_filters) {
1270 for (int i = 0; i < key_filters.Count; i++) {
1271 IKeyFilter filter = (IKeyFilter) key_filters[i];
1272 if (filter.PreFilterKey (key))
1278 #endregion // Public Static Methods
1281 public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
1282 public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
1283 #endregion // Delegates
1285 [DllImport ("libc")]
1286 static extern int uname (IntPtr buf);