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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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-2005 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
27 // define to log API calls to stdout
32 using System.ComponentModel;
33 using System.Collections;
34 using System.Diagnostics;
35 using System.Runtime.InteropServices;
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
47 static public bool DropTarget {
49 return driver.DropTarget;
53 driver.DropTarget=value;
57 static public Keys ModifierKeys {
59 return driver.ModifierKeys;
63 static public MouseButtons MouseButtons {
65 return driver.MouseButtons;
69 static public Point MousePosition {
71 return driver.MousePosition;
76 #endregion // Subclasses
78 #region Constructor & Destructor
80 Console.WriteLine("Mono System.Windows.Forms Assembly [Revision: 41731; built: 2005/2/15 5:56:12]");
82 // Don't forget to throw the mac in here somewhere, too
83 default_class_name="SWFClass";
85 if (Environment.OSVersion.Platform == (PlatformID)128) {
86 if (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null)
87 driver=XplatUIOSX.GetInstance();
89 driver=XplatUIX11.GetInstance();
91 driver=XplatUIWin32.GetInstance();
97 Console.WriteLine("XplatUI Destructor called");
99 #endregion // Constructor & Destructor
101 #region Public Static Properties
102 internal static string DefaultClassName {
104 return default_class_name;
108 default_class_name=value;
112 static public Size CursorSize {
114 return driver.CursorSize;
118 static public bool DragFullWindows {
120 return driver.DragFullWindows;
124 static public Size DragSize {
126 return driver.DragSize;
130 static public Size IconSize {
132 return driver.IconSize;
136 static public int KeyboardSpeed {
138 return driver.KeyboardSpeed;
142 static public int KeyboardDelay {
144 return driver.KeyboardSpeed;
148 static public Size MaxWindowTrackSize {
150 return driver.MaxWindowTrackSize;
154 static public Size MinimizedWindowSize {
156 return driver.MinimizedWindowSize;
160 static public Size MinimizedWindowSpacingSize {
162 return driver.MinimizedWindowSpacingSize;
166 static public Size MinimumWindowSize {
168 return driver.MinimumWindowSize;
172 static public Size MinWindowTrackSize {
174 return driver.MinWindowTrackSize;
178 static public Size SmallIconSize {
180 return driver.SmallIconSize;
184 static public int MouseButtonCount {
186 return driver.MouseButtonCount;
190 static public bool MouseButtonsSwapped {
192 return driver.MouseButtonsSwapped;
196 static public bool MouseWheelPresent {
198 return driver.MouseWheelPresent;
202 static public Rectangle VirtualScreen {
204 return driver.VirtualScreen;
208 static public Rectangle WorkingArea {
210 return driver.WorkingArea;
213 #endregion // Public Static Properties
216 internal static event EventHandler Idle {
218 driver.Idle += value;
221 driver.Idle -= value;
227 #region Public Static Methods
228 internal static void Activate(IntPtr handle) {
230 Console.WriteLine("Activate({0:X}): Called", handle.ToInt32());
232 driver.Activate(handle);
235 internal static bool CalculateWindowRect(IntPtr handle, ref Rectangle ClientRect, int Style, int ExStyle, IntPtr MenuHandle, out Rectangle WindowRect) {
237 Console.WriteLine("CalculateWindowRect({0:X}): Called", handle.ToInt32());
239 return driver.CalculateWindowRect(handle, ref ClientRect, Style, ExStyle, MenuHandle, out WindowRect);
242 internal static void CaretVisible(IntPtr handle, bool visible) {
244 Console.WriteLine("CaretVisible({0:X}, {1}): Called", handle.ToInt32(), visible);
246 driver.CaretVisible(handle, visible);
249 internal static void CreateCaret(IntPtr handle, int width, int height) {
251 Console.WriteLine("CreateCaret({0:X}), {1}, {2}: Called", handle.ToInt32(), width, height);
253 driver.CreateCaret(handle, width, height);
256 internal static IntPtr CreateWindow(CreateParams cp) {
258 Console.WriteLine("CreateWindow(): Called");
260 return driver.CreateWindow(cp);
263 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
265 Console.WriteLine("CreateWindow(): Called");
267 return driver.CreateWindow(Parent, X, Y, Width, Height);
270 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
272 Console.WriteLine("ClientToScreen({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
274 driver.ClientToScreen(handle, ref x, ref y);
277 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
279 Console.WriteLine("DefineCursor(...): Called");
281 return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
284 internal static IntPtr DefineStdCursor(StdCursor id) {
285 return driver.DefineStdCursor(id);
288 internal static IntPtr DefWndProc(ref Message msg) {
289 return driver.DefWndProc(ref msg);
292 internal static void DestroyCaret(IntPtr handle) {
294 Console.WriteLine("DestroyCaret({0:X}): Called", handle.ToInt32());
296 driver.DestroyCaret(handle);
299 internal static void DestroyCursor(IntPtr cursor) {
301 Console.WriteLine("DestroyCursor({0:X}): Called", cursor.ToInt32());
303 driver.DestroyCursor(cursor);
306 internal static void DestroyWindow(IntPtr handle) {
308 Console.WriteLine("DestroyWindow({0:X}): Called", handle.ToInt32());
310 driver.DestroyWindow(handle);
313 internal static IntPtr DispatchMessage(ref MSG msg) {
314 return driver.DispatchMessage(ref msg);
317 internal static void DoEvents() {
321 internal static void EnableThemes() {
322 driver.EnableThemes();
325 internal static void EnableWindow(IntPtr handle, bool Enable) {
327 Console.WriteLine("EnableWindow({0:X}, {1}): Called", handle.ToInt32(), Enable);
329 driver.EnableWindow(handle, Enable);
332 internal static void Exit() {
336 internal static void EraseWindowBackground(IntPtr handle, IntPtr wParam) {
337 driver.EraseWindowBackground(handle, wParam);
340 internal static IntPtr GetActive() {
342 Console.WriteLine("GetActive(): Called");
344 return driver.GetActive();
347 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
349 Console.WriteLine("GetCursorInfo({0:X}): Called", cursor.ToInt32());
351 driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
354 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
356 Console.WriteLine("GetCursorPos({0:X}): Called", handle.ToInt32());
358 driver.GetCursorPos(handle, out x, out y);
361 internal static void GetDisplaySize(out Size size) {
363 Console.WriteLine("GetDisplaySize(): Called");
365 driver.GetDisplaySize(out size);
368 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
370 Console.WriteLine("GetFontMetrics(): Called");
372 return driver.GetFontMetrics(g, font, out ascent, out descent);
375 internal static Graphics GetMenuDC(IntPtr handle, IntPtr ncpaint_region) {
377 Console.WriteLine("GetMenuDC({0:X}): Called", handle.ToInt32());
379 return driver.GetMenuDC(handle, ncpaint_region);
382 internal static Point GetMenuOrigin(IntPtr handle) {
384 Console.WriteLine("GetMenuOrigin({0:X}): Called", handle.ToInt32());
386 return driver.GetMenuOrigin(handle);
389 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
390 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
393 internal static IntPtr GetParent(IntPtr hWnd) {
395 Console.WriteLine("GetParent({0:X}): Called", hWnd.ToInt32());
397 return driver.GetParent(hWnd);
400 internal static bool GetText(IntPtr hWnd, out string text) {
402 Console.WriteLine("GetText(): Called");
404 return driver.GetText(hWnd, out text);
407 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) {
409 Console.WriteLine("GetWindowPos({0:X}): Called", handle.ToInt32());
411 driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
414 internal static FormWindowState GetWindowState(IntPtr handle) {
416 Console.WriteLine("GetWindowState({0:X}): Called", handle.ToInt32());
418 return driver.GetWindowState(handle);
421 internal static void GrabInfo(out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea) {
423 Console.WriteLine("GrabInfo(): Called");
425 driver.GrabInfo(out handle, out GrabConfined, out GrabArea);
428 internal static void GrabWindow(IntPtr handle, IntPtr ConfineToHwnd) {
430 Console.WriteLine("GrabWindow({0:X}): Called", handle.ToInt32());
432 driver.GrabWindow(handle, ConfineToHwnd);
435 internal static void HandleException(Exception e) {
436 driver.HandleException(e);
439 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
441 Console.WriteLine("Invalidate({0:X}, {1}, {2}): Called", handle.ToInt32(), rc, clear);
443 driver.Invalidate(handle, rc, clear);
446 internal static bool IsVisible(IntPtr hWnd) {
448 Console.WriteLine("IsVisible({0:X}): Called", hWnd.ToInt32());
450 return driver.IsVisible(hWnd);
453 internal static void KillTimer (Timer timer)
456 Console.WriteLine("KillTimer({0}): Called", timer);
458 driver.KillTimer (timer);
461 internal static void MenuToScreen(IntPtr handle, ref int x, ref int y) {
463 Console.WriteLine("MenuToScreen({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
465 driver.MenuToScreen(handle, ref x, ref y);
468 internal static void OverrideCursor(IntPtr cursor) {
470 Console.WriteLine("OverrideCursor({0:X}): Called", cursor.ToInt32());
472 driver.OverrideCursor(cursor);
475 internal static void PaintEventEnd(IntPtr handle) {
477 Console.WriteLine("PaintEventEnd({0:X}): Called", handle.ToInt32());
479 driver.PaintEventEnd(handle);
482 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
484 Console.WriteLine("PaintEventStart({0:X}): Called", handle.ToInt32());
486 return driver.PaintEventStart(handle);
489 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
490 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
493 internal static void ReleaseMenuDC(IntPtr handle, Graphics dc) {
495 Console.WriteLine("ReleaseMenuDC({0:X}): Called", handle.ToInt32());
497 driver.ReleaseMenuDC(handle, dc);
500 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
502 Console.WriteLine("ScreenToClient({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
504 driver.ScreenToClient (handle, ref x, ref y);
507 internal static void ScreenToMenu(IntPtr handle, ref int x, ref int y) {
509 Console.WriteLine("ScreenToMenu({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
511 driver.ScreenToMenu(handle, ref x, ref y);
514 internal static void ScrollWindow(IntPtr handle, Rectangle rectangle, int XAmount, int YAmount, bool with_children) {
516 Console.WriteLine("ScrollWindow({0:X}, {1}, {2}, {3}, {4}): Called", handle.ToInt32(), rectangle, XAmount, YAmount, with_children);
518 driver.ScrollWindow(handle, rectangle, XAmount, YAmount, with_children);
521 internal static void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children) {
523 Console.WriteLine("ScrollWindow({0:X}, {2}, {3}, {4}): Called", handle.ToInt32(), XAmount, YAmount, with_children);
525 driver.ScrollWindow(handle, XAmount, YAmount, with_children);
528 internal static void SendAsyncMethod (AsyncMethodData data) {
530 Console.WriteLine("SendAsyncMethod({0}): Called", data);
532 driver.SendAsyncMethod (data);
535 internal static void SetBorderStyle(IntPtr handle, BorderStyle border_style) {
537 Console.WriteLine("SetBorderStyle({0:X}, {1}): Called", handle.ToInt32(), border_style);
539 driver.SetBorderStyle(handle, border_style);
542 internal static void SetCaretPos(IntPtr handle, int x, int y) {
544 Console.WriteLine("SetCaretPos({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
546 driver.SetCaretPos(handle, x, y);
549 internal static void SetCursor(IntPtr handle, IntPtr cursor) {
551 Console.WriteLine("SetCursor({0:X}, {1:X}): Called", handle.ToInt32(), cursor.ToInt32());
553 driver.SetCursor(handle, cursor);
556 internal static void SetCursorPos(IntPtr handle, int x, int y) {
558 Console.WriteLine("SetCursorPos({0:X}, {1}, {2}): Called", handle.ToInt32(), x, y);
560 driver.SetCursorPos(handle, x, y);
563 internal static void SetFocus(IntPtr handle) {
565 Console.WriteLine("SetFocus({0:X}): Called", handle.ToInt32());
567 driver.SetFocus(handle);
570 internal static void SetIcon(IntPtr handle, Icon icon) {
572 Console.WriteLine("SetIcon({0:X}, {1}): Called", handle.ToInt32(), icon);
574 driver.SetIcon(handle, icon);
577 internal static void SetMenu(IntPtr handle, IntPtr menu_handle) {
579 Console.WriteLine("SetMenu({0:X}, {1:X}): Called", handle.ToInt32(), menu_handle.ToInt32());
581 driver.SetMenu(handle, menu_handle);
584 internal static void SetModal(IntPtr handle, bool Modal) {
586 Console.WriteLine("SetModal({0:X}, {1}): Called", handle.ToInt32(), Modal);
588 driver.SetModal(handle, Modal);
591 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
593 Console.WriteLine("SetParent({0:X}, {1:X}): Called", hWnd.ToInt32(), hParent.ToInt32());
595 return driver.SetParent(hWnd, hParent);
598 internal static void SetTimer (Timer timer)
601 Console.WriteLine("SetTimer({0}): Called", timer);
603 driver.SetTimer (timer);
606 internal static bool SetTopmost(IntPtr handle, IntPtr hWndOwner, bool Enabled) {
608 Console.WriteLine("SetTopMost({0:X}, {1:X}, {2}): Called", handle.ToInt32(), hWndOwner.ToInt32(), Enabled);
610 return driver.SetTopmost(handle, hWndOwner, Enabled);
613 internal static bool SetVisible(IntPtr hWnd, bool visible) {
615 Console.WriteLine("SetVisible({0:X}, {1}): Called", hWnd.ToInt32(), visible);
617 return driver.SetVisible(hWnd, visible);
620 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
622 Console.WriteLine("SetWindowPos({0:X}, {1}, {2}, {3}, {4}): Called", handle.ToInt32(), x, y, width, height);
624 driver.SetWindowPos(handle, x, y, width, height);
627 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
629 Console.WriteLine("SetWindowState({0:X} {1}): Called", handle.ToInt32(), state);
631 driver.SetWindowState(handle, state);
634 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
636 Console.WriteLine("SetWindowStyle({0:X}): Called", handle.ToInt32());
638 driver.SetWindowStyle(handle, cp);
641 internal static void SetWindowBackground(IntPtr handle, Color color) {
643 Console.WriteLine("SetWindowBackground({0:X}, {1}): Called", handle.ToInt32(), color);
645 driver.SetWindowBackground(handle, color);
648 internal static bool SetZOrder(IntPtr handle, IntPtr AfterhWnd, bool Top, bool Bottom) {
650 Console.WriteLine("SetZOrder({0:X}, {1:X}, {2}, {3}): Called", handle.ToInt32(), AfterhWnd.ToInt32(), Top, Bottom);
652 return driver.SetZOrder(handle, AfterhWnd, Top, Bottom);
655 internal static void ShowCursor(bool show) {
657 Console.WriteLine("ShowCursor({0}): Called", show);
659 driver.ShowCursor(show);
662 internal static bool SystrayAdd(IntPtr handle, string tip, Icon icon, out ToolTip tt) {
664 Console.WriteLine("SystrayAdd({0:X}, {1}): Called", handle.ToInt32(), tip);
666 return driver.SystrayAdd(handle, tip, icon, out tt);
669 internal static void SystrayChange(IntPtr handle, string tip, Icon icon, ref ToolTip tt) {
671 Console.WriteLine("SystrayChange({0:X}, {1}): Called", handle.ToInt32(), tip);
673 driver.SystrayChange(handle, tip, icon, ref tt);
676 internal static void SystrayRemove(IntPtr handle, ref ToolTip tt) {
678 Console.WriteLine("SystrayRemove({0:X}): Called", handle.ToInt32());
680 driver.SystrayRemove(handle, ref tt);
683 internal static bool Text(IntPtr hWnd, string text) {
685 Console.WriteLine("Text({0:X}, {1}): Called", hWnd.ToInt32(), text);
687 return driver.Text(hWnd, text);
690 internal static bool TranslateMessage(ref MSG msg) {
691 return driver.TranslateMessage(ref msg);
694 internal static void UngrabWindow(IntPtr handle) {
696 Console.WriteLine("UngrabWindow({0:X}): Called", handle.ToInt32());
698 driver.UngrabWindow(handle);
701 internal static void UpdateWindow(IntPtr handle) {
703 Console.WriteLine("UpdateWindow({0:X}): Called", handle.ToInt32());
705 driver.UpdateWindow(handle);
708 // Santa's little helper
709 internal static void Version() {
710 Console.WriteLine("Xplat version $Revision: $");
713 internal static void Where() {
716 #endregion // Public Static Methods