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 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
30 using System.ComponentModel;
31 using System.Collections;
32 using System.Diagnostics;
33 using System.Runtime.InteropServices;
37 namespace System.Windows.Forms {
38 internal class XplatUI {
39 #region Local Variables
40 static XplatUIDriver driver;
41 static String default_class_name;
42 #endregion // Local Variables
47 static public Keys ModifierKeys {
49 return driver.ModifierKeys;
53 static public MouseButtons MouseButtons {
55 return driver.MouseButtons;
59 static public Point MousePosition {
61 return driver.MousePosition;
65 static public bool DropTarget {
67 return driver.DropTarget;
71 driver.DropTarget=value;
76 #endregion // Subclasses
78 #region Constructor & Destructor
80 // Don't forget to throw the mac in here somewhere, too
81 default_class_name="SWFClass";
83 if (Environment.OSVersion.Platform == (PlatformID)128) {
84 if (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null)
85 driver=XplatUIOSX.GetInstance();
87 driver=XplatUIX11.GetInstance();
89 driver=XplatUIWin32.GetInstance();
92 Console.WriteLine("#region #line XplatUI Constructor called");
96 Console.WriteLine("XplatUI Destructor called");
98 #endregion // Constructor & Destructor
100 #region Public Static Properties
101 internal static string DefaultClassName {
103 return default_class_name;
107 default_class_name=value;
111 static public Size CursorSize {
113 return driver.CursorSize;
117 static public bool DragFullWindows {
119 return driver.DragFullWindows;
123 static public Size DragSize {
125 return driver.DragSize;
129 static public Size IconSize {
131 return driver.IconSize;
135 static public Size MaxWindowTrackSize {
137 return driver.MaxWindowTrackSize;
141 static public Size MinimizedWindowSize {
143 return driver.MinimizedWindowSize;
147 static public Size MinimizedWindowSpacingSize {
149 return driver.MinimizedWindowSpacingSize;
153 static public Size MinimumWindowSize {
155 return driver.MinimumWindowSize;
159 static public Size MinWindowTrackSize {
161 return driver.MinWindowTrackSize;
165 static public Size SmallIconSize {
167 return driver.SmallIconSize;
171 static public int MouseButtonCount {
173 return driver.MouseButtonCount;
177 static public bool MouseButtonsSwapped {
179 return driver.MouseButtonsSwapped;
183 static public bool MouseWheelPresent {
185 return driver.MouseWheelPresent;
189 static public Rectangle VirtualScreen {
191 return driver.VirtualScreen;
195 static public Rectangle WorkingArea {
197 return driver.WorkingArea;
200 #endregion // Public Static Properties
202 internal static event EventHandler Idle {
204 driver.Idle += value;
207 driver.Idle -= value;
211 #region Public Static Methods
212 internal static void Exit() {
216 internal static void GetDisplaySize(out Size size) {
217 driver.GetDisplaySize(out size);
220 internal static void EnableThemes() {
221 driver.EnableThemes();
224 internal static bool Text(IntPtr hWnd, string text) {
225 return driver.Text(hWnd, text);
228 internal static bool GetText(IntPtr hWnd, out string text) {
229 return driver.GetText(hWnd, out text);
232 internal static bool SetVisible(IntPtr hWnd, bool visible) {
233 return driver.SetVisible(hWnd, visible);
236 internal static bool IsVisible(IntPtr hWnd) {
237 return driver.IsVisible(hWnd);
240 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
241 return driver.SetParent(hWnd, hParent);
244 internal static IntPtr GetParent(IntPtr hWnd) {
245 return driver.GetParent(hWnd);
248 internal static void Version() {
249 Console.WriteLine("Xplat version $revision: $");
252 internal static IntPtr CreateWindow(CreateParams cp) {
253 return driver.CreateWindow(cp);
256 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
257 return driver.CreateWindow(Parent, X, Y, Width, Height);
260 internal static void DestroyWindow(IntPtr handle) {
261 driver.DestroyWindow(handle);
264 internal static FormWindowState GetWindowState(IntPtr handle) {
265 return driver.GetWindowState(handle);
268 internal static void SetWindowState(IntPtr handle, FormWindowState state) {
269 driver.SetWindowState(handle, state);
272 internal static void SetWindowStyle(IntPtr handle, CreateParams cp) {
273 driver.SetWindowStyle(handle, cp);
276 internal static void UpdateWindow(IntPtr handle) {
277 driver.UpdateWindow(handle);
280 internal static void SetWindowBackground(IntPtr handle, Color color) {
281 driver.SetWindowBackground(handle, color);
284 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
285 return driver.PaintEventStart(handle);
288 internal static void PaintEventEnd(IntPtr handle) {
289 driver.PaintEventEnd(handle);
292 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
293 driver.SetWindowPos(handle, x, y, width, height);
296 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) {
297 driver.GetWindowPos(handle, is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
300 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
301 driver.Invalidate(handle, rc, clear);
304 internal static void Activate(IntPtr handle) {
305 driver.Activate(handle);
308 internal static void EnableWindow(IntPtr handle, bool Enable) {
309 driver.EnableWindow(handle, Enable);
312 internal static void SetModal(IntPtr handle, bool Modal) {
313 driver.SetModal(handle, Modal);
316 internal static IntPtr DefWndProc(ref Message msg) {
317 return driver.DefWndProc(ref msg);
320 internal static void HandleException(Exception e) {
321 driver.HandleException(e);
324 internal static void DoEvents() {
328 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
329 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
332 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
333 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
336 internal static bool TranslateMessage(ref MSG msg) {
337 return driver.TranslateMessage(ref msg);
340 internal static IntPtr DispatchMessage(ref MSG msg) {
341 return driver.DispatchMessage(ref msg);
344 internal static void GrabWindow(IntPtr hWnd, IntPtr ConfineToHwnd) {
345 driver.GrabWindow(hWnd, ConfineToHwnd);
348 internal static void GrabInfo(out IntPtr hWnd, out bool GrabConfined, out Rectangle GrabArea) {
349 driver.GrabInfo(out hWnd, out GrabConfined, out GrabArea);
352 internal static void ReleaseWindow(IntPtr hWnd) {
353 driver.ReleaseWindow(hWnd);
356 internal static bool SetZOrder(IntPtr hWnd, IntPtr AfterhWnd, bool Top, bool Bottom) {
357 return driver.SetZOrder(hWnd, AfterhWnd, Top, Bottom);
360 internal static bool SetTopmost(IntPtr hWnd, IntPtr hWndOwner, bool Enabled) {
361 return driver.SetTopmost(hWnd, hWndOwner, Enabled);
364 internal static bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
365 return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
368 internal static void SetCursor(IntPtr hwnd, IntPtr cursor) {
369 driver.SetCursor(hwnd, cursor);
372 internal static void ShowCursor(bool show) {
373 driver.ShowCursor(show);
376 internal static void OverrideCursor(IntPtr cursor) {
377 driver.OverrideCursor(cursor);
380 internal static IntPtr DefineCursor(Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot) {
381 return driver.DefineCursor(bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
384 internal static IntPtr DefineStdCursor(StdCursor id) {
385 return driver.DefineStdCursor(id);
388 internal static void DestroyCursor(IntPtr cursor) {
389 driver.DestroyCursor(cursor);
392 internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
393 driver.GetCursorInfo(cursor, out width, out height, out hotspot_x, out hotspot_y);
396 internal static void SetCursorPos(IntPtr handle, int x, int y) {
397 driver.SetCursorPos(handle, x, y);
400 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
401 driver.GetCursorPos(handle, out x, out y);
404 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
405 driver.ScreenToClient (handle, ref x, ref y);
408 internal static void ClientToScreen(IntPtr handle, ref int x, ref int y) {
409 driver.ClientToScreen(handle, ref x, ref y);
412 internal static void SendAsyncMethod (AsyncMethodData data) {
413 driver.SendAsyncMethod (data);
416 internal static void CreateCaret(IntPtr hwnd, int width, int height) {
417 driver.CreateCaret(hwnd, width, height);
420 internal static void DestroyCaret(IntPtr hwnd) {
421 driver.DestroyCaret(hwnd);
424 internal static void SetCaretPos(IntPtr hwnd, int x, int y) {
425 driver.SetCaretPos(hwnd, x, y);
428 internal static void CaretVisible(IntPtr hwnd, bool visible) {
429 driver.CaretVisible(hwnd, visible);
432 internal static void SetFocus(IntPtr hwnd) {
433 driver.SetFocus(hwnd);
436 internal static IntPtr GetActive() {
437 return driver.GetActive();
440 internal static bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
441 return driver.GetFontMetrics(g, font, out ascent, out descent);
444 internal static void SetTimer (Timer timer)
446 driver.SetTimer (timer);
449 internal static void KillTimer (Timer timer)
451 driver.KillTimer (timer);
454 internal static int KeyboardSpeed {
456 return driver.KeyboardSpeed;
460 internal static int KeyboardDelay {
462 return driver.KeyboardSpeed;
466 internal static void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear) {
467 driver.ScrollWindow(hwnd, rectangle, XAmount, YAmount, clear);
470 internal static void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
471 driver.ScrollWindow(hwnd, XAmount, YAmount, clear);
474 internal static bool SystrayAdd(IntPtr hwnd, string tip, Icon icon, out ToolTip tt) {
475 return driver.SystrayAdd(hwnd, tip, icon, out tt);
478 internal static void SystrayChange(IntPtr hwnd, string tip, Icon icon, ref ToolTip tt) {
479 driver.SystrayChange(hwnd, tip, icon, ref tt);
482 internal static void SystrayRemove(IntPtr hwnd, ref ToolTip tt) {
483 driver.SystrayRemove(hwnd, ref tt);
487 // Santa's little helper
488 internal static void Where() {
489 Console.WriteLine("Here: {0}", new StackTrace().ToString());
491 #endregion // Public Static Methods