Wed Feb 24 15:47:16 CET 2010 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUI.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2004-2006 Novell, Inc.
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24
25 // NOT COMPLETE
26
27 // define to log API calls to stdout
28 #undef DriverDebug
29 #undef DriverDebugPaint
30 #undef DriverDebugCreate
31 #undef DriverDebugDestroy
32 #undef DriverDebugState
33
34 using System;
35 using System.Drawing;
36 using System.ComponentModel;
37 using System.Collections;
38 using System.Diagnostics;
39 using System.Runtime.InteropServices;
40 using System.Threading;
41
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
49
50                 #region Private Methods
51                 internal static string Window(IntPtr handle) {
52                         return String.Format("'{0}' ({1:X})", Control.FromHandle(handle), handle.ToInt32());
53                 }
54                 #endregion      // Private Methods
55
56                 #region Subclasses
57                 public class State {
58                         static public Keys ModifierKeys {
59                                 get {
60                                         return driver.ModifierKeys;
61                                 }
62                         }
63
64                         static public MouseButtons MouseButtons {
65                                 get {
66                                         return driver.MouseButtons;
67                                 }
68                         }
69
70                         static public Point MousePosition {
71                                 get {
72                                         return driver.MousePosition;
73                                 }
74                         }
75
76                 }
77                 #endregion      // Subclasses
78
79                 #region Constructor & Destructor
80                 static XplatUI() {
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();
85
86                         if (RunningOnUnix) {
87                                 //if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) {
88                                 //        driver=XplatUIX11_new.GetInstance ();
89                                 //} else 
90                                 if (Environment.GetEnvironmentVariable ("MONO_MWF_MAC_FORCE_X11") != null) {
91                                         driver = XplatUIX11.GetInstance ();
92                                 } else {
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 ();
98                                         } else {
99                                                 string os = Marshal.PtrToStringAnsi (buf);
100                                                 if (os == "Darwin")
101                                                         driver=XplatUICarbon.GetInstance ();
102                                                 else
103                                                         driver=XplatUIX11.GetInstance ();
104                                         }
105                                         Marshal.FreeHGlobal (buf);
106                                 }
107                         } else {
108                                 driver=XplatUIWin32.GetInstance();
109                         }
110
111                         driver.InitializeDriver();
112
113                         // Initialize things that need to be done after the driver is ready
114                         DataFormats.GetFormat(0);
115
116 #if NET_2_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 ();
121 #endif
122                 }
123                 #endregion      // Constructor & Destructor
124
125                 #region Public Static Properties
126
127                 public static bool RunningOnUnix {
128                         get {
129                                 int p = (int) Environment.OSVersion.Platform;
130                                 
131                                 return (p == 4 || p == 6 || p == 128);
132                         }
133                 }
134
135                 public static int ActiveWindowTrackingDelay {
136                         get { return driver.ActiveWindowTrackingDelay; }
137                 }
138
139                 internal static string DefaultClassName {
140                         get {
141                                 return default_class_name;
142                         }
143
144                         set {
145                                 default_class_name=value;
146                         }
147                 }
148
149                 static public Size Border3DSize {
150                         get {
151                                 return driver.Border3DSize;
152                         }
153                 }
154
155                 static public Size BorderSize {
156                         get {
157                                 return driver.BorderSize;
158                         }
159                 }
160
161                 static public Size CaptionButtonSize {
162                         get {
163                                 return driver.CaptionButtonSize;
164                         }
165                 }
166
167                 static public int CaptionHeight {
168                         get {
169                                 return driver.CaptionHeight;
170                         }
171                 }
172
173                 public static int CaretBlinkTime { get { return driver.CaretBlinkTime; } }
174                 public static int CaretWidth { get { return driver.CaretWidth; } }
175                 
176                 static public Size CursorSize {
177                         get {
178                                 return driver.CursorSize;
179                         }
180                 }
181
182                 static public Size DoubleClickSize {
183                         get {
184                                 return driver.DoubleClickSize;
185                         }
186                 }
187
188                 static public int DoubleClickTime {
189                         get {
190                                 return driver.DoubleClickTime;
191                         }
192                 }
193
194                 static public bool DragFullWindows {
195                         get {
196                                 return driver.DragFullWindows;
197                         }
198                 }
199
200                 static public Size DragSize {
201                         get {
202                                 return driver.DragSize;
203                         }
204                 }
205
206                 static public Size FixedFrameBorderSize {
207                         get {
208                                 return driver.FixedFrameBorderSize;
209                         }
210                 }
211
212                 public static int FontSmoothingContrast { get { return driver.FontSmoothingContrast; } }
213                 public static int FontSmoothingType { get { return driver.FontSmoothingType; } }
214
215                 public static Size FrameBorderSize {
216                         get {
217                                 return driver.FrameBorderSize;
218                         }
219                 }
220
221                 public static int HorizontalResizeBorderThickness { get { return driver.HorizontalResizeBorderThickness; } }
222                 
223                 static public int HorizontalScrollBarHeight {
224                         get {
225                                 return driver.HorizontalScrollBarHeight;
226                         }
227                 }
228
229                 static public Size IconSize {
230                         get {
231                                 return driver.IconSize;
232                         }
233                 }
234
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; } }
250                 
251                 static public int KeyboardSpeed {
252                         get {
253                                 return driver.KeyboardSpeed;
254                         }
255                 }
256
257                 static public int KeyboardDelay {
258                         get {
259                                 return driver.KeyboardDelay;
260                         }
261                 }
262
263                 static public Size MaxWindowTrackSize {
264                         get {
265                                 return driver.MaxWindowTrackSize;
266                         }
267                 }
268
269                 static public bool MenuAccessKeysUnderlined {
270                         get {
271                                 return driver.MenuAccessKeysUnderlined;
272                         }
273                 }
274
275                 static public Size MenuBarButtonSize { get { return driver.MenuBarButtonSize; } }
276
277                 public static Size MenuButtonSize {
278                         get {
279                                 return driver.MenuButtonSize;
280                         }
281                 }
282
283                 static public int MenuShowDelay { get { return driver.MenuShowDelay; } }
284                 
285                 static public Size MinimizedWindowSize {
286                         get {
287                                 return driver.MinimizedWindowSize;
288                         }
289                 }
290
291                 static public Size MinimizedWindowSpacingSize {
292                         get {
293                                 return driver.MinimizedWindowSpacingSize;
294                         }
295                 }
296
297                 static public Size MinimumWindowSize {
298                         get {
299                                 return driver.MinimumWindowSize;
300                         }
301                 }
302
303                 static public Size MinimumFixedToolWindowSize {
304                         get { return driver.MinimumFixedToolWindowSize; }
305                 }
306
307                 static public Size MinimumSizeableToolWindowSize {
308                         get { return driver.MinimumSizeableToolWindowSize; }
309                 }
310
311                 static public Size MinimumNoBorderWindowSize {
312                         get { return driver.MinimumNoBorderWindowSize; }
313                 }
314
315                 static public Size MinWindowTrackSize {
316                         get {
317                                 return driver.MinWindowTrackSize;
318                         }
319                 }
320
321                 public static int MouseSpeed {
322                         get { return driver.MouseSpeed; }
323                 }
324                 
325                 static public Size SmallIconSize {
326                         get {
327                                 return driver.SmallIconSize;
328                         }
329                 }
330
331                 static public int MenuHeight {
332                         get {
333                                 return driver.MenuHeight;
334                         }
335                 }
336
337                 static public int MouseButtonCount {
338                         get {
339                                 return driver.MouseButtonCount;
340                         }
341                 }
342
343                 static public bool MouseButtonsSwapped {
344                         get {
345                                 return driver.MouseButtonsSwapped;
346                         }
347                 }
348
349                 static public Size MouseHoverSize {
350                         get {
351                                 return driver.MouseHoverSize;
352                         }
353                 }
354
355                 static public int MouseHoverTime {
356                         get {
357                                 return driver.MouseHoverTime;
358                         }
359                 }
360
361                 static public int MouseWheelScrollDelta {
362                         get {
363                                 return driver.MouseWheelScrollDelta;
364                         }
365                 }
366                 
367                 static public bool MouseWheelPresent {
368                         get {
369                                 return driver.MouseWheelPresent;
370                         }
371                 }
372
373                 public static LeftRightAlignment PopupMenuAlignment {
374                         get { return driver.PopupMenuAlignment; }
375                 }
376                 
377 #if NET_2_0
378                 public static PowerStatus PowerStatus {
379                         get { return driver.PowerStatus; }
380                 }
381 #endif
382
383                 public static bool RequiresPositiveClientAreaSize {
384                         get {
385                                 return driver.RequiresPositiveClientAreaSize;
386                         }
387                 }
388
389                 public static int SizingBorderWidth {
390                         get { return driver.SizingBorderWidth; }
391                 }
392                 
393                 public static Size SmallCaptionButtonSize {
394                         get { return driver.SmallCaptionButtonSize; }
395                 }
396                 
397                 public static bool UIEffectsEnabled {
398                         get { return driver.UIEffectsEnabled; }
399                 }
400                 
401                 static public bool UserClipWontExposeParent {
402                         get {
403                                 return driver.UserClipWontExposeParent;
404                         }
405                 }
406
407                 public static int VerticalResizeBorderThickness { get { return driver.VerticalResizeBorderThickness; } }
408
409                 static public int VerticalScrollBarWidth {
410                         get {
411                                 return driver.VerticalScrollBarWidth;
412                         }
413                 }
414
415                 static public Rectangle VirtualScreen {
416                         get {
417                                 return driver.VirtualScreen;
418                         }
419                 }
420
421                 static public Rectangle WorkingArea {
422                         get {
423                                 return driver.WorkingArea;
424                         }
425                 }
426
427                 public static bool ThemesEnabled {
428                         get {
429                                 return XplatUI.driver.ThemesEnabled;
430                         }
431                 }
432
433                 public static int ToolWindowCaptionHeight {
434                         get {
435                                 return driver.ToolWindowCaptionHeight;
436                         }
437                 }
438
439                 public static Size ToolWindowCaptionButtonSize {
440                         get {
441                                 return driver.ToolWindowCaptionButtonSize;
442                         }
443                 }
444                 #endregion      // Public Static Properties
445
446                 #region Events
447
448                 internal static event EventHandler Idle {
449                         add {
450                                 driver.Idle += value;
451                         }
452                         remove {
453                                 driver.Idle -= value;
454                         }
455                 }
456
457                 #endregion      // Events
458
459                 #region Public Static Methods
460                 internal static void Activate(IntPtr handle) {
461                         #if DriverDebug
462                                 Console.WriteLine("Activate({0}): Called", Window(handle));
463                         #endif
464                         driver.Activate(handle);
465                 }
466
467                 internal static void AudibleAlert(AlertType alert) {
468                         #if DriverDebug
469                                 Console.WriteLine("AudibleAlert(): Called");
470                         #endif
471                         driver.AudibleAlert(alert);
472                 }
473
474                 internal static void BeginMoveResize (IntPtr handle)
475                 {
476                         driver.BeginMoveResize (handle);
477                 }
478
479                 internal static bool CalculateWindowRect(ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect) {
480                         #if DriverDebug
481                                 Console.WriteLine("CalculateWindowRect({0}, {1}, {2}): Called", ClientRect, cp, menu);
482                         #endif
483                         return driver.CalculateWindowRect(ref ClientRect, cp, menu, out WindowRect);
484                 }
485
486                 internal static void CaretVisible(IntPtr handle, bool visible) {
487                         #if DriverDebug
488                                 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
489                         #endif
490                         driver.CaretVisible(handle, visible);
491                 }
492
493                 internal static void CreateCaret(IntPtr handle, int width, int height) {
494                         #if DriverDebug
495                                 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
496                         #endif
497                         driver.CreateCaret(handle, width, height);
498                 }
499
500                 internal static IntPtr CreateWindow(CreateParams cp) {
501                         #if DriverDebug || DriverDebugCreate
502                                 IntPtr handle;
503
504                                 handle = driver.CreateWindow(cp);
505
506                                 Console.WriteLine("CreateWindow(): Called, returning {0:X}", handle.ToInt32());
507                                 return handle;
508                         #else
509                                 return driver.CreateWindow(cp);
510                         #endif
511                 }
512
513                 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
514                         #if DriverDebug || DriverDebugCreate
515                                 Console.WriteLine("CreateWindow(): Called");
516                         #endif
517                         return driver.CreateWindow(Parent, X, Y, Width, Height);
518                 }
519
520                 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
521                         #if DriverDebug
522                                 Console.WriteLine("ClientToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
523                         #endif
524                         driver.ClientToScreen(handle, ref x, ref y);
525                 }
526
527                 internal static int[] ClipboardAvailableFormats(IntPtr handle) {
528                         #if DriverDebug
529                                 Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
530                         #endif
531                         return driver.ClipboardAvailableFormats(handle);
532                 }
533
534                 internal static void ClipboardClose(IntPtr handle) {
535                         #if DriverDebug
536                                 Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
537                         #endif
538                         driver.ClipboardClose(handle);
539                 }
540
541                 internal static int ClipboardGetID(IntPtr handle, string format) {
542                         #if DriverDebug
543                                 Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
544                         #endif
545                         return driver.ClipboardGetID(handle, format);
546                 }
547
548                 internal static IntPtr ClipboardOpen(bool primary_selection) {
549                         #if DriverDebug
550                                 Console.WriteLine("ClipboardOpen(): Called");
551                         #endif
552                         return driver.ClipboardOpen (primary_selection);
553                 }
554
555                 internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
556                         #if DriverDebug
557                                 Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, type, converter);
558                         #endif
559                         driver.ClipboardStore(handle, obj, type, converter);
560                 }
561
562                 internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
563                         #if DriverDebug
564                                 Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
565                         #endif
566                         return driver.ClipboardRetrieve(handle, type, converter);
567                 }
568
569                 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
570                         #if DriverDebug
571                                 Console.WriteLine("DefineCursor(...): Called");
572                         #endif
573                         return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
574                 }
575
576                 internal static IntPtr DefineStdCursor(StdCursor id) {
577                         return driver.DefineStdCursor(id);
578                 }
579                 
580                 internal static Bitmap DefineStdCursorBitmap(StdCursor id) {
581                         return driver.DefineStdCursorBitmap(id);
582                 }
583
584                 internal static IntPtr DefWndProc(ref Message msg) {
585                         return driver.DefWndProc(ref msg);
586                 }
587
588                 internal static void DestroyCaret(IntPtr handle) {
589                         #if DriverDebug
590                                 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
591                         #endif
592                         driver.DestroyCaret(handle);
593                 }
594
595                 internal static void DestroyCursor(IntPtr cursor) {
596                         #if DriverDebug
597                                 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
598                         #endif
599                         driver.DestroyCursor(cursor);
600                 }
601
602                 internal static void DestroyWindow(IntPtr handle) {
603                         #if DriverDebug || DriverDebugDestroy
604                                 Console.WriteLine("DestroyWindow({0}): Called", Window(handle));
605                         #endif
606                         driver.DestroyWindow(handle);
607                 }
608
609                 internal static IntPtr DispatchMessage(ref MSG msg) {
610                         return driver.DispatchMessage(ref msg);
611                 }
612
613                 internal static void DoEvents() {
614                         driver.DoEvents();
615                 }
616
617                 internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
618                         #if DriverDebug
619                                 Console.WriteLine("DrawReversibleRectangle({0}, {1}, {2}): Called", Window(handle), rect, line_width);
620                         #endif
621                         driver.DrawReversibleRectangle(handle, rect, line_width);
622                 }
623
624                 internal static void FillReversibleRectangle (Rectangle rectangle, Color backColor)
625                 {
626                         #if DriverDebug
627                                 Console.WriteLine("FillReversibleRectangle({0}, {1}): Called", rectangle, backColor);
628                         #endif
629                         driver.FillReversibleRectangle (rectangle, backColor);
630                 }
631
632                 internal static void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
633                 {
634                         #if DriverDebug
635                                 Console.WriteLine("DrawReversibleFrame({0}, {1}, {2}): Called", rectangle, backColor, style);
636                         #endif
637                         driver.DrawReversibleFrame (rectangle, backColor, style);
638                 }
639
640                 internal static void DrawReversibleLine (Point start, Point end, Color backColor)
641                 {
642                         #if DriverDebug
643                                 Console.WriteLine("DrawReversibleLine({0}, {1}, {2}): Called", start, end, backColor);
644                         #endif
645                         driver.DrawReversibleLine (start, end, backColor);
646                 }
647
648                 internal static void EnableThemes() {
649                         driver.EnableThemes();
650                 }
651
652                 internal static void EnableWindow(IntPtr handle, bool Enable) {
653                         #if DriverDebug || DriverDebugState
654                                 Console.WriteLine("EnableWindow({0}, {1}): Called", Window(handle), Enable);
655                         #endif
656                         driver.EnableWindow(handle, Enable);
657                 }
658
659                 internal static void EndLoop(Thread thread) {
660                         #if DriverDebug
661                                 Console.WriteLine("EndLoop({0:X}): Called", thread.GetHashCode());
662                         #endif
663                         driver.EndLoop(thread);
664                 }
665
666                 internal static IntPtr GetActive() {
667                         #if DriverDebug
668                                 Console.WriteLine("GetActive(): Called");
669                         #endif
670                         return driver.GetActive();
671                 }
672
673                 internal static SizeF GetAutoScaleSize(Font font) {
674                         #if DriverDebug
675                                 Console.WriteLine("GetAutoScaleSize({0}): Called", font);
676                         #endif
677                         return driver.GetAutoScaleSize(font);
678                 }
679
680                 internal static Region GetClipRegion(IntPtr handle) {
681                         #if DriverDebug
682                                 Console.WriteLine("GetClipRegion({0}): Called", Window(handle));
683                         #endif
684                         return driver.GetClipRegion(handle);
685                 }
686
687                 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
688                         #if DriverDebug
689                                 Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
690                         #endif
691                         driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
692                 }
693
694                 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
695                         #if DriverDebug
696                                 Console.WriteLine("GetCursorPos({0}): Called", Window(handle));
697                         #endif
698                         driver.GetCursorPos(handle, out x, out y);
699                 }
700
701                 internal static void GetDisplaySize(out Size size) {
702                         #if DriverDebug
703                                 Console.WriteLine("GetDisplaySize(): Called");
704                         #endif
705                         driver.GetDisplaySize(out size);
706                 }
707
708                 internal static IntPtr GetFocus() {
709                         #if DriverDebug
710                                 Console.WriteLine("GetFocus(): Called, Result:{0}", Window(driver.GetFocus()));
711                         #endif
712                         return driver.GetFocus();
713                 }
714
715                 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
716                         #if DriverDebug
717                                 Console.WriteLine("GetFontMetrics(): Called");
718                         #endif
719                         return driver.GetFontMetrics(g, font, out ascent, out descent);
720                 }
721                         
722                 internal static Point GetMenuOrigin(IntPtr handle) {
723                         #if DriverDebug
724                                 Console.WriteLine("GetMenuOrigin({0}): Called", Window(handle));
725                         #endif
726                         return driver.GetMenuOrigin(handle);
727                 }
728
729                 internal static bool GetMessage(object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
730                         return driver.GetMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
731                 }
732
733                 internal static IntPtr GetParent(IntPtr handle) {
734                         #if DriverDebug
735                                 Console.WriteLine("GetParent({0}): Called", Window(handle));
736                         #endif
737                         return driver.GetParent(handle);
738                 }
739
740                 internal static IntPtr GetPreviousWindow(IntPtr handle) {
741                         return driver.GetPreviousWindow(handle);
742                 }
743
744                 internal static bool GetText(IntPtr handle, out string text) {
745                         #if DriverDebug
746                                 Console.WriteLine("GetText({0}): Called", Window(handle));
747                         #endif
748                         return driver.GetText(handle, out text);
749                 }
750
751                 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) {
752                         #if DriverDebug
753                                 Console.WriteLine("GetWindowPos({0}): Called", Window(handle));
754                         #endif
755                         driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
756                 }
757
758                 /* this method can (and does, on X11) return
759                  * (FormWindowState)(-1), when the state of the window
760                  * cannot be determined (in the X11 case, when the
761                  * window isn't mapped.)  Checking for the additional
762                  * return value is less expensive than
763                  * throwing/catching an exception. */
764                 internal static FormWindowState GetWindowState(IntPtr handle) {
765                         #if DriverDebug
766                                 Console.WriteLine("GetWindowState({0}): Called", Window(handle));
767                         #endif
768                         return driver.GetWindowState(handle);
769                 }
770
771                 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
772                         #if DriverDebug
773                                 Console.WriteLine("GrabInfo(): Called");
774                         #endif
775                         driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
776                 }
777
778                 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
779                         #if DriverDebug
780                                 Console.WriteLine("GrabWindow({0}, {1}): Called", Window(handle), Window(ConfineToHwnd));
781                         #endif
782                         driver.GrabWindow(handle, ConfineToHwnd);
783                 }
784
785                 internal static void HandleException(Exception e) {
786                         driver.HandleException(e);
787                 }
788
789                 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
790                         #if DriverDebug
791                                 Console.WriteLine("Invalidate({0}, {1}, {2}): Called", Window(handle), rc, clear);
792                         #endif
793                         driver.Invalidate(handle, rc, clear);
794                 }
795
796                 internal static void InvalidateNC (IntPtr handle)
797                 {
798                         #if DriverDebug
799                                 Console.WriteLine("InvalidateNC({0}): Called", Window(handle));
800                         #endif
801                         driver.InvalidateNC(handle);
802                 }
803
804
805                 internal static bool IsEnabled(IntPtr handle) {
806                         #if DriverDebug || DriverDebugState
807                                 Console.WriteLine("IsEnabled({0}): Called, Result={1}", Window(handle), driver.IsEnabled(handle));
808                         #endif
809                         return driver.IsEnabled(handle);
810                 }
811
812                 internal static bool IsKeyLocked (VirtualKeys key)
813                 {
814                         #if DriverDebug || DriverDebugState
815                                 Console.WriteLine("IsKeyLocked({0}): Called, Result={1}", key, driver.IsKeyLocked(key));
816                         #endif
817                         return driver.IsKeyLocked (key);
818                 }
819
820                 internal static bool IsVisible(IntPtr handle) {
821                         #if DriverDebug || DriverDebugState
822                                 Console.WriteLine("IsVisible({0}): Called, Result={1}", Window(handle), driver.IsVisible(handle));
823                         #endif
824                         return driver.IsVisible(handle);
825                 }
826
827                 internal static void KillTimer (Timer timer)
828                 {
829                         #if DriverDebug
830                                 Console.WriteLine("KillTimer({0}): Called", timer);
831                         #endif
832                         driver.KillTimer (timer);
833                 }
834
835                 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
836                         #if DriverDebug
837                                 Console.WriteLine("MenuToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
838                         #endif
839                         driver.MenuToScreen(handle, ref x, ref y);
840                 }
841
842                 internal static void OverrideCursor(IntPtr cursor) {
843                         #if DriverDebug
844                                 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
845                         #endif
846                         driver.OverrideCursor(cursor);
847                 }
848
849                 internal static void PaintEventEnd (ref Message msg, IntPtr handle, bool client) {
850                         #if DriverDebug || DriverDebugPaint
851                                 Console.WriteLine("PaintEventEnd({0}, {1}, {2}): Called from thread {3}", msg, Window(handle), client, Thread.CurrentThread.GetHashCode());
852                         #endif
853                         driver.PaintEventEnd (ref msg, handle, client);
854                 }
855
856                 internal static PaintEventArgs PaintEventStart (ref Message msg, IntPtr handle, bool client) {
857                         #if DriverDebug || DriverDebugPaint
858                                 Console.WriteLine("PaintEventStart({0}, {1}, {2}): Called from thread {3}", msg, Window(handle), client, Thread.CurrentThread.GetHashCode());
859                         #endif
860                         return driver.PaintEventStart (ref msg, handle, client);
861                 }
862
863                 internal static bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
864                         return driver.PeekMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
865                 }
866
867                 internal static bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
868                         #if DriverDebug
869                                 Console.WriteLine("PostMessage({0}, {1}, {2:X}, {3:X}): Called", Window(hwnd), message, wParam.ToInt32(), lParam.ToInt32());
870                         #endif
871                         return driver.PostMessage(hwnd, message, wParam, lParam);
872                 }
873
874                 internal static bool PostMessage(ref MSG msg) {
875                         #if DriverDebug
876                                 Console.WriteLine("PostMessage({0}): Called", msg);
877                         #endif
878                         return driver.PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
879                 }
880
881                 internal static void PostQuitMessage(int exitCode) {
882                         #if DriverDebug
883                                 Console.WriteLine("PostQuitMessage({0}): Called", exitCode);
884                         #endif
885                         driver.PostQuitMessage(exitCode);
886                 }
887
888                 internal static void RaiseIdle (EventArgs e)
889                 {
890                         #if DriverDebug
891                                 Console.WriteLine("RaiseIdle({0}): Called", e.ToString ());
892                         #endif
893                         
894                         driver.RaiseIdle (e);
895                 }
896                 
897                 internal static void RequestAdditionalWM_NCMessages(IntPtr handle, bool hover, bool leave) {
898                         #if DriverDebug
899                                 Console.WriteLine("RequestAdditionalWM_NCMessages({0}, {1}, {2}): Called", Window(handle), hover, leave);
900                         #endif
901                         driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
902                 }
903
904                 internal static void RequestNCRecalc(IntPtr handle) {
905                         #if DriverDebug
906                                 Console.WriteLine("RequestNCRecalc({0}): Called", Window(handle));
907                         #endif
908                         driver.RequestNCRecalc(handle);
909                 }
910
911                 internal static void ResetMouseHover(IntPtr handle) {
912                         #if DriverDebug
913                                 Console.WriteLine("ResetMouseHover({0}): Called", Window(handle));
914                         #endif
915                         driver.ResetMouseHover(handle);
916                 }
917
918                 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
919                         #if DriverDebug
920                                 Console.WriteLine("ScreenToClient({0}, {1}, {2}): Called", Window(handle), x, y);
921                         #endif
922                         driver.ScreenToClient (handle, ref x, ref y);
923                 }
924
925                 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
926                         #if DriverDebug
927                                 Console.WriteLine("ScreenToMenu({0}, {1}, {2}): Called", Window(handle), x, y);
928                         #endif
929                         driver.ScreenToMenu(handle, ref x, ref y);
930                 }
931
932                 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
933                         #if DriverDebug
934                                 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}, {4}): Called", Window(handle), rectangle, XAmount, YAmount, with_children);
935                         #endif
936                         driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
937                 }
938
939                 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
940                         #if DriverDebug
941                                 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}): Called", Window(handle), XAmount, YAmount, with_children);
942                         #endif
943                         driver.ScrollWindow(handle, XAmount, YAmount, with_children);
944                 }
945
946                 internal static void SendAsyncMethod (AsyncMethodData data) {
947                         #if DriverDebug
948                                 Console.WriteLine("SendAsyncMethod({0}): Called", data);
949                         #endif
950                         driver.SendAsyncMethod (data);
951                 }
952
953                 internal static int SendInput (IntPtr hwnd, Queue keys) {
954                         #if DriverDebug
955                                 Console.WriteLine("SendInput({0}, {1}): Called", hwnd, keys);
956                         #endif
957                         return driver.SendInput (hwnd, keys);
958                 }
959
960                 internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) {
961                         #if DriverDebug
962                                 Console.WriteLine("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window(handle), message, wParam.ToInt32(), lParam.ToInt32());
963                         #endif
964                         return driver.SendMessage (handle, message, wParam, lParam);
965                 }
966
967                 internal static void SendMessage (ref Message m) {
968                         #if DriverDebug
969                                 Console.WriteLine("SendMessage ({0}): Called", m);
970                         #endif
971                         m.Result = driver.SendMessage(m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
972                 }
973
974                 internal static void SetAllowDrop (IntPtr handle, bool value)
975                 {
976                         #if DriverDebug
977                         Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
978                         #endif
979                         driver.SetAllowDrop (handle, value);
980                 }
981
982                 internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
983                         #if DriverDebug
984                                 Console.WriteLine("SetBorderStyle({0}, {1}): Called", Window(handle), border_style);
985                         #endif
986                         driver.SetBorderStyle(handle, border_style);
987                 }
988
989                 internal static void SetCaretPos(IntPtr handle, int x, int y) {
990                         #if DriverDebug
991                                 Console.WriteLine("SetCaretPos({0}, {1}, {2}): Called", Window(handle), x, y);
992                         #endif
993                         driver.SetCaretPos(handle, x, y);
994                 }
995
996                 internal static void SetClipRegion(IntPtr handle, Region region) {
997                         #if DriverDebug
998                                 Console.WriteLine("SetClipRegion({0}, {1}): Called", Window(handle), region);
999                         #endif
1000                         driver.SetClipRegion(handle, region);
1001                 }
1002
1003                 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
1004                         #if DriverDebug
1005                                 Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
1006                         #endif
1007                         driver.SetCursor(handle, cursor);
1008                 }
1009
1010                 internal static void SetCursorPos(IntPtr handle, int x, int y) {
1011                         #if DriverDebug
1012                                 Console.WriteLine("SetCursorPos({0}, {1}, {2}): Called", Window(handle), x, y);
1013                         #endif
1014                         driver.SetCursorPos(handle, x, y);
1015                 }
1016
1017                 internal static void SetFocus(IntPtr handle) {
1018                         #if DriverDebug
1019                                 Console.WriteLine("SetFocus({0}): Called", Window(handle));
1020                         #endif
1021                         driver.SetFocus(handle);
1022                 }
1023
1024                 internal static void SetForegroundWindow(IntPtr handle) {
1025                         #if DriverDebug
1026                                 Console.WriteLine("SetForegroundWindow({0}): Called", Window(handle));
1027                         #endif
1028                         driver.SetForegroundWindow(handle);
1029                 }
1030
1031                 internal static void SetIcon(IntPtr handle, Icon icon) {
1032                         #if DriverDebug
1033                                 Console.WriteLine("SetIcon({0}, {1}): Called", Window(handle), icon);
1034                         #endif
1035                         driver.SetIcon(handle, icon);
1036                 }
1037
1038                 internal static void SetMenu(IntPtr handle, Menu menu) {
1039                         #if DriverDebug
1040                                 Console.WriteLine("SetMenu({0}, {1}): Called", Window(handle), menu);
1041                         #endif
1042                         driver.SetMenu(handle, menu);
1043                 }
1044
1045                 internal static void SetModal(IntPtr handle, bool Modal) {
1046                         #if DriverDebug || DriverDebugState
1047                                 Console.WriteLine("SetModal({0}, {1}): Called", Window(handle), Modal);
1048                         #endif
1049                         driver.SetModal(handle, Modal);
1050                 }
1051
1052                 internal static IntPtr SetParent(IntPtr handle, IntPtr hParent) {
1053                         #if DriverDebug
1054                                 Console.WriteLine("SetParent({0}, {1:X}): Called", Window(handle), Window(hParent));
1055                         #endif
1056                         return driver.SetParent(handle, hParent);
1057                 }
1058
1059                 internal static void SetTimer (Timer timer)
1060                 {
1061                         #if DriverDebug
1062                                 Console.WriteLine("SetTimer({0}): Called", timer);
1063                         #endif
1064                         driver.SetTimer (timer);
1065                 }
1066
1067                 internal static bool SetTopmost(IntPtr handle, bool Enabled) {
1068                         #if DriverDebug
1069                                 Console.WriteLine("SetTopMost({0}, {1}): Called", Window(handle), Enabled);
1070                         #endif
1071                         return driver.SetTopmost(handle, Enabled);
1072                 }
1073
1074                 internal static bool SetOwner(IntPtr handle, IntPtr hWndOwner) {
1075                         #if DriverDebug
1076                                 Console.WriteLine("SetOwner({0}, {1}): Called", Window(handle), Window(hWndOwner));
1077                         #endif
1078                         return driver.SetOwner(handle, hWndOwner);
1079                 }
1080
1081                 internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
1082                 {
1083                         #if DriverDebug || DriverDebugState
1084                                 Console.WriteLine("SetVisible({0}, {1}, {2}): Called", Window(handle), visible, activate);
1085                         #endif
1086                         return driver.SetVisible (handle, visible, activate);
1087                 }
1088
1089                 internal static void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
1090                         #if DriverDebug || DriverDebugState
1091                                 Console.WriteLine("SetWindowMinMax({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max);
1092                         #endif
1093                         driver.SetWindowMinMax(handle, maximized, min, max);
1094                 }
1095
1096                 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
1097                         #if DriverDebug
1098                                 Console.WriteLine("SetWindowPos({0}, {1}, {2}, {3}, {4}): Called", Window(handle), x, y, width, height);
1099                         #endif
1100                         driver.SetWindowPos(handle, x, y, width, height);
1101                 }
1102
1103                 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
1104                         #if DriverDebug || DriverDebugState
1105                                 Console.WriteLine("SetWindowState({0} {1}): Called", Window(handle), state);
1106                         #endif
1107                         driver.SetWindowState(handle, state);
1108                 }
1109
1110                 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
1111                         #if DriverDebug
1112                                 Console.WriteLine("SetWindowStyle({0}): Called", Window(handle));
1113                         #endif
1114                         driver.SetWindowStyle(handle, cp);
1115                 }
1116
1117                 internal static double GetWindowTransparency (IntPtr handle)
1118                 {
1119                         #if DriverDebug
1120                                 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
1121                         #endif
1122                         return driver.GetWindowTransparency(handle);
1123                 }
1124
1125                 internal static void SetWindowTransparency(IntPtr handle, double transparency, Color key) 
1126                 {
1127                         #if DriverDebug
1128                                 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
1129                         #endif
1130                         driver.SetWindowTransparency(handle, transparency, key);
1131                 }
1132
1133                 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
1134                         #if DriverDebug
1135                                 Console.WriteLine("SetZOrder({0}, {1:X}, {2}, {3}): Called", Window(handle), Window(AfterhWnd), Top, Bottom);
1136                         #endif
1137                         return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
1138                 }
1139
1140                 internal static void ShowCursor(bool show) {
1141                         #if DriverDebug
1142                                 Console.WriteLine("ShowCursor({0}): Called", show);
1143                         #endif
1144                         driver.ShowCursor(show);
1145                 }
1146
1147                 internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
1148                         #if DriverDebug
1149                         Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", Window(handle), data, allowedEffects);
1150                         #endif
1151                         return driver.StartDrag (handle, data, allowedEffects);
1152                 }
1153
1154                 internal static object StartLoop(Thread thread) {
1155                         #if DriverDebug
1156                                 Console.WriteLine("StartLoop({0:X}): Called", thread.GetHashCode());
1157                         #endif
1158                         return driver.StartLoop(thread);
1159                 }
1160
1161                 internal static TransparencySupport SupportsTransparency() {
1162                         #if DriverDebug
1163                                 Console.WriteLine("SupportsTransparency(): Called, result={0}", driver.SupportsTransparency());
1164                         #endif
1165                         return driver.SupportsTransparency();
1166                 }
1167
1168                 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
1169                         #if DriverDebug
1170                                 Console.WriteLine("SystrayAdd({0}, {1}): Called", Window(handle), tip);
1171                         #endif
1172                         return driver.SystrayAdd(handle, tip, icon, out tt);
1173                 }
1174
1175                 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
1176                         #if DriverDebug
1177                                 Console.WriteLine("SystrayChange({0}, {1}): Called", Window(handle), tip);
1178                         #endif
1179                         driver.SystrayChange(handle, tip, icon, ref tt);
1180                 }
1181
1182                 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
1183                         #if DriverDebug
1184                                 Console.WriteLine("SystrayRemove({0}): Called", Window(handle));
1185                         #endif
1186                         driver.SystrayRemove(handle, ref tt);
1187                 }
1188
1189 #if NET_2_0
1190                 internal static void SystrayBalloon(IntPtr handle, int timeout, string title, string text, ToolTipIcon icon) {
1191                         #if DriverDebug
1192                                 Console.WriteLine("SystrayBalloon ({0}, {1}, {2}, {3}, {4}): Called", Window(handle), timeout, title, text, icon);
1193                         #endif
1194                         driver.SystrayBalloon(handle, timeout, title, text, icon);
1195                 }
1196 #endif
1197
1198                 internal static bool Text(IntPtr handle, string text) {
1199                         #if DriverDebug
1200                                 Console.WriteLine("Text({0}, {1}): Called", Window(handle), text);
1201                         #endif
1202                         return driver.Text(handle, text);
1203                 }
1204
1205                 internal static bool TranslateMessage(ref MSG msg) {
1206                         return driver.TranslateMessage(ref msg);
1207                 }
1208
1209                 internal static void UngrabWindow(IntPtr handle) {
1210                         #if DriverDebug
1211                                 Console.WriteLine("UngrabWindow({0}): Called", Window(handle));
1212                         #endif
1213                         driver.UngrabWindow(handle);
1214                 }
1215
1216                 internal static void UpdateWindow(IntPtr handle) {
1217                         #if DriverDebug
1218                                 Console.WriteLine("UpdateWindow({0}): Called", Window(handle));
1219                         #endif
1220                         driver.UpdateWindow(handle);
1221                 }
1222
1223                 // double buffering
1224                 internal static void CreateOffscreenDrawable (IntPtr handle,
1225                                                             int width, int height,
1226                                                             out object offscreen_drawable)
1227                 {
1228 #if DriverDebug
1229                         Console.WriteLine("CreateOffscreenDrawable({2}, {0},{1}): Called", width, height, Window(handle));
1230 #endif
1231                         driver.CreateOffscreenDrawable (handle, width, height,
1232                                                         out offscreen_drawable);
1233                 }
1234
1235                 internal static void DestroyOffscreenDrawable (object offscreen_drawable)
1236                 {
1237 #if DriverDebug
1238                         Console.WriteLine("DestroyOffscreenDrawable(): Called");
1239 #endif
1240                         driver.DestroyOffscreenDrawable (offscreen_drawable);
1241                 }
1242
1243                 internal static Graphics GetOffscreenGraphics (object offscreen_drawable)
1244                 {
1245 #if DriverDebug
1246                         Console.WriteLine("GetOffscreenGraphics(): Called");
1247 #endif
1248                         return driver.GetOffscreenGraphics (offscreen_drawable);
1249                 }
1250
1251                 internal static void BlitFromOffscreen (IntPtr dest_handle,
1252                                                       Graphics dest_dc,
1253                                                       object offscreen_drawable,
1254                                                       Graphics offscreen_dc,
1255                                                       Rectangle r)
1256                 {
1257 #if DriverDebug
1258                         Console.WriteLine("BlitFromOffscreen({0}): Called", Window(dest_handle));
1259 #endif
1260                         driver.BlitFromOffscreen (dest_handle, dest_dc, offscreen_drawable, offscreen_dc, r);
1261                 }
1262
1263
1264                 // Santa's little helper
1265                 internal static void Version() {
1266                         Console.WriteLine("Xplat version $Revision: $");
1267                 }
1268
1269                 internal static void AddKeyFilter (IKeyFilter value)
1270                 {
1271                         lock (key_filters) {
1272                                 key_filters.Add (value);
1273                         }
1274                 }
1275
1276                 internal static bool FilterKey (KeyFilterData key)
1277                 {
1278                         lock (key_filters) {
1279                                 for (int i = 0; i < key_filters.Count; i++) {
1280                                         IKeyFilter filter = (IKeyFilter) key_filters[i];
1281                                         if (filter.PreFilterKey (key))
1282                                                 return true;
1283                                 }
1284                         }
1285                         return false;
1286                 }
1287                 #endregion      // Public Static Methods
1288
1289                 #region Delegates
1290                 public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
1291                 public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
1292                 #endregion      // Delegates
1293
1294                 [DllImport ("libc")]
1295                 static extern int uname (IntPtr buf);
1296         }
1297 }