1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
|
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (c) 2004-2006 Novell, Inc.
//
// Authors:
// Peter Bartok pbartok@novell.com
// NOT COMPLETE
// define to log API calls to stdout
#undef DriverDebug
#undef DriverDebugPaint
#undef DriverDebugCreate
#undef DriverDebugDestroy
#undef DriverDebugState
using System;
using System.Drawing;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Windows.Forms {
internal class XplatUI {
#region Local Variables
static XplatUIDriver driver;
// static String default_class_name;
internal static ArrayList key_filters = new ArrayList ();
#endregion // Local Variables
#region Private Methods
internal static string Window (IntPtr handle)
{
return String.Format ("'{0}' ({1:X})", Control.FromHandle (handle), handle.ToInt32 ());
}
[Conditional ("DriverDebug")]
static void DriverDebug (string format, params object [] args)
{
Console.WriteLine (String.Format (format, args));
}
#endregion // Private Methods
#region Subclasses
public class State {
static public Keys ModifierKeys {
get {
return driver.ModifierKeys;
}
}
static public MouseButtons MouseButtons {
get {
return driver.MouseButtons;
}
}
static public Point MousePosition {
get {
return driver.MousePosition;
}
}
}
#endregion // Subclasses
#region Constructor & Destructor
static XplatUI ()
{
// Compose name with current domain id because on Win32 we register class name
// and name must be unique to process. If we load MWF into multiple appdomains
// and try to register same class name we fail.
// default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID ().ToString ();
if (RunningOnUnix) {
//if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) {
// driver=XplatUIX11_new.GetInstance ();
//} else
if (Environment.GetEnvironmentVariable ("MONO_MWF_MAC_FORCE_X11") != null) {
driver = XplatUIX11.GetInstance ();
} else {
IntPtr buf = Marshal.AllocHGlobal (8192);
// This is a hacktastic way of getting sysname from uname ()
if (uname (buf) != 0) {
// WTF: We cannot run uname
driver=XplatUIX11.GetInstance ();
} else {
string os = Marshal.PtrToStringAnsi (buf);
if (os == "Darwin")
driver=XplatUICarbon.GetInstance ();
else
driver=XplatUIX11.GetInstance ();
}
Marshal.FreeHGlobal (buf);
}
} else {
driver=XplatUIWin32.GetInstance ();
}
driver.InitializeDriver ();
// Initialize things that need to be done after the driver is ready
DataFormats.GetFormat (0);
// Signal that the Application loop can be run.
// This allows UIA to initialize a11y support for MWF
// before the main loop begins.
Application.FirePreRun ();
}
#endregion // Constructor & Destructor
#region Public Static Properties
public static bool RunningOnUnix {
get {
int p = (int) Environment.OSVersion.Platform;
return (p == 4 || p == 6 || p == 128);
}
}
public static int ActiveWindowTrackingDelay {
get { return driver.ActiveWindowTrackingDelay; }
}
// Compose name with current domain id because on Win32 we register class name
// and name must be unique to process. If we load MWF into multiple appdomains
// and try to register same class name we fail.
internal static string GetDefaultClassName (Type type)
{
return "SWFClass" + Thread.GetDomainID ().ToString () + "." + type.ToString ();
}
static public Size Border3DSize {
get {
return driver.Border3DSize;
}
}
static public Size BorderSize {
get {
return driver.BorderSize;
}
}
static public Size CaptionButtonSize {
get {
return driver.CaptionButtonSize;
}
}
static public int CaptionHeight {
get {
return driver.CaptionHeight;
}
}
public static int CaretBlinkTime { get { return driver.CaretBlinkTime; } }
public static int CaretWidth { get { return driver.CaretWidth; } }
static public Size CursorSize {
get {
return driver.CursorSize;
}
}
static public Size DoubleClickSize {
get {
return driver.DoubleClickSize;
}
}
static public int DoubleClickTime {
get {
return driver.DoubleClickTime;
}
}
static public bool DragFullWindows {
get {
return driver.DragFullWindows;
}
}
static public Size DragSize {
get {
return driver.DragSize;
}
}
static public Size FixedFrameBorderSize {
get {
return driver.FixedFrameBorderSize;
}
}
public static int FontSmoothingContrast { get { return driver.FontSmoothingContrast; } }
public static int FontSmoothingType { get { return driver.FontSmoothingType; } }
public static Size FrameBorderSize {
get {
return driver.FrameBorderSize;
}
}
public static int HorizontalResizeBorderThickness { get { return driver.HorizontalResizeBorderThickness; } }
static public int HorizontalScrollBarHeight {
get {
return driver.HorizontalScrollBarHeight;
}
}
static public Size IconSize {
get {
return driver.IconSize;
}
}
public static bool IsActiveWindowTrackingEnabled { get { return driver.IsActiveWindowTrackingEnabled; } }
public static bool IsComboBoxAnimationEnabled { get { return driver.IsComboBoxAnimationEnabled; } }
public static bool IsDropShadowEnabled { get { return driver.IsDropShadowEnabled; } }
public static bool IsFontSmoothingEnabled { get { return driver.IsFontSmoothingEnabled; } }
public static bool IsHotTrackingEnabled { get { return driver.IsHotTrackingEnabled; } }
public static bool IsIconTitleWrappingEnabled { get { return driver.IsIconTitleWrappingEnabled; } }
public static bool IsKeyboardPreferred { get { return driver.IsKeyboardPreferred; } }
public static bool IsListBoxSmoothScrollingEnabled { get { return driver.IsListBoxSmoothScrollingEnabled; } }
public static bool IsMenuAnimationEnabled { get { return driver.IsMenuAnimationEnabled; } }
public static bool IsMenuFadeEnabled { get { return driver.IsMenuFadeEnabled; } }
public static bool IsMinimizeRestoreAnimationEnabled { get { return driver.IsMinimizeRestoreAnimationEnabled; } }
public static bool IsSelectionFadeEnabled { get { return driver.IsSelectionFadeEnabled; } }
public static bool IsSnapToDefaultEnabled { get { return driver.IsSnapToDefaultEnabled; } }
public static bool IsTitleBarGradientEnabled { get { return driver.IsTitleBarGradientEnabled; } }
public static bool IsToolTipAnimationEnabled { get { return driver.IsToolTipAnimationEnabled; } }
static public int KeyboardSpeed {
get {
return driver.KeyboardSpeed;
}
}
static public int KeyboardDelay {
get {
return driver.KeyboardDelay;
}
}
static public Size MaxWindowTrackSize {
get {
return driver.MaxWindowTrackSize;
}
}
static public bool MenuAccessKeysUnderlined {
get {
return driver.MenuAccessKeysUnderlined;
}
}
static public Size MenuBarButtonSize { get { return driver.MenuBarButtonSize; } }
public static Size MenuButtonSize {
get {
return driver.MenuButtonSize;
}
}
static public int MenuShowDelay { get { return driver.MenuShowDelay; } }
static public Size MinimizedWindowSize {
get {
return driver.MinimizedWindowSize;
}
}
static public Size MinimizedWindowSpacingSize {
get {
return driver.MinimizedWindowSpacingSize;
}
}
static public Size MinimumWindowSize {
get {
return driver.MinimumWindowSize;
}
}
static public Size MinimumFixedToolWindowSize {
get { return driver.MinimumFixedToolWindowSize; }
}
static public Size MinimumSizeableToolWindowSize {
get { return driver.MinimumSizeableToolWindowSize; }
}
static public Size MinimumNoBorderWindowSize {
get { return driver.MinimumNoBorderWindowSize; }
}
static public Size MinWindowTrackSize {
get {
return driver.MinWindowTrackSize;
}
}
public static int MouseSpeed {
get { return driver.MouseSpeed; }
}
static public Size SmallIconSize {
get {
return driver.SmallIconSize;
}
}
static public int MenuHeight {
get {
return driver.MenuHeight;
}
}
static public int MouseButtonCount {
get {
return driver.MouseButtonCount;
}
}
static public bool MouseButtonsSwapped {
get {
return driver.MouseButtonsSwapped;
}
}
static public Size MouseHoverSize {
get {
return driver.MouseHoverSize;
}
}
static public int MouseHoverTime {
get {
return driver.MouseHoverTime;
}
}
static public int MouseWheelScrollDelta {
get {
return driver.MouseWheelScrollDelta;
}
}
static public bool MouseWheelPresent {
get {
return driver.MouseWheelPresent;
}
}
public static LeftRightAlignment PopupMenuAlignment {
get { return driver.PopupMenuAlignment; }
}
public static PowerStatus PowerStatus {
get { return driver.PowerStatus; }
}
public static bool RequiresPositiveClientAreaSize {
get {
return driver.RequiresPositiveClientAreaSize;
}
}
public static int SizingBorderWidth {
get { return driver.SizingBorderWidth; }
}
public static Size SmallCaptionButtonSize {
get { return driver.SmallCaptionButtonSize; }
}
public static bool UIEffectsEnabled {
get { return driver.UIEffectsEnabled; }
}
static public bool UserClipWontExposeParent {
get {
return driver.UserClipWontExposeParent;
}
}
public static int VerticalResizeBorderThickness { get { return driver.VerticalResizeBorderThickness; } }
static public int VerticalScrollBarWidth {
get {
return driver.VerticalScrollBarWidth;
}
}
static public Rectangle VirtualScreen {
get {
return driver.VirtualScreen;
}
}
static public Rectangle WorkingArea {
get {
return driver.WorkingArea;
}
}
public static Screen[] AllScreens {
get {
return driver.AllScreens;
}
}
public static bool ThemesEnabled {
get {
return XplatUI.driver.ThemesEnabled;
}
}
public static int ToolWindowCaptionHeight {
get {
return driver.ToolWindowCaptionHeight;
}
}
public static Size ToolWindowCaptionButtonSize {
get {
return driver.ToolWindowCaptionButtonSize;
}
}
#endregion // Public Static Properties
#region Events
internal static event EventHandler Idle {
add {
driver.Idle += value;
}
remove {
driver.Idle -= value;
}
}
#endregion // Events
#region Public Static Methods
internal static void Activate (IntPtr handle)
{
DriverDebug ("Activate ({0}): Called", Window (handle));
driver.Activate (handle);
}
internal static void AudibleAlert (AlertType alert)
{
DriverDebug ("AudibleAlert (): Called");
driver.AudibleAlert (alert);
}
internal static void BeginMoveResize (IntPtr handle)
{
driver.BeginMoveResize (handle);
}
internal static bool CalculateWindowRect (ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect)
{
DriverDebug ("CalculateWindowRect ({0}, {1}, {2}): Called", ClientRect, cp, menu);
return driver.CalculateWindowRect (ref ClientRect, cp, menu, out WindowRect);
}
internal static void CaretVisible (IntPtr handle, bool visible)
{
DriverDebug ("CaretVisible ({0:X}, {1}): Called", handle.ToInt32 (), visible);
driver.CaretVisible (handle, visible);
}
internal static void CreateCaret (IntPtr handle, int width, int height)
{
DriverDebug ("CreateCaret ({0:X}), {1}, {2}: Called", handle.ToInt32 (), width, height);
driver.CreateCaret (handle, width, height);
}
internal static IntPtr CreateWindow (CreateParams cp)
{
#if DriverDebug || DriverDebugCreate
IntPtr handle;
handle = driver.CreateWindow (cp);
Console.WriteLine ("CreateWindow (): Called, returning {0:X}", handle.ToInt32 ());
return handle;
#else
return driver.CreateWindow (cp);
#endif
}
internal static IntPtr CreateWindow (IntPtr Parent, int X, int Y, int Width, int Height)
{
#if DriverDebug || DriverDebugCreate
Console.WriteLine ("CreateWindow (): Called");
#endif
return driver.CreateWindow (Parent, X, Y, Width, Height);
}
internal static void ClientToScreen (IntPtr handle, ref int x, ref int y)
{
#if DriverDebug
Console.WriteLine ("ClientToScreen ({0}, {1}, {2}): Called", Window (handle), x, y);
#endif
driver.ClientToScreen (handle, ref x, ref y);
}
internal static int[] ClipboardAvailableFormats (IntPtr handle)
{
DriverDebug ("ClipboardAvailableTypes ({0:X}): Called", handle.ToInt32 ());
return driver.ClipboardAvailableFormats (handle);
}
internal static void ClipboardClose (IntPtr handle)
{
DriverDebug ("ClipboardClose ({0:X}): Called", handle.ToInt32 ());
driver.ClipboardClose (handle);
}
internal static int ClipboardGetID (IntPtr handle, string format)
{
DriverDebug ("ClipboardGetID ({0:X}, {1}): Called", handle.ToInt32 (), format);
return driver.ClipboardGetID (handle, format);
}
internal static IntPtr ClipboardOpen (bool primary_selection)
{
DriverDebug ("ClipboardOpen (): Called");
return driver.ClipboardOpen (primary_selection);
}
internal static void ClipboardStore (IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter, bool copy)
{
DriverDebug ("ClipboardStore ({0:X}, {1}, {2}, {3}, {4}): Called", handle.ToInt32 (), obj, type, converter, copy);
driver.ClipboardStore (handle, obj, type, converter, copy);
}
internal static object ClipboardRetrieve (IntPtr handle, int type, XplatUI.ClipboardToObject converter)
{
DriverDebug ("ClipboardRetrieve ({0:X}, type, {1}): Called", handle.ToInt32 (), converter);
return driver.ClipboardRetrieve (handle, type, converter);
}
internal static IntPtr DefineCursor (Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot)
{
DriverDebug ("DefineCursor (...): Called");
return driver.DefineCursor (bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
}
internal static IntPtr DefineStdCursor (StdCursor id)
{
return driver.DefineStdCursor (id);
}
internal static Bitmap DefineStdCursorBitmap (StdCursor id)
{
return driver.DefineStdCursorBitmap (id);
}
internal static IntPtr DefWndProc (ref Message msg)
{
return driver.DefWndProc (ref msg);
}
internal static void DestroyCaret (IntPtr handle)
{
DriverDebug ("DestroyCaret ({0:X}): Called", handle.ToInt32 ());
driver.DestroyCaret (handle);
}
internal static void DestroyCursor (IntPtr cursor)
{
DriverDebug ("DestroyCursor ({0:X}): Called", cursor.ToInt32 ());
driver.DestroyCursor (cursor);
}
internal static void DestroyWindow (IntPtr handle)
{
DriverDebug ("DestroyWindow ({0}): Called", Window (handle));
driver.DestroyWindow (handle);
}
internal static IntPtr DispatchMessage (ref MSG msg)
{
return driver.DispatchMessage (ref msg);
}
internal static void DoEvents ()
{
driver.DoEvents ();
}
internal static void DrawReversibleRectangle (IntPtr handle, Rectangle rect, int line_width)
{
DriverDebug ("DrawReversibleRectangle ({0}, {1}, {2}): Called", Window (handle), rect, line_width);
driver.DrawReversibleRectangle (handle, rect, line_width);
}
internal static void FillReversibleRectangle (Rectangle rectangle, Color backColor)
{
DriverDebug ("FillReversibleRectangle ({0}, {1}): Called", rectangle, backColor);
driver.FillReversibleRectangle (rectangle, backColor);
}
internal static void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
{
DriverDebug ("DrawReversibleFrame ({0}, {1}, {2}): Called", rectangle, backColor, style);
driver.DrawReversibleFrame (rectangle, backColor, style);
}
internal static void DrawReversibleLine (Point start, Point end, Color backColor)
{
DriverDebug ("DrawReversibleLine ({0}, {1}, {2}): Called", start, end, backColor);
driver.DrawReversibleLine (start, end, backColor);
}
internal static void EnableThemes ()
{
driver.EnableThemes ();
}
internal static void EnableWindow (IntPtr handle, bool Enable)
{
DriverDebug ("EnableWindow ({0}, {1}): Called", Window (handle), Enable);
driver.EnableWindow (handle, Enable);
}
internal static void EndLoop (Thread thread)
{
DriverDebug ("EndLoop ({0:X}): Called", thread.GetHashCode ());
driver.EndLoop (thread);
}
internal static IntPtr GetActive ()
{
DriverDebug ("GetActive (): Called");
return driver.GetActive ();
}
internal static SizeF GetAutoScaleSize (Font font)
{
DriverDebug ("GetAutoScaleSize ({0}): Called", font);
return driver.GetAutoScaleSize (font);
}
internal static Region GetClipRegion (IntPtr handle)
{
DriverDebug ("GetClipRegion ({0}): Called", Window (handle));
return driver.GetClipRegion (handle);
}
internal static void GetCursorInfo (IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y)
{
DriverDebug ("GetCursorInfo ({0}): Called", cursor.ToInt32 ());
driver.GetCursorInfo (cursor, out width, out height, out hotspot_x, out hotspot_y);
}
internal static void GetCursorPos (IntPtr handle, out int x, out int y)
{
DriverDebug ("GetCursorPos ({0}): Called", Window (handle));
driver.GetCursorPos (handle, out x, out y);
}
internal static void GetDisplaySize (out Size size)
{
DriverDebug ("GetDisplaySize (): Called");
driver.GetDisplaySize (out size);
}
internal static IntPtr GetFocus ()
{
DriverDebug ("GetFocus (): Called, Result:{0}", Window (driver.GetFocus ()));
return driver.GetFocus ();
}
internal static bool GetFontMetrics (Graphics g, Font font, out int ascent, out int descent)
{
DriverDebug ("GetFontMetrics (): Called");
return driver.GetFontMetrics (g, font, out ascent, out descent);
}
internal static Point GetMenuOrigin (IntPtr handle)
{
DriverDebug ("GetMenuOrigin ({0}): Called", Window (handle));
return driver.GetMenuOrigin (handle);
}
internal static bool GetMessage (object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax)
{
return driver.GetMessage (queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
}
internal static IntPtr GetParent (IntPtr handle)
{
DriverDebug ("GetParent ({0}): Called", Window (handle));
return driver.GetParent (handle);
}
internal static IntPtr GetPreviousWindow (IntPtr handle)
{
return driver.GetPreviousWindow (handle);
}
internal static bool GetText (IntPtr handle, out string text)
{
DriverDebug ("GetText ({0}): Called", Window (handle));
return driver.GetText (handle, out text);
}
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)
{
DriverDebug ("GetWindowPos ({0}): Called", Window (handle));
driver.GetWindowPos (handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
}
/* this method can (and does, on X11) return
* (FormWindowState) (-1), when the state of the window
* cannot be determined (in the X11 case, when the
* window isn't mapped.) Checking for the additional
* return value is less expensive than
* throwing/catching an exception. */
internal static FormWindowState GetWindowState (IntPtr handle)
{
DriverDebug ("GetWindowState ({0}): Called", Window (handle));
return driver.GetWindowState (handle);
}
internal static void GrabInfo (out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea)
{
DriverDebug ("GrabInfo (): Called");
driver.GrabInfo (out handle, out GrabConfined, out GrabArea);
}
internal static void GrabWindow (IntPtr handle, IntPtr ConfineToHwnd)
{
DriverDebug ("GrabWindow ({0}, {1}): Called", Window (handle), Window (ConfineToHwnd));
driver.GrabWindow (handle, ConfineToHwnd);
}
internal static void HandleException (Exception e)
{
driver.HandleException (e);
}
internal static void Invalidate (IntPtr handle, Rectangle rc, bool clear)
{
DriverDebug ("Invalidate ({0}, {1}, {2}): Called", Window (handle), rc, clear);
driver.Invalidate (handle, rc, clear);
}
internal static void InvalidateNC (IntPtr handle)
{
DriverDebug ("InvalidateNC ({0}): Called", Window (handle));
driver.InvalidateNC (handle);
}
internal static bool IsEnabled (IntPtr handle)
{
#if DriverDebug || DriverDebugState
Console.WriteLine ("IsEnabled ({0}): Called, Result={1}", Window (handle), driver.IsEnabled (handle));
#endif
return driver.IsEnabled (handle);
}
internal static bool IsKeyLocked (VirtualKeys key)
{
#if DriverDebug || DriverDebugState
Console.WriteLine ("IsKeyLocked ({0}): Called, Result={1}", key, driver.IsKeyLocked (key));
#endif
return driver.IsKeyLocked (key);
}
internal static bool IsVisible (IntPtr handle)
{
#if DriverDebug || DriverDebugState
Console.WriteLine ("IsVisible ({0}): Called, Result={1}", Window (handle), driver.IsVisible (handle));
#endif
return driver.IsVisible (handle);
}
internal static void KillTimer (Timer timer)
{
DriverDebug ("KillTimer ({0}): Called", timer);
driver.KillTimer (timer);
}
internal static void MenuToScreen (IntPtr handle, ref int x, ref int y)
{
DriverDebug ("MenuToScreen ({0}, {1}, {2}): Called", Window (handle), x, y);
driver.MenuToScreen (handle, ref x, ref y);
}
internal static void OverrideCursor (IntPtr cursor)
{
DriverDebug ("OverrideCursor ({0:X}): Called", cursor.ToInt32 ());
driver.OverrideCursor (cursor);
}
internal static void PaintEventEnd (ref Message msg, IntPtr handle, bool client)
{
#if DriverDebug || DriverDebugPaint
Console.WriteLine ("PaintEventEnd ({0}, {1}, {2}): Called from thread {3}", msg, Window (handle), client, Thread.CurrentThread.GetHashCode ());
#endif
driver.PaintEventEnd (ref msg, handle, client);
}
internal static PaintEventArgs PaintEventStart (ref Message msg, IntPtr handle, bool client)
{
#if DriverDebug || DriverDebugPaint
Console.WriteLine ("PaintEventStart ({0}, {1}, {2}): Called from thread {3}", msg, Window (handle), client, Thread.CurrentThread.GetHashCode ());
#endif
return driver.PaintEventStart (ref msg, handle, client);
}
internal static bool PeekMessage (Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags)
{
return driver.PeekMessage (queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
}
internal static bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam)
{
DriverDebug ("PostMessage ({0}, {1}, {2:X}, {3:X}): Called", Window (hwnd), message, wParam.ToInt32 (), lParam.ToInt32 ());
return driver.PostMessage (hwnd, message, wParam, lParam);
}
internal static bool PostMessage (ref MSG msg)
{
DriverDebug ("PostMessage ({0}): Called", msg);
return driver.PostMessage (msg.hwnd, msg.message, msg.wParam, msg.lParam);
}
internal static void PostQuitMessage (int exitCode)
{
DriverDebug ("PostQuitMessage ({0}): Called", exitCode);
driver.PostQuitMessage (exitCode);
}
internal static void RaiseIdle (EventArgs e)
{
DriverDebug ("RaiseIdle ({0}): Called", e.ToString ());
driver.RaiseIdle (e);
}
internal static void RequestAdditionalWM_NCMessages (IntPtr handle, bool hover, bool leave)
{
DriverDebug ("RequestAdditionalWM_NCMessages ({0}, {1}, {2}): Called", Window (handle), hover, leave);
driver.RequestAdditionalWM_NCMessages (handle, hover, leave);
}
internal static void RequestNCRecalc (IntPtr handle)
{
DriverDebug ("RequestNCRecalc ({0}): Called", Window (handle));
driver.RequestNCRecalc (handle);
}
internal static void ResetMouseHover (IntPtr handle)
{
DriverDebug ("ResetMouseHover ({0}): Called", Window (handle));
driver.ResetMouseHover (handle);
}
internal static void ScreenToClient (IntPtr handle, ref int x, ref int y)
{
DriverDebug ("ScreenToClient ({0}, {1}, {2}): Called", Window (handle), x, y);
driver.ScreenToClient (handle, ref x, ref y);
}
internal static void ScreenToMenu (IntPtr handle, ref int x, ref int y)
{
DriverDebug ("ScreenToMenu ({0}, {1}, {2}): Called", Window (handle), x, y);
driver.ScreenToMenu (handle, ref x, ref y);
}
internal static void ScrollWindow (IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children)
{
DriverDebug ("ScrollWindow ({0}, {1}, {2}, {3}, {4}): Called", Window (handle), rectangle, XAmount, YAmount, with_children);
driver.ScrollWindow (handle, rectangle, XAmount, YAmount, with_children);
}
internal static void ScrollWindow (IntPtr handle, int XAmount, int YAmount, bool with_children)
{
DriverDebug ("ScrollWindow ({0}, {1}, {2}, {3}): Called", Window (handle), XAmount, YAmount, with_children);
driver.ScrollWindow (handle, XAmount, YAmount, with_children);
}
internal static void SendAsyncMethod (AsyncMethodData data)
{
DriverDebug ("SendAsyncMethod ({0}): Called", data);
driver.SendAsyncMethod (data);
}
internal static int SendInput (IntPtr hwnd, Queue keys)
{
DriverDebug ("SendInput ({0}, {1}): Called", hwnd, keys);
return driver.SendInput (hwnd, keys);
}
internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam)
{
DriverDebug ("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window (handle), message, wParam.ToInt32 (), lParam.ToInt32 ());
return driver.SendMessage (handle, message, wParam, lParam);
}
internal static void SendMessage (ref Message m)
{
DriverDebug ("SendMessage ({0}): Called", m);
m.Result = driver.SendMessage (m.HWnd, (Msg)m.Msg, m.WParam, m.LParam);
}
internal static void SetAllowDrop (IntPtr handle, bool value)
{
DriverDebug ("SetAllowDrop ({0}, {1}): Called", handle, value);
driver.SetAllowDrop (handle, value);
}
internal static void SetBorderStyle (IntPtr handle, FormBorderStyle border_style)
{
DriverDebug ("SetBorderStyle ({0}, {1}): Called", Window (handle), border_style);
driver.SetBorderStyle (handle, border_style);
}
internal static void SetCaretPos (IntPtr handle, int x, int y)
{
DriverDebug ("SetCaretPos ({0}, {1}, {2}): Called", Window (handle), x, y);
driver.SetCaretPos (handle, x, y);
}
internal static void SetClipRegion (IntPtr handle, Region region)
{
DriverDebug ("SetClipRegion ({0}, {1}): Called", Window (handle), region);
driver.SetClipRegion (handle, region);
}
internal static void SetCursor (IntPtr handle, IntPtr cursor)
{
DriverDebug ("SetCursor ({0}, {1:X}): Called", Window (handle), cursor.ToInt32 ());
driver.SetCursor (handle, cursor);
}
internal static void SetCursorPos (IntPtr handle, int x, int y)
{
DriverDebug ("SetCursorPos ({0}, {1}, {2}): Called", Window (handle), x, y);
driver.SetCursorPos (handle, x, y);
}
internal static void SetFocus (IntPtr handle)
{
DriverDebug ("SetFocus ({0}): Called", Window (handle));
driver.SetFocus (handle);
}
internal static void SetForegroundWindow (IntPtr handle)
{
DriverDebug ("SetForegroundWindow ({0}): Called", Window (handle));
driver.SetForegroundWindow (handle);
}
internal static void SetIcon (IntPtr handle, Icon icon)
{
DriverDebug ("SetIcon ({0}, {1}): Called", Window (handle), icon);
driver.SetIcon (handle, icon);
}
internal static void SetMenu (IntPtr handle, Menu menu)
{
DriverDebug ("SetMenu ({0}, {1}): Called", Window (handle), menu);
driver.SetMenu (handle, menu);
}
internal static void SetModal (IntPtr handle, bool Modal)
{
DriverDebug ("SetModal ({0}, {1}): Called", Window (handle), Modal);
driver.SetModal (handle, Modal);
}
internal static IntPtr SetParent (IntPtr handle, IntPtr hParent)
{
DriverDebug ("SetParent ({0}, {1:X}): Called", Window (handle), Window (hParent));
return driver.SetParent (handle, hParent);
}
internal static void SetTimer (Timer timer)
{
DriverDebug ("SetTimer ({0}): Called", timer);
driver.SetTimer (timer);
}
internal static bool SetTopmost (IntPtr handle, bool Enabled)
{
DriverDebug ("SetTopMost ({0}, {1}): Called", Window (handle), Enabled);
return driver.SetTopmost (handle, Enabled);
}
internal static bool SetOwner (IntPtr handle, IntPtr hWndOwner)
{
DriverDebug ("SetOwner ({0}, {1}): Called", Window (handle), Window (hWndOwner));
return driver.SetOwner (handle, hWndOwner);
}
internal static bool SetVisible (IntPtr handle, bool visible, bool activate)
{
#if DriverDebug || DriverDebugState
Console.WriteLine ("SetVisible ({0}, {1}, {2}): Called", Window (handle), visible, activate);
#endif
return driver.SetVisible (handle, visible, activate);
}
internal static void SetWindowMinMax (IntPtr handle, Rectangle maximized, Size min, Size max)
{
#if DriverDebug || DriverDebugState
Console.WriteLine ("SetWindowMinMax ({0}, {1}, {2}, {3}): Called", Window (handle), maximized, min, max);
#endif
driver.SetWindowMinMax (handle, maximized, min, max);
}
internal static void SetWindowPos (IntPtr handle, int x, int y, int width, int height)
{
DriverDebug ("SetWindowPos ({0}, {1}, {2}, {3}, {4}): Called", Window (handle), x, y, width, height);
driver.SetWindowPos (handle, x, y, width, height);
}
internal static void SetWindowState (IntPtr handle, FormWindowState state)
{
#if DriverDebug || DriverDebugState
Console.WriteLine ("SetWindowState ({0} {1}): Called", Window (handle), state);
#endif
driver.SetWindowState (handle, state);
}
internal static void SetWindowStyle (IntPtr handle, CreateParams cp)
{
DriverDebug ("SetWindowStyle ({0}): Called", Window (handle));
driver.SetWindowStyle (handle, cp);
}
internal static double GetWindowTransparency (IntPtr handle)
{
DriverDebug ("SetWindowTransparency ({0}): Called", Window (handle));
return driver.GetWindowTransparency (handle);
}
internal static void SetWindowTransparency (IntPtr handle, double transparency, Color key)
{
DriverDebug ("SetWindowTransparency ({0}): Called", Window (handle));
driver.SetWindowTransparency (handle, transparency, key);
}
internal static bool SetZOrder (IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom)
{
DriverDebug ("SetZOrder ({0}, {1:X}, {2}, {3}): Called", Window (handle), Window (AfterhWnd), Top, Bottom);
return driver.SetZOrder (handle, AfterhWnd, Top, Bottom);
}
internal static void ShowCursor (bool show)
{
DriverDebug ("ShowCursor ({0}): Called", show);
driver.ShowCursor (show);
}
internal static DragDropEffects StartDrag (IntPtr handle, object data, DragDropEffects allowedEffects)
{
DriverDebug ("StartDrag ({0}, {1}, {2}): Called", Window (handle), data, allowedEffects);
return driver.StartDrag (handle, data, allowedEffects);
}
internal static object StartLoop (Thread thread)
{
DriverDebug ("StartLoop ({0:X}): Called", thread.GetHashCode ());
return driver.StartLoop (thread);
}
internal static TransparencySupport SupportsTransparency ()
{
DriverDebug ("SupportsTransparency (): Called, result={0}", driver.SupportsTransparency ());
return driver.SupportsTransparency ();
}
internal static bool SystrayAdd (IntPtr handle, string tip, Icon icon, out ToolTip tt)
{
DriverDebug ("SystrayAdd ({0}, {1}): Called", Window (handle), tip);
return driver.SystrayAdd (handle, tip, icon, out tt);
}
internal static void SystrayChange (IntPtr handle, string tip, Icon icon, ref ToolTip tt)
{
DriverDebug ("SystrayChange ({0}, {1}): Called", Window (handle), tip);
driver.SystrayChange (handle, tip, icon, ref tt);
}
internal static void SystrayRemove (IntPtr handle, ref ToolTip tt)
{
DriverDebug ("SystrayRemove ({0}): Called", Window (handle));
driver.SystrayRemove (handle, ref tt);
}
internal static void SystrayBalloon (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
{
DriverDebug ("SystrayBalloon ({0}, {1}, {2}, {3}, {4}): Called", Window (handle), timeout, title, text, icon);
driver.SystrayBalloon (handle, timeout, title, text, icon);
}
internal static bool Text (IntPtr handle, string text)
{
DriverDebug ("Text ({0}, {1}): Called", Window (handle), text);
return driver.Text (handle, text);
}
internal static bool TranslateMessage (ref MSG msg)
{
return driver.TranslateMessage (ref msg);
}
internal static void UngrabWindow (IntPtr handle)
{
DriverDebug ("UngrabWindow ({0}): Called", Window (handle));
driver.UngrabWindow (handle);
}
internal static void UpdateWindow (IntPtr handle)
{
DriverDebug ("UpdateWindow ({0}): Called", Window (handle));
driver.UpdateWindow (handle);
}
// double buffering
internal static void CreateOffscreenDrawable (IntPtr handle,
int width, int height,
out object offscreen_drawable)
{
DriverDebug ("CreateOffscreenDrawable ({2}, {0},{1}): Called", width, height, Window (handle));
driver.CreateOffscreenDrawable (handle, width, height,
out offscreen_drawable);
}
internal static void DestroyOffscreenDrawable (object offscreen_drawable)
{
DriverDebug ("DestroyOffscreenDrawable (): Called");
driver.DestroyOffscreenDrawable (offscreen_drawable);
}
internal static Graphics GetOffscreenGraphics (object offscreen_drawable)
{
DriverDebug ("GetOffscreenGraphics (): Called");
return driver.GetOffscreenGraphics (offscreen_drawable);
}
internal static void BlitFromOffscreen (IntPtr dest_handle,
Graphics dest_dc,
object offscreen_drawable,
Graphics offscreen_dc,
Rectangle r)
{
DriverDebug ("BlitFromOffscreen ({0}): Called", Window (dest_handle));
driver.BlitFromOffscreen (dest_handle, dest_dc, offscreen_drawable, offscreen_dc, r);
}
// Santa's little helper
internal static void Version ()
{
Console.WriteLine ("Xplat version $Revision: $");
}
internal static void AddKeyFilter (IKeyFilter value)
{
lock (key_filters) {
key_filters.Add (value);
}
}
internal static bool FilterKey (KeyFilterData key)
{
lock (key_filters) {
for (int i = 0; i < key_filters.Count; i++) {
IKeyFilter filter = (IKeyFilter) key_filters[i];
if (filter.PreFilterKey (key))
return true;
}
}
return false;
}
#endregion // Public Static Methods
#region Delegates
public delegate bool ClipboardToObject (int type, IntPtr data, out object obj);
public delegate bool ObjectToClipboard (ref int type, object obj, out byte[] data);
#endregion // Delegates
[DllImport ("libc")]
static extern int uname (IntPtr buf);
}
}
|