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.6 2004/08/09 20:55:59 pbartok
30 // - Removed Run method, was only required for initial development
32 // Revision 1.5 2004/08/09 20:51:25 pbartok
33 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
35 // Revision 1.4 2004/08/09 17:02:29 jackson
36 // Get default window properties from the theme
38 // Revision 1.3 2004/08/09 15:56:44 jackson
39 // Remove defaults, these are handled by the theme now.
41 // Revision 1.2 2004/08/04 20:11:24 pbartok
42 // - Added Invalidate handling
44 // Revision 1.1 2004/07/09 05:21:25 pbartok
53 using System.ComponentModel;
54 using System.Collections;
55 using System.Diagnostics;
56 using System.Runtime.InteropServices;
59 // Random architecture notes
63 // - set location/size
73 namespace System.Windows.Forms {
74 public class XplatUI {
75 #region Local Variables
76 static XplatUIDriver driver;
77 static String default_class_name;
78 #endregion // Local Variables
83 static public Keys ModifierKeys {
85 return driver.ModifierKeys;
89 static public MouseButtons MouseButtons {
91 return driver.MouseButtons;
95 static public Point MousePosition {
97 return driver.MousePosition;
101 static public bool DropTarget {
103 return driver.DropTarget;
107 driver.DropTarget=value;
111 #endregion // Subclasses
113 #region Constructor & Destructor
115 // Don't forget to throw the mac in here somewhere, too
116 default_class_name="SWFClass";
118 if (Environment.OSVersion.Platform == (PlatformID)128) {
119 driver=XplatUIX11.GetInstance();
121 driver=XplatUIWin32.GetInstance();
124 Console.WriteLine("#region #line XplatUI Constructor called");
128 Console.WriteLine("XplatUI Destructor called");
130 #endregion // Constructor & Destructor
132 #region Public Static Properties
133 internal static string DefaultClassName {
135 return default_class_name;
139 default_class_name=value;
142 #endregion // Public Static Properties
144 #region Public Static Methods
145 internal static void Exit() {
149 internal static bool Text(IntPtr hWnd, string text) {
150 return driver.Text(hWnd, text);
153 internal static bool SetVisible(IntPtr hWnd, bool visible) {
154 return driver.SetVisible(hWnd, visible);
157 internal static bool IsVisible(IntPtr hWnd) {
158 return driver.IsVisible(hWnd);
161 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
162 return driver.SetParent(hWnd, hParent);
165 internal static IntPtr GetParent(IntPtr hWnd) {
166 return driver.GetParent(hWnd);
169 internal static void Version() {
170 Console.WriteLine("Xplat version $revision: $");
173 internal static IntPtr CreateWindow(CreateParams cp) {
174 return driver.CreateWindow(cp);
177 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
178 return driver.CreateWindow(Parent, X, Y, Width, Height);
181 internal static void DestroyWindow(IntPtr handle) {
182 driver.DestroyWindow(handle);
185 internal static void RefreshWindow(IntPtr handle) {
186 driver.RefreshWindow(handle);
189 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
190 return driver.PaintEventStart(handle);
193 internal static void PaintEventEnd(IntPtr handle) {
194 driver.PaintEventEnd(handle);
197 internal static void SetWindowPos(IntPtr handle, Rectangle rc) {
198 driver.SetWindowPos(handle, rc);
201 internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
202 driver.MoveWindow(hWnd, x, y, width, height);
205 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
206 driver.SetWindowPos(handle, x, y, width, height);
209 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
210 driver.Invalidate(handle, rc, clear);
213 internal static void Activate(IntPtr handle) {
214 driver.Activate(handle);
217 internal static IntPtr DefWndProc(ref Message msg) {
218 return driver.DefWndProc(ref msg);
221 internal static void HandleException(Exception e) {
222 driver.HandleException(e);
225 internal static void DoEvents() {
229 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
230 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
233 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
234 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
237 internal static bool TranslateMessage(ref MSG msg) {
238 return driver.TranslateMessage(ref msg);
241 internal static bool DispatchMessage(ref MSG msg) {
242 return driver.DispatchMessage(ref msg);
245 internal static void GrabWindow(IntPtr hWnd) {
246 driver.GrabWindow(hWnd);
248 internal static void ReleaseWindow(IntPtr hWnd) {
249 driver.ReleaseWindow(hWnd);
252 // Santa's little helper
253 internal static void Where() {
254 Console.WriteLine("Here: {0}", new StackTrace().ToString());
256 #endregion // Public Static Methods