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.8 2004/08/11 18:55:46 pbartok
30 // - Added method to calculate difference between decorated window and raw
33 // Revision 1.7 2004/08/10 17:39:22 pbartok
34 // - Added GetWindowPos method
36 // Revision 1.6 2004/08/09 20:55:59 pbartok
37 // - Removed Run method, was only required for initial development
39 // Revision 1.5 2004/08/09 20:51:25 pbartok
40 // - Implemented GrabWindow/ReleaseWindow methods to allow pointer capture
42 // Revision 1.4 2004/08/09 17:02:29 jackson
43 // Get default window properties from the theme
45 // Revision 1.3 2004/08/09 15:56:44 jackson
46 // Remove defaults, these are handled by the theme now.
48 // Revision 1.2 2004/08/04 20:11:24 pbartok
49 // - Added Invalidate handling
51 // Revision 1.1 2004/07/09 05:21:25 pbartok
60 using System.ComponentModel;
61 using System.Collections;
62 using System.Diagnostics;
63 using System.Runtime.InteropServices;
66 // Random architecture notes
70 // - set location/size
80 namespace System.Windows.Forms {
81 public class XplatUI {
82 #region Local Variables
83 static XplatUIDriver driver;
84 static String default_class_name;
85 #endregion // Local Variables
90 static public Keys ModifierKeys {
92 return driver.ModifierKeys;
96 static public MouseButtons MouseButtons {
98 return driver.MouseButtons;
102 static public Point MousePosition {
104 return driver.MousePosition;
108 static public bool DropTarget {
110 return driver.DropTarget;
114 driver.DropTarget=value;
118 #endregion // Subclasses
120 #region Constructor & Destructor
122 // Don't forget to throw the mac in here somewhere, too
123 default_class_name="SWFClass";
125 if (Environment.OSVersion.Platform == (PlatformID)128) {
126 driver=XplatUIX11.GetInstance();
128 driver=XplatUIWin32.GetInstance();
131 Console.WriteLine("#region #line XplatUI Constructor called");
135 Console.WriteLine("XplatUI Destructor called");
137 #endregion // Constructor & Destructor
139 #region Public Static Properties
140 internal static string DefaultClassName {
142 return default_class_name;
146 default_class_name=value;
149 #endregion // Public Static Properties
151 #region Public Static Methods
152 internal static void Exit() {
156 internal static bool Text(IntPtr hWnd, string text) {
157 return driver.Text(hWnd, text);
160 internal static bool SetVisible(IntPtr hWnd, bool visible) {
161 return driver.SetVisible(hWnd, visible);
164 internal static bool IsVisible(IntPtr hWnd) {
165 return driver.IsVisible(hWnd);
168 internal static IntPtr SetParent(IntPtr hWnd, IntPtr hParent) {
169 return driver.SetParent(hWnd, hParent);
172 internal static IntPtr GetParent(IntPtr hWnd) {
173 return driver.GetParent(hWnd);
176 internal static void Version() {
177 Console.WriteLine("Xplat version $revision: $");
180 internal static IntPtr CreateWindow(CreateParams cp) {
181 return driver.CreateWindow(cp);
184 internal static IntPtr CreateWindow(IntPtr Parent, int X, int Y, int Width, int Height) {
185 return driver.CreateWindow(Parent, X, Y, Width, Height);
188 internal static void DestroyWindow(IntPtr handle) {
189 driver.DestroyWindow(handle);
192 internal static void RefreshWindow(IntPtr handle) {
193 driver.RefreshWindow(handle);
196 internal static PaintEventArgs PaintEventStart(IntPtr handle) {
197 return driver.PaintEventStart(handle);
200 internal static void PaintEventEnd(IntPtr handle) {
201 driver.PaintEventEnd(handle);
204 internal static void MoveWindow(IntPtr hWnd, int x, int y, int width, int height) {
205 driver.MoveWindow(hWnd, x, y, width, height);
208 internal static void SetWindowPos(IntPtr handle, int x, int y, int width, int height) {
209 driver.SetWindowPos(handle, x, y, width, height);
212 internal static void GetWindowPos(IntPtr handle, out int x, out int y, out int width, out int height) {
213 driver.GetWindowPos(handle, out x, out y, out width, out height);
216 internal static void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
217 driver.Invalidate(handle, rc, clear);
220 internal static void Activate(IntPtr handle) {
221 driver.Activate(handle);
224 internal static IntPtr DefWndProc(ref Message msg) {
225 return driver.DefWndProc(ref msg);
228 internal static void HandleException(Exception e) {
229 driver.HandleException(e);
232 internal static void DoEvents() {
236 internal static bool PeekMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
237 return driver.PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
240 internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
241 return driver.GetMessage(ref msg, hWnd, wFilterMin, wFilterMax);
244 internal static bool TranslateMessage(ref MSG msg) {
245 return driver.TranslateMessage(ref msg);
248 internal static bool DispatchMessage(ref MSG msg) {
249 return driver.DispatchMessage(ref msg);
252 internal static void GrabWindow(IntPtr hWnd) {
253 driver.GrabWindow(hWnd);
256 internal static void ReleaseWindow(IntPtr hWnd) {
257 driver.ReleaseWindow(hWnd);
260 internal static bool CalculateWindowRect(IntPtr hWnd, ref Rectangle ClientRect, int Style, bool HasMenu, out Rectangle WindowRect) {
261 return driver.CalculateWindowRect(hWnd, ref ClientRect, Style, HasMenu, out WindowRect);
264 // Santa's little helper
265 internal static void Where() {
266 Console.WriteLine("Here: {0}", new StackTrace().ToString());
268 #endregion // Public Static Methods