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.15 2004/08/20 19:14:35 jackson
30 // Expose functionality to send async messages through the driver
32 // Revision 1.14 2004/08/13 21:42:15 pbartok
33 // - Changed signature for GetCursorPos
35 // Revision 1.13 2004/08/13 19:00:15 jordi
36 // implements PointToClient (ScreenToClient)
38 // Revision 1.12 2004/08/13 18:53:14 pbartok
39 // - Changed GetWindowPos to also provide client area size
41 // Revision 1.11 2004/08/12 22:59:03 pbartok
42 // - Implemented method to get current mouse position
44 // Revision 1.10 2004/08/11 22:20:59 pbartok
47 // Revision 1.9 2004/08/11 19:19:44 pbartok
48 // - We had SetWindowPos and MoveWindow to set window positions and size,
49 // removed MoveWindow. We have GetWindowPos, so it made sense to keep
50 // SetWindowPos as matching counterpart
51 // - Added some X11 sanity checking
53 // Revision 1.8 2004/08/11 18:55:46 pbartok
54 // - Added method to calculate difference between decorated window and raw
57 // Revision 1.7 2004/08/10 17:39:22 pbartok
58 // - Added GetWindowPos method
60 // Revision 1.6 2004/08/09 20:55:59 pbartok
61 // - Removed Run method, was only required for initial development
63 // Revision 1.5 2004/08/09 20:51:25 pbartok
64 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
66 // Revision 1.4 2004/08/09 17:02:29 jackson
67 // Get default window properties from the theme
69 // Revision 1.3 2004/08/09 15:56:44 jackson
70 // Remove defaults, these are handled by the theme now.
72 // Revision 1.2 2004/08/04 20:11:24 pbartok
73 // - Added Invalidate handling
75 // Revision 1.1 2004/07/09 05:21:25 pbartok
84 using System.ComponentModel;
85 using System.Collections;
86 using System.Diagnostics;
87 using System.Runtime.InteropServices;
90 // Random architecture notes
94 // - set location/size
104 namespace System.Windows.Forms {
105 internal class XplatUI {
106 #region Local Variables
107 static XplatUIDriver driver;
108 static String default_class_name;
109 #endregion // Local Variables
114 static public Keys ModifierKeys {
116 return driver.ModifierKeys;
120 static public MouseButtons MouseButtons {
122 return driver.MouseButtons;
126 static public Point MousePosition {
128 return driver.MousePosition;
132 static public bool DropTarget {
134 return driver.DropTarget;
138 driver.DropTarget=value;
142 #endregion // Subclasses
144 #region Constructor & Destructor
146 // Don't forget to throw the mac in here somewhere, too
147 default_class_name="SWFClass";
149 if (Environment.OSVersion.Platform == (PlatformID)128) {
150 driver=XplatUIX11.GetInstance();
152 driver=XplatUIWin32.GetInstance();
155 Console.WriteLine("#region #line XplatUI Constructor called");
159 Console.WriteLine("XplatUI Destructor called");
161 #endregion // Constructor & Destructor
163 #region Public Static Properties
164 internal static string DefaultClassName {
166 return default_class_name;
170 default_class_name=value;
173 #endregion // Public Static Properties
175 #region Public Static Methods
176 internal static void Exit() {
180 internal static void EnableThemes() {
181 driver.EnableThemes();
184 internal static bool Text(IntPtr hWnd, string text) {
185 return driver.Text(hWnd, text);
188 internal static bool SetVisible(IntPtr hWnd, bool visible) {
189 return driver.SetVisible(hWnd, visible);
192 internal static bool IsVisible(IntPtr hWnd) {
193 return driver.IsVisible(hWnd);
196 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
197 return driver.SetParent(hWnd, hParent);
200 internal static IntPtr GetParent(IntPtr hWnd) {
201 return driver.GetParent(hWnd);
204 internal static void Version() {
205 Console.WriteLine("Xplat version $revision: $");
208 internal static IntPtr CreateWindow(CreateParams cp) {
209 return driver.CreateWindow(cp);
212 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
213 return driver.CreateWindow(Parent, X, Y, Width, Height);
216 internal static void DestroyWindow(IntPtr handle) {
217 driver.DestroyWindow(handle);
220 internal static void RefreshWindow(IntPtr handle) {
221 driver.RefreshWindow(handle);
224 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
225 return driver.PaintEventStart(handle);
228 internal static void PaintEventEnd(IntPtr handle) {
229 driver.PaintEventEnd(handle);
232 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
233 driver.SetWindowPos(handle, x, y, width, height);
236 internal static void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height, out int client_width, out int client_height) {
237 driver.GetWindowPos(handle, out x, out y, out width, out height, out client_width, out client_height);
240 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
241 driver.Invalidate(handle, rc, clear);
244 internal static void Activate(IntPtr handle) {
245 driver.Activate(handle);
248 internal static IntPtr DefWndProc(ref Message msg) {
249 return driver.DefWndProc(ref msg);
252 internal static void HandleException(Exception e) {
253 driver.HandleException(e);
256 internal static void DoEvents() {
260 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
261 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
264 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
265 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
268 internal static bool TranslateMessage(ref MSG msg) {
269 return driver.TranslateMessage(ref msg);
272 internal static bool DispatchMessage(ref MSG msg) {
273 return driver.DispatchMessage(ref msg);
276 internal static void GrabWindow(IntPtr hWnd) {
277 driver.GrabWindow(hWnd);
280 internal static void ReleaseWindow(IntPtr hWnd) {
281 driver.ReleaseWindow(hWnd);
284 internal static bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
285 return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
288 internal static void GetCursorPos(IntPtr handle, out int x, out int y) {
289 driver.GetCursorPos(handle, out x, out y);
292 internal static void ScreenToClient(IntPtr handle, ref int x, ref int y) {
293 driver.ScreenToClient (handle, ref x, ref y);
296 internal static void SendAsyncMethod (AsyncMethodData data) {
297 driver.SendAsyncMethod (data);
300 // Santa's little helper
301 internal static void Where() {
302 Console.WriteLine("Here: {0}", new StackTrace().ToString());
304 #endregion // Public Static Methods