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