* TreeView.cs: Don't draw the selected node when we lose
[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-2005 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
30 using System;
31 using System.Drawing;
32 using System.ComponentModel;
33 using System.Collections;
34 using System.Diagnostics;
35 using System.Runtime.InteropServices;
36
37 /// X11 Version
38 namespace System.Windows.Forms {
39         internal class XplatUI {
40                 #region Local Variables
41                 static XplatUIDriver            driver;
42                 static String                   default_class_name;
43                 #endregion      // Local Variables
44
45                 #region Subclasses
46                 public class State {
47                         static public Keys ModifierKeys {
48                                 get {
49                                         return driver.ModifierKeys;
50                                 }
51                         }
52
53                         static public MouseButtons MouseButtons {
54                                 get {
55                                         return driver.MouseButtons;
56                                 }
57                         }
58
59                         static public Point MousePosition {
60                                 get {
61                                         return driver.MousePosition;
62                                 }
63                         }
64
65                 }
66                 #endregion      // Subclasses
67
68                 #region Constructor & Destructor
69                 static XplatUI() {
70                         Console.WriteLine("Mono System.Windows.Forms Assembly [Revision: 51965; built: 2005/10/20 3:34:45]");
71
72                         // Don't forget to throw the mac in here somewhere, too
73                         default_class_name="SWFClass";
74
75                         // check for Unix platforms - see FAQ for more details
76                         // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
77                         int platform = (int) Environment.OSVersion.Platform;
78                         if ((platform == 4) || (platform == 128)) {
79                                 if (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null)
80                                         driver=XplatUIOSX.GetInstance();
81                                 else
82                                         driver=XplatUIX11.GetInstance();
83                         } else {
84                                 driver=XplatUIWin32.GetInstance();
85                         }
86
87                         driver.InitializeDriver();
88
89                 }
90                 #endregion      // Constructor & Destructor
91
92                 #region Public Static Properties
93                 internal static string DefaultClassName {
94                         get {
95                                 return default_class_name;
96                         }
97
98                         set {
99                                 default_class_name=value;
100                         }
101                 }
102
103                 static public int CaptionHeight {
104                         get {
105                                 return driver.Caption;
106                         }
107                 }
108
109                 static public Size CursorSize {
110                         get {
111                                 return driver.CursorSize;
112                         }
113                 }
114
115                 static public bool DragFullWindows {
116                         get {
117                                 return driver.DragFullWindows;
118                         }
119                 }
120
121                 static public Size DragSize {
122                         get {
123                                 return driver.DragSize;
124                         }
125                 }
126
127                 public static Size FrameBorderSize {
128                         get {
129                                 return driver.FrameBorderSize;
130                         }
131                 }
132
133                 static public Size IconSize {
134                         get {
135                                 return driver.IconSize;
136                         }
137                 }
138
139                 static public int KeyboardSpeed {
140                         get {
141                                 return driver.KeyboardSpeed;
142                         }
143                 }
144
145                 static public int KeyboardDelay {
146                         get {
147                                 return driver.KeyboardSpeed;
148                         }
149                 }
150
151                 static public Size MaxWindowTrackSize {
152                         get {
153                                 return driver.MaxWindowTrackSize;
154                         }
155                 }
156
157                 static public Size MinimizedWindowSize {
158                         get {
159                                 return driver.MinimizedWindowSize;
160                         }
161                 }
162
163                 static public Size MinimizedWindowSpacingSize {
164                         get {
165                                 return driver.MinimizedWindowSpacingSize;
166                         }
167                 }
168
169                 static public Size MinimumWindowSize {
170                         get {
171                                 return driver.MinimumWindowSize;
172                         }
173                 }
174
175                 static public Size MinWindowTrackSize {
176                         get {
177                                 return driver.MinWindowTrackSize;
178                         }
179                 }
180
181                 static public Size SmallIconSize {
182                         get {
183                                 return driver.SmallIconSize;
184                         }
185                 }
186
187                 static public int MouseButtonCount {
188                         get {
189                                 return driver.MouseButtonCount;
190                         }
191                 }
192
193                 static public bool MouseButtonsSwapped {
194                         get {
195                                 return driver.MouseButtonsSwapped;
196                         }
197                 }
198
199                 static public bool MouseWheelPresent {
200                         get {
201                                 return driver.MouseWheelPresent;
202                         }
203                 }
204
205                 static public Rectangle VirtualScreen {
206                         get {
207                                 return driver.VirtualScreen;
208                         }
209                 }
210
211                 static public Rectangle WorkingArea {
212                         get {
213                                 return driver.WorkingArea;
214                         }
215                 }
216                 #endregion      // Public Static Properties
217
218                 #region Events
219                 internal static event EventHandler Idle {
220                         add {
221                                 driver.Idle += value;
222                         }
223                         remove {
224                                 driver.Idle -= value;
225                         }
226                 }
227                 
228                 #endregion      // Events
229
230                 #region Public Static Methods
231                 internal static void Activate(IntPtr handle) {
232                         #if DriverDebug
233                                 Console.WriteLine("Activate({0:X}): Called", handle.ToInt32());
234                         #endif
235                         driver.Activate(handle);
236                 }
237
238                 internal static bool CalculateWindowRect(IntPtr handle, ref Rectangle ClientRect, int Style, int ExStyle, IntPtr MenuHandle, out Rectangle WindowRect) {
239                         #if DriverDebug
240                                 Console.WriteLine("CalculateWindowRect({0:X}): Called", handle.ToInt32());
241                         #endif
242                         return driver.CalculateWindowRect(handle, ref ClientRect, Style, ExStyle, MenuHandle, out WindowRect);
243                 }
244
245                 internal static void CaretVisible(IntPtr handle, bool visible) {
246                         #if DriverDebug
247                                 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
248                         #endif
249                         driver.CaretVisible(handle, visible);
250                 }
251
252                 internal static void CreateCaret(IntPtr handle, int width, int height) {
253                         #if DriverDebug
254                                 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
255                         #endif
256                         driver.CreateCaret(handle, width, height);
257                 }
258
259                 internal static IntPtr CreateWindow(CreateParams cp) {
260                         #if DriverDebug
261                                 Console.WriteLine("CreateWindow(): Called");
262                         #endif
263                         return driver.CreateWindow(cp);
264                 }
265
266                 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
267                         #if DriverDebug
268                                 Console.WriteLine("CreateWindow(): Called");
269                         #endif
270                         return driver.CreateWindow(Parent, X, Y, Width, Height);
271                 }
272
273                 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
274                         #if DriverDebug
275                                 Console.WriteLine("ClientToScreen({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
276                         #endif
277                         driver.ClientToScreen(handle, ref x, ref y);
278                 }
279
280                 internal static int[] ClipboardAvailableFormats(IntPtr handle) {
281                         #if DriverDebug
282                                 Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
283                         #endif
284                         return driver.ClipboardAvailableFormats(handle);
285                 }
286
287                 internal static void ClipboardClose(IntPtr handle) {
288                         #if DriverDebug
289                                 Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
290                         #endif
291                         driver.ClipboardClose(handle);
292                 }
293
294                 internal static int ClipboardGetID(IntPtr handle, string format) {
295                         #if DriverDebug
296                                 Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
297                         #endif
298                         return driver.ClipboardGetID(handle, format);
299                 }
300
301                 internal static IntPtr ClipboardOpen() {
302                         #if DriverDebug
303                                 Console.WriteLine("ClipboardOpen(): Called");
304                         #endif
305                         return driver.ClipboardOpen();
306                 }
307
308                 internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
309                         #if DriverDebug
310                                 Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, (ClipboardFormat)type, converter);
311                         #endif
312                         driver.ClipboardStore(handle, obj, type, converter);
313                 }
314
315                 internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
316                         #if DriverDebug
317                                 Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
318                         #endif
319                         return driver.ClipboardRetrieve(handle, type, converter);
320                 }
321
322                 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
323                         #if DriverDebug
324                                 Console.WriteLine("DefineCursor(...): Called");
325                         #endif
326                         return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
327                 }
328
329                 internal static IntPtr DefineStdCursor(StdCursor id) {
330                         return driver.DefineStdCursor(id);
331                 }
332
333                 internal static IntPtr DefWndProc(ref Message msg) {
334                         return driver.DefWndProc(ref msg);
335                 }
336
337                 internal static void DestroyCaret(IntPtr handle) {
338                         #if DriverDebug
339                                 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
340                         #endif
341                         driver.DestroyCaret(handle);
342                 }
343
344                 internal static void DestroyCursor(IntPtr cursor) {
345                         #if DriverDebug
346                                 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
347                         #endif
348                         driver.DestroyCursor(cursor);
349                 }
350
351                 internal static void DestroyWindow(IntPtr handle) {
352                         #if DriverDebug
353                                 Console.WriteLine("DestroyWindow({0:X}): Called", handle.ToInt32());
354                         #endif
355                         driver.DestroyWindow(handle);
356                 }
357
358                 internal static IntPtr DispatchMessage(ref MSG msg) {
359                         return driver.DispatchMessage(ref msg);
360                 }
361
362                 internal static void DoEvents() {
363                         driver.DoEvents();
364                 }
365
366                 internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
367                         #if DriverDebug
368                                 Console.WriteLine("DrawReversibleRectangle({0:X}, {1}, {2}): Called", handle.ToInt32(), rect, line_width);
369                         #endif
370                         driver.DrawReversibleRectangle(handle, rect, line_width);
371                 }
372
373                 internal static void EnableThemes() {
374                         driver.EnableThemes();
375                 }
376
377                 internal static void EnableWindow(IntPtr handle, bool Enable) {
378                         #if DriverDebug
379                                 Console.WriteLine("EnableWindow({0:X}, {1}): Called", handle.ToInt32(), Enable);
380                         #endif
381                         driver.EnableWindow(handle, Enable);
382                 }
383
384                 internal static void Exit() {
385                         driver.Exit();
386                 }
387
388                 internal static IntPtr GetActive() {
389                         #if DriverDebug
390                                 Console.WriteLine("GetActive(): Called");
391                         #endif
392                         return driver.GetActive();
393                 }
394
395                 internal static SizeF GetAutoScaleSize(Font font) {
396                         #if DriverDebug
397                                 Console.WriteLine("GetAutoScaleSize({0}): Called", font);
398                         #endif
399                         return driver.GetAutoScaleSize(font);
400                 }
401
402                 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
403                         #if DriverDebug
404                                 Console.WriteLine("GetCursorInfo({0:X}): Called", cursor.ToInt32());
405                         #endif
406                         driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
407                 }
408
409                 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
410                         #if DriverDebug
411                                 Console.WriteLine("GetCursorPos({0:X}): Called", handle.ToInt32());
412                         #endif
413                         driver.GetCursorPos(handle, out x, out y);
414                 }
415
416                 internal static void GetDisplaySize(out Size size) {
417                         #if DriverDebug
418                                 Console.WriteLine("GetDisplaySize(): Called");
419                         #endif
420                         driver.GetDisplaySize(out size);
421                 }
422
423                 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
424                         #if DriverDebug
425                                 Console.WriteLine("GetFontMetrics(): Called");
426                         #endif
427                         return driver.GetFontMetrics(g, font, out ascent, out descent);
428                 }
429                         
430                 internal static Graphics GetMenuDC(IntPtr handle, IntPtr ncpaint_region) {
431                         #if DriverDebug
432                                 Console.WriteLine("GetMenuDC({0:X}): Called", handle.ToInt32());
433                         #endif
434                         return driver.GetMenuDC(handle, ncpaint_region);
435                 }
436
437                 internal static Point GetMenuOrigin(IntPtr handle) {
438                         #if DriverDebug
439                                 Console.WriteLine("GetMenuOrigin({0:X}): Called", handle.ToInt32());
440                         #endif
441                         return driver.GetMenuOrigin(handle);
442                 }
443
444                 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
445                         return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
446                 }
447
448                 internal static IntPtr GetParent(IntPtr hWnd) {
449                         #if DriverDebug
450                                 Console.WriteLine("GetParent({0:X}): Called", hWnd.ToInt32());
451                         #endif
452                         return driver.GetParent(hWnd);
453                 }
454
455                 internal static bool GetText(IntPtr hWnd, out string text) {
456                         #if DriverDebug
457                                 Console.WriteLine("GetText(): Called");
458                         #endif
459                         return driver.GetText(hWnd, out text);
460                 }
461
462                 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) {
463                         #if DriverDebug
464                                 Console.WriteLine("GetWindowPos({0:X}): Called", handle.ToInt32());
465                         #endif
466                         driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
467                 }
468
469                 internal static FormWindowState GetWindowState(IntPtr handle) {
470                         #if DriverDebug
471                                 Console.WriteLine("GetWindowState({0:X}): Called", handle.ToInt32());
472                         #endif
473                         return driver.GetWindowState(handle);
474                 }
475
476                 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
477                         #if DriverDebug
478                                 Console.WriteLine("GrabInfo(): Called");
479                         #endif
480                         driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
481                 }
482
483                 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
484                         #if DriverDebug
485                                 Console.WriteLine("GrabWindow({0:X}): Called", handle.ToInt32());
486                         #endif
487                         driver.GrabWindow(handle, ConfineToHwnd);
488                 }
489
490                 internal static void HandleException(Exception e) {
491                         driver.HandleException(e);
492                 }
493
494                 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
495                         #if DriverDebug
496                                 Console.WriteLine("Invalidate({0:X}, {1}, {2}): Called", handle.ToInt32(), rc, clear);
497                         #endif
498                         driver.Invalidate(handle, rc, clear);
499                 }
500
501                 internal static bool IsVisible(IntPtr hWnd) {
502                         #if DriverDebug
503                                 Console.WriteLine("IsVisible({0:X}): Called", hWnd.ToInt32());
504                         #endif
505                         return driver.IsVisible(hWnd);
506                 }
507
508                 internal static void KillTimer (Timer timer)
509                 {
510                         #if DriverDebug
511                                 Console.WriteLine("KillTimer({0}): Called", timer);
512                         #endif
513                         driver.KillTimer (timer);
514                 }
515
516                 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
517                         #if DriverDebug
518                                 Console.WriteLine("MenuToScreen({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
519                         #endif
520                         driver.MenuToScreen(handle, ref x, ref y);
521                 }
522
523                 internal static void OverrideCursor(IntPtr cursor) {
524                         #if DriverDebug
525                                 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
526                         #endif
527                         driver.OverrideCursor(cursor);
528                 }
529
530                 internal static void PaintEventEnd(IntPtr handle, bool client) {
531                         #if DriverDebug
532                                 Console.WriteLine("PaintEventEnd({0:X}, {1}): Called", handle.ToInt32(), client);
533                         #endif
534                         driver.PaintEventEnd(handle, client);
535                 }
536
537                 internal static PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
538                         #if DriverDebug
539                                 Console.WriteLine("PaintEventStart({0:X}, {1}): Called", handle.ToInt32(), client);
540                         #endif
541                         return driver.PaintEventStart(handle, client);
542                 }
543
544                 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
545                         return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
546                 }
547
548                 internal static void ReleaseMenuDC(IntPtr handle, Graphics dc) {
549                         #if DriverDebug
550                                 Console.WriteLine("ReleaseMenuDC({0:X}): Called", handle.ToInt32());
551                         #endif
552                         driver.ReleaseMenuDC(handle, dc);
553                 }
554
555                 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
556                         #if DriverDebug
557                                 Console.WriteLine("ScreenToClient({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
558                         #endif
559                         driver.ScreenToClient (handle, ref x, ref y);
560                 }
561
562                 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
563                         #if DriverDebug
564                                 Console.WriteLine("ScreenToMenu({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
565                         #endif
566                         driver.ScreenToMenu(handle, ref x, ref y);
567                 }
568
569                 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
570                         #if DriverDebug
571                                 Console.WriteLine("ScrollWindow({0:X}, {1}, {2}, {3}, {4}): Called", handle.ToInt32(), rectangle, XAmount, YAmount, with_children);
572                         #endif
573                         driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
574                 }
575
576                 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
577                         #if DriverDebug
578                                 Console.WriteLine("ScrollWindow({0:X}, {2}, {3}, {4}): Called", handle.ToInt32(), XAmount, YAmount, with_children);
579                         #endif
580                         driver.ScrollWindow(handle, XAmount, YAmount, with_children);
581                 }
582
583                 internal static void SendAsyncMethod (AsyncMethodData data) {
584                         #if DriverDebug
585                                 Console.WriteLine("SendAsyncMethod({0}): Called", data);
586                         #endif
587                         driver.SendAsyncMethod (data);
588                 }
589
590                 internal static void SetAllowDrop (IntPtr handle, bool value)
591                 {
592                         #if DriverDebug
593                         Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
594                         #endif
595                         driver.SetAllowDrop (handle, value);
596                 }
597
598                 internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
599                         #if DriverDebug
600                                 Console.WriteLine("SetBorderStyle({0:X}, {1}): Called", handle.ToInt32(), border_style);
601                         #endif
602                         driver.SetBorderStyle(handle, border_style);
603                 }
604
605                 internal static void SetCaretPos(IntPtr handle, int x, int y) {
606                         #if DriverDebug
607                                 Console.WriteLine("SetCaretPos({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
608                         #endif
609                         driver.SetCaretPos(handle, x, y);
610                 }
611
612                 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
613                         #if DriverDebug
614                                 Console.WriteLine("SetCursor({0:X}, {1:X}): Called", handle.ToInt32(), cursor.ToInt32());
615                         #endif
616                         driver.SetCursor(handle, cursor);
617                 }
618
619                 internal static void SetCursorPos(IntPtr handle, int x, int y) {
620                         #if DriverDebug
621                                 Console.WriteLine("SetCursorPos({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
622                         #endif
623                         driver.SetCursorPos(handle, x, y);
624                 }
625
626                 internal static void SetFocus(IntPtr handle) {
627                         #if DriverDebug
628                                 Console.WriteLine("SetFocus({0:X}): Called", handle.ToInt32());
629                         #endif
630                         driver.SetFocus(handle);
631                 }
632
633                 internal static void SetIcon(IntPtr handle, Icon icon) {
634                         #if DriverDebug
635                                 Console.WriteLine("SetIcon({0:X}, {1}): Called", handle.ToInt32(), icon);
636                         #endif
637                         driver.SetIcon(handle, icon);
638                 }
639
640                 internal static void SetMenu(IntPtr handle, IntPtr menu_handle) {
641                         #if DriverDebug
642                                 Console.WriteLine("SetMenu({0:X}, {1:X}): Called", handle.ToInt32(), menu_handle.ToInt32());
643                         #endif
644                         driver.SetMenu(handle, menu_handle);
645                 }
646
647                 internal static void SetModal(IntPtr handle, bool Modal) {
648                         #if DriverDebug
649                                 Console.WriteLine("SetModal({0:X}, {1}): Called", handle.ToInt32(), Modal);
650                         #endif
651                         driver.SetModal(handle, Modal);
652                 }
653
654                 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
655                         #if DriverDebug
656                                 Console.WriteLine("SetParent({0:X}, {1:X}): Called", hWnd.ToInt32(), hParent.ToInt32());
657                         #endif
658                         return driver.SetParent(hWnd, hParent);
659                 }
660
661                 internal static void SetTimer (Timer timer)
662                 {
663                         #if DriverDebug
664                                 Console.WriteLine("SetTimer({0}): Called", timer);
665                         #endif
666                         driver.SetTimer (timer);
667                 }
668
669                 internal static bool SetTopmost(IntPtr handle, IntPtr hWndOwner, bool Enabled) {
670                         #if DriverDebug
671                                 Console.WriteLine("SetTopMost({0:X}, {1:X}, {2}): Called", handle.ToInt32(), hWndOwner.ToInt32(), Enabled);
672                         #endif
673                         return driver.SetTopmost(handle, hWndOwner, Enabled);
674                 }
675
676                 internal static bool SetVisible(IntPtr hWnd, bool visible) {
677                         #if DriverDebug
678                                 Console.WriteLine("SetVisible({0:X}, {1}): Called", hWnd.ToInt32(), visible);
679                         #endif
680                         return driver.SetVisible(hWnd, visible);
681                 }
682
683                 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
684                         #if DriverDebug
685                                 Console.WriteLine("SetWindowPos({0:X}, {1}, {2}, {3}, {4}): Called", handle.ToInt32(), x, y, width, height);
686                         #endif
687                         driver.SetWindowPos(handle, x, y, width, height);
688                 }
689
690                 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
691                         #if DriverDebug
692                                 Console.WriteLine("SetWindowState({0:X} {1}): Called", handle.ToInt32(), state);
693                         #endif
694                         driver.SetWindowState(handle, state);
695                 }
696
697                 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
698                         #if DriverDebug
699                                 Console.WriteLine("SetWindowStyle({0:X}): Called", handle.ToInt32());
700                         #endif
701                         driver.SetWindowStyle(handle, cp);
702                 }
703
704                 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
705                         #if DriverDebug
706                                 Console.WriteLine("SetZOrder({0:X}, {1:X}, {2}, {3}): Called", handle.ToInt32(), AfterhWnd.ToInt32(), Top, Bottom);
707                         #endif
708                         return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
709                 }
710
711                 internal static void ShowCursor(bool show) {
712                         #if DriverDebug
713                                 Console.WriteLine("ShowCursor({0}): Called", show);
714                         #endif
715                         driver.ShowCursor(show);
716                 }
717
718                 internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
719                         #if DriverDebug
720                         Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", handle, data, allowedEffects);
721                         #endif
722                         return driver.StartDrag (handle, data, allowedEffects);
723                 }
724
725                 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
726                         #if DriverDebug
727                                 Console.WriteLine("SystrayAdd({0:X}, {1}): Called", handle.ToInt32(), tip);
728                         #endif
729                         return driver.SystrayAdd(handle, tip, icon, out tt);
730                 }
731
732                 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
733                         #if DriverDebug
734                                 Console.WriteLine("SystrayChange({0:X}, {1}): Called", handle.ToInt32(), tip);
735                         #endif
736                         driver.SystrayChange(handle, tip, icon, ref tt);
737                 }
738
739                 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
740                         #if DriverDebug
741                                 Console.WriteLine("SystrayRemove({0:X}): Called", handle.ToInt32());
742                         #endif
743                         driver.SystrayRemove(handle, ref tt);
744                 }
745
746                 internal static bool Text(IntPtr hWnd, string text) {
747                         #if DriverDebug
748                                 Console.WriteLine("Text({0:X}, {1}): Called", hWnd.ToInt32(), text);
749                         #endif
750                         return driver.Text(hWnd, text);
751                 }
752
753                 internal static bool TranslateMessage(ref MSG msg) {
754                         return driver.TranslateMessage(ref msg);
755                 }
756
757                 internal static void UngrabWindow(IntPtr handle) {
758                         #if DriverDebug
759                                 Console.WriteLine("UngrabWindow({0:X}): Called", handle.ToInt32());
760                         #endif
761                         driver.UngrabWindow(handle);
762                 }
763
764                 internal static void UpdateWindow(IntPtr handle) {
765                         #if DriverDebug
766                                 Console.WriteLine("UpdateWindow({0:X}): Called", handle.ToInt32());
767                         #endif
768                         driver.UpdateWindow(handle);
769                 }
770
771                 // Santa's little helper
772                 internal static void Version() {
773                         Console.WriteLine("Xplat version $Revision: $");
774                 }
775
776                 internal static void Where() {
777                         XplatUIX11.Where();
778                 }
779                 #endregion      // Public Static Methods
780
781                 #region Delegates
782                 public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
783                 public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
784                 #endregion      // Delegates
785
786         }
787 }