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
28 // $Log: XplatUI.cs,v $
29 // Revision 1.7 2004/08/10 17:39:22 pbartok
30 // - Added GetWindowPos method
32 // Revision 1.6 2004/08/09 20:55:59 pbartok
33 // - Removed Run method, was only required for initial development
35 // Revision 1.5 2004/08/09 20:51:25 pbartok
36 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
38 // Revision 1.4 2004/08/09 17:02:29 jackson
39 // Get default window properties from the theme
41 // Revision 1.3 2004/08/09 15:56:44 jackson
42 // Remove defaults, these are handled by the theme now.
44 // Revision 1.2 2004/08/04 20:11:24 pbartok
45 // - Added Invalidate handling
47 // Revision 1.1 2004/07/09 05:21:25 pbartok
56 using System.ComponentModel;
57 using System.Collections;
58 using System.Diagnostics;
59 using System.Runtime.InteropServices;
62 // Random architecture notes
66 // - set location/size
76 namespace System.Windows.Forms {
77 public class XplatUI {
78 #region Local Variables
79 static XplatUIDriver driver;
80 static String default_class_name;
81 #endregion // Local Variables
86 static public Keys ModifierKeys {
88 return driver.ModifierKeys;
92 static public MouseButtons MouseButtons {
94 return driver.MouseButtons;
98 static public Point MousePosition {
100 return driver.MousePosition;
104 static public bool DropTarget {
106 return driver.DropTarget;
110 driver.DropTarget=value;
114 #endregion // Subclasses
116 #region Constructor & Destructor
118 // Don't forget to throw the mac in here somewhere, too
119 default_class_name="SWFClass";
121 if (Environment.OSVersion.Platform == (PlatformID)128) {
122 driver=XplatUIX11.GetInstance();
124 driver=XplatUIWin32.GetInstance();
127 Console.WriteLine("#region #line XplatUI Constructor called");
131 Console.WriteLine("XplatUI Destructor called");
133 #endregion // Constructor & Destructor
135 #region Public Static Properties
136 internal static string DefaultClassName {
138 return default_class_name;
142 default_class_name=value;
145 #endregion // Public Static Properties
147 #region Public Static Methods
148 internal static void Exit() {
152 internal static bool Text(IntPtr hWnd, string text) {
153 return driver.Text(hWnd, text);
156 internal static bool SetVisible(IntPtr hWnd, bool visible) {
157 return driver.SetVisible(hWnd, visible);
160 internal static bool IsVisible(IntPtr hWnd) {
161 return driver.IsVisible(hWnd);
164 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
165 return driver.SetParent(hWnd, hParent);
168 internal static IntPtr GetParent(IntPtr hWnd) {
169 return driver.GetParent(hWnd);
172 internal static void Version() {
173 Console.WriteLine("Xplat version $revision: $");
176 internal static IntPtr CreateWindow(CreateParams cp) {
177 return driver.CreateWindow(cp);
180 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
181 return driver.CreateWindow(Parent, X, Y, Width, Height);
184 internal static void DestroyWindow(IntPtr handle) {
185 driver.DestroyWindow(handle);
188 internal static void RefreshWindow(IntPtr handle) {
189 driver.RefreshWindow(handle);
192 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
193 return driver.PaintEventStart(handle);
196 internal static void PaintEventEnd(IntPtr handle) {
197 driver.PaintEventEnd(handle);
200 internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
201 driver.MoveWindow(hWnd, x, y, width, height);
204 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
205 driver.SetWindowPos(handle, x, y, width, height);
208 internal static void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height) {
209 driver.GetWindowPos(handle, out x, out y, out width, out height);
212 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
213 driver.Invalidate(handle, rc, clear);
216 internal static void Activate(IntPtr handle) {
217 driver.Activate(handle);
220 internal static IntPtr DefWndProc(ref Message msg) {
221 return driver.DefWndProc(ref msg);
224 internal static void HandleException(Exception e) {
225 driver.HandleException(e);
228 internal static void DoEvents() {
232 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
233 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
236 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
237 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
240 internal static bool TranslateMessage(ref MSG msg) {
241 return driver.TranslateMessage(ref msg);
244 internal static bool DispatchMessage(ref MSG msg) {
245 return driver.DispatchMessage(ref msg);
248 internal static void GrabWindow(IntPtr hWnd) {
249 driver.GrabWindow(hWnd);
251 internal static void ReleaseWindow(IntPtr hWnd) {
252 driver.ReleaseWindow(hWnd);
255 // Santa's little helper
256 internal static void Where() {
257 Console.WriteLine("Here: {0}", new StackTrace().ToString());
259 #endregion // Public Static Methods