In System.Windows.Forms:
[mono-project.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / XplatUI.cs
blobf4228970f97e5ebf44a2d6c5cca039662fe40e3f
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.
20 // Copyright (c) 2004-2006 Novell, Inc.
22 // Authors:
23 // Peter Bartok pbartok@novell.com
25 // NOT COMPLETE
27 // define to log API calls to stdout
28 #undef DriverDebug
29 #undef DriverDebugPaint
30 #undef DriverDebugCreate
31 #undef DriverDebugDestroy
32 #undef DriverDebugState
34 using System;
35 using System.Drawing;
36 using System.ComponentModel;
37 using System.Collections;
38 using System.Diagnostics;
39 using System.Runtime.InteropServices;
40 using System.Threading;
41 using System.Windows.Forms.X11Internal;
43 namespace System.Windows.Forms {
44 internal class XplatUI {
45 #region Local Variables
46 static XplatUIDriver driver;
47 static String default_class_name;
48 #endregion // Local Variables
50 #region Private Methods
51 internal static string Window(IntPtr handle) {
52 return String.Format("'{0}' ({1:X})", Control.FromHandle(handle), handle.ToInt32());
54 #endregion // Private Methods
56 #region Subclasses
57 public class State {
58 static public Keys ModifierKeys {
59 get {
60 return driver.ModifierKeys;
64 static public MouseButtons MouseButtons {
65 get {
66 return driver.MouseButtons;
70 static public Point MousePosition {
71 get {
72 return driver.MousePosition;
77 #endregion // Subclasses
79 #region Constructor & Destructor
80 static XplatUI() {
81 // Compose name with current domain id because on Win32 we register class name
82 // and name must be unique to process. If we load MWF into multiple appdomains
83 // and try to register same class name we fail.
84 default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID().ToString();
86 // check for Unix platforms - see FAQ for more details
87 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
88 int platform = (int) Environment.OSVersion.Platform;
89 if ((platform == 4) || (platform == 128)) {
90 if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_QUARTZ_BACKEND") != null)
91 driver=XplatUIOSX.GetInstance ();
92 else if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null)
93 driver=XplatUIX11_new.GetInstance ();
94 else
95 driver=XplatUIX11.GetInstance ();
96 } else {
97 driver=XplatUIWin32.GetInstance();
100 driver.InitializeDriver();
102 // Initialize things that need to be done after the driver is ready
103 DataFormats.GetFormat(0);
105 #endregion // Constructor & Destructor
107 #region Public Static Properties
108 internal static string DefaultClassName {
109 get {
110 return default_class_name;
113 set {
114 default_class_name=value;
118 static public int CaptionHeight {
119 get {
120 return driver.Caption;
124 static public Size CursorSize {
125 get {
126 return driver.CursorSize;
130 static public bool DragFullWindows {
131 get {
132 return driver.DragFullWindows;
136 static public Size DragSize {
137 get {
138 return driver.DragSize;
142 public static Size FrameBorderSize {
143 get {
144 return driver.FrameBorderSize;
148 static public int HorizontalScrollBarHeight {
149 get {
150 return driver.HorizontalScrollBarHeight;
154 static public Size IconSize {
155 get {
156 return driver.IconSize;
160 static public int KeyboardSpeed {
161 get {
162 return driver.KeyboardSpeed;
166 static public int KeyboardDelay {
167 get {
168 return driver.KeyboardSpeed;
172 static public Size MaxWindowTrackSize {
173 get {
174 return driver.MaxWindowTrackSize;
178 static public Size MinimizedWindowSize {
179 get {
180 return driver.MinimizedWindowSize;
184 static public Size MinimizedWindowSpacingSize {
185 get {
186 return driver.MinimizedWindowSpacingSize;
190 static public Size MinimumWindowSize {
191 get {
192 return driver.MinimumWindowSize;
196 static public Size MinWindowTrackSize {
197 get {
198 return driver.MinWindowTrackSize;
202 static public Size SmallIconSize {
203 get {
204 return driver.SmallIconSize;
208 static public int MenuHeight {
209 get {
210 return driver.MenuHeight;
214 static public int MouseButtonCount {
215 get {
216 return driver.MouseButtonCount;
220 static public bool MouseButtonsSwapped {
221 get {
222 return driver.MouseButtonsSwapped;
226 static public Size MouseHoverSize {
227 get {
228 return driver.MouseHoverSize;
232 static public int MouseHoverTime {
233 get {
234 return driver.MouseHoverTime;
238 static public bool MouseWheelPresent {
239 get {
240 return driver.MouseWheelPresent;
244 static public bool UserClipWontExposeParent {
245 get {
246 return driver.UserClipWontExposeParent;
250 static public int VerticalScrollBarWidth {
251 get {
252 return driver.VerticalScrollBarWidth;
256 static public Rectangle VirtualScreen {
257 get {
258 return driver.VirtualScreen;
262 static public Rectangle WorkingArea {
263 get {
264 return driver.WorkingArea;
268 public static bool ThemesEnabled {
269 get {
270 return XplatUI.driver.ThemesEnabled;
275 #endregion // Public Static Properties
277 #region Events
278 internal static event EventHandler Idle {
279 add {
280 driver.Idle += value;
282 remove {
283 driver.Idle -= value;
287 #endregion // Events
289 #region Public Static Methods
290 internal static void Activate(IntPtr handle) {
291 #if DriverDebug
292 Console.WriteLine("Activate({0}): Called", Window(handle));
293 #endif
294 driver.Activate(handle);
297 internal static void AudibleAlert() {
298 #if DriverDebug
299 Console.WriteLine("AudibleAlert(): Called");
300 #endif
301 driver.AudibleAlert();
304 internal static bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect) {
305 #if DriverDebug
306 Console.WriteLine("CalculateWindowRect({0}, {1}, {2}, {3}): Called", ClientRect, Style, ExStyle, menu);
307 #endif
308 return driver.CalculateWindowRect(ref ClientRect, Style, ExStyle, menu, out WindowRect);
311 internal static void CaretVisible(IntPtr handle, bool visible) {
312 #if DriverDebug
313 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
314 #endif
315 driver.CaretVisible(handle, visible);
318 internal static void CreateCaret(IntPtr handle, int width, int height) {
319 #if DriverDebug
320 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
321 #endif
322 driver.CreateCaret(handle, width, height);
325 internal static IntPtr CreateWindow(CreateParams cp) {
326 #if DriverDebug || DriverDebugCreate
327 IntPtr handle;
329 handle = driver.CreateWindow(cp);
331 Console.WriteLine("CreateWindow(): Called, returning {0:X}", handle.ToInt32());
332 return handle;
333 #else
334 return driver.CreateWindow(cp);
335 #endif
338 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
339 #if DriverDebug || DriverDebugCreate
340 Console.WriteLine("CreateWindow(): Called");
341 #endif
342 return driver.CreateWindow(Parent, X, Y, Width, Height);
345 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
346 #if DriverDebug
347 Console.WriteLine("ClientToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
348 #endif
349 driver.ClientToScreen(handle, ref x, ref y);
352 internal static int[] ClipboardAvailableFormats(IntPtr handle) {
353 #if DriverDebug
354 Console.WriteLine("ClipboardAvailableTypes({0:X}): Called", handle.ToInt32());
355 #endif
356 return driver.ClipboardAvailableFormats(handle);
359 internal static void ClipboardClose(IntPtr handle) {
360 #if DriverDebug
361 Console.WriteLine("ClipboardClose({0:X}): Called", handle.ToInt32());
362 #endif
363 driver.ClipboardClose(handle);
366 internal static int ClipboardGetID(IntPtr handle, string format) {
367 #if DriverDebug
368 Console.WriteLine("ClipboardGetID({0:X}, {1}): Called", handle.ToInt32(), format);
369 #endif
370 return driver.ClipboardGetID(handle, format);
373 internal static IntPtr ClipboardOpen(bool primary_selection) {
374 #if DriverDebug
375 Console.WriteLine("ClipboardOpen(): Called");
376 #endif
377 return driver.ClipboardOpen (primary_selection);
380 internal static void ClipboardStore(IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter) {
381 #if DriverDebug
382 Console.WriteLine("ClipboardStore({0:X}, {1}, {2}): Called", handle.ToInt32(), obj, type, converter);
383 #endif
384 driver.ClipboardStore(handle, obj, type, converter);
387 internal static object ClipboardRetrieve(IntPtr handle, int type, XplatUI.ClipboardToObject converter) {
388 #if DriverDebug
389 Console.WriteLine("ClipboardRetrieve({0:X}, type, {1}): Called", handle.ToInt32(), converter);
390 #endif
391 return driver.ClipboardRetrieve(handle, type, converter);
394 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
395 #if DriverDebug
396 Console.WriteLine("DefineCursor(...): Called");
397 #endif
398 return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
401 internal static IntPtr DefineStdCursor(StdCursor id) {
402 return driver.DefineStdCursor(id);
405 internal static IntPtr DefWndProc(ref Message msg) {
406 return driver.DefWndProc(ref msg);
409 internal static void DestroyCaret(IntPtr handle) {
410 #if DriverDebug
411 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
412 #endif
413 driver.DestroyCaret(handle);
416 internal static void DestroyCursor(IntPtr cursor) {
417 #if DriverDebug
418 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
419 #endif
420 driver.DestroyCursor(cursor);
423 internal static void DestroyWindow(IntPtr handle) {
424 #if DriverDebug || DriverDebugDestroy
425 Console.WriteLine("DestroyWindow({0}): Called", Window(handle));
426 #endif
427 driver.DestroyWindow(handle);
430 internal static IntPtr DispatchMessage(ref MSG msg) {
431 return driver.DispatchMessage(ref msg);
434 internal static void DoEvents() {
435 driver.DoEvents();
438 internal static void DrawReversibleRectangle(IntPtr handle, Rectangle rect, int line_width) {
439 #if DriverDebug
440 Console.WriteLine("DrawReversibleRectangle({0}, {1}, {2}): Called", Window(handle), rect, line_width);
441 #endif
442 driver.DrawReversibleRectangle(handle, rect, line_width);
445 internal static void EnableThemes() {
446 driver.EnableThemes();
449 internal static void EnableWindow(IntPtr handle, bool Enable) {
450 #if DriverDebug || DriverDebugState
451 Console.WriteLine("EnableWindow({0}, {1}): Called", Window(handle), Enable);
452 #endif
453 driver.EnableWindow(handle, Enable);
456 internal static void EndLoop(Thread thread) {
457 #if DriverDebug
458 Console.WriteLine("EndLoop({0:X}): Called", thread.GetHashCode());
459 #endif
460 driver.EndLoop(thread);
463 internal static IntPtr GetActive() {
464 #if DriverDebug
465 Console.WriteLine("GetActive(): Called");
466 #endif
467 return driver.GetActive();
470 internal static SizeF GetAutoScaleSize(Font font) {
471 #if DriverDebug
472 Console.WriteLine("GetAutoScaleSize({0}): Called", font);
473 #endif
474 return driver.GetAutoScaleSize(font);
477 internal static Region GetClipRegion(IntPtr handle) {
478 #if DriverDebug
479 Console.WriteLine("GetClipRegion({0}): Called", Window(handle));
480 #endif
481 return driver.GetClipRegion(handle);
484 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
485 #if DriverDebug
486 Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
487 #endif
488 driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
491 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
492 #if DriverDebug
493 Console.WriteLine("GetCursorPos({0}): Called", Window(handle));
494 #endif
495 driver.GetCursorPos(handle, out x, out y);
498 internal static void GetDisplaySize(out Size size) {
499 #if DriverDebug
500 Console.WriteLine("GetDisplaySize(): Called");
501 #endif
502 driver.GetDisplaySize(out size);
505 internal static IntPtr GetFocus() {
506 #if DriverDebug
507 Console.WriteLine("GetFocus(): Called, Result:{0}", Window(driver.GetFocus()));
508 #endif
509 return driver.GetFocus();
512 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
513 #if DriverDebug
514 Console.WriteLine("GetFontMetrics(): Called");
515 #endif
516 return driver.GetFontMetrics(g, font, out ascent, out descent);
519 internal static Point GetMenuOrigin(IntPtr handle) {
520 #if DriverDebug
521 Console.WriteLine("GetMenuOrigin({0}): Called", Window(handle));
522 #endif
523 return driver.GetMenuOrigin(handle);
526 internal static bool GetMessage(object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
527 return driver.GetMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
530 internal static IntPtr GetParent(IntPtr handle) {
531 #if DriverDebug
532 Console.WriteLine("GetParent({0}): Called", Window(handle));
533 #endif
534 return driver.GetParent(handle);
537 internal static bool GetText(IntPtr handle, out string text) {
538 #if DriverDebug
539 Console.WriteLine("GetText({0}): Called", Window(handle));
540 #endif
541 return driver.GetText(handle, out text);
544 internal static void GetWindowPos(IntPtr handle, bool is_toplevel, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
545 #if DriverDebug
546 Console.WriteLine("GetWindowPos({0}): Called", Window(handle));
547 #endif
548 driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
551 /* this method can (and does, on X11) return
552 * (FormWindowState)(-1), when the state of the window
553 * cannot be determined (in the X11 case, when the
554 * window isn't mapped.) Checking for the additional
555 * return value is less expensive than
556 * throwing/catching an exception. */
557 internal static FormWindowState GetWindowState(IntPtr handle) {
558 #if DriverDebug
559 Console.WriteLine("GetWindowState({0}): Called", Window(handle));
560 #endif
561 return driver.GetWindowState(handle);
564 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
565 #if DriverDebug
566 Console.WriteLine("GrabInfo(): Called");
567 #endif
568 driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
571 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
572 #if DriverDebug
573 Console.WriteLine("GrabWindow({0}, {1}): Called", Window(handle), Window(ConfineToHwnd));
574 #endif
575 driver.GrabWindow(handle, ConfineToHwnd);
578 internal static void HandleException(Exception e) {
579 driver.HandleException(e);
582 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
583 #if DriverDebug
584 Console.WriteLine("Invalidate({0}, {1}, {2}): Called", Window(handle), rc, clear);
585 #endif
586 driver.Invalidate(handle, rc, clear);
589 internal static void InvalidateNC (IntPtr handle)
591 #if DriverDebug
592 Console.WriteLine("InvalidateNC({0}): Called", Window(handle));
593 #endif
594 driver.InvalidateNC(handle);
598 internal static bool IsEnabled(IntPtr handle) {
599 #if DriverDebug || DriverDebugState
600 Console.WriteLine("IsEnabled({0}): Called, Result={1}", Window(handle), driver.IsEnabled(handle));
601 #endif
602 return driver.IsEnabled(handle);
605 internal static bool IsVisible(IntPtr handle) {
606 #if DriverDebug || DriverDebugState
607 Console.WriteLine("IsVisible({0}): Called, Result={1}", Window(handle), driver.IsVisible(handle));
608 #endif
609 return driver.IsVisible(handle);
612 internal static void KillTimer (Timer timer)
614 #if DriverDebug
615 Console.WriteLine("KillTimer({0}): Called", timer);
616 #endif
617 driver.KillTimer (timer);
620 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
621 #if DriverDebug
622 Console.WriteLine("MenuToScreen({0}, {1}, {2}): Called", Window(handle), x, y);
623 #endif
624 driver.MenuToScreen(handle, ref x, ref y);
627 internal static void OverrideCursor(IntPtr cursor) {
628 #if DriverDebug
629 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
630 #endif
631 driver.OverrideCursor(cursor);
634 internal static void PaintEventEnd(IntPtr handle, bool client) {
635 #if DriverDebug || DriverDebugPaint
636 Console.WriteLine("PaintEventEnd({0}, {1}): Called from thread {2}", Window(handle), client, Thread.CurrentThread.GetHashCode());
637 #endif
638 driver.PaintEventEnd(handle, client);
641 internal static PaintEventArgs PaintEventStart(IntPtr handle, bool client) {
642 #if DriverDebug || DriverDebugPaint
643 Console.WriteLine("PaintEventStart({0}, {1}): Called from thread {2}", Window(handle), client, Thread.CurrentThread.GetHashCode());
644 #endif
645 return driver.PaintEventStart(handle, client);
648 internal static bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
649 return driver.PeekMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
652 internal static bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) {
653 #if DriverDebug
654 Console.WriteLine("PostMessage({0}, {1}, {2:X}, {3:X}): Called", Window(hwnd), message, wParam.ToInt32(), lParam.ToInt32());
655 #endif
656 return driver.PostMessage(hwnd, message, wParam, lParam);
659 internal static bool PostMessage(ref MSG msg) {
660 #if DriverDebug
661 Console.WriteLine("PostMessage({0}): Called", msg);
662 #endif
663 return driver.PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);
666 internal static void PostQuitMessage(int exitCode) {
667 #if DriverDebug
668 Console.WriteLine("PostQuitMessage({0}): Called", exitCode);
669 #endif
670 driver.PostQuitMessage(exitCode);
673 internal static void RequestAdditionalWM_NCMessages(IntPtr handle, bool hover, bool leave) {
674 #if DriverDebug
675 Console.WriteLine("RequestAdditionalWM_NCMessages({0}, {1}, {2}): Called", Window(handle), hover, leave);
676 #endif
677 driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
680 internal static void RequestNCRecalc(IntPtr handle) {
681 #if DriverDebug
682 Console.WriteLine("RequestNCRecalc({0}): Called", Window(handle));
683 #endif
684 driver.RequestNCRecalc(handle);
687 internal static void ResetMouseHover(IntPtr handle) {
688 #if DriverDebug
689 Console.WriteLine("ResetMouseHover({0}): Called", Window(handle));
690 #endif
691 driver.ResetMouseHover(handle);
694 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
695 #if DriverDebug
696 Console.WriteLine("ScreenToClient({0}, {1}, {2}): Called", Window(handle), x, y);
697 #endif
698 driver.ScreenToClient (handle, ref x, ref y);
701 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
702 #if DriverDebug
703 Console.WriteLine("ScreenToMenu({0}, {1}, {2}): Called", Window(handle), x, y);
704 #endif
705 driver.ScreenToMenu(handle, ref x, ref y);
708 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
709 #if DriverDebug
710 Console.WriteLine("ScrollWindow({0}, {1}, {2}, {3}, {4}): Called", Window(handle), rectangle, XAmount, YAmount, with_children);
711 #endif
712 driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
715 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
716 #if DriverDebug
717 Console.WriteLine("ScrollWindow({0}, {2}, {3}, {4}): Called", Window(handle), XAmount, YAmount, with_children);
718 #endif
719 driver.ScrollWindow(handle, XAmount, YAmount, with_children);
722 internal static void SendAsyncMethod (AsyncMethodData data) {
723 #if DriverDebug
724 Console.WriteLine("SendAsyncMethod({0}): Called", data);
725 #endif
726 driver.SendAsyncMethod (data);
729 internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) {
730 #if DriverDebug
731 Console.WriteLine("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window(handle), message, wParam.ToInt32(), lParam.ToInt32());
732 #endif
733 return driver.SendMessage (handle, message, wParam, lParam);
736 internal static void SendMessage (ref Message m) {
737 #if DriverDebug
738 Console.WriteLine("SendMessage ({0}): Called", m);
739 #endif
740 m.Result = driver.SendMessage(m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
743 internal static void SetAllowDrop (IntPtr handle, bool value)
745 #if DriverDebug
746 Console.WriteLine ("SetAllowDrop({0}, {1}): Called", handle, value);
747 #endif
748 driver.SetAllowDrop (handle, value);
751 internal static void SetBorderStyle(IntPtr handle, FormBorderStyle border_style) {
752 #if DriverDebug
753 Console.WriteLine("SetBorderStyle({0}, {1}): Called", Window(handle), border_style);
754 #endif
755 driver.SetBorderStyle(handle, border_style);
758 internal static void SetCaretPos(IntPtr handle, int x, int y) {
759 #if DriverDebug
760 Console.WriteLine("SetCaretPos({0}, {1}, {2}): Called", Window(handle), x, y);
761 #endif
762 driver.SetCaretPos(handle, x, y);
765 internal static void SetClipRegion(IntPtr handle, Region region) {
766 #if DriverDebug
767 Console.WriteLine("SetClipRegion({0}, {1}): Called", Window(handle), region);
768 #endif
769 driver.SetClipRegion(handle, region);
772 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
773 #if DriverDebug
774 Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
775 #endif
776 driver.SetCursor(handle, cursor);
779 internal static void SetCursorPos(IntPtr handle, int x, int y) {
780 #if DriverDebug
781 Console.WriteLine("SetCursorPos({0}, {1}, {2}): Called", Window(handle), x, y);
782 #endif
783 driver.SetCursorPos(handle, x, y);
786 internal static void SetFocus(IntPtr handle) {
787 #if DriverDebug
788 Console.WriteLine("SetFocus({0}): Called", Window(handle));
789 #endif
790 driver.SetFocus(handle);
793 internal static void SetIcon(IntPtr handle, Icon icon) {
794 #if DriverDebug
795 Console.WriteLine("SetIcon({0}, {1}): Called", Window(handle), icon);
796 #endif
797 driver.SetIcon(handle, icon);
800 internal static void SetMenu(IntPtr handle, Menu menu) {
801 #if DriverDebug
802 Console.WriteLine("SetMenu({0}, {1}): Called", Window(handle), menu);
803 #endif
804 driver.SetMenu(handle, menu);
807 internal static void SetModal(IntPtr handle, bool Modal) {
808 #if DriverDebug || DriverDebugState
809 Console.WriteLine("SetModal({0}, {1}): Called", Window(handle), Modal);
810 #endif
811 driver.SetModal(handle, Modal);
814 internal static IntPtr SetParent(IntPtr handle, IntPtr hParent) {
815 #if DriverDebug
816 Console.WriteLine("SetParent({0}, {1:X}): Called", Window(handle), Window(hParent));
817 #endif
818 return driver.SetParent(handle, hParent);
821 internal static void SetTimer (Timer timer)
823 #if DriverDebug
824 Console.WriteLine("SetTimer({0}): Called", timer);
825 #endif
826 driver.SetTimer (timer);
829 internal static bool SetTopmost(IntPtr handle, IntPtr hWndOwner, bool Enabled) {
830 #if DriverDebug
831 Console.WriteLine("SetTopMost({0}, {1}, {2}): Called", Window(handle), Window(hWndOwner), Enabled);
832 #endif
833 return driver.SetTopmost(handle, hWndOwner, Enabled);
836 internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
838 #if DriverDebug || DriverDebugState
839 Console.WriteLine("SetVisible({0}, {1}, {2}): Called", Window(handle), visible, activate);
840 #endif
841 return driver.SetVisible (handle, visible, activate);
844 internal static void SetWindowMinMax(IntPtr handle, Rectangle maximized, Size min, Size max) {
845 #if DriverDebug || DriverDebugState
846 Console.WriteLine("SetWindowMinMax({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max);
847 #endif
848 driver.SetWindowMinMax(handle, maximized, min, max);
851 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
852 #if DriverDebug
853 Console.WriteLine("SetWindowPos({0}, {1}, {2}, {3}, {4}): Called", Window(handle), x, y, width, height);
854 #endif
855 driver.SetWindowPos(handle, x, y, width, height);
858 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
859 #if DriverDebug || DriverDebugState
860 Console.WriteLine("SetWindowState({0} {1}): Called", Window(handle), state);
861 #endif
862 driver.SetWindowState(handle, state);
865 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
866 #if DriverDebug
867 Console.WriteLine("SetWindowStyle({0}): Called", Window(handle));
868 #endif
869 driver.SetWindowStyle(handle, cp);
872 internal static double GetWindowTransparency (IntPtr handle)
874 #if DriverDebug
875 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
876 #endif
877 return driver.GetWindowTransparency(handle);
880 internal static void SetWindowTransparency(IntPtr handle, double transparency, Color key)
882 #if DriverDebug
883 Console.WriteLine("SetWindowTransparency({0}): Called", Window(handle));
884 #endif
885 driver.SetWindowTransparency(handle, transparency, key);
888 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
889 #if DriverDebug
890 Console.WriteLine("SetZOrder({0}, {1:X}, {2}, {3}): Called", Window(handle), Window(AfterhWnd), Top, Bottom);
891 #endif
892 return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
895 internal static void ShowCursor(bool show) {
896 #if DriverDebug
897 Console.WriteLine("ShowCursor({0}): Called", show);
898 #endif
899 driver.ShowCursor(show);
902 internal static DragDropEffects StartDrag(IntPtr handle, object data, DragDropEffects allowedEffects) {
903 #if DriverDebug
904 Console.WriteLine ("StartDrag({0}, {1}, {2}): Called", Window(handle), data, allowedEffects);
905 #endif
906 return driver.StartDrag (handle, data, allowedEffects);
909 internal static object StartLoop(Thread thread) {
910 #if DriverDebug
911 Console.WriteLine("StartLoop({0:X}): Called", thread.GetHashCode());
912 #endif
913 return driver.StartLoop(thread);
916 internal static TransparencySupport SupportsTransparency() {
917 #if DriverDebug
918 Console.WriteLine("SupportsTransparency(): Called, result={0}", driver.SupportsTransparency());
919 #endif
920 return driver.SupportsTransparency();
923 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
924 #if DriverDebug
925 Console.WriteLine("SystrayAdd({0}, {1}): Called", Window(handle), tip);
926 #endif
927 return driver.SystrayAdd(handle, tip, icon, out tt);
930 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
931 #if DriverDebug
932 Console.WriteLine("SystrayChange({0}, {1}): Called", Window(handle), tip);
933 #endif
934 driver.SystrayChange(handle, tip, icon, ref tt);
937 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
938 #if DriverDebug
939 Console.WriteLine("SystrayRemove({0}): Called", Window(handle));
940 #endif
941 driver.SystrayRemove(handle, ref tt);
944 internal static bool Text(IntPtr handle, string text) {
945 #if DriverDebug
946 Console.WriteLine("Text({0}, {1}): Called", Window(handle), text);
947 #endif
948 return driver.Text(handle, text);
951 internal static bool TranslateMessage(ref MSG msg) {
952 return driver.TranslateMessage(ref msg);
955 internal static void UngrabWindow(IntPtr handle) {
956 #if DriverDebug
957 Console.WriteLine("UngrabWindow({0}): Called", Window(handle));
958 #endif
959 driver.UngrabWindow(handle);
962 internal static void UpdateWindow(IntPtr handle) {
963 #if DriverDebug
964 Console.WriteLine("UpdateWindow({0}): Called", Window(handle));
965 #endif
966 driver.UpdateWindow(handle);
969 // Santa's little helper
970 internal static void Version() {
971 Console.WriteLine("Xplat version $Revision: $");
974 internal static void Where() {
975 XplatUIX11.Where();
977 #endregion // Public Static Methods
979 #region Delegates
980 public delegate bool ClipboardToObject(int type, IntPtr data, out object obj);
981 public delegate bool ObjectToClipboard(ref int type, object obj, out byte[] data);
982 #endregion // Delegates