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