New test.
[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 using System.Windows.Forms.X11Internal;
42
43 namespace System.Windows.Forms {
44         internal class XplatUI {
45                 #region Local Variables
46                 static XplatUIDriver            driver;
47                 static String                   default_class_name;
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                         // check for Unix platforms - see FAQ for more details
87                         // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
88                         int platform = (int) Environment.OSVersion.Platform;
89                         if ((platform == 4) || (platform == 128)) {
90                                 if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_QUARTZ_BACKEND") != null)
91                                         driver=XplatUIOSX.GetInstance ();
92                                 else if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null)
93                                         driver=XplatUIX11_new.GetInstance ();
94                                 else
95                                         driver=XplatUIX11.GetInstance ();
96                         } else {
97                                 driver=XplatUIWin32.GetInstance();
98                         }
99
100                         driver.InitializeDriver();
101
102                         // Initialize things that need to be done after the driver is ready
103                         DataFormats.GetFormat(0);
104                 }
105                 #endregion      // Constructor & Destructor
106
107                 #region Public Static Properties
108                 internal static string DefaultClassName {
109                         get {
110                                 return default_class_name;
111                         }
112
113                         set {
114                                 default_class_name=value;
115                         }
116                 }
117
118                 static public int CaptionHeight {
119                         get {
120                                 return driver.Caption;
121                         }
122                 }
123
124                 static public Size CursorSize {
125                         get {
126                                 return driver.CursorSize;
127                         }
128                 }
129
130                 static public bool DragFullWindows {
131                         get {
132                                 return driver.DragFullWindows;
133                         }
134                 }
135
136                 static public Size DragSize {
137                         get {
138                                 return driver.DragSize;
139                         }
140                 }
141
142                 public static Size FrameBorderSize {
143                         get {
144                                 return driver.FrameBorderSize;
145                         }
146                 }
147
148                 static public int HorizontalScrollBarHeight {
149                         get {
150                                 return driver.HorizontalScrollBarHeight;
151                         }
152                 }
153
154                 static public Size IconSize {
155                         get {
156                                 return driver.IconSize;
157                         }
158                 }
159
160                 static public int KeyboardSpeed {
161                         get {
162                                 return driver.KeyboardSpeed;
163                         }
164                 }
165
166                 static public int KeyboardDelay {
167                         get {
168                                 return driver.KeyboardSpeed;
169                         }
170                 }
171
172                 static public Size MaxWindowTrackSize {
173                         get {
174                                 return driver.MaxWindowTrackSize;
175                         }
176                 }
177
178                 static public Size MinimizedWindowSize {
179                         get {
180                                 return driver.MinimizedWindowSize;
181                         }
182                 }
183
184                 static public Size MinimizedWindowSpacingSize {
185                         get {
186                                 return driver.MinimizedWindowSpacingSize;
187                         }
188                 }
189
190                 static public Size MinimumWindowSize {
191                         get {
192                                 return driver.MinimumWindowSize;
193                         }
194                 }
195
196                 static public Size MinWindowTrackSize {
197                         get {
198                                 return driver.MinWindowTrackSize;
199                         }
200                 }
201
202                 static public Size SmallIconSize {
203                         get {
204                                 return driver.SmallIconSize;
205                         }
206                 }
207
208                 static public int MenuHeight {
209                         get {
210                                 return driver.MenuHeight;
211                         }
212                 }
213
214                 static public int MouseButtonCount {
215                         get {
216                                 return driver.MouseButtonCount;
217                         }
218                 }
219
220                 static public bool MouseButtonsSwapped {
221                         get {
222                                 return driver.MouseButtonsSwapped;
223                         }
224                 }
225
226                 static public Size MouseHoverSize {
227                         get {
228                                 return driver.MouseHoverSize;
229                         }
230                 }
231
232                 static public int MouseHoverTime {
233                         get {
234                                 return driver.MouseHoverTime;
235                         }
236                 }
237
238                 static public bool MouseWheelPresent {
239                         get {
240                                 return driver.MouseWheelPresent;
241                         }
242                 }
243
244                 static public bool UserClipWontExposeParent {
245                         get {
246                                 return driver.UserClipWontExposeParent;
247                         }
248                 }
249
250                 static public int VerticalScrollBarWidth {
251                         get {
252                                 return driver.VerticalScrollBarWidth;
253                         }
254                 }
255
256                 static public Rectangle VirtualScreen {
257                         get {
258                                 return driver.VirtualScreen;
259                         }
260                 }
261
262                 static public Rectangle WorkingArea {
263                         get {
264                                 return driver.WorkingArea;
265                         }
266                 }
267
268                 public static bool ThemesEnabled {
269                         get {
270                                 return XplatUI.driver.ThemesEnabled;
271                         }
272                 }
273  
274
275                 #endregion      // Public Static Properties
276
277                 #region Events
278                 internal static event EventHandler Idle {
279                         add {
280                                 driver.Idle += value;
281                         }
282                         remove {
283                                 driver.Idle -= value;
284                         }
285                 }
286                 
287                 #endregion      // Events
288
289                 #region Public Static Methods
290                 internal static void Activate(IntPtr handle) {
291                         #if DriverDebug
292                                 Console.WriteLine("Activate({0}): Called", Window(handle));
293                         #endif
294                         driver.Activate(handle);
295                 }
296
297                 internal static void AudibleAlert() {
298                         #if DriverDebug
299                                 Console.WriteLine("AudibleAlert(): Called");
300                         #endif
301                         driver.AudibleAlert();
302                 }
303
304                 internal static bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect) {
305                         #if DriverDebug
306                                 Console.WriteLine("CalculateWindowRect({0}, {1}, {2}, {3}): Called", ClientRect, Style, ExStyle, menu);
307                         #endif
308                         return driver.CalculateWindowRect(ref ClientRect, Style, ExStyle, menu, out WindowRect);
309                 }
310
311                 internal static void CaretVisible(IntPtr handle, bool visible) {
312                         #if DriverDebug
313                                 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
314                         #endif
315                         driver.CaretVisible(handle, visible);
316                 }
317
318                 internal static void CreateCaret(IntPtr handle, int width, int height) {
319                         #if DriverDebug
320                                 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
321                         #endif
322                         driver.CreateCaret(handle, width, height);
323                 }
324
325                 internal static IntPtr CreateWindow(CreateParams cp) {
326                         #if DriverDebug || DriverDebugCreate
327                                 IntPtr handle;
328
329                                 handle = driver.CreateWindow(cp);
330
331                                 Console.WriteLine("CreateWindow(): Called, returning {0:X}", handle.ToInt32());
332                                 return handle;
333                         #else
334                                 return driver.CreateWindow(cp);
335                         #endif
336                 }
337
338                 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
339                         #if DriverDebug || DriverDebugCreate
340                                 Console.WriteLine("CreateWindow(): Called");
341                         #endif
342                         return driver.CreateWindow(Parent, X, Y, Width, Height);
343                 }
344
345                 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
346                         #if DriverDebug
347                                 Console.WriteLine("ClientToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
348                         #endif
349                         driver.ClientToScreen(handle, ref x, ref y);
350                 }
351
352                 internal static int[] ClipboardAvailableFormats(IntPtr handle) {
353                         #if DriverDebug
354                                 Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
355                         #endif
356                         return driver.ClipboardAvailableFormats(handle);
357                 }
358
359                 internal static void ClipboardClose(IntPtr handle) {
360                         #if DriverDebug
361                                 Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
362                         #endif
363                         driver.ClipboardClose(handle);
364                 }
365
366                 internal static int ClipboardGetID(IntPtr handle, string format) {
367                         #if DriverDebug
368                                 Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
369                         #endif
370                         return driver.ClipboardGetID(handle, format);
371                 }
372
373                 internal static IntPtr ClipboardOpen(bool primary_selection) {
374                         #if DriverDebug
375                                 Console.WriteLine("ClipboardOpen(): Called");
376                         #endif
377                         return driver.ClipboardOpen (primary_selection);
378                 }
379
380                 internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
381                         #if DriverDebug
382                                 Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, type, converter);
383                         #endif
384                         driver.ClipboardStore(handle, obj, type, converter);
385                 }
386
387                 internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
388                         #if DriverDebug
389                                 Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
390                         #endif
391                         return driver.ClipboardRetrieve(handle, type, converter);
392                 }
393
394                 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
395                         #if DriverDebug
396                                 Console.WriteLine("DefineCursor(...): Called");
397                         #endif
398                         return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
399                 }
400
401                 internal static IntPtr DefineStdCursor(StdCursor id) {
402                         return driver.DefineStdCursor(id);
403                 }
404
405                 internal static IntPtr DefWndProc(ref Message msg) {
406                         return driver.DefWndProc(ref msg);
407                 }
408
409                 internal static void DestroyCaret(IntPtr handle) {
410                         #if DriverDebug
411                                 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
412                         #endif
413                         driver.DestroyCaret(handle);
414                 }
415
416                 internal static void DestroyCursor(IntPtr cursor) {
417                         #if DriverDebug
418                                 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
419                         #endif
420                         driver.DestroyCursor(cursor);
421                 }
422
423                 internal static void DestroyWindow(IntPtr handle) {
424                         #if DriverDebug || DriverDebugDestroy
425                                 Console.WriteLine("DestroyWindow({0}): Called", Window(handle));
426                         #endif
427                         driver.DestroyWindow(handle);
428                 }
429
430                 internal static IntPtr DispatchMessage(ref MSG msg) {
431                         return driver.DispatchMessage(ref msg);
432                 }
433
434                 internal static void DoEvents() {
435                         driver.DoEvents();
436                 }
437
438                 internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
439                         #if DriverDebug
440                                 Console.WriteLine("DrawReversibleRectangle({0}, {1}, {2}): Called", Window(handle), rect, line_width);
441                         #endif
442                         driver.DrawReversibleRectangle(handle, rect, line_width);
443                 }
444
445                 internal static void EnableThemes() {
446                         driver.EnableThemes();
447                 }
448
449                 internal static void EnableWindow(IntPtr handle, bool Enable) {
450                         #if DriverDebug || DriverDebugState
451                                 Console.WriteLine("EnableWindow({0}, {1}): Called", Window(handle), Enable);
452                         #endif
453                         driver.EnableWindow(handle, Enable);
454                 }
455
456                 internal static void EndLoop(Thread thread) {
457                         #if DriverDebug
458                                 Console.WriteLine("EndLoop({0:X}): Called", thread.GetHashCode());
459                         #endif
460                         driver.EndLoop(thread);
461                 }
462
463                 internal static IntPtr GetActive() {
464                         #if DriverDebug
465                                 Console.WriteLine("GetActive(): Called");
466                         #endif
467                         return driver.GetActive();
468                 }
469
470                 internal static SizeF GetAutoScaleSize(Font font) {
471                         #if DriverDebug
472                                 Console.WriteLine("GetAutoScaleSize({0}): Called", font);
473                         #endif
474                         return driver.GetAutoScaleSize(font);
475                 }
476
477                 internal static Region GetClipRegion(IntPtr handle) {
478                         #if DriverDebug
479                                 Console.WriteLine("GetClipRegion({0}): Called", Window(handle));
480                         #endif
481                         return driver.GetClipRegion(handle);
482                 }
483
484                 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
485                         #if DriverDebug
486                                 Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
487                         #endif
488                         driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
489                 }
490
491                 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
492                         #if DriverDebug
493                                 Console.WriteLine("GetCursorPos({0}): Called", Window(handle));
494                         #endif
495                         driver.GetCursorPos(handle, out x, out y);
496                 }
497
498                 internal static void GetDisplaySize(out Size size) {
499                         #if DriverDebug
500                                 Console.WriteLine("GetDisplaySize(): Called");
501                         #endif
502                         driver.GetDisplaySize(out size);
503                 }
504
505                 internal static IntPtr GetFocus() {
506                         #if DriverDebug
507                                 Console.WriteLine("GetFocus(): Called, Result:{0}", Window(driver.GetFocus()));
508                         #endif
509                         return driver.GetFocus();
510                 }
511
512                 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
513                         #if DriverDebug
514                                 Console.WriteLine("GetFontMetrics(): Called");
515                         #endif
516                         return driver.GetFontMetrics(g, font, out ascent, out descent);
517                 }
518                         
519                 internal static Point GetMenuOrigin(IntPtr handle) {
520                         #if DriverDebug
521                                 Console.WriteLine("GetMenuOrigin({0}): Called", Window(handle));
522                         #endif
523                         return driver.GetMenuOrigin(handle);
524                 }
525
526                 internal static bool GetMessage(object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
527                         return driver.GetMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
528                 }
529
530                 internal static IntPtr GetParent(IntPtr handle) {
531                         #if DriverDebug
532                                 Console.WriteLine("GetParent({0}): Called", Window(handle));
533                         #endif
534                         return driver.GetParent(handle);
535                 }
536
537                 internal static bool GetText(IntPtr handle, out string text) {
538                         #if DriverDebug
539                                 Console.WriteLine("GetText({0}): Called", Window(handle));
540                         #endif
541                         return driver.GetText(handle, out text);
542                 }
543
544                 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) {
545                         #if DriverDebug
546                                 Console.WriteLine("GetWindowPos({0}): Called", Window(handle));
547                         #endif
548                         driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
549                 }
550
551                 /* this method can (and does, on X11) return
552                  * (FormWindowState)(-1), when the state of the window
553                  * cannot be determined (in the X11 case, when the
554                  * window isn't mapped.)  Checking for the additional
555                  * return value is less expensive than
556                  * throwing/catching an exception. */
557                 internal static FormWindowState GetWindowState(IntPtr handle) {
558                         #if DriverDebug
559                                 Console.WriteLine("GetWindowState({0}): Called", Window(handle));
560                         #endif
561                         return driver.GetWindowState(handle);
562                 }
563
564                 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
565                         #if DriverDebug
566                                 Console.WriteLine("GrabInfo(): Called");
567                         #endif
568                         driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
569                 }
570
571                 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
572                         #if DriverDebug
573                                 Console.WriteLine("GrabWindow({0}, {1}): Called", Window(handle), Window(ConfineToHwnd));
574                         #endif
575                         driver.GrabWindow(handle, ConfineToHwnd);
576                 }
577
578                 internal static void HandleException(Exception e) {
579                         driver.HandleException(e);
580                 }
581
582                 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
583                         #if DriverDebug
584                                 Console.WriteLine("Invalidate({0}, {1}, {2}): Called", Window(handle), rc, clear);
585                         #endif
586                         driver.Invalidate(handle, rc, clear);
587                 }
588
589                 internal static void InvalidateNC (IntPtr handle)
590                 {
591                         #if DriverDebug
592                                 Console.WriteLine("InvalidateNC({0}): Called", Window(handle));
593                         #endif
594                         driver.InvalidateNC(handle);
595                 }
596
597
598                 internal static bool IsEnabled(IntPtr handle) {
599                         #if DriverDebug || DriverDebugState
600                                 Console.WriteLine("IsEnabled({0}): Called, Result={1}", Window(handle), driver.IsEnabled(handle));
601                         #endif
602                         return driver.IsEnabled(handle);
603                 }
604
605                 internal static bool IsVisible(IntPtr handle) {
606                         #if DriverDebug || DriverDebugState
607                                 Console.WriteLine("IsVisible({0}): Called, Result={1}", Window(handle), driver.IsVisible(handle));
608                         #endif
609                         return driver.IsVisible(handle);
610                 }
611
612                 internal static void KillTimer (Timer timer)
613                 {
614                         #if DriverDebug
615                                 Console.WriteLine("KillTimer({0}): Called", timer);
616                         #endif
617                         driver.KillTimer (timer);
618                 }
619
620                 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
621                         #if DriverDebug
622                                 Console.WriteLine("MenuToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
623                         #endif
624                         driver.MenuToScreen(handle, ref x, ref y);
625                 }
626
627                 internal static void OverrideCursor(IntPtr cursor) {
628                         #if DriverDebug
629                                 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
630                         #endif
631                         driver.OverrideCursor(cursor);
632                 }
633
634                 internal static void PaintEventEnd(IntPtr handle, bool client) {
635                         #if DriverDebug || DriverDebugPaint
636                                 Console.WriteLine("PaintEventEnd({0}, {1}): Called from thread {2}", Window(handle), client, Thread.CurrentThread.GetHashCode());
637                         #endif
638                         driver.PaintEventEnd(handle, client);
639                 }
640
641                 internal static PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
642                         #if DriverDebug || DriverDebugPaint
643                                 Console.WriteLine("PaintEventStart({0}, {1}): Called from thread {2}", Window(handle), client, Thread.CurrentThread.GetHashCode());
644                         #endif
645                         return driver.PaintEventStart(handle, client);
646                 }
647
648                 internal static bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
649                         return driver.PeekMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
650                 }
651
652                 internal static bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
653                         #if DriverDebug
654                                 Console.WriteLine("PostMessage({0}, {1}, {2:X}, {3:X}): Called", Window(hwnd), message, wParam.ToInt32(), lParam.ToInt32());
655                         #endif
656                         return driver.PostMessage(hwnd, message, wParam, lParam);
657                 }
658
659                 internal static bool PostMessage(ref MSG msg) {
660                         #if DriverDebug
661                                 Console.WriteLine("PostMessage({0}): Called", msg);
662                         #endif
663                         return driver.PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
664                 }
665
666                 internal static void PostQuitMessage(int exitCode) {
667                         #if DriverDebug
668                                 Console.WriteLine("PostQuitMessage({0}): Called", exitCode);
669                         #endif
670                         driver.PostQuitMessage(exitCode);
671                 }
672
673                 internal static void RequestAdditionalWM_NCMessages(IntPtr handle, bool hover, bool leave) {
674                         #if DriverDebug
675                                 Console.WriteLine("RequestAdditionalWM_NCMessages({0}, {1}, {2}): Called", Window(handle), hover, leave);
676                         #endif
677                         driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
678                 }
679
680                 internal static void RequestNCRecalc(IntPtr handle) {
681                         #if DriverDebug
682                                 Console.WriteLine("RequestNCRecalc({0}): Called", Window(handle));
683                         #endif
684                         driver.RequestNCRecalc(handle);
685                 }
686
687                 internal static void ResetMouseHover(IntPtr handle) {
688                         #if DriverDebug
689                                 Console.WriteLine("ResetMouseHover({0}): Called", Window(handle));
690                         #endif
691                         driver.ResetMouseHover(handle);
692                 }
693
694                 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
695                         #if DriverDebug
696                                 Console.WriteLine("ScreenToClient({0}, {1}, {2}): Called", Window(handle), x, y);
697                         #endif
698                         driver.ScreenToClient (handle, ref x, ref y);
699                 }
700
701                 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
702                         #if DriverDebug
703                                 Console.WriteLine("ScreenToMenu({0}, {1}, {2}): Called", Window(handle), x, y);
704                         #endif
705                         driver.ScreenToMenu(handle, ref x, ref y);
706                 }
707
708                 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
709                         #if DriverDebug
710                                 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}, {4}): Called", Window(handle), rectangle, XAmount, YAmount, with_children);
711                         #endif
712                         driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
713                 }
714
715                 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
716                         #if DriverDebug
717                                 Console.WriteLine("ScrollWindow({0}, {2}, {3}, {4}): Called", Window(handle), XAmount, YAmount, with_children);
718                         #endif
719                         driver.ScrollWindow(handle, XAmount, YAmount, with_children);
720                 }
721
722                 internal static void SendAsyncMethod (AsyncMethodData data) {
723                         #if DriverDebug
724                                 Console.WriteLine("SendAsyncMethod({0}): Called", data);
725                         #endif
726                         driver.SendAsyncMethod (data);
727                 }
728
729                 internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) {
730                         #if DriverDebug
731                                 Console.WriteLine("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window(handle), message, wParam.ToInt32(), lParam.ToInt32());
732                         #endif
733                         return driver.SendMessage (handle, message, wParam, lParam);
734                 }
735
736                 internal static void SendMessage (ref Message m) {
737                         #if DriverDebug
738                                 Console.WriteLine("SendMessage ({0}): Called", m);
739                         #endif
740                         m.Result = driver.SendMessage(m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
741                 }
742
743                 internal static void SetAllowDrop (IntPtr handle, bool value)
744                 {
745                         #if DriverDebug
746                         Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
747                         #endif
748                         driver.SetAllowDrop (handle, value);
749                 }
750
751                 internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
752                         #if DriverDebug
753                                 Console.WriteLine("SetBorderStyle({0}, {1}): Called", Window(handle), border_style);
754                         #endif
755                         driver.SetBorderStyle(handle, border_style);
756                 }
757
758                 internal static void SetCaretPos(IntPtr handle, int x, int y) {
759                         #if DriverDebug
760                                 Console.WriteLine("SetCaretPos({0}, {1}, {2}): Called", Window(handle), x, y);
761                         #endif
762                         driver.SetCaretPos(handle, x, y);
763                 }
764
765                 internal static void SetClipRegion(IntPtr handle, Region region) {
766                         #if DriverDebug
767                                 Console.WriteLine("SetClipRegion({0}, {1}): Called", Window(handle), region);
768                         #endif
769                         driver.SetClipRegion(handle, region);
770                 }
771
772                 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
773                         #if DriverDebug
774                                 Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
775                         #endif
776                         driver.SetCursor(handle, cursor);
777                 }
778
779                 internal static void SetCursorPos(IntPtr handle, int x, int y) {
780                         #if DriverDebug
781                                 Console.WriteLine("SetCursorPos({0}, {1}, {2}): Called", Window(handle), x, y);
782                         #endif
783                         driver.SetCursorPos(handle, x, y);
784                 }
785
786                 internal static void SetFocus(IntPtr handle) {
787                         #if DriverDebug
788                                 Console.WriteLine("SetFocus({0}): Called", Window(handle));
789                         #endif
790                         driver.SetFocus(handle);
791                 }
792
793                 internal static void SetIcon(IntPtr handle, Icon icon) {
794                         #if DriverDebug
795                                 Console.WriteLine("SetIcon({0}, {1}): Called", Window(handle), icon);
796                         #endif
797                         driver.SetIcon(handle, icon);
798                 }
799
800                 internal static void SetMenu(IntPtr handle, Menu menu) {
801                         #if DriverDebug
802                                 Console.WriteLine("SetMenu({0}, {1}): Called", Window(handle), menu);
803                         #endif
804                         driver.SetMenu(handle, menu);
805                 }
806
807                 internal static void SetModal(IntPtr handle, bool Modal) {
808                         #if DriverDebug || DriverDebugState
809                                 Console.WriteLine("SetModal({0}, {1}): Called", Window(handle), Modal);
810                         #endif
811                         driver.SetModal(handle, Modal);
812                 }
813
814                 internal static IntPtr SetParent(IntPtr handle, IntPtr hParent) {
815                         #if DriverDebug
816                                 Console.WriteLine("SetParent({0}, {1:X}): Called", Window(handle), Window(hParent));
817                         #endif
818                         return driver.SetParent(handle, hParent);
819                 }
820
821                 internal static void SetTimer (Timer timer)
822                 {
823                         #if DriverDebug
824                                 Console.WriteLine("SetTimer({0}): Called", timer);
825                         #endif
826                         driver.SetTimer (timer);
827                 }
828
829                 internal static bool SetTopmost(IntPtr handle, IntPtr hWndOwner, bool Enabled) {
830                         #if DriverDebug
831                                 Console.WriteLine("SetTopMost({0}, {1}, {2}): Called", Window(handle), Window(hWndOwner), Enabled);
832                         #endif
833                         return driver.SetTopmost(handle, hWndOwner, Enabled);
834                 }
835
836                 internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
837                 {
838                         #if DriverDebug || DriverDebugState
839                                 Console.WriteLine("SetVisible({0}, {1}, {2}): Called", Window(handle), visible, activate);
840                         #endif
841                         return driver.SetVisible (handle, visible, activate);
842                 }
843
844                 internal static void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
845                         #if DriverDebug || DriverDebugState
846                                 Console.WriteLine("SetWindowMinMax({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max);
847                         #endif
848                         driver.SetWindowMinMax(handle, maximized, min, max);
849                 }
850
851                 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
852                         #if DriverDebug
853                                 Console.WriteLine("SetWindowPos({0}, {1}, {2}, {3}, {4}): Called", Window(handle), x, y, width, height);
854                         #endif
855                         driver.SetWindowPos(handle, x, y, width, height);
856                 }
857
858                 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
859                         #if DriverDebug || DriverDebugState
860                                 Console.WriteLine("SetWindowState({0} {1}): Called", Window(handle), state);
861                         #endif
862                         driver.SetWindowState(handle, state);
863                 }
864
865                 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
866                         #if DriverDebug
867                                 Console.WriteLine("SetWindowStyle({0}): Called", Window(handle));
868                         #endif
869                         driver.SetWindowStyle(handle, cp);
870                 }
871
872                 internal static void SetWindowTransparency(IntPtr handle, double transparency, Color key) 
873                 {
874                         #if DriverDebug
875                                 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
876                         #endif
877                         driver.SetWindowTransparency(handle, transparency, key);
878                 }
879
880                 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
881                         #if DriverDebug
882                                 Console.WriteLine("SetZOrder({0}, {1:X}, {2}, {3}): Called", Window(handle), Window(AfterhWnd), Top, Bottom);
883                         #endif
884                         return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
885                 }
886
887                 internal static void ShowCursor(bool show) {
888                         #if DriverDebug
889                                 Console.WriteLine("ShowCursor({0}): Called", show);
890                         #endif
891                         driver.ShowCursor(show);
892                 }
893
894                 internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
895                         #if DriverDebug
896                         Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", Window(handle), data, allowedEffects);
897                         #endif
898                         return driver.StartDrag (handle, data, allowedEffects);
899                 }
900
901                 internal static object StartLoop(Thread thread) {
902                         #if DriverDebug
903                                 Console.WriteLine("StartLoop({0:X}): Called", thread.GetHashCode());
904                         #endif
905                         return driver.StartLoop(thread);
906                 }
907
908                 internal static bool SupportsTransparency() {
909                         #if DriverDebug
910                                 Console.WriteLine("SupportsTransparency(): Called, result={0}", driver.SupportsTransparency());
911                         #endif
912                         return driver.SupportsTransparency();
913                 }
914
915                 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
916                         #if DriverDebug
917                                 Console.WriteLine("SystrayAdd({0}, {1}): Called", Window(handle), tip);
918                         #endif
919                         return driver.SystrayAdd(handle, tip, icon, out tt);
920                 }
921
922                 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
923                         #if DriverDebug
924                                 Console.WriteLine("SystrayChange({0}, {1}): Called", Window(handle), tip);
925                         #endif
926                         driver.SystrayChange(handle, tip, icon, ref tt);
927                 }
928
929                 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
930                         #if DriverDebug
931                                 Console.WriteLine("SystrayRemove({0}): Called", Window(handle));
932                         #endif
933                         driver.SystrayRemove(handle, ref tt);
934                 }
935
936                 internal static bool Text(IntPtr handle, string text) {
937                         #if DriverDebug
938                                 Console.WriteLine("Text({0}, {1}): Called", Window(handle), text);
939                         #endif
940                         return driver.Text(handle, text);
941                 }
942
943                 internal static bool TranslateMessage(ref MSG msg) {
944                         return driver.TranslateMessage(ref msg);
945                 }
946
947                 internal static void UngrabWindow(IntPtr handle) {
948                         #if DriverDebug
949                                 Console.WriteLine("UngrabWindow({0}): Called", Window(handle));
950                         #endif
951                         driver.UngrabWindow(handle);
952                 }
953
954                 internal static void UpdateWindow(IntPtr handle) {
955                         #if DriverDebug
956                                 Console.WriteLine("UpdateWindow({0}): Called", Window(handle));
957                         #endif
958                         driver.UpdateWindow(handle);
959                 }
960
961                 // Santa's little helper
962                 internal static void Version() {
963                         Console.WriteLine("Xplat version $Revision: $");
964                 }
965
966                 internal static void Where() {
967                         XplatUIX11.Where();
968                 }
969                 #endregion      // Public Static Methods
970
971                 #region Delegates
972                 public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
973                 public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
974                 #endregion      // Delegates
975
976         }
977 }